Class: Rubocop::Cop::Style::ParameterLists

Inherits:
Cop
  • Object
show all
Defined in:
lib/rubocop/cop/style/parameter_lists.rb

Overview

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.

Constant Summary collapse

MSG =
'Avoid parameter lists longer than %d parameters.'

Instance Attribute Summary

Attributes inherited from Cop

#autocorrect, #corrections, #debug, #disabled_lines, #offences

Instance Method Summary collapse

Methods inherited from Cop

#add_offence, all, #autocorrect_action, cop_name, cop_type, #do_autocorrect, #ignore_node, inherited, #initialize, lint?, #name, rails?, style?

Constructor Details

This class inherits a constructor from Rubocop::Cop::Cop

Instance Method Details

#on_args(node) ⇒ Object



13
14
15
16
17
18
# 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
end