Add new Rails/HashLiteralKeysConversion cop#1333
Add new Rails/HashLiteralKeysConversion cop#1333fatkodima wants to merge 1 commit intorubocop:masterfrom
Rails/HashLiteralKeysConversion cop#1333Conversation
|
Nice! Although I'm seeing this false positive: value = { 'foo' => 'bar' }
{ key: value }.deep_symbolize_keysFor |
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 😅 |
|
ping @koic |
Closes #1332.