You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[java] UselessParentheses: False negative when on the right-hand side of an assignment statement #6775
UselessParentheses reports redundant parentheses around the initializer of a variable declaration (double value = (a / b);). The identical redundant parentheses around the right-hand side of a plain assignment statement (value = (a / b);) are not reported. The parentheses are equally useless in both positions — removing them changes neither parsing nor operator precedence.
publicclassAfter {
publicstaticvoidmain(String[] argv) {
inta; a = Integer.parseInt(argv[0]);
intb; b = Integer.parseInt(argv[1]);
doublevalue; value = (a / b);
System.out.println(value);
}
}
Expected behavior
Both forms should be reported. The parentheses around a / b are redundant whether a / b is a variable initializer or the right-hand side of an assignment expression.
Actual behavior
Variable-initializer form → 1 violation:
Before.java:5: UselessParentheses: Useless parentheses around `a / b`.
Assignment-statement form → 0 violations. The rule does not inspect the RHS of an AssignmentExpression for useless parentheses, only VariableInitializer.
changed the title [-][java] UselessParentheses: not reported on the right-hand side of an assignment statement[/-][+][java] UselessParentheses: False negative when on the right-hand side of an assignment statement[/+]on Jun 11, 2026
Activity
[-][java] UselessParentheses: not reported on the right-hand side of an assignment statement[/-][+][java] UselessParentheses: False negative when on the right-hand side of an assignment statement[/+]Fix: UselessParentheses: not reported on the right-hand side of an as…
[doc] Update release notes (#6775, #6776)
[java] Fix pmd#6775: UselessParentheses: not reported on the right-ha…