Menu

#1165 SimplifyConditional false positive

PMD-5.1.1
closed
None
PMD
3-Major
Bug
4.3, 5
2014-04-27
2014-02-05
No

Consider the following code:

if (
arguments == null ||
arguments.length < 3 || arguments.length > 4 ||
!(arguments[0] instanceof String ) ||
!(arguments[1] instanceof Boolean ) ||
!(arguments[2] instanceof String ) ||
arguments.length == 4 && !(arguments[3] instanceof String )
) {
throw new IllegalArgumentException( "" );
}

For the second line "arguments==null" I get an error, that the null check is not neccessary. This is obviously wrong. I guess the instanceof call on the array element confuses PMD.

I guess it is PMD 4.3. I got it with Sonar 3.7.1.

Discussion

  • Andreas Dangel

    Andreas Dangel - 2014-04-13
    • status: open --> in-progress
    • assigned_to: Andreas Dangel
    • Milestone: New Tickets --> PMD-Next
    • Affects version: 4.3 --> 4.3, 5
     
  • Andreas Dangel

    Andreas Dangel - 2014-04-25

    Will be fixed with the next PMD release.

     
  • Andreas Dangel

    Andreas Dangel - 2014-04-25
    • status: in-progress --> closed
     

Log in to post a comment.