public class CyclomaticComplexityCheck extends AbstractCheck
Check has following properties:
switchBlockAsSingleDecisionPoint - controls whether to treat the whole switch block as a single decision point. Default value is false
| Modifier and Type | Field and Description |
|---|---|
private java.math.BigInteger |
currentValue
The current value.
|
private static int |
DEFAULT_COMPLEXITY_VALUE
Default allowed complexity.
|
private static java.math.BigInteger |
INITIAL_VALUE
The initial current value.
|
private int |
max
Threshold to report error for.
|
static java.lang.String |
MSG_KEY
A key is pointing to the warning message text in "messages.properties"
file.
|
private boolean |
switchBlockAsSingleDecisionPoint
Whether to treat the whole switch block as a single decision point.
|
private java.util.Deque<java.math.BigInteger> |
valueStack
Stack of values - all but the current value.
|
| Constructor and Description |
|---|
CyclomaticComplexityCheck() |
| Modifier and Type | Method and Description |
|---|---|
int[] |
getAcceptableTokens()
The configurable token set.
|
int[] |
getDefaultTokens()
Returns the default token a check is interested in.
|
int[] |
getRequiredTokens()
The tokens that this check must be registered for.
|
protected void |
incrementCurrentValue(java.math.BigInteger amount)
Increments the current value by a specified amount.
|
private void |
leaveMethodDef(DetailAST ast)
Process the end of a method definition.
|
void |
leaveToken(DetailAST ast)
Called after all the child nodes have been process.
|
protected java.math.BigInteger |
popValue()
Pops a value off the stack and makes it the current value.
|
protected void |
pushValue()
Push the current value on the stack.
|
void |
setMax(int max)
Set the maximum threshold allowed.
|
void |
setSwitchBlockAsSingleDecisionPoint(boolean switchBlockAsSingleDecisionPoint)
Sets whether to treat the whole switch block as a single decision point.
|
private void |
visitMethodDef()
Process the start of the method definition.
|
void |
visitToken(DetailAST ast)
Called to process a token.
|
protected void |
visitTokenHook(DetailAST ast)
Hook called when visiting a token.
|
beginTree, destroy, finishTree, getClassLoader, getFileContents, getLine, getLines, getTabWidth, getTokenNames, init, isCommentNodesRequired, log, log, setClassLoader, setFileContents, setMessages, setTabWidth, setTokensgetCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, log, setId, setSeverityconfigure, contextualize, finishLocalSetup, getConfiguration, setupChildpublic static final java.lang.String MSG_KEY
private static final java.math.BigInteger INITIAL_VALUE
private static final int DEFAULT_COMPLEXITY_VALUE
private final java.util.Deque<java.math.BigInteger> valueStack
private boolean switchBlockAsSingleDecisionPoint
private java.math.BigInteger currentValue
private int max
public void setSwitchBlockAsSingleDecisionPoint(boolean switchBlockAsSingleDecisionPoint)
switchBlockAsSingleDecisionPoint - whether to treat the whole switch
block as a single decision point.public final void setMax(int max)
max - the maximum thresholdpublic int[] getDefaultTokens()
AbstractCheckgetDefaultTokens in class AbstractCheckTokenTypespublic int[] getAcceptableTokens()
AbstractCheckgetAcceptableTokens in class AbstractCheckTokenTypespublic final int[] getRequiredTokens()
AbstractCheckgetRequiredTokens in class AbstractCheckTokenTypespublic void visitToken(DetailAST ast)
AbstractCheckvisitToken in class AbstractCheckast - the token to processpublic void leaveToken(DetailAST ast)
AbstractCheckleaveToken in class AbstractCheckast - the token leavingprotected final void visitTokenHook(DetailAST ast)
ast - the token being visitedprivate void leaveMethodDef(DetailAST ast)
ast - the token representing the method definitionprotected final void incrementCurrentValue(java.math.BigInteger amount)
amount - the amount to increment byprotected final void pushValue()
protected final java.math.BigInteger popValue()
private void visitMethodDef()