Sha256: f246bf55d859e53c71b4f69a739551fdc7f752fc1b3760036fe758318308a54a
Contents?: true
Size: 1.31 KB
Versions: 14
Compression:
Stored size: 1.31 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 include AutocorrectAlignment MSG = 'Align the parameters of a method call if they span ' \ 'more than one line.' def on_send(node) _receiver, method, *args = *node return if method == :[]= return if args.size <= 1 check_alignment(args, base_column(node, args)) end private def fixed_indentation? cop_config['EnforcedStyle'] == 'with_fixed_indentation' end def base_column(node, args) if fixed_indentation? lineno = target_method_lineno(node) line = node.loc.expression.source_buffer.source_line(lineno) indentation_of_line = /\S.*/.match(line).begin(0) indentation_of_line + configured_indentation_width else args.first.loc.column end end def target_method_lineno(node) if node.loc.selector node.loc.selector.line else # l.(1) has no selector, so we use the opening parenthesis instead node.loc.begin.line end end end end end end
Version data entries
14 entries across 14 versions & 1 rubygems