pmd: fix #1099 UseArraysAsList false positives
This commit is contained in:
@ -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
|
||||
|
@ -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[
|
||||
|
@ -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>
|
||||
|
Reference in New Issue
Block a user