class Rubocop::Cop::Style::ParameterLists

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.

Constants

MSG

Public Instance Methods

on_args(node) click to toggle source
Calls superclass method
# File lib/rubocop/cop/style/parameter_lists.rb, line 13
def on_args(node)
  if args_count(node) > max_params
    add_offence(:convention, node.loc.expression,
                sprintf(MSG, max_params))
  end

  super
end

Private Instance Methods

args_count(node) click to toggle source
# File lib/rubocop/cop/style/parameter_lists.rb, line 24
def args_count(node)
  if count_keyword_args?
    node.children.size
  else
    node.children.reject { |a| a.type == :kwoptarg }.size
  end
end
count_keyword_args?() click to toggle source
# File lib/rubocop/cop/style/parameter_lists.rb, line 36
def count_keyword_args?
  ParameterLists.config['CountKeywordArgs']
end
max_params() click to toggle source
# File lib/rubocop/cop/style/parameter_lists.rb, line 32
def max_params
  ParameterLists.config['Max']
end