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

Style/HashSyntax: EnforcedShorthandSyntax: always cause syntax error on ruby 3.1 #10494

Closed
zw963 opened this issue Mar 31, 2022 · 0 comments · Fixed by #10497
Closed

Style/HashSyntax: EnforcedShorthandSyntax: always cause syntax error on ruby 3.1 #10494

zw963 opened this issue Mar 31, 2022 · 0 comments · Fixed by #10497
Labels

Comments

@zw963
Copy link

zw963 commented Mar 31, 2022

Following is a sample:

return failed msg: 'Added', contact: contact if contact.present?

When run rubocop -a . for above file, it will be changed to:

return failed msg: 'Added', contact:  if contact.present?

Which is a syntax error.

version

rubocop 1.26.1, ruby 3.1.0, with following settings:

# .rubocop.yml
Style/HashSyntax:
  EnforcedShorthandSyntax: always
@koic koic added the bug label Mar 31, 2022
koic added a commit to koic/rubocop that referenced this issue Mar 31, 2022
Fixes rubocop#10494.

This PR fixes a false positive for `Style/HashSyntax` when `return`
with one line `if` condition follows (without parentheses).
koic added a commit that referenced this issue Apr 2, 2022
…sh_syntax

[Fix #10494] Fix a false positive for `Style/HashSyntax`
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