public class ParameterNumberCheck extends Check
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) {
...
}
Constructor and Description |
---|
ParameterNumberCheck() |
Modifier and Type | Method and Description |
---|---|
int[] |
getDefaultTokens()
Returns the default token a check is interested in.
|
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, destroy, finishTree, getAcceptableTokens, getClassLoader, getFileContents, getLine, getLines, getRequiredTokens, getTabWidth, getTokenNames, init, isCommentNodesRequired, leaveToken, log, log, setClassLoader, setFileContents, setMessages, setTabWidth, setTokens
getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, log, setId, setSeverity
configure, contextualize, finishLocalSetup, getConfiguration, setupChild
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()
Check
getDefaultTokens
in class Check
TokenTypes
public void visitToken(DetailAST ast)
Check
visitToken
in class Check
ast
- the token to processCopyright © 2001–2015. All rights reserved.