public class SimplifyBooleanExpressionCheck extends Check
Checks for overly complicated boolean expressions. Currently finds code like
if (b == true)
, b || true
, !false
,
etc.
Rationale: Complex boolean logic makes code hard to understand and maintain.
An example of how to configure the check is:
<module name="SimplifyBooleanExpression"/>
Constructor and Description |
---|
SimplifyBooleanExpressionCheck() |
Modifier and Type | Method and Description |
---|---|
int[] |
getAcceptableTokens()
Prevent user from changing tokens in the configuration.
|
int[] |
getDefaultTokens()
Returns the default token a check is interested in.
|
int[] |
getRequiredTokens()
The tokens that this check must be registered for.
|
void |
visitToken(DetailAST aAST)
Called to process a token.
|
beginTree, destroy, finishTree, getClassLoader, getFileContents, getLines, getTabWidth, getTokenNames, init, leaveToken, log, log, setClassLoader, setFileContents, setMessages, setTabWidth, setTokens
getId, getMessageBundle, getSeverity, getSeverityLevel, log, log, log, log, log, log, log, log, log, setId, setSeverity
configure, contextualize, finishLocalSetup, getConfiguration, setupChild
public int[] getDefaultTokens()
getDefaultTokens
in class Check
TokenTypes
public int[] getAcceptableTokens()
getAcceptableTokens
in class Check
Check
public int[] getRequiredTokens()
getRequiredTokens
in class Check
TokenTypes
public void visitToken(DetailAST aAST)
visitToken
in class Check
aAST
- the token to process