diff --git a/pom.xml b/pom.xml index ef304f788..969b803e7 100644 --- a/pom.xml +++ b/pom.xml @@ -1122,7 +1122,6 @@ .*.checks.coding.FinalLocalVariableCheck83100 .*.checks.coding.IllegalInstantiationCheck8197 .*.checks.coding.IllegalTypeCheck9394 - .*.checks.coding.InnerAssignmentCheck88100 .*.checks.coding.ModifiedControlVariableCheck9197 .*.checks.coding.OverloadMethodsDeclarationOrderCheck93100 .*.checks.coding.ParameterAssignmentCheck8096 diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/InnerAssignmentCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/InnerAssignmentCheck.java index c69e2f635..8ac590402 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/InnerAssignmentCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/InnerAssignmentCheck.java @@ -191,7 +191,7 @@ public class InnerAssignmentCheck } final DetailAST expr = ast.getParent(); final AST exprNext = expr.getNextSibling(); - return exprNext != null && exprNext.getType() == TokenTypes.SEMI; + return exprNext.getType() == TokenTypes.SEMI; } /** @@ -237,20 +237,26 @@ public class InnerAssignmentCheck * one of the allowed type paths */ private static boolean isInContext(DetailAST ast, int[]... contextSet) { + boolean found = false; for (int[] element : contextSet) { DetailAST current = ast; final int len = element.length; for (int j = 0; j < len; j++) { current = current.getParent(); final int expectedType = element[j]; - if (current == null || current.getType() != expectedType) { + if (current.getType() != expectedType) { + found = false; break; } - if (j == len - 1) { - return true; + else { + found = true; } } + + if (found) { + break; + } } - return false; + return found; } }