class RuboCop::Cop::Layout::AssignmentIndentation
Checks the indentation of the first line of the right-hand-side of a multi-line assignment.
The indentation of the remaining lines can be corrected with other cops such as ‘Layout/IndentationConsistency` and `Layout/EndAlignment`.
@example
# bad value = if foo 'bar' end # good value = if foo 'bar' end
Constants
- MSG
Private Instance Methods
Source
# File lib/rubocop/cop/layout/assignment_indentation.rb, line 43 def autocorrect(corrector, node) AlignmentCorrector.correct(corrector, processed_source, node, column_delta) end
Source
# File lib/rubocop/cop/layout/assignment_indentation.rb, line 34 def check_assignment(node, rhs) return unless rhs return unless node.loc.operator return if same_line?(node.loc.operator, rhs) base = display_column(leftmost_multiple_assignment(node).source_range) check_alignment([rhs], base + configured_indentation_width) end
Source
# File lib/rubocop/cop/layout/assignment_indentation.rb, line 47 def leftmost_multiple_assignment(node) return node unless same_line?(node, node.parent) && node.parent.assignment? leftmost_multiple_assignment(node.parent) node.parent end