Skip to content

Commit

Permalink
Merge pull request rubocop#11392 from koic/fix_an_incorrect_autocorre…
Browse files Browse the repository at this point in the history
…ct_for_style_redundant_double_splat_hash_braces

Fix an incorrect autocorrect for `Style/RedundantDoubleSplatHashBraces`
  • Loading branch information
koic authored Jan 7, 2023
2 parents f9248c8 + 36d8ea7 commit 6e3f7c1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#11392](https://github.com/rubocop/rubocop/pull/11392): Fix an incorrect autocorrect for `Style/RedundantDoubleSplatHashBraces` using double splat in double splat hash braces. ([@koic][])
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def on_hash(node)
return unless double_splat_hash_braces?(grandparent)

add_offense(grandparent) do |corrector|
corrector.replace(grandparent, node.pairs.map(&:source).join(', '))
corrector.replace(grandparent, node.children.map(&:source).join(', '))
end
end
end
Expand Down
11 changes: 11 additions & 0 deletions spec/rubocop/cop/style/redundant_double_splat_hash_braces_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@
RUBY
end

it 'registers an offense when using double splat in double splat hash braces' do
expect_offense(<<~RUBY)
do_something(**{foo: bar, **options})
^^^^^^^^^^^^^^^^^^^^^^^ Remove the redundant double splat and braces, use keyword arguments directly.
RUBY

expect_correction(<<~RUBY)
do_something(foo: bar, **options)
RUBY
end

it 'does not register an offense when using keyword arguments' do
expect_no_offenses(<<~RUBY)
do_something(foo: bar, baz: qux)
Expand Down

0 comments on commit 6e3f7c1

Please sign in to comment.