class RuboCop::Cop::Layout::AlignParameters
end
123
baz)
bar,
def foo(
# bad
end
123
baz)
def foo(bar,
# bad
end
123
)
baz
bar,
def foo(
end
123
baz)
def foo(bar,
# good
@example EnforcedStyle: with_fixed_indentation
end
123
baz)
bar,
def foo(
# bad
end
123
baz)
def foo(bar,
# bad
end
123
)
baz
bar,
def foo(
end
123
baz)
def foo(bar,
# good
@example EnforcedStyle: with_first_parameter (default)
FirstParameterIndentation.
To set the alignment of the first argument, use the cop
definition are aligned.
Here we check if the parameters on a multi-line method call or
def autocorrect(node)
def autocorrect(node) AlignmentCorrector.correct(processed_source, node, column_delta) end
def base_column(node, args)
def base_column(node, args) if fixed_indentation? lineno = target_method_lineno(node) line = node.source_range.source_buffer.source_line(lineno) indentation_of_line = /\S.*/.match(line).begin(0) indentation_of_line + configured_indentation_width else display_column(args.first.source_range) end end
def fixed_indentation?
def fixed_indentation? cop_config['EnforcedStyle'] == 'with_fixed_indentation' end
def message(_node)
def message(_node) fixed_indentation? ? FIXED_INDENT_MSG : ALIGN_PARAMS_MSG end
def on_def(node)
def on_def(node) return if node.arguments.size < 2 check_alignment(node.arguments, base_column(node, node.arguments)) end
def target_method_lineno(node)
def target_method_lineno(node) node.loc.keyword.line end