class Reek::SmellDetectors::LongYieldList
A variant on LongParameterList
that checks the number of items passed to a block by a yield
call.
See {file:docs/Long-Yield-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_yield_list.rb, line 18 def self.default_config super.merge MAX_ALLOWED_PARAMS_KEY => DEFAULT_MAX_ALLOWED_PARAMS end
Calls superclass method
Reek::SmellDetectors::BaseDetector::default_config
Public Instance Methods
Source
# File lib/reek/smell_detectors/long_yield_list.rb, line 28 def sniff context.local_nodes(:yield).select do |yield_node| yield_node.args.length > max_allowed_params end.map do |yield_node| count = yield_node.args.length smell_warning( lines: [yield_node.line], message: "yields #{count} parameters", parameters: { count: count }) end end
Checks the number of parameters in the given scope.
@return [Array<SmellWarning>]
@quality :reek:DuplicateMethodCall { max_calls: 2 }
Private Instance Methods
Source
# File lib/reek/smell_detectors/long_yield_list.rb, line 42 def max_allowed_params value(MAX_ALLOWED_PARAMS_KEY, context) end