Sha256: b95e75c1c3313a121fa4dfcfee3cae531746450a2af8f80581fa882e1213ce44
Contents?: true
Size: 960 Bytes
Versions: 12
Compression:
Stored size: 960 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_nodes = [:defn, :iter, :defs] 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
12 entries across 12 versions & 2 rubygems