Class ParameterNumberCheck

  • All Implemented Interfaces:
    Configurable, Contextualizable

    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:
     
    
      &#064;Override
      public void needsLotsOfParameters(int a,
          int b, int c, int d, int e, int f, int g, int h) {
          ...
      }
     
     
    Author:
    Oliver Burn
    • Method Detail

      • setMax

        public void setMax​(int max)
        Sets the maximum number of allowed parameters.
        Parameters:
        max - the max allowed parameters
      • setIgnoreOverriddenMethods

        public void setIgnoreOverriddenMethods​(boolean ignoreOverriddenMethods)
        Ignore number of parameters for methods with @Override annotation.
        Parameters:
        ignoreOverriddenMethods - set ignore overridden methods
      • getAcceptableTokens

        public int[] getAcceptableTokens()
        Description copied from class: AbstractCheck
        The configurable token set. Used to protect Checks against malicious users who specify an unacceptable token set in the configuration file. The default implementation returns the check's default tokens.
        Specified by:
        getAcceptableTokens in class AbstractCheck
        Returns:
        the token set this check is designed for.
        See Also:
        TokenTypes