public class ConfusingConditionCheck
extends com.puppycrawl.tools.checkstyle.api.AbstractCheck
Examples:
"if" expression contains negation
if (a != b && c != d)
{
smth1();
}
else
{
smth2();
}
You can escape of negation in "if" expression
and swapped code in "if" and "else" block:
if (a == b || c == d)
{
smth2();
}
else
{
smth1();
}
| Modifier and Type | Field and Description |
|---|---|
static String |
MSG_KEY
The key is pointing to the message text String in
"messages.properties file".This message used for common cases.
|
| Constructor and Description |
|---|
ConfusingConditionCheck() |
| Modifier and Type | Method and Description |
|---|---|
int[] |
getAcceptableTokens() |
int[] |
getDefaultTokens() |
int[] |
getRequiredTokens() |
void |
setIgnoreInnerIf(boolean aIgnoreInnerIf)
Enable(true) | Disable(false) warnings for all inner "if".
|
void |
setIgnoreNullCaseInIf(boolean ignoreNullCaseInIf)
Disable(true) | Enable(false) warnings.
|
void |
setIgnoreSequentialIf(boolean ignoreSequentialIf)
Enable(true) | Disable(false) warnings for all "if" that follows the
"else".
|
void |
setIgnoreThrowInElse(boolean ignoreThrowInElse)
Disable(true) | Enable(false) warnings.
|
void |
setMultiplyFactorForElseBlocks(int multiplyFactorForElseBlocks)
Sets multiplyFactorForElseBlocks field.
|
void |
visitToken(com.puppycrawl.tools.checkstyle.api.DetailAST literalIf) |
beginTree, clearMessages, destroy, finishTree, getFileContents, getLine, getLines, getMessages, getTabWidth, getTokenNames, init, isCommentNodesRequired, leaveToken, log, log, log, setFileContents, setTabWidth, setTokensfinishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeveritypublic static final String MSG_KEY
public void setIgnoreInnerIf(boolean aIgnoreInnerIf)
aIgnoreInnerIf - ignore inner ifpublic void setIgnoreSequentialIf(boolean ignoreSequentialIf)
ignoreSequentialIf - ignore sequential ifpublic void setIgnoreNullCaseInIf(boolean ignoreNullCaseInIf)
ignoreNullCaseInIf - if true disable warnings for "if".public void setIgnoreThrowInElse(boolean ignoreThrowInElse)
ignoreThrowInElse - if true disable warnings for "if".public void setMultiplyFactorForElseBlocks(int multiplyFactorForElseBlocks)
multiplyFactorForElseBlocks - define multiplyFactorForElseBlocks field.multiplyFactorForElseBlockspublic int[] getDefaultTokens()
getDefaultTokens in class com.puppycrawl.tools.checkstyle.api.AbstractCheckpublic int[] getAcceptableTokens()
getAcceptableTokens in class com.puppycrawl.tools.checkstyle.api.AbstractCheckpublic int[] getRequiredTokens()
getRequiredTokens in class com.puppycrawl.tools.checkstyle.api.AbstractCheckpublic void visitToken(com.puppycrawl.tools.checkstyle.api.DetailAST literalIf)
visitToken in class com.puppycrawl.tools.checkstyle.api.AbstractCheckCopyright © 2021. All rights reserved.