-
Notifications
You must be signed in to change notification settings - Fork 235
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
no-negated-condition
rule could detect and fix (not (eq...
and others
#2655
Comments
Why wouldn't they all be safe and desirable? I'm a big fan of boolean simplification rules. Such rules exist in other plugins, e.g. |
This could be part of the next major release #2319 as a breaking change if the PR is ready. Could also put it all behind a new option on the rule (off by default) to avoid a breaking change and release it sooner (with the option to be enabled by default in next major release). This is the my preferred option. |
That was just a remark as I encountered situation where some one wanted to have comparisons always done in one direction even if that would require negation. But objectively looking it won't break anything and code will be simplified :) |
If someone has a personal preference on that, they can disable the rule :) but boolean simplification is a good idea for a rule. |
Hmm as some code for that would be based on code from #2653 maybe we will make both helpers mentioned here and double negation hidden behind the option |
Negation connected with some other helpers could be simplified:
(not (eq ...))
->(not-eq ...)
(not (not-eq ...))
->(eq ...)
(not (gt ...))
->(lte ...)
(not (gte ...))
->(lt ...)
(not (lt ...))
->(gte ...)
(not (lte ...))
->(gt ...)
Cases with eq and not-eq looks harmless to autofix, but rest may not always be desirable so it could be enabled with some setting.
The text was updated successfully, but these errors were encountered: