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

Open
marcandre opened this issue Jun 13, 2020 · 2 comments
Open

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

marcandre opened this issue Jun 13, 2020 · 2 comments

Comments

@marcandre
Copy link
Contributor

@marcandre marcandre commented Jun 13, 2020

$ 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 changed the title Issue with Style/FrozenStringLiteralComment and %i[...] Issue with Lint/BooleanSymbol and %i[...] Jun 13, 2020
@bquorning
Copy link
Member

@bquorning bquorning commented Jun 14, 2020

The fix is pretty easy – just adding e.g. next unless node.source.include?(':') right before

boolean_literal = node.source.delete(':')

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

@marcandre marcandre commented Jun 14, 2020

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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.