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
New Check: AvoidFinalConditionInversion #112
Comments
It would be a good idea to insert "how to avoid" advice into violation message, but sure it's impossible to cover all cases, so Check has to put violation like (Condition inversion could be avoided.) |
That should be done in: return, loops and if conditions, right? |
Message should be simple, do not propose solution. Yes, loops, if , returns should be checked. Beware that check might find some very debatable cases, please run it on big projects and try to make sure that code would become better after required changes (some additional options might be required) |
discussion thread: https://groups.google.com/forum/#!topic/sevntu-checkstyle/KlQhTDDlhZA |
implemented by Alexey. |
According to De Morgan's lows the resulted expressions should be as follows:
and
|
description was updated. |
We need a check that could catch "not" operator - "!" (an exclamation mark) that is used as final operation, but it is possible without changing a meaning of condition change its parts to make condition more readable.
Bad code examples:
isDifferent(): return ! (a == b); ==should be==> return a != b;
isLower(): boolean c = !(a > b); ==should be==> boolean c = a <= b;
isLowerLimits(): if (! ((a>=8) && (b>=5)) ) ==should be==> if ((a<8) || (b<5))
Big example (not sure we could catch such cases):
==should be==>
The text was updated successfully, but these errors were encountered: