-
-
Notifications
You must be signed in to change notification settings - Fork 83
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
Performance/StringInclude
autocorrect is unsafe
#145
Labels
bug
Something isn't working
Comments
Adding another edge case -
|
Note that |
koic
added a commit
to koic/rubocop-performance
that referenced
this issue
Jul 16, 2020
Fixes rubocop#145. This PR marks `Performance/StringInclude` as `SafeAutocorrect: false` and disable autocorrect by default. The cop's offenses are not safe to auto-correct if a receiver is nil.
8 tasks
koic
added a commit
that referenced
this issue
Jul 17, 2020
…orrect [Fix #145] Mark `Performance/StringInclude` as unsafe
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
New cop
Performance/StringInclude
introduced by #117 is unsafe when use with--auto-correct
.match
and=~
. But the return values betweenmatch
or=~
andinclude?
are different. If the value is used, the behavior is altered.=~
doesn't raise an error in case ofnil =~ /foobar/
. Same, behavior is altered.Two examples that broke in our codebase:
I think it should only fix
match?
and reservematch
and=~
in the case of--auto-correct-all
. I don't know if you can make that distinction?If not, maybe move this cop as unsafe? What do you think?
The text was updated successfully, but these errors were encountered: