Sha256: 6a4357d38c28ca13f6a1765a5770476d0a916b19cebbc469104da347c709c621
Contents?: true
Size: 1.05 KB
Versions: 1
Compression:
Stored size: 1.05 KB
Contents
# frozen_string_literal: true require_relative 'smell_detector' require_relative 'smell_warning' module Reek module Smells # # 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. class BooleanParameter < SmellDetector # # Checks whether the given method has any Boolean parameters. # # @return [Array<SmellWarning>] # # :reek:FeatureEnvy def sniff(ctx) ctx.default_assignments.select do |_parameter, value| [:true, :false].include?(value.type) end.map do |parameter, _value| smell_warning( context: ctx, lines: [ctx.exp.line], message: "has boolean parameter '#{parameter}'", parameters: { parameter: parameter.to_s }) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
reek-4.4.2 | lib/reek/smells/boolean_parameter.rb |