Class: Rubocop::Cop::ParameterLists

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

Constant Summary collapse

ERROR_MESSAGE =
'Avoid parameter lists longer than four parameters.'

Instance Attribute Summary

Attributes inherited from Cop

#correlations, #offences

Instance Method Summary collapse

Methods inherited from Cop

#add_offence, enabled?, #has_report?, inherited, #initialize

Constructor Details

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

Instance Method Details

#inspect(file, source, tokens, sexp) ⇒ Object



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

def inspect(file, source, tokens, sexp)
  each(:params, sexp) do |params|
    if params[1] && params[1].size > 4
      add_offence(:convention, params[1][0][-1].lineno, ERROR_MESSAGE)
    end
  end
end