#1282 False Positive with implicit String.valuesOf() (Java)

This commit is contained in:
Andreas Dangel
2014-11-15 17:02:50 +01:00
parent 55a912e731
commit 0bca478e31
3 changed files with 20 additions and 1 deletions

View File

@ -220,7 +220,9 @@ public class Test {
<property name="xpath">
<value>
<![CDATA[
//Expression/PrimaryExpression/PrimaryPrefix/Expression[count(*)=1 and count(./CastExpression)=0 and count(./ConditionalExpression[@Ternary='true'])=0]
//Expression/PrimaryExpression/PrimaryPrefix/Expression
[count(*)=1][count(./CastExpression)=0][count(./ConditionalExpression[@Ternary='true'])=0]
[not(./AdditiveExpression[//Literal[@StringLiteral='true']])]
|
//Expression/ConditionalAndExpression/PrimaryExpression/PrimaryPrefix/Expression[
count(*)=1 and

View File

@ -224,6 +224,22 @@ public class Test {
public static int thisShouldBreak(final int x, final int y, final int z) {
return x - (y + z);
}
}
]]></code>
</test-code>
<test-code>
<description>#1282 False Positive with implicit String.valuesOf() (Java)</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
package com.mycompany.mavenproject1;
import java.io.IOException;
public class NewClass {
public void falsePositive(Boolean b) throws IOException {
System.out.write(( "" + b ).getBytes());
}
}
]]></code>
</test-code>

View File

@ -12,3 +12,4 @@
* [#1276](https://sourceforge.net/p/pmd/bugs/1276/): False positive in UnusedPrivateMethod with inner enum
* [#1281](https://sourceforge.net/p/pmd/bugs/1281/): UnusedPrivateMethod incorrectly flagged for methods nested private classes
* [#1282](https://sourceforge.net/p/pmd/bugs/1282/): False Positive with implicit String.valuesOf() (Java)