Class: Rubocop::Cop::AlignParameters
- Defined in:
- lib/rubocop/cop/align_parameters.rb
Constant Summary collapse
- MSG =
'Align the parameters of a method call if they span ' + 'more than one line.'
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
#on_send(node) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rubocop/cop/align_parameters.rb', line 9 def on_send(node) _receiver, method, *args = *node if method != :[]= && args.size > 1 first_arg_col = args.first.loc.expression.column prev_arg_line = args.first.loc.expression.line prev_arg_col = first_arg_col args.each do |arg| cur_arg_line = arg.loc.expression.line cur_arg_col = arg.loc.expression.column if cur_arg_line != prev_arg_line && cur_arg_col != first_arg_col add_offence(:convetion, cur_arg_line, MSG) end prev_arg_col = cur_arg_col prev_arg_line = cur_arg_line end end super end |