pmd: fixed #1064 Exception running PrematureDeclaration
This commit is contained in:
parent
a00532595a
commit
3e8c42384b
@ -1,5 +1,6 @@
|
||||
????? ??, 2013 - 5.0.3:
|
||||
|
||||
Fixed bug 1064: Exception running PrematureDeclaration
|
||||
Fixed bug 1068: CPD fails on broken symbolic links
|
||||
|
||||
|
||||
|
@ -151,9 +151,8 @@ public class PrematureDeclarationRule extends AbstractJavaRule {
|
||||
* @return String
|
||||
*/
|
||||
private static String varNameIn(ASTLocalVariableDeclaration node) {
|
||||
|
||||
ASTVariableDeclarator declarator = (ASTVariableDeclarator)node.jjtGetChild(1);
|
||||
return ((ASTVariableDeclaratorId) declarator.jjtGetChild(0)).getImage();
|
||||
ASTVariableDeclarator declarator = node.getFirstChildOfType(ASTVariableDeclarator.class);
|
||||
return ((ASTVariableDeclaratorId) declarator.jjtGetChild(0)).getImage();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -45,4 +45,24 @@ public class Bar {
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>Bug #1064 Exception running PrematureDeclaration</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Bar {
|
||||
public int lengthSumOf(String[] strings) {
|
||||
|
||||
if (strings == null || strings.length == 0) return 0;
|
||||
|
||||
@SuppressWarnings("unchecked") Integer sum = 0; // optimal placement
|
||||
|
||||
for (int i=0; i<strings.length; i++) {
|
||||
sum += strings[i].length();
|
||||
}
|
||||
|
||||
return sum;
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
</test-data>
|
||||
|
Loading…
x
Reference in New Issue
Block a user