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:
Michal Kordas 2015-08-21 23:50:36 +02:00 committed by Roman Ivanov
parent d1f4e8d400
commit 27375d0815
1 changed files with 3 additions and 3 deletions

View File

@ -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)) {