pmd: fix #1095 AvoidFinalLocalVariable false positive

This commit is contained in:
Andreas Dangel committed 2013-08-10 21:19:29 +02:00
1 parent acc799e79d
commit 99a0c59b98
4 files changed
+15 -1

No files matched your search

+1
View File
@@ -30,6 +30,7 @@ Fixed bug 991: AvoidSynchronizedAtMethodLevel for static methods
Fixed bug 1084: NPE at UselessStringValueOfRule.java:36
Fixed bug 1091: file extension for fortran seems to be wrong in cpdgui tools
Fixed bug 1092: Wrong Attribute "excludemarker" in Ant Task Documentation
Fixed bug 1095: AvoidFinalLocalVariable false positive
Fixed bug 1099: UseArraysAsList false positives
Fixed bug 1102: False positive: shift operator parenthesis
Fixed bug 1104: IdempotentOperation false positive
@@ -366,6 +366,7 @@ Avoid using final local variables, turn them into fields.
<value><![CDATA[
//LocalVariableDeclaration[
@Final = 'true'
and not(../../ForStatement)
and
(
(count(VariableDeclarator/VariableInitializer) = 0)
@@ -12,7 +12,6 @@ public class ControversialRulesTest extends SimpleAggregatorTst {
@Before
public void setUp() {
addRule(RULESET, "AssignmentInOperand");
addRule(RULESET, "AvoidFinalLocalVariable");
addRule(RULESET, "AvoidLiteralsInIfCondition");
addRule(RULESET, "AvoidPrefixingMethodParameters");
addRule(RULESET, "AvoidUsingNativeCode");
@@ -51,4 +51,17 @@ public class A {
}
]]></code>
</test-code>
<test-code>
<description>#1095 AvoidFinalLocalVariable false positive</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
public class Test {
public void test() {
final File[] files = new File(".").listFiles();
for (final File f : files) { f.getAbsolutePath(); }
}
}
]]></code>
</test-code>
</test-data>