From 91ad44ba0a6e7b921ced0df0c7705f3c21d4dc59 Mon Sep 17 00:00:00 2001 From: Xavier Le Vourch Date: Tue, 26 Aug 2008 19:19:14 +0000 Subject: [PATCH] Fixed false negative in UselessOverridingMethod using < 0 instead of > 0 in getting argument list size. Maybe we should have a rule to detect this... git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/branches/pmd/4.2.x@6408 51baf565-9d33-0410-a72c-fc3788e3496d --- pmd/etc/changelog.txt | 1 + .../rules/basic/xml/UselessOverridingMethod.xml | 14 ++++++++++++++ .../pmd/rules/UselessOverridingMethod.java | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/pmd/etc/changelog.txt b/pmd/etc/changelog.txt index 297234bff8..30f639ff6a 100644 --- a/pmd/etc/changelog.txt +++ b/pmd/etc/changelog.txt @@ -14,6 +14,7 @@ Fixed bug 2056318 - False positive for AvoidInstantiatingObjectsInLoops Optimizations and false positive fixes in PreserveStackTrace @SuppressWarnings("all") disables all warnings All comment types are now stored in ASTCompilationUnit, not just formal ones +Fixed false negative in UselessOverridingMethod New rule: Basic ruleset: EmptyInitializer diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/basic/xml/UselessOverridingMethod.xml b/pmd/regress/test/net/sourceforge/pmd/rules/basic/xml/UselessOverridingMethod.xml index 31fec5b345..e61caae460 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/basic/xml/UselessOverridingMethod.xml +++ b/pmd/regress/test/net/sourceforge/pmd/rules/basic/xml/UselessOverridingMethod.xml @@ -229,6 +229,20 @@ public class Foo extends Bar public Object clone() throws CloneNotSupportedException { return super.clone(); } +} + ]]> + + + + 1 + diff --git a/pmd/src/net/sourceforge/pmd/rules/UselessOverridingMethod.java b/pmd/src/net/sourceforge/pmd/rules/UselessOverridingMethod.java index f8371c6ed0..d888fb083c 100644 --- a/pmd/src/net/sourceforge/pmd/rules/UselessOverridingMethod.java +++ b/pmd/src/net/sourceforge/pmd/rules/UselessOverridingMethod.java @@ -97,7 +97,7 @@ public class UselessOverridingMethod extends AbstractRule { try { List parameters = node.findChildNodesWithXPath("./MethodDeclarator/FormalParameters/*"); - if ( parameters != null && parameters.size() < 0 ) { + if ( parameters != null && parameters.size() > 0 ) { result = true; } } catch (JaxenException e) {