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

Commits on Oct 11, 2023

  1. Fix an incorrect autocorrect for Style/RedundantDoubleSplatHashBraces

    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 committed Oct 11, 2023
    Configuration menu
    Copy the full SHA
    99e6f85 View commit details
    Browse the repository at this point in the history