Menu

#1243 Useless Parentheses False Positive

PMD-5.1.3
closed
None
PMD
3-Major
Bug
5.1.2
2014-09-04
2014-08-14
shenzinator
No

The UselessParentheses rule gets triggered by the following method:

public static int thisShouldBreak(final int x, final int y, final int z) {
    return x - (y + z);
}

PMD feels that the parentheses around "y + z" are useless, however you cannot simply fix the rule by removing the parentheses because x - (y + z) != x - y + z but instead x - y - z.

Is PMD suggesting that we distribute the negative as part of removing the parentheses?

Thank you!

Discussion

  • Andreas Dangel

    Andreas Dangel - 2014-08-18
    • status: open --> closed
    • assigned_to: Andreas Dangel
    • Milestone: New Tickets --> PMD-next
     
  • Andreas Dangel

    Andreas Dangel - 2014-08-18

    This will be fixed with the next PMD release (5.1.3).

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.