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

HashSyntax autocorrect breaks return statements #7972

Closed
viraptor opened this issue May 15, 2020 · 0 comments · Fixed by #7973
Closed

HashSyntax autocorrect breaks return statements #7972

viraptor opened this issue May 15, 2020 · 0 comments · Fixed by #7973
Labels

Comments

@viraptor
Copy link

HashSyntax autocorrection results in a broken return syntax if the braces were not included.


Expected behavior

return :a => 1

should get autocorrected to:

return {a: 1}

Actual behavior

Gets corrected to:

return a: 1

Which gives:

SyntaxError ((irb):6: syntax error, unexpected ':', expecting keyword_end)

Steps to reproduce the problem

rubocop --only Style/HashSyntax -a ...

RuboCop version

Include the output of rubocop -V or bundle exec rubocop -V if using Bundler. Here's an example:

0.83.0 (using Parser 2.7.1.2, running on ruby 2.5.8 x86_64-darwin18)
@koic koic added the bug label May 15, 2020
koic added a commit to koic/rubocop that referenced this issue May 15, 2020
Fixes rubocop#7972.

Fix an incorrect autocorrect for `Style/HashSyntax` when using
a return value uses `return`.
bbatsov pushed a commit that referenced this issue May 15, 2020
Fixes #7972.

Fix an incorrect autocorrect for `Style/HashSyntax` when using
a return value uses `return`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants