Sha256: 67cdd7756f8ff9b644faa090a73c5678cecf38d1d545ba7ecfe917f945953e73
Contents?: true
Size: 1.18 KB
Versions: 6
Compression:
Stored size: 1.18 KB
Contents
require 'reek/smells/smell_detector' require 'reek/smell_warning' module Reek module Smells # # A Long Parameter List occurs when a method has more than one # or two parameters, or when a method yields more than one or # two objects to an associated block. # # Currently +LongParameterList+ reports any method or block with too # many parameters. # class LongParameterList < SmellDetector # The name of the config field that sets the maximum number of # parameters permitted in any method or block. MAX_ALLOWED_PARAMS_KEY = 'max_params' def self.default_config super.adopt(MAX_ALLOWED_PARAMS_KEY => 3) end def initialize(config) super @max_params = config['max_params'] @action = 'has' end # # Checks the number of parameters in the given scope. # Any smells found are added to the +report+. # def examine_context(ctx, report) num_params = ctx.parameters.length return false if num_params <= @max_params report << SmellWarning.new(self, ctx, "#{@action} #{num_params} parameters") end end end end
Version data entries
6 entries across 6 versions & 2 rubygems