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.
Will be fixed with the next PMD release.