public final class ExecutableStatementCountCheck extends AbstractCheck
Restricts the number of executable statements to a specified limit.
max - Specify the maximum threshold allowed.
Type is int.
Default value is 30.
tokens - tokens to check
Type is java.lang.String[].
Validation type is tokenSet.
Default value is:
CTOR_DEF,
METHOD_DEF,
INSTANCE_INIT,
STATIC_INIT,
COMPACT_CTOR_DEF,
LAMBDA.
To configure the check:
<module name="ExecutableStatementCount"/>
To configure the check with a threshold of 20 for constructor and method definitions:
<module name="ExecutableStatementCount"> <property name="max" value="20"/> <property name="tokens" value="CTOR_DEF,METHOD_DEF"/> </module>
Parent is com.puppycrawl.tools.checkstyle.TreeWalker
Violation Message Keys:
executableStatementCount
| Modifier and Type | Class and Description |
|---|---|
private static class |
ExecutableStatementCountCheck.Context
Class to encapsulate counting information about one member.
|
AutomaticBean.OutputStreamOptions| Modifier and Type | Field and Description |
|---|---|
private ExecutableStatementCountCheck.Context |
context
Current method context.
|
private java.util.Deque<ExecutableStatementCountCheck.Context> |
contextStack
Stack of method contexts.
|
private static int |
DEFAULT_MAX
Default threshold.
|
private int |
max
Specify the maximum threshold allowed.
|
static java.lang.String |
MSG_KEY
A key is pointing to the warning message text in "messages.properties"
file.
|
| Constructor and Description |
|---|
ExecutableStatementCountCheck()
Constructs a
ExecutableStatementCountCheck. |
| Modifier and Type | Method and Description |
|---|---|
void |
beginTree(DetailAST rootAST)
Called before the starting to process a tree.
|
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.
|
private static boolean |
isContainerNode(DetailAST node)
Check if the node is of type ctor (compact or canonical),
instance/ static initializer, method definition or lambda.
|
private void |
leaveContainerNode(DetailAST ast)
Process the end of a container node.
|
void |
leaveToken(DetailAST ast)
Called after all the child nodes have been process.
|
void |
setMax(int max)
Setter to specify the maximum threshold allowed.
|
private void |
visitContainerNode(DetailAST ast)
Process the start of the container node.
|
private void |
visitSlist(DetailAST ast)
Process the end of a statement list.
|
void |
visitToken(DetailAST ast)
Called to process a token.
|
clearViolations, destroy, finishTree, getFileContents, getLine, getLineCodePoints, getLines, getTabWidth, getTokenNames, getViolations, init, isCommentNodesRequired, log, log, log, setFileContents, setTabWidth, setTokensfinishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverityconfigure, contextualize, getConfiguration, setupChildpublic static final java.lang.String MSG_KEY
private static final int DEFAULT_MAX
private final java.util.Deque<ExecutableStatementCountCheck.Context> contextStack
private int max
private ExecutableStatementCountCheck.Context context
public ExecutableStatementCountCheck()
ExecutableStatementCountCheck.public int[] getDefaultTokens()
AbstractCheckgetDefaultTokens in class AbstractCheckTokenTypespublic int[] getRequiredTokens()
AbstractCheckgetRequiredTokens in class AbstractCheckTokenTypespublic int[] getAcceptableTokens()
AbstractCheckgetAcceptableTokens in class AbstractCheckTokenTypespublic void setMax(int max)
max - the maximum threshold.public void beginTree(DetailAST rootAST)
AbstractCheckbeginTree in class AbstractCheckrootAST - the root of the treepublic void visitToken(DetailAST ast)
AbstractCheckvisitToken in class AbstractCheckast - the token to processpublic void leaveToken(DetailAST ast)
AbstractCheckleaveToken in class AbstractCheckast - the token leavingprivate void visitContainerNode(DetailAST ast)
ast - the token representing the container node.private void leaveContainerNode(DetailAST ast)
ast - the token representing the container node.private void visitSlist(DetailAST ast)
ast - the token representing the statement list.private static boolean isContainerNode(DetailAST node)
node - AST node we are checkingCopyright © 2001-2022. All Rights Reserved.