Class: Rubocop::Cop::ParameterLists

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

Constant Summary collapse

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

Instance Attribute Summary

Attributes inherited from Cop

#debug, #disabled_lines, #offences

Instance Method Summary collapse

Methods inherited from Cop

#add_offence, cop_name, #has_report?, #ignore_node, inherited, #initialize, #inspect, #name, #on_comment

Constructor Details

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

Instance Method Details

#max_paramsObject



18
19
20
# File 'lib/rubocop/cop/parameter_lists.rb', line 18

def max_params
  ParameterLists.config['Max']
end

#on_args(node) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/rubocop/cop/parameter_lists.rb', line 8

def on_args(node)
  args_count = node.children.size

  if args_count > max_params
    add_offence(:convention, node.loc.line, sprintf(MSG, max_params))
  end

  super
end