You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not sure if this is a bug with Style/NegatedIf/Style/NegatedUnless or this is just how they were designed to work and a new cop/config flag would need added. I like that if !/unless ! gets replaced with the respective unless/if, but I would also like if x != y/unless x != y to also get replaced with the respective unless x == y/if x == y.
This would be false negatives, not false positives. The Style/Negated* cops is for detecting unary operator like !foo, not binary operator like foo != bar. Also if foo != bar is allowed because it might be intended. On the other hand, double negation such as unless foo != bar can be detected by Style/InvertibleUnlessCondition cop. The cop is disabled by default, so enable it explicitly if needed. #11432
I'm not sure if this is a bug with
Style/NegatedIf
/Style/NegatedUnless
or this is just how they were designed to work and a new cop/config flag would need added. I like thatif !
/unless !
gets replaced with the respectiveunless
/if
, but I would also likeif x != y
/unless x != y
to also get replaced with the respectiveunless x == y
/if x == y
.Expected behavior
Actual behavior
Rubocop didn't complain about any of the following
Steps to reproduce the problem
Create a file with the above conditions and see no rubocop errors from any of them.
Minimal Config:
RuboCop version
I tested again with the 1.45.1 release
The text was updated successfully, but these errors were encountered: