Sha256: ef12b1dc111fdb2114dc35536464d811f43fcc6ca72bbc93a6c4f8a5c987b7b9
Contents?: true
Size: 956 Bytes
Versions: 5
Compression:
Stored size: 956 Bytes
Contents
module Pelusa module Lint class ManyArguments 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 end private def name "Methods have short argument lists" end def limit Pelusa.configuration['ManyArguments'].fetch('limit', 3) end def iterate_lines!(klass) iterator = Iterator.new 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 end end end
Version data entries
5 entries across 5 versions & 1 rubygems