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

Lint/SymbolConversion false positive for Hash keys that contain ":" #9455

Closed
s-mage opened this issue Jan 29, 2021 · 2 comments · Fixed by #9456
Closed

Lint/SymbolConversion false positive for Hash keys that contain ":" #9455

s-mage opened this issue Jan 29, 2021 · 2 comments · Fixed by #9456
Labels

Comments

@s-mage
Copy link

s-mage commented Jan 29, 2021

Hello. Thanks for your work on the rubocop, it's a great tool.

I've found a false positive for Lint/SymbolConversion cop. It reacts on hash keys like :"one:two" and suggests to replace them with :onetwo. It doesn't fail on var = :"one:two" though.


Expected behavior

Don't get triggered on hashes with keys that contain :.

Actual behavior

{ "one:two": "three" }
# [Lint/SymbolConversion] [W]  Unnecessary symbol conversion; use `"onetwo":` instead.

Steps to reproduce the problem

Any hash with key like :"something:something_else" shows the warning.

RuboCop version

->  rubocop -V
warning: parser/current is loading parser/ruby26, which recognizes
warning: 2.6.6-compliant syntax, but you are running 2.6.5.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
1.9.0 (using Parser 3.0.0.0, rubocop-ast 1.4.1, running on ruby 2.6.5 x86_64-darwin19)
  - rubocop-performance 1.9.2
  - rubocop-rails 2.9.1
@koic koic added the bug label Jan 29, 2021
@s-mage
Copy link
Author

s-mage commented Jan 29, 2021

Just found another one:

{ "one=": 1 } # [Lint/SymbolConversion] [W]  Unnecessary symbol conversion; use `one=:` instead. ...
> { one=: 1 }
SyntaxError: unexpected ':'

Not sure if it should be a separate issue

@koic
Copy link
Member

koic commented Jan 29, 2021

@s-mage Yeah, maybe a slightly different issue. Can you please open a new another issue?

koic added a commit to koic/rubocop that referenced this issue Jan 29, 2021
Fixes rubocop#9455.

This PR fixes a false positive for `Lint/SymbolConversion`
when hash keys that contain `":"`.
dvandersluis added a commit that referenced this issue Jan 29, 2021
…_conversion

[Fix #9455] Fix a false positive for `Lint/SymbolConversion`
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