public final class BooleanExpressionComplexityCheck extends AbstractCheck
Modifier and Type | Class and Description |
---|---|
private class |
BooleanExpressionComplexityCheck.Context
Represents context (method/expression) in which we check complexity.
|
Modifier and Type | Field and Description |
---|---|
private BooleanExpressionComplexityCheck.Context |
context
Current context.
|
private java.util.Deque<BooleanExpressionComplexityCheck.Context> |
contextStack
Stack of contexts.
|
private static int |
DEFAULT_MAX
Default allowed complexity.
|
private int |
max
Maximum allowed complexity.
|
static java.lang.String |
MSG_KEY
A key is pointing to the warning message text in "messages.properties"
file.
|
Constructor and Description |
---|
BooleanExpressionComplexityCheck()
Creates new instance of the check.
|
Modifier and Type | Method and Description |
---|---|
int[] |
getAcceptableTokens()
The configurable token set.
|
int[] |
getDefaultTokens()
Returns the default token a check is interested in.
|
int |
getMax()
Getter for maximum allowed complexity.
|
int[] |
getRequiredTokens()
The tokens that this check must be registered for.
|
private static boolean |
isPassedInParameter(DetailAST logicalOperator)
Checks if logical operator is part of constructor or method call.
|
private static boolean |
isPipeOperator(DetailAST binaryOr)
Checks if
binary OR is applied to exceptions
in
multi-catch (pipe-syntax). |
private void |
leaveExpr(DetailAST ast)
Restores previous context.
|
private void |
leaveMethodDef()
Removes old context.
|
void |
leaveToken(DetailAST ast)
Called after all the child nodes have been process.
|
void |
setMax(int max)
Setter for maximum allowed complexity.
|
private void |
visitExpr()
Creates and pushes new context.
|
private void |
visitMethodDef(DetailAST ast)
Creates new context for a given method.
|
void |
visitToken(DetailAST ast)
Called to process a token.
|
beginTree, destroy, finishTree, getClassLoader, getFileContents, getLine, getLines, getTabWidth, getTokenNames, init, isCommentNodesRequired, log, log, setClassLoader, setFileContents, setMessages, setTabWidth, setTokens
getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, log, setId, setSeverity
configure, contextualize, finishLocalSetup, getConfiguration, setupChild
public static final java.lang.String MSG_KEY
private static final int DEFAULT_MAX
private final java.util.Deque<BooleanExpressionComplexityCheck.Context> contextStack
private int max
private BooleanExpressionComplexityCheck.Context context
public BooleanExpressionComplexityCheck()
public int[] getDefaultTokens()
AbstractCheck
getDefaultTokens
in class AbstractCheck
TokenTypes
public int[] getRequiredTokens()
AbstractCheck
getRequiredTokens
in class AbstractCheck
TokenTypes
public int[] getAcceptableTokens()
AbstractCheck
getAcceptableTokens
in class AbstractCheck
TokenTypes
public int getMax()
public void setMax(int max)
max
- new maximum allowed complexity.public void visitToken(DetailAST ast)
AbstractCheck
visitToken
in class AbstractCheck
ast
- the token to processprivate static boolean isPassedInParameter(DetailAST logicalOperator)
logicalOperator
- logical operatorprivate static boolean isPipeOperator(DetailAST binaryOr)
binary OR
is applied to exceptions
in
multi-catch (pipe-syntax).binaryOr
- binary or
public void leaveToken(DetailAST ast)
AbstractCheck
leaveToken
in class AbstractCheck
ast
- the token leavingprivate void visitMethodDef(DetailAST ast)
ast
- a method we start to check.private void leaveMethodDef()
private void visitExpr()
private void leaveExpr(DetailAST ast)
ast
- expression we leave.