Class ParameterNumberCheck

java.lang.Object
com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
com.puppycrawl.tools.checkstyle.api.AbstractCheck
com.puppycrawl.tools.checkstyle.checks.sizes.ParameterNumberCheck
com.qulice.checkstyle.ParameterNumberCheck
All Implemented Interfaces:
com.puppycrawl.tools.checkstyle.api.Configurable, com.puppycrawl.tools.checkstyle.api.Contextualizable

public final class ParameterNumberCheck extends com.puppycrawl.tools.checkstyle.checks.sizes.ParameterNumberCheck
Number of parameters, tolerant to constructors that only take attributes and to private methods.

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
    Constructor
    Description
    Default constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    visitToken(com.puppycrawl.tools.checkstyle.api.DetailAST ast)
     

    Methods inherited from class com.puppycrawl.tools.checkstyle.checks.sizes.ParameterNumberCheck

    getAcceptableTokens, getDefaultTokens, getRequiredTokens, setIgnoreAnnotatedBy, setIgnoreOverriddenMethods, setMax

    Methods 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, setTokens

    Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter

    finishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverity

    Methods inherited from class com.puppycrawl.tools.checkstyle.AbstractAutomaticBean

    configure, contextualize, getConfiguration, setupChild

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ParameterNumberCheck

      public ParameterNumberCheck()
      Default constructor.
  • Method Details

    • visitToken

      public void visitToken(com.puppycrawl.tools.checkstyle.api.DetailAST ast)
      Overrides:
      visitToken in class com.puppycrawl.tools.checkstyle.checks.sizes.ParameterNumberCheck