Sha256: e321264439b2b1e2f6a0b28eb21b3aad62e281fb4e242890bdcb16725f934a11
Contents?: true
Size: 1023 Bytes
Versions: 4
Compression:
Stored size: 1023 Bytes
Contents
require 'simplabs/excellent/checks/base' module Simplabs module Excellent module Checks # This check reports method and blocks that have more parameters than the threshold. Methods with long parameter lists are harder to understand # and often an indicator for bad design as well. # # ==== Applies to # # * methods # * blocks class ParameterNumberCheck < Base DEFAULT_THRESHOLD = 3 def initialize(options = {}) #:nodoc: super @threshold = options[:threshold] || DEFAULT_THRESHOLD @interesting_contexts = [Parsing::MethodContext, Parsing::SingletonMethodContext, Parsing::BlockContext] end def evaluate(context) #:nodoc: unless context.parameters.length <= @threshold add_warning(context, '{{method}} has {{parameters}} parameters.', { :method => context.full_name, :parameters => context.parameters.length }) end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems