lib/pelusa/lint/many_arguments.rb in pelusa-0.2.2 vs lib/pelusa/lint/many_arguments.rb in pelusa-0.2.3
- old
+ new
@@ -4,12 +4,12 @@
def initialize
@violations = Set.new
end
def check(klass)
- initialize
iterate_lines!(klass)
+
return SuccessfulAnalysis.new(name) if @violations.empty?
FailedAnalysis.new(name, formatted_violations) do |violations|
"Methods with more than #{limit} arguments: #{violations.join(', ')}"
end
@@ -24,15 +24,14 @@
def limit
Pelusa.configuration['ManyArguments'].fetch('limit', 3)
end
def iterate_lines!(klass)
- iterator = Iterator.new do |node|
+ ClassAnalyzer.walk(klass) do |node|
if node.is_a?(Rubinius::AST::Define) && node.arguments.total_args > limit
@violations << node.name
end
end
- Array(klass).each(&iterator)
end
def formatted_violations
@violations.to_a
end