Sha256: 3e0311017829cdae914da20e60fb33084d43cc22ee76cccf352b69dafda22092
Contents?: true
Size: 1.03 KB
Versions: 3
Compression:
Stored size: 1.03 KB
Contents
# encoding: utf-8 module Rubocop module Cop module Style # Here we check if the parameters on a multi-line method call are # aligned. class AlignParameters < Cop MSG = 'Align the parameters of a method call if they span ' + 'more than one line.' 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(:convention, arg.loc.expression, MSG) end prev_arg_col = cur_arg_col prev_arg_line = cur_arg_line end end super end end end end end
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
rubocop-0.9.1 | lib/rubocop/cop/style/align_parameters.rb |
sabat-rubocop-0.9.0 | lib/rubocop/cop/style/align_parameters.rb |
rubocop-0.9.0 | lib/rubocop/cop/style/align_parameters.rb |