pmd: fix #975 false positive in ClassCastExceptionWithToArray

This commit is contained in:
Andreas Dangel
2013-03-17 10:11:02 +01:00
parent 41c44e5d8d
commit 5f45a28621
3 changed files with 20 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
????? ??, 2013 - 5.0.3: ????? ??, 2013 - 5.0.3:
Fixed bug 968: Issues with JUnit4 @Test annotation with expected exception (Thanks to Yiannis Paschalidis) Fixed bug 968: Issues with JUnit4 @Test annotation with expected exception (Thanks to Yiannis Paschalidis)
Fixed bug 975: false positive in ClassCastExceptionWithToArray
Fixed bug 976: UselessStringValueOf wrong when appending character arrays Fixed bug 976: UselessStringValueOf wrong when appending character arrays
Fixed bug 977: MisplacedNullCheck makes false positives Fixed bug 977: MisplacedNullCheck makes false positives
Fixed bug 984: Cyclomatic complexity should treat constructors like methods Fixed bug 984: Cyclomatic complexity should treat constructors like methods

View File

@@ -297,7 +297,7 @@ in a ClassCastException.
<value> <value>
<![CDATA[ <![CDATA[
//CastExpression[Type/ReferenceType/ClassOrInterfaceType[@Image != //CastExpression[Type/ReferenceType/ClassOrInterfaceType[@Image !=
"Object"]]//PrimaryExpression "Object"]]/PrimaryExpression
[ [
PrimaryPrefix/Name[ends-with(@Image, '.toArray')] PrimaryPrefix/Name[ends-with(@Image, '.toArray')]
and and

View File

@@ -46,4 +46,22 @@ public class Foo {
} }
]]></code> ]]></code>
</test-code> </test-code>
<test-code>
<description>#975 false positive in ClassCastExceptionWithToArray</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
import org.apache.commons.dbutils.*;
import org.apache.commons.dbutils.handlers.*;
public class Test {
public void foo() {
QueryRunner qr = getQueryRunner();
List<?> parms = new java.util.ArrayList();
// public <T> T QueryRunner.query(String sql, ResultSetHandler<T> rsh, Object... params)
String result = (String) qr.query( sql, new ScalarHandler(), parms.toArray() );
}
}
]]></code>
</test-code>
</test-data> </test-data>