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
It is a known fact, that unless adds cognitive overhead. Personally, I always try to avoid it if if looks better/simpler.
This cop will detect places where unless is completely unneeded and can be replaced by if.
I was thinking, that there is a similar cop already, but was not able to find it.
This is great, although I'm sure about the name. It's not that the unless is redundant (as in "duplicated"), it's more that it's confusing / unnatural. Style/UnnaturalUnless? Style/ClearCondition? idk, can't think of a better name 🤷♂️
I like the idea. unless is a pain in the ass frequently, especially for non-native English speakers.
However, I agree with @vlad-pisanov that the cop name could be better.
It is a known fact, that
unless
adds cognitive overhead. Personally, I always try to avoid it ifif
looks better/simpler.This cop will detect places where
unless
is completely unneeded and can be replaced byif
.I was thinking, that there is a similar cop already, but was not able to find it.
For example,
I saw at least many offenses in the rubocop itself. Here are only a few examples:
rubocop/lib/rubocop/cop/layout/trailing_empty_lines.rb
Line 59 in 1e5f19a
rubocop/lib/rubocop/cop/layout/multiline_assignment_layout.rb
Line 99 in 1e5f19a
rubocop/lib/rubocop/cop/metrics/parameter_lists.rb
Line 82 in 1e5f19a
Related: #11399
There is a kinda related cop already (
Style/NegatedUnless
), but it only checks for simple negations with!
.The text was updated successfully, but these errors were encountered: