pmd: fix #1047 False Positive in 'for' loops for LocalVariableCouldBeFinal in 5.0.1

This commit is contained in:
Andreas Dangel committed 2012-12-16 12:06:09 +01:00
1 parent 58c9deab49
commit 48e6520912
3 files changed
+17 -2

No files matched your search

+1
View File
@@ -1,6 +1,7 @@
???? ??, 2012 - 5.1.0:
Fixed bug 1044: Unknown option: -excludemarker
Fixed bug 1047: False Positive in 'for' loops for LocalVariableCouldBeFinal in 5.0.1
Fixed bug 1048: CommentContent Rule, String Index out of range Exception
November 28, 2012 - 5.0.1:
+3 -2
View File
@@ -1,4 +1,5 @@
/**
* Fix wrong consumption of modifiers (e.g. "final") in a for-each loop.
* Check for wrong java usage when catching multiple exceptions.
*
* Andreas Dangel 12/2012
@@ -1924,9 +1925,9 @@ void ForStatement() :
{
"for" "("
(
LOOKAHEAD(Modifiers() Type() <IDENTIFIER> ":")
LOOKAHEAD(LocalVariableDeclaration() ":")
{checkForBadJDK15ForLoopSyntaxArgumentsUsage();}
Modifiers() LocalVariableDeclaration() ":" Expression()
LocalVariableDeclaration() ":" Expression()
|
[ ForInit() ] ";"
[ Expression() ] ";"
@@ -146,4 +146,17 @@ public class Foo {
}
]]></code>
</test-code>
<test-code>
<description>Bug #1047 False Positive in 'for' loops for LocalVariableCouldBeFinal in 5.0.1</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
public class Foo {
public void bar() {
for ( final String c : strings ) {
System.out.println(c); // use c
}
}
}
]]></code>
</test-code>
</test-data>