Class: Rubocop::Cop::OpMethod
Constant Summary collapse
- ERROR_MESSAGE =
'When defining the %s operator, name its argument other.'
Instance Attribute Summary
Attributes inherited from Cop
#correlations, #debug, #disabled_lines, #offences
Instance Method Summary collapse
Methods inherited from Cop
#add_offence, cop_name, #has_report?, inherited, #initialize, #name
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 15 16 17 18 19 |
# File 'lib/rubocop/cop/op_method.rb', line 8 def inspect(file, source, tokens, sexp) each(:def, sexp) do |s| if binary_operator?(s) && !%w([] []= <<).include?(s[1][1]) params = parameters(s[2]) unless params[0][1] == 'other' add_offence(:convention, params[0][2].lineno, sprintf(ERROR_MESSAGE, s[1][1])) end end end end |