Skip to content

Commit

Permalink
[Fix #9434] Fix false positive in FirstArgumentIndentation
Browse files Browse the repository at this point in the history
Setter calls are a kind of method invocation that
Layout/FirstArgumentIndentation should just skip.
  • Loading branch information
jonas054 committed Jul 10, 2021
1 parent dc858b7 commit 83e2b6a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog/fix_first_argument_indentation_false_pos.md
@@ -0,0 +1 @@
* [#9434](https://github.com/rubocop/rubocop/issues/9434): Fix false positive for setter calls in `Layout/FirstArgumentIndentation`. ([@jonas054][])
2 changes: 1 addition & 1 deletion lib/rubocop/cop/layout/first_argument_indentation.rb
Expand Up @@ -154,7 +154,7 @@ class FirstArgumentIndentation < Base

def on_send(node)
return if style != :consistent && enforce_first_argument_with_fixed_indentation?
return if !node.arguments? || bare_operator?(node)
return if !node.arguments? || bare_operator?(node) || node.setter_method?

indent = base_indentation(node) + configured_indentation_width

Expand Down
9 changes: 9 additions & 0 deletions spec/rubocop/cop/layout/first_argument_indentation_spec.rb
Expand Up @@ -134,6 +134,15 @@
end
end

context 'for a setter call' do
it 'accepts an unindented value' do
expect_no_offenses(<<~RUBY)
foo.baz =
bar
RUBY
end
end

context 'for assignment' do
it 'accepts a correctly indented first argument and does not care ' \
'about the second argument' do
Expand Down

0 comments on commit 83e2b6a

Please sign in to comment.