diff --git a/java-checks/src/main/java/org/sonar/java/checks/DeadStoreCheck.java b/java-checks/src/main/java/org/sonar/java/checks/DeadStoreCheck.java index b665f8eb475..5a5460d9be2 100644 --- a/java-checks/src/main/java/org/sonar/java/checks/DeadStoreCheck.java +++ b/java-checks/src/main/java/org/sonar/java/checks/DeadStoreCheck.java @@ -198,7 +198,7 @@ private static boolean isUsualDefaultValue(ExpressionTree tree) { return "0".equals(value) || "1".equals(value); case UNARY_MINUS: case UNARY_PLUS: - return isUsualDefaultValue(((UnaryExpressionTree) tree).expression()); + return isUsualDefaultValue(((UnaryExpressionTree) expr).expression()); default: return false; } diff --git a/java-checks/src/test/files/checks/DeadStoreCheck.java b/java-checks/src/test/files/checks/DeadStoreCheck.java index dd0d12d1886..ea5d2edf01c 100644 --- a/java-checks/src/test/files/checks/DeadStoreCheck.java +++ b/java-checks/src/test/files/checks/DeadStoreCheck.java @@ -301,7 +301,7 @@ int testIntLiterals() { b = 0; // Noncompliant b = 1; // Noncompliant int c = +1; // Compliant - int d = -(1); // Compliant + int d = (-1); // Compliant int e = -1; // Compliant // Only int literals are excluded