pmd: fix #1099 UseArraysAsList false positives

This commit is contained in:
Andreas Dangel
2013-08-03 22:00:23 +02:00
parent 0859285b8b
commit cc095674b0
3 changed files with 20 additions and 1 deletions

View File

@ -3,6 +3,7 @@
Fixed bug 991: AvoidSynchronizedAtMethodLevel for static methods
Fixed bug 1084: NPE at UselessStringValueOfRule.java:36
Fixed bug 1092: Wrong Attribute "excludemarker" in Ant Task Documentation
Fixed bug 1099: UseArraysAsList false positives
Fixed bug 1104: IdempotentOperation false positive
Fixed bug 1107: PMD 5.0.4 couldn't parse call of parent outer java class method from inner class
Fixed bug 1111: False positive: Useless parentheses

View File

@ -193,7 +193,7 @@ an array of objects. It is faster than executing a loop to copy all the elements
<value>
<![CDATA[
//Statement[
(ForStatement) and (count(.//IfStatement)=0)
(ForStatement) and (ForStatement//VariableInitializer//Literal[@IntLiteral='true' and @Image='0']) and (count(.//IfStatement)=0)
]
//StatementExpression[
PrimaryExpression/PrimaryPrefix/Name[

View File

@ -100,6 +100,24 @@ public class Test {
l.add(a[i].toString()); // won't trigger the rule
}
}
}
]]></code>
</test-code>
<test-code>
<description>#1099 UseArraysAsList false positives</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
public class Test {
public void foo() {
String [] result = new String[10000];
// some code which populates result
// copy n items from result to a List, such that resultList[i] = result[i+1]
List<String> resultList = new ArrayList<String>();
for (int i = 1; i <= n; i++) {
resultList.add(result[i]);
}
}
}
]]></code>
</test-code>