Sha256: e52c22d844dcdfbf2bb659bc260e741b1c1e42f902462167bff8ed835e76d848
Contents?: true
Size: 1.29 KB
Versions: 8
Compression:
Stored size: 1.29 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 + 2 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
8 entries across 8 versions & 2 rubygems