Sha256: d185d9f404f1ccdf4e6afe2783096ad4c79f45d874ea3607916bdd9f581adeda
Contents?: true
Size: 1017 Bytes
Versions: 3
Compression:
Stored size: 1017 Bytes
Contents
# encoding: utf-8 module Rubocop module Cop module Style # This cop checks for methods with too many parameters. # The maximum number of parameters in configurable. # On Ruby 2.0+ keyword arguments can optionally # be excluded from the total count. class ParameterLists < Cop MSG = 'Avoid parameter lists longer than %d parameters.' def on_args(node) if args_count(node) > max_params add_offence(:convention, node.loc.expression, sprintf(MSG, max_params)) end super end private def args_count(node) if count_keyword_args? node.children.size else node.children.reject { |a| a.type == :kwoptarg }.size end end def max_params ParameterLists.config['Max'] end def count_keyword_args? ParameterLists.config['CountKeywordArgs'] end end end end end
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
rubocop-0.9.1 | lib/rubocop/cop/style/parameter_lists.rb |
sabat-rubocop-0.9.0 | lib/rubocop/cop/style/parameter_lists.rb |
rubocop-0.9.0 | lib/rubocop/cop/style/parameter_lists.rb |