From cb9861dd1f4ea69432e43f84db0b49b3ad10533f Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Wed, 23 Jan 2013 21:24:36 +0100 Subject: [PATCH] pmd: fixed #878 False positive: UnusedFormalParameter for abstract methods --- pmd/etc/changelog.txt | 1 + .../rule/unusedcode/UnusedFormalParameterRule.java | 2 +- .../java/rule/unusedcode/xml/UnusedFormalParameter.xml | 10 ++++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/pmd/etc/changelog.txt b/pmd/etc/changelog.txt index cc04ee2cf0..87f0b2f6f6 100644 --- a/pmd/etc/changelog.txt +++ b/pmd/etc/changelog.txt @@ -1,5 +1,6 @@ ???? ??, 2012 - 5.0.2: +Fixed bug 878: False positive: UnusedFormalParameter for abstract methods Fixed bug 1012: False positive: Useless parentheses. Fixed bug 1026: PMD doesn't handle 'value =' in SuppressWarnings annotation Fixed bug 1037: Facing a showstopper issue in PMD Report Class (report listeners) diff --git a/pmd/src/main/java/net/sourceforge/pmd/lang/java/rule/unusedcode/UnusedFormalParameterRule.java b/pmd/src/main/java/net/sourceforge/pmd/lang/java/rule/unusedcode/UnusedFormalParameterRule.java index 44a5673697..a3a0a921cf 100644 --- a/pmd/src/main/java/net/sourceforge/pmd/lang/java/rule/unusedcode/UnusedFormalParameterRule.java +++ b/pmd/src/main/java/net/sourceforge/pmd/lang/java/rule/unusedcode/UnusedFormalParameterRule.java @@ -33,7 +33,7 @@ public class UnusedFormalParameterRule extends AbstractJavaRule { if (!node.isPrivate() && !getProperty(CHECKALL_DESCRIPTOR)) { return data; } - if (!node.isNative()) { + if (!node.isNative() && !node.isAbstract()) { check(node, data); } return data; diff --git a/pmd/src/test/resources/net/sourceforge/pmd/lang/java/rule/unusedcode/xml/UnusedFormalParameter.xml b/pmd/src/test/resources/net/sourceforge/pmd/lang/java/rule/unusedcode/xml/UnusedFormalParameter.xml index a9396c97cf..9fd0a0b53a 100644 --- a/pmd/src/test/resources/net/sourceforge/pmd/lang/java/rule/unusedcode/xml/UnusedFormalParameter.xml +++ b/pmd/src/test/resources/net/sourceforge/pmd/lang/java/rule/unusedcode/xml/UnusedFormalParameter.xml @@ -234,4 +234,14 @@ class Foo { ]]> + + #878 don't flag abstract methods even if checkall property is set when checking an abstract class + true + 0 + +