Parent

Class/Module Index [+]

Quicksearch

Reek::Smells::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.

Public Instance Methods

examine_context(method_ctx) click to toggle source

Checks whether the given method has any Boolean parameters.

@return [Array<SmellWarning>]

# File lib/reek/smells/boolean_parameter.rb, line 27
def examine_context(method_ctx)
  method_ctx.parameters.default_assignments.select do |param, value|
    [:true, :false].include?(value[0])
  end.map do |param, value|
    SmellWarning.new(SMELL_CLASS, method_ctx.full_name, [method_ctx.exp.line],
                     "has boolean parameter '#{param.to_s}'",
                     @source, SMELL_SUBCLASS, {PARAMETER_KEY => param.to_s})
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.