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/BracesAroundHashParameters #6443

Commits on Nov 5, 2018

  1. Fix an incorrect autocorrect for Style/BracesAroundHashParameters

    Fixes rubocop/rubocop-jp#45. (This link is Japanese issue)
    
    This PR fixes an incorrect autocorrect for `Style/BracesAroundHashParameters`
    when the opening brace is before the first hash element.
    
    ```console
    % rubocop -V
    0.60.0 (using Parser 2.5.1.2, running on ruby 2.5.1 x86_64-darwin17)
    
    % cat example.rb
    # frozen_string_literal: true
    
    foo = Foo.new(
      { foo: 'foo',
        bar: 'bar',
        baz: 'this is the last element'}
    )
    ```
    
    The following difference is the execution result of `rubocop -a` command.
    
    ## Before
    
    The last element is lost.
    
    ```diff
    diff --git a/example.rb b/example.rb
    index ecf9711..c9a02b8 100644
    --- a/example.rb
    +++ b/example.rb
    @@ -1,7 +1,6 @@
     # frozen_string_literal: true
    
     foo = Foo.new(
    -  { foo: 'foo',
    -    bar: 'bar',
    -    baz: 'this is the last element'}
    +  foo: 'foo',
    +  bar: 'bar'
     )
    ```
    
    ## After
    
    Remove only the braces.
    
    ```diff
    diff --git a/example.rb b/example.rb
    index ecf9711..57790da 100644
    --- a/example.rb
    +++ b/example.rb
    @@ -1,7 +1,7 @@
     # frozen_string_literal: true
    
     foo = Foo.new(
    -  { foo: 'foo',
    -    bar: 'bar',
    -    baz: 'this is the last element'}
    +  foo: 'foo',
    +  bar: 'bar',
    +  baz: 'this is the last element'
     )
    ```
    koic committed Nov 5, 2018
    Configuration menu
    Copy the full SHA
    df46f61 View commit details
    Browse the repository at this point in the history