Skip to content

Commit

Permalink
[Fix rubocop#6936] Fix MultilineMethodArgumentLineBreaks when bracket…
Browse files Browse the repository at this point in the history
… hash assignment on multiple lines
  • Loading branch information
Buildkite committed May 23, 2019
1 parent b82b3ef commit 504a514
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

* [#5976](https://github.com/rubocop-hq/rubocop/issues/5976): Warn for Rails Cops. ([@koic][])

### Bug fixes

* [#6936](https://github.com/rubocop-hq/rubocop/issues/6936): Fix `Layout/MultilineMethodArgumentLineBreaks` when bracket hash assignment on multiple lines. ([@maxh][])

## 0.70.0 (2019-05-21)

### New features
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class MultilineMethodArgumentLineBreaks < Cop
'on a separate line.'

def on_send(node)
return if node.method_name == :[]=

args = node.arguments

# If there is a trailing hash arg without explicit braces, like this:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,33 @@
end
end

context 'when bracket hash assignment on multiple lines' do
it 'does not add any offenses' do
expect_no_offenses(
<<-RUBY
class Thing
def call
bar['foo'] = ::Time.zone.at(
huh['foo'],
)
end
end
RUBY
)
end
end

context 'when bracket hash assignment key on multiple lines' do
it 'does not add any offenses' do
expect_no_offenses(
<<-RUBY
a['b',
'c', 'd'] = e
RUBY
)
end
end

context 'when two arguments are on next line' do
it 'does not add any offenses' do
expect_no_offenses(
Expand Down

0 comments on commit 504a514

Please sign in to comment.