class Reek::SmellDetectors::BooleanParameter
A Boolean parameter effectively permits a method’s caller to decide which execution path to take. The offending parameter is a kind of Control Couple.
Currently Reek
can only detect a Boolean parameter when it has a default initializer.
See {file:docs/Boolean-Parameter.md} for details.
Constants
- BOOLEAN_VALUES
Public Instance Methods
Source
# File lib/reek/smell_detectors/boolean_parameter.rb, line 24 def sniff context.default_assignments.select do |_parameter, value| BOOLEAN_VALUES.include?(value.type) end.map do |parameter, _value| smell_warning( lines: [source_line], message: "has boolean parameter '#{parameter}'", parameters: { parameter: parameter.to_s }) end end
Checks whether the given method has any Boolean parameters.
@return [Array<SmellWarning>]