public final class ReturnCountCheck extends AbstractFormatCheck
Restricts the number of return statements in methods, constructors and lambda expressions
(2 by default). Ignores specified methods (equals() by default).
Rationale: Too many return points can be indication that code is attempting to do too much or may be difficult to understand.
| Modifier and Type | Field and Description |
|---|---|
static String |
MSG_KEY
A key is pointing to the warning message text in "messages.properties"
file.
|
| Constructor and Description |
|---|
ReturnCountCheck()
Creates new instance of the checks.
|
| 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 |
getMax()
Getter for max property.
|
int[] |
getRequiredTokens()
The tokens that this check must be registered for.
|
void |
leaveToken(DetailAST ast)
Called after all the child nodes have been process.
|
void |
setMax(int max)
Setter for max property.
|
void |
visitToken(DetailAST ast)
Called to process a token.
|
getFormat, getRegexp, setCompileFlags, setFormatdestroy, 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 String MSG_KEY
public ReturnCountCheck()
public int[] getDefaultTokens()
CheckgetDefaultTokens in class CheckTokenTypespublic int[] getRequiredTokens()
CheckgetRequiredTokens in class CheckTokenTypespublic int[] getAcceptableTokens()
CheckgetAcceptableTokens in class CheckTokenTypespublic int getMax()
public void setMax(int max)
max - maximum allowed number of return statements.public void beginTree(DetailAST rootAST)
Checkpublic void visitToken(DetailAST ast)
CheckvisitToken in class Checkast - the token to processpublic void leaveToken(DetailAST ast)
CheckleaveToken in class Checkast - the token leavingCopyright © 2001-2015. All Rights Reserved.