Skip to content

Commit

Permalink
Merge pull request #10458 from koic/fix_false_positive_for_layout_mul…
Browse files Browse the repository at this point in the history
…tiline_method_call_indentation

[Fix #10456] Fix a false positive for `Layout/MultilineMethodCallIndentation`
  • Loading branch information
koic committed Mar 19, 2022
2 parents 5b6e3a2 + 30f8583 commit ef61df5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
@@ -0,0 +1 @@
* [#10456](https://github.com/rubocop/rubocop/issues/10456): Fix a false positive for `Layout/MultilineMethodCallIndentation` when using `EnforcedStyle: indented` with indented assignment method. ([@koic][])
4 changes: 3 additions & 1 deletion lib/rubocop/cop/mixin/multiline_expression_indentation.rb
Expand Up @@ -29,7 +29,9 @@ def on_send(node)
# b c { block }. <-- b is indented relative to a
# d <-- d is indented relative to a
def left_hand_side(lhs)
lhs = lhs.parent while lhs.parent&.send_type? && lhs.parent.loc.dot
while lhs.parent&.send_type? && lhs.parent.loc.dot && !lhs.parent.assignment_method?
lhs = lhs.parent
end
lhs
end

Expand Down
Expand Up @@ -985,6 +985,15 @@ def foo
.to_s
RUBY
end

it "accepts indentation of assignment to obj.#{lhs} with newline after =" do
expect_no_offenses(<<~RUBY)
obj.#{lhs} =
int_part
.abs
.to_s
RUBY
end
end

include_examples 'assignment', 'a'
Expand Down

0 comments on commit ef61df5

Please sign in to comment.