forked from phoedos/pmd
pmd: fix #1047 False Positive in 'for' loops for LocalVariableCouldBeFinal in 5.0.1
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
???? ??, 2012 - 5.0.2:
|
???? ??, 2012 - 5.0.2:
|
||||||
|
|
||||||
Fixed bug 1044: Unknown option: -excludemarker
|
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
|
Fixed bug 1048: CommentContent Rule, String Index out of range Exception
|
||||||
|
|
||||||
November 28, 2012 - 5.0.1:
|
November 28, 2012 - 5.0.1:
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
|
* Fix wrong consumption of modifiers (e.g. "final") in a for-each loop.
|
||||||
|
*
|
||||||
|
* Andreas Dangel 12/2012
|
||||||
|
* ===================================================================
|
||||||
* Enhance grammar to use LocalVariableDeclaration in a for-each loop.
|
* Enhance grammar to use LocalVariableDeclaration in a for-each loop.
|
||||||
* This enhances the symbol table to recognize variables declared in such
|
* This enhances the symbol table to recognize variables declared in such
|
||||||
* a for-each loop.
|
* a for-each loop.
|
||||||
@ -1914,9 +1918,9 @@ void ForStatement() :
|
|||||||
{
|
{
|
||||||
"for" "("
|
"for" "("
|
||||||
(
|
(
|
||||||
LOOKAHEAD(Modifiers() Type() <IDENTIFIER> ":")
|
LOOKAHEAD(LocalVariableDeclaration() ":")
|
||||||
{checkForBadJDK15ForLoopSyntaxArgumentsUsage();}
|
{checkForBadJDK15ForLoopSyntaxArgumentsUsage();}
|
||||||
Modifiers() LocalVariableDeclaration() ":" Expression()
|
LocalVariableDeclaration() ":" Expression()
|
||||||
|
|
|
|
||||||
[ ForInit() ] ";"
|
[ ForInit() ] ";"
|
||||||
[ Expression() ] ";"
|
[ Expression() ] ";"
|
||||||
|
@ -146,4 +146,17 @@ public class Foo {
|
|||||||
}
|
}
|
||||||
]]></code>
|
]]></code>
|
||||||
</test-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>
|
</test-data>
|
||||||
|
Reference in New Issue
Block a user