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/HashTransformValues vs no-braces hashes in arrays #9940

Closed
zverok opened this issue Jul 19, 2021 · 0 comments · Fixed by #9941
Closed

Style/HashTransformValues vs no-braces hashes in arrays #9940

zverok opened this issue Jul 19, 2021 · 0 comments · Fixed by #9941
Labels

Comments

@zverok
Copy link
Contributor

zverok commented Jul 19, 2021

Code:

x = {a: 1, b: 2}.to_h { |key, val| [key, value: val] }

.rubocop.yml:

Style/HashAsLastArrayItem:
  EnforcedStyle: no_braces

Run rubocop --only Style/HashTransformValues -A


Expected behavior

x = {a: 1, b: 2}.transform_values { |val| {value: val} }

Actual behavior

x = {a: 1, b: 2}.transform_values { |val| value: val }

RuboCop version

$ rubocop -V
1.18.3 (using Parser 3.0.1.1, rubocop-ast 1.7.0, running on ruby 2.7.3 x86_64-linux)
@koic koic added the bug label Jul 19, 2021
koic added a commit to koic/rubocop that referenced this issue Jul 19, 2021
…formValues`

Fixes rubocop#9940.

This PR fixes an incorrect auto-correct for `Style/HashTransformValues`
when value is a hash literal for `_.to_h{...}`.
bbatsov pushed a commit that referenced this issue Jul 20, 2021
…ues`

Fixes #9940.

This PR fixes an incorrect auto-correct for `Style/HashTransformValues`
when value is a hash literal for `_.to_h{...}`.
thearjunmdas pushed a commit to thearjunmdas/rubocop that referenced this issue Aug 20, 2021
…formValues`

Fixes rubocop#9940.

This PR fixes an incorrect auto-correct for `Style/HashTransformValues`
when value is a hash literal for `_.to_h{...}`.
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