Sha256: 4b2426862bbc05efb708ff263d02c8759b4e68cb92f8234e463c99298bab78de
Contents?: true
Size: 1.18 KB
Versions: 5
Compression:
Stored size: 1.18 KB
Contents
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. # @api private class BooleanParameter < SmellDetector def self.smell_category 'ControlCouple' end # # Checks whether the given method has any Boolean parameters. # # @return [Array<SmellWarning>] # def examine_context(method_ctx) method_ctx.default_assignments.select do |_param, value| [:true, :false].include?(value[0]) end.map do |parameter, _value| SmellWarning.new self, context: method_ctx.full_name, lines: [method_ctx.exp.line], message: "has boolean parameter '#{parameter}'", parameters: { name: parameter.to_s } end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems