-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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/Casecmp cop fails when autocorrectting #2664
Comments
I've found that changing Looks like there are a few bugs in the current implementation (apart from the crash). I'll try to sort them out. |
If it's not all lower case, then the comparison will always be You are right, though. |
some more examples that produce slightly different crashes for me in my duplicate thread #2727
and
|
Getting the same problem, reduced the crash to |
crashes aside, this just seems wrong: x.upcase == 'FOO' evaluates to true or false depending on whether or not x is equivalent to FOO regardless of case. So one would be tempted to use casecmp, but it's wrong because when the strings are not equal, casecmp returns -1 or 1 (it's a comparator after all, not a boolean method), and these are not false in Ruby. The cop should convert the above to
not simply
|
@stamhankar999 that's been fixed on master |
Ok, thanks! |
@bbatsov We have already received several reports on this same issue. New minor version? |
Soon. There are a few outstanding PRs that I'd like to get merged before 0.37. I'll likely ship it over the weekend or on Monday. |
@tobypinder Please confirm if you still have a problem with the new release. |
For me, RuboCop no longer crahses on the given example after
which was included in v0.37.0, so I feel confident the issue can be closed. |
The
Performance/Casecmp
cop seems to consistently fail while autocorrecting.It works fine without --auto-correct
But with, it throws exception (shown with
-d
set for stacktrace).Reproduce with
System
Discovered in 0.36.0, Tested on master branch.
The text was updated successfully, but these errors were encountered: