public class ParameterNumberCheck extends AbstractCheck
Checks the number of parameters that a method or constructor has.
The default allowable number of parameters is 7.
To change the number of allowable parameters, set property max.
Allows to ignore number of parameters for methods with
@Override
annotation.
An example of how to configure the check is:
<module name="ParameterNumber"/>
An example of how to configure the check to allow 10 parameters
and ignoring parameters for methods with @Override
annotation is:
<module name="ParameterNumber"> <property name="max" value="10"/> <property name="ignoreOverriddenMethods" value="true"/> </module>Java code that will be ignored:
@Override
public void needsLotsOfParameters(int a,
int b, int c, int d, int e, int f, int g, int h) {
...
}
AutomaticBean.OutputStreamOptions
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 |
---|
ParameterNumberCheck() |
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.
|
void |
setIgnoreOverriddenMethods(boolean ignoreOverriddenMethods)
Ignore number of parameters for methods with
@
Override annotation. |
void |
setMax(int max)
Sets the maximum number of allowed parameters.
|
void |
visitToken(DetailAST ast)
Called to process a token.
|
beginTree, clearMessages, destroy, finishTree, getClassLoader, getFileContents, getLine, getLines, getMessages, getTabWidth, getTokenNames, init, isCommentNodesRequired, leaveToken, log, log, log, setClassLoader, setFileContents, setTabWidth, setTokens
finishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverity
configure, contextualize, getConfiguration, setupChild
public static final String MSG_KEY
public ParameterNumberCheck()
public void setMax(int max)
max
- the max allowed parameterspublic void setIgnoreOverriddenMethods(boolean ignoreOverriddenMethods)
Override
annotation.ignoreOverriddenMethods
- set ignore overridden methodspublic int[] getDefaultTokens()
AbstractCheck
getDefaultTokens
in class AbstractCheck
TokenTypes
public int[] getAcceptableTokens()
AbstractCheck
getAcceptableTokens
in class AbstractCheck
TokenTypes
public int[] getRequiredTokens()
AbstractCheck
getRequiredTokens
in class AbstractCheck
TokenTypes
public void visitToken(DetailAST ast)
AbstractCheck
visitToken
in class AbstractCheck
ast
- the token to processCopyright © 2001–2018. All rights reserved.