Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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' ) ```
- Loading branch information