Sha256: a59115c1822a0e3775409ec23ac048ebbe8330eff24bab3a9916caebec7169a0
Contents?: true
Size: 674 Bytes
Versions: 1
Compression:
Stored size: 674 Bytes
Contents
require 'roodi/checks/check' module Roodi module Checks class ParameterNumberCheck < Check def initialize(parameter_count = 5) super() @parameter_count = parameter_count end def interesting_nodes [:defn] end def evaluate(node) method_name = node[1] arguments = node[2][1][1] parameter_count = arguments.inject(-1) { |count, each| count = count + (each.class == Symbol ? 1 : 0) } add_error "Method name \"#{method_name}\" has #{parameter_count} parameters. It should have #{@parameter_count} or less." unless parameter_count <= @parameter_count end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
roodi-1.2.0 | lib/roodi/checks/parameter_number_check.rb |