Sha256: 4f1d26e9dcc9396be8281c9d90d3a27e28d3c5e4936200a3325d085611f2e4ad
Contents?: true
Size: 823 Bytes
Versions: 2
Compression:
Stored size: 823 Bytes
Contents
require 'simplabs/excellent/checks/base' module Simplabs module Excellent module Checks class ParameterNumberCheck < Base DEFAULT_THRESHOLD = 3 def initialize(options = {}) super() @threshold = options[:threshold] || DEFAULT_THRESHOLD end def interesting_nodes [:defn] end def evaluate(node) method_name = node[1] parameters = node[2][1..-1] parameter_count = parameters.inject(0) { |count, each| count = count + (each.class == Symbol ? 1 : 0) } unless parameter_count <= @threshold add_error('Method {{method}} has {{parameter_count}} parameters.', { :method => method_name, :parameter_count => parameter_count }) end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
simplabs-excellent-1.0.0 | lib/simplabs/excellent/checks/parameter_number_check.rb |
simplabs-excellent-1.0.1 | lib/simplabs/excellent/checks/parameter_number_check.rb |