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

Issue with Lint/BooleanSymbol and %i[...] #8151

Closed
marcandre opened this issue Jun 13, 2020 · 2 comments · Fixed by #8836
Closed

Issue with Lint/BooleanSymbol and %i[...] #8151

marcandre opened this issue Jun 13, 2020 · 2 comments · Fixed by #8836
Labels
bug good first issue Easy task, suitable for newcomers to the project help wanted

Comments

@marcandre
Copy link
Contributor

$ echo "%i[foo false]" | rubocop -s test -a --only Lint/BooleanSymbol
Inspecting 1 file
W

Offenses:

test:1:8: W: [Corrected] Lint/BooleanSymbol: Symbol with a boolean name - you probably meant to use false.
%i[foo false]
       ^^^^^

1 file inspected, 1 offense detected, 1 offense corrected
====================
%i[foo false]
  1. Looks like this isn't crashing by chance. There's no spec for this case

  2. Autocorrection should not try to autocorrect this case

@marcandre marcandre added bug good first issue Easy task, suitable for newcomers to the project help wanted labels Jun 13, 2020
@marcandre marcandre changed the title Issue with Style/FrozenStringLiteralComment and %i[...] Issue with Lint/BooleanSymbol and %i[...] Jun 13, 2020
@bquorning
Copy link
Contributor

The fix is pretty easy – just adding e.g. next unless node.source.include?(':') right before https://github.com/rubocop-hq/rubocop/blob/b571ba252fba0e13331871b065b28f27c107eeda/lib/rubocop/cop/lint/boolean_symbol.rb#L38

But I cannot seem to write a failing spec – the autocorrector doesn’t loop infinitely in the current version of the code, so maybe the fix should be part of #7868 (where the issue was originally reported)?

@marcandre
Copy link
Contributor Author

If you replace the delete by delete!, all specs pass. Write a failing spec for that :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug good first issue Easy task, suitable for newcomers to the project help wanted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants