SmellDetector
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.
The default value of the MAX_ALLOWED_PARAMS_KEY configuration value.
The name of the config field that sets the maximum number of parameters permitted in any method or block.
Checks the number of parameters in the given method.
@return [Array<SmellWarning>]
# File lib/reek/smells/long_parameter_list.rb, line 49 def examine_context(ctx) @max_allowed_params = value(MAX_ALLOWED_PARAMS_KEY, ctx, DEFAULT_MAX_ALLOWED_PARAMS) num_params = ctx.exp.arg_names.length return [] if num_params <= @max_allowed_params smell = SmellWarning.new(SMELL_CLASS, ctx.full_name, [ctx.exp.line], "has #{num_params} parameters", @source, SMELL_SUBCLASS, {PARAMETER_COUNT_KEY => num_params}) [smell] end
Generated with the Darkfish Rdoc Generator 2.