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
Consider disabling Style/InvertibleUnlessCondition
?
#595
Comments
This is a misunderstanding of what the cop is suggesting: # bad
foo unless n.odd?
# also bad (supposed contradiction)
foo if !n.odd?
# good
foo if n.even? I've opened rubocop/rubocop#12562 to improve the offense message to make this clearer. -Favor `if` with inverted condition over `unless`.
+Prefer `if n.even?` over `unless n.odd?`. |
What about when there's no inverse method like for This issue was opened because there's no good alternative to: Looking at the rule implementation, I don't understand why it considers using |
Transcribing my comments on the Slack thread, where I addressed those points:
|
(following up from internal Slack discussion)
This rule is disabled by default in RuboCop's config. It was enabled in #486.
It's causing some problems since it can contradict
Style/NegatedIf
.Also it does not match the styleguide rule for "Favour
unless
overif
for negative conditions".The text was updated successfully, but these errors were encountered: