Skip to content

Commit

Permalink
Merge pull request #8780 from dvandersluis/fix/layout-assignment-inde…
Browse files Browse the repository at this point in the history
…ntation-infinite-loop

[Fix #8774] Fix false positive with `Layout/ArrayAlignment` for parallel assignment
  • Loading branch information
koic committed Sep 24, 2020
2 parents 4298f75 + 09ee45e commit f07d413
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,10 @@

## master (unreleased)

### Bug fixes

* [#8774](https://github.com/rubocop-hq/rubocop/issues/8774): Fix a false positive for `Layout/ArrayAlignment` with parallel assignment. ([@dvandersluis][])

## 0.91.1 (2020-09-23)

### Bug fixes
Expand Down
1 change: 1 addition & 0 deletions lib/rubocop/cop/layout/array_alignment.rb
Expand Up @@ -44,6 +44,7 @@ class ArrayAlignment < Cop

def on_array(node)
return if node.children.size < 2
return if node.parent&.masgn_type?

check_alignment(node.children, base_column(node, node.children))
end
Expand Down
14 changes: 14 additions & 0 deletions spec/rubocop/cop/layout/array_alignment_spec.rb
Expand Up @@ -169,6 +169,13 @@
]
RUBY
end

it 'does not register an offense or try to correct parallel assignment' do
expect_no_offenses(<<~RUBY)
thing, foo =
1, 2
RUBY
end
end

context 'when aligned with fixed indentation' do
Expand Down Expand Up @@ -328,5 +335,12 @@
]
RUBY
end

it 'does not register an offense or try to correct parallel assignment' do
expect_no_offenses(<<~RUBY)
thing, foo =
1, 2
RUBY
end
end
end

0 comments on commit f07d413

Please sign in to comment.