-
-
Notifications
You must be signed in to change notification settings - Fork 263
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
Add new Rails/HashLiteralKeysConversion
cop
#1333
base: master
Are you sure you want to change the base?
Conversation
Nice! Although I'm seeing this false positive: value = { 'foo' => 'bar' }
{ key: value }.deep_symbolize_keys For |
661d89b
to
54cfc83
Compare
Good catch! Thank you. |
Another tricky false positive: the { a: [ { 'b' => 1 } ] }.deep_symbolize_keys
# => { a: [ { b: 1 } ] } Lastly, if we wanted to be really fancy, we could also detect interpolated keys: ( |
54cfc83
to
df568b2
Compare
Fixed for nested arrays and
Do not want to be fancy - the code is already pretty complex and the usecase is pretty rare, imo. |
Last false positive in our repo: a combination of the previous two cases (nested arrays + non-literal hash value) value = { 'foo' => 'bar' }
{ a: [{ value: value }] }.deep_symbolize_keys # ⚠️ Redundant hash keys conversion, all the keys have the required type.
# => { a: [{ foo: 'bar' }] } |
df568b2
to
b0441e3
Compare
Fixed that too 😅 |
Closes #1332.