From cc095674b033e658aa055bbebf98c9b85c7d1b09 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sat, 3 Aug 2013 22:00:23 +0200 Subject: [PATCH] pmd: fix #1099 UseArraysAsList false positives --- pmd/etc/changelog.txt | 1 + .../resources/rulesets/java/optimizations.xml | 2 +- .../rule/optimizations/xml/UseArraysAsList.xml | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/pmd/etc/changelog.txt b/pmd/etc/changelog.txt index f10b0ae8bb..6c3be5e09e 100644 --- a/pmd/etc/changelog.txt +++ b/pmd/etc/changelog.txt @@ -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 diff --git a/pmd/src/main/resources/rulesets/java/optimizations.xml b/pmd/src/main/resources/rulesets/java/optimizations.xml index d640290a99..9dff0813a5 100644 --- a/pmd/src/main/resources/rulesets/java/optimizations.xml +++ b/pmd/src/main/resources/rulesets/java/optimizations.xml @@ -193,7 +193,7 @@ an array of objects. It is faster than executing a loop to copy all the elements + + + #1099 UseArraysAsList false positives + 0 + resultList = new ArrayList(); + for (int i = 1; i <= n; i++) { + resultList.add(result[i]); + } + } } ]]>