Fixed bug 2645268 - ClassCastException in UselessOperationOnImmutable.getDeclaration
Problem was due to incorrect assumption about AST structure, when Annotations are present on a local declaration. git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/branches/pmd/4.2.x@6879 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
Fixed bug 2590258 - NPE with nicerhtml output
|
Fixed bug 2590258 - NPE with nicerhtml output
|
||||||
Fixed bug 2317099 - False + in SimplifyCondition
|
Fixed bug 2317099 - False + in SimplifyCondition
|
||||||
Fixed bug 2606609 - False "UnusedImports" positive in package-info.java
|
Fixed bug 2606609 - False "UnusedImports" positive in package-info.java
|
||||||
|
Fixed bug 2645268 - ClassCastException in UselessOperationOnImmutable.getDeclaration
|
||||||
|
|
||||||
New rule:
|
New rule:
|
||||||
StrictExceptions : AvoidCatchingGenericException
|
StrictExceptions : AvoidCatchingGenericException
|
||||||
|
@@ -180,6 +180,21 @@ public BigDecimal myMethod(Object pObj)
|
|||||||
//...
|
//...
|
||||||
|
|
||||||
return cout;
|
return cout;
|
||||||
|
}
|
||||||
|
]]></code>
|
||||||
|
</test-code>
|
||||||
|
<test-code>
|
||||||
|
<description><![CDATA[
|
||||||
|
2645268, ClassCastException using Annotation on Local Field
|
||||||
|
]]></description>
|
||||||
|
<expected-problems>1</expected-problems>
|
||||||
|
<code><![CDATA[
|
||||||
|
public class Foo {
|
||||||
|
public void foo() {
|
||||||
|
@NotNull
|
||||||
|
BigDecimal bd = new BigDecimal(5);
|
||||||
|
bd.divideToIntegralValue(new BigDecimal(5));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]]></code>
|
]]></code>
|
||||||
</test-code>
|
</test-code>
|
||||||
|
@@ -86,7 +86,7 @@ public class UselessOperationOnImmutable extends AbstractJavaRule {
|
|||||||
private ASTVariableDeclaratorId getDeclaration(ASTLocalVariableDeclaration node) {
|
private ASTVariableDeclaratorId getDeclaration(ASTLocalVariableDeclaration node) {
|
||||||
ASTType type = node.getTypeNode();
|
ASTType type = node.getTypeNode();
|
||||||
if (mapClasses.keySet().contains(type.getTypeImage())) {
|
if (mapClasses.keySet().contains(type.getTypeImage())) {
|
||||||
return (ASTVariableDeclaratorId) node.jjtGetChild(1).jjtGetChild(0);
|
return node.findChildrenOfType(ASTVariableDeclaratorId.class).get(0);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user