Invert negated if-else. #1555
Fixes `NegatedIfElse` inspection violations. Description: >Reports if statements which contain else branches and whose conditions are negated. Flipping the order of the if and else branches will usually increase the clarity of such statements.
This commit is contained in:
parent
d1f4e8d400
commit
27375d0815
|
|
@ -328,11 +328,11 @@ public class LeftCurlyCheck
|
|||
String braceLine) {
|
||||
// not on the same line
|
||||
if (startToken.getLineNo() + 1 == brace.getLineNo()) {
|
||||
if (!Utils.whitespaceBefore(brace.getColumnNo(), braceLine)) {
|
||||
log(brace, MSG_KEY_LINE_NEW, "{", brace.getColumnNo() + 1);
|
||||
if (Utils.whitespaceBefore(brace.getColumnNo(), braceLine)) {
|
||||
log(brace, MSG_KEY_LINE_PREVIOUS, "{", brace.getColumnNo() + 1);
|
||||
}
|
||||
else {
|
||||
log(brace, MSG_KEY_LINE_PREVIOUS, "{", brace.getColumnNo() + 1);
|
||||
log(brace, MSG_KEY_LINE_NEW, "{", brace.getColumnNo() + 1);
|
||||
}
|
||||
}
|
||||
else if (!Utils.whitespaceBefore(brace.getColumnNo(), braceLine)) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue