public class NestedSwitchCheck
extends com.puppycrawl.tools.checkstyle.api.AbstractCheck
This check ensures that there is no switch block inside other switch block. In such case nested block should be exposed into new method.
Assuming following block:
switch (color) {
case GREEN:
switch (type) {
case MEDIUM:
}
case BLUE:
}
Nested switch block that checks type parameter should be converted into separate
method.
To enable this check use following configuration:
<module name="NestedSwitchCheck"/>
| Modifier and Type | Field and Description |
|---|---|
static String |
MSG_KEY
A key is pointing to the warning message text in "messages.properties"
file.
|
| Constructor and Description |
|---|
NestedSwitchCheck() |
| Modifier and Type | Method and Description |
|---|---|
void |
beginTree(com.puppycrawl.tools.checkstyle.api.DetailAST rootAST) |
int[] |
getAcceptableTokens() |
int[] |
getDefaultTokens() |
int[] |
getRequiredTokens() |
void |
leaveToken(com.puppycrawl.tools.checkstyle.api.DetailAST aAST) |
void |
setMax(int max)
Setter for maximum allowed nesting depth.
|
void |
visitToken(com.puppycrawl.tools.checkstyle.api.DetailAST aAST) |
clearMessages, destroy, finishTree, getFileContents, getLine, getLines, getMessages, getTabWidth, getTokenNames, init, isCommentNodesRequired, log, log, log, setFileContents, setTabWidth, setTokensfinishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeveritypublic static final String MSG_KEY
public final void setMax(int max)
max - maximum allowed nesting depth.public int[] getDefaultTokens()
getDefaultTokens in class com.puppycrawl.tools.checkstyle.api.AbstractCheckpublic int[] getAcceptableTokens()
getAcceptableTokens in class com.puppycrawl.tools.checkstyle.api.AbstractCheckpublic final int[] getRequiredTokens()
getRequiredTokens in class com.puppycrawl.tools.checkstyle.api.AbstractCheckpublic void beginTree(com.puppycrawl.tools.checkstyle.api.DetailAST rootAST)
beginTree in class com.puppycrawl.tools.checkstyle.api.AbstractCheckpublic void visitToken(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
visitToken in class com.puppycrawl.tools.checkstyle.api.AbstractCheckpublic void leaveToken(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
leaveToken in class com.puppycrawl.tools.checkstyle.api.AbstractCheckCopyright © 2021. All rights reserved.