From bf4e38c0c400b7aa0fe6d72755cc83e932bd7add Mon Sep 17 00:00:00 2001 From: Michal Kordas Date: Sat, 8 Aug 2015 14:58:53 +0200 Subject: [PATCH] Remove redundant and confusing else. #1555 Fixes `ConfusingElse` inspection violation. Description: >Reports confusing else branches. else branches are confusing when the if statement is followed by other statements and the if branch cannot complete normally, for example because it ends with a return statement. In these cases the statements in the else can be moved after the if statement and the else branch removed. --- .../java/com/puppycrawl/tools/checkstyle/TreeWalker.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/TreeWalker.java b/src/main/java/com/puppycrawl/tools/checkstyle/TreeWalker.java index cbe74cee9..1bf78afa9 100755 --- a/src/main/java/com/puppycrawl/tools/checkstyle/TreeWalker.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/TreeWalker.java @@ -579,12 +579,7 @@ public final class TreeWalker if (ast1.getLineNo() < ast2.getLineNo()) { return false; } - else { - if (ast1.getColumnNo() > ast2.getColumnNo()) { - return true; - } - } - return false; + return ast1.getColumnNo() > ast2.getColumnNo(); } /**