class RuboCop::Cop::Layout::FirstParameterIndentation
end
123
second_param)
first_param,
def some_method(
# good
# opening parenthesis.
# The first parameter should always be indented one step more than the
@example EnforcedStyle: align_parentheses
end
123
second_param)
first_param,
def some_method(
# good
# preceding line.
# The first parameter should always be indented one step more than the
@example EnforcedStyle: consistent (default)
end
123
second_param)
first_param,
def some_method(
# bad
@example
nesting that are irrelevant for method definitions.
Layout/FirstArgumentIndentation, which supports options related to
For indenting the first argument of method calls, check out
Layout/ParameterAlignment, not by this cop.
definition. Parameters after the first one are checked by
Checks the indentation of the first parameter in a method
def autocorrect(corrector, node)
def autocorrect(corrector, node) AlignmentCorrector.correct(corrector, processed_source, node, @column_delta) end
def base_description(_)
def base_description(_) if style == brace_alignment_style 'the position of the opening parenthesis' else 'the start of the line where the left parenthesis is' end end
def brace_alignment_style
def brace_alignment_style :align_parentheses end
def check(def_node)
def check(def_node) return if ignored_node?(def_node) left_parenthesis = def_node.arguments.loc.begin first_elem = def_node.arguments.first return unless first_elem return if same_line?(first_elem, left_parenthesis) check_first(first_elem, left_parenthesis, nil, 0) end
def message(base_description)
def message(base_description) format( MSG, configured_indentation_width: configured_indentation_width, base_description: base_description ) end
def on_def(node)
def on_def(node) return if node.arguments.empty? return if node.arguments.loc.begin.nil? check(node) end