class Reek::SmellDetectors::LongParameterList
A Long Parameter List occurs when a method has more than one or two parameters, or when a method yields more than one or two objects to an associated block.
Currently LongParameterList
reports any method or block with too many parameters.
See {file:docs/Long-Parameter-List.md} for details.
Constants
- DEFAULT_MAX_ALLOWED_PARAMS
- MAX_ALLOWED_PARAMS_KEY
-
The name of the config field that sets the maximum number of parameters permitted in any method or block.
Public Class Methods
Source
# File lib/reek/smell_detectors/long_parameter_list.rb, line 22 def self.default_config super.merge( MAX_ALLOWED_PARAMS_KEY => DEFAULT_MAX_ALLOWED_PARAMS, SmellConfiguration::OVERRIDES_KEY => { 'initialize' => { MAX_ALLOWED_PARAMS_KEY => 5 } }) end
Calls superclass method
Reek::SmellDetectors::BaseDetector::default_config
Public Instance Methods
Source
# File lib/reek/smell_detectors/long_parameter_list.rb, line 35 def sniff count = expression.arg_names.length return [] if count <= max_allowed_params [smell_warning( lines: [source_line], message: "has #{count} parameters", parameters: { count: count })] end
Checks the number of parameters in the given method.
@return [Array<SmellWarning>]
Private Instance Methods
Source
# File lib/reek/smell_detectors/long_parameter_list.rb, line 47 def max_allowed_params value(MAX_ALLOWED_PARAMS_KEY, context) end