-
-
Notifications
You must be signed in to change notification settings - Fork 270
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
Rails/NegateInclude should not auto correct double negation include? #460
Comments
Thank you for your feedback. I'm not sure about this is an expected behavior change. Let's take a look at answer knu/sorted_set#2. |
Yes, I don't think RuboCop should be working around what seems like a bug in Ruby or a core gem. |
I'm afraid this is still a bug in |
JFYI, The cop is already marked as unsafe. |
Thank you for clarifying! |
This looks very similar to #384
Expected behavior
!!collection.include?(x) should not correct to !collection.exclude?(x)
Actual behavior
Correction was applied, but resulted in broken code - not all collections support the
exclude?
method.Although In most cases
!!collection.include?(x)
is equivalent tocollection.include?(x)
, there are exceptions. In particular, ruby3.0
introduced a breaking change inSortedSet#include?
: if the object is not in the sorted set, the method returnsnil
instead offalse
- hence the need for the!!
trick.RuboCop version
The text was updated successfully, but these errors were encountered: