Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix an incorrect autocorrect for Style/RedundantDoubleSplatHashBraces #12262

Conversation

koic
Copy link
Member

@koic koic commented Oct 11, 2023

This PR fixes the following incorrect autocorrect for Style/RedundantDoubleSplatHashBraces when using double splat hash braces with merge method call twice.

$ bundle exec rspec  spec/rubocop/cop/style/redundant_double_splat_hash_braces_spec.rb:82
Run options: include {:locations=>{"./spec/rubocop/cop/style/redundant_double_splat_hash_braces_spec.rb"=>[82]}}
(snip)

  Failures:

    1) RuboCop::Cop::Style::RedundantDoubleSplatHashBraces registers an offense
    when using double splat hash braces with `merge` method call twice
    Failure/Error: expect(new_source).to eq(correction)

      expected: "do_something(foo: bar, **options)\ndo_something(baz: qux, **options)\n"
           got: "do_something(foo: bar, **options)\ndo_something(baz: qux.merge(options))\n"

      (compared using ==)

      Diff:
      @@ -1,3 +1,3 @@
       do_something(foo: bar, **options)
      -do_something(baz: qux, **options)
      +do_something(baz: qux.merge(options))

# ./lib/rubocop/rspec/expect_offense.rb:164:in `expect_correction'
# ./spec/rubocop/cop/style/redundant_double_splat_hash_braces_spec.rb:90:in `block (2 levels) in <top (required)>'

Finished in 0.15475 seconds (files took 1.24 seconds to load)
1 example, 1 failure

Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.

@koic koic force-pushed the fix_incorrect_autocorrect_for_style_redundant_double_splat_hash_braces branch from d0cf905 to 24e8ca5 Compare October 11, 2023 12:14
This PR fixes the following incorrect autocorrect for `Style/RedundantDoubleSplatHashBraces`
when using double splat hash braces with `merge` method call twice.

```console
$ bundle exec rspec  spec/rubocop/cop/style/redundant_double_splat_hash_braces_spec.rb:82
Run options: include {:locations=>{"./spec/rubocop/cop/style/redundant_double_splat_hash_braces_spec.rb"=>[82]}}
(snip)

Failures:

  1) RuboCop::Cop::Style::RedundantDoubleSplatHashBraces registers an offense
     when using double splat hash braces with `merge` method call twice
     Failure/Error: expect(new_source).to eq(correction)

       expected: "do_something(foo: bar, **options)\ndo_something(baz: qux, **options)\n"
            got: "do_something(foo: bar, **options)\ndo_something(baz: qux.merge(options))\n"

       (compared using ==)

       Diff:
       @@ -1,3 +1,3 @@
        do_something(foo: bar, **options)
       -do_something(baz: qux, **options)
       +do_something(baz: qux.merge(options))

     # ./lib/rubocop/rspec/expect_offense.rb:164:in `expect_correction'
     # ./spec/rubocop/cop/style/redundant_double_splat_hash_braces_spec.rb:90:in `block (2 levels) in <top (required)>'

Finished in 0.15475 seconds (files took 1.24 seconds to load)
1 example, 1 failure
```
@koic koic force-pushed the fix_incorrect_autocorrect_for_style_redundant_double_splat_hash_braces branch from 24e8ca5 to 99e6f85 Compare October 11, 2023 12:16
@bbatsov bbatsov merged commit e162c99 into rubocop:master Oct 11, 2023
28 checks passed
@koic koic deleted the fix_incorrect_autocorrect_for_style_redundant_double_splat_hash_braces branch October 11, 2023 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants