Class ParameterNumberCheck
- All Implemented Interfaces:
com.puppycrawl.tools.checkstyle.api.Configurable,com.puppycrawl.tools.checkstyle.api.Contextualizable
The stock ParameterNumber check treats a constructor as it
treats a method, while a constructor has no choice: it must accept a
value for every attribute of its class. A long list of parameters there
is a symptom of a class with too many attributes, and the class is what
has to be blamed, not its constructor. That's why a constructor with no
more parameters than the number of attributes of its class passes here,
no matter how big the limit is.
A private method passes too. It is invisible outside its class, its parameters belong to no contract anybody else can see, and wrapping them into a new type only to satisfy the limit buys nothing.
So does a method of a JNA binding, whose parameter list repeats the signature of a native function and cannot be shortened without breaking the mapping.
- Since:
- 1.0
-
Nested Class Summary
Nested classes/interfaces inherited from class com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
com.puppycrawl.tools.checkstyle.AbstractAutomaticBean.OutputStreamOptions -
Field Summary
Fields inherited from class com.puppycrawl.tools.checkstyle.checks.sizes.ParameterNumberCheck
MSG_KEY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvisitToken(com.puppycrawl.tools.checkstyle.api.DetailAST ast) Methods inherited from class com.puppycrawl.tools.checkstyle.checks.sizes.ParameterNumberCheck
getAcceptableTokens, getDefaultTokens, getRequiredTokens, setIgnoreAnnotatedBy, setIgnoreOverriddenMethods, setMaxMethods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractCheck
beginTree, clearViolations, destroy, finishTree, getFileContents, getFilePath, getLine, getLineCodePoints, getLines, getTabWidth, getTokenNames, getViolations, init, isCommentNodesRequired, leaveToken, log, log, log, setFileContents, setTabWidth, setTokensMethods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
finishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverityMethods inherited from class com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
configure, contextualize, getConfiguration, setupChild
-
Constructor Details
-
ParameterNumberCheck
public ParameterNumberCheck()Default constructor.
-
-
Method Details
-
visitToken
public void visitToken(com.puppycrawl.tools.checkstyle.api.DetailAST ast) - Overrides:
visitTokenin classcom.puppycrawl.tools.checkstyle.checks.sizes.ParameterNumberCheck
-