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
This commit is contained in:
Xavier Le Vourch 2008-08-26 19:19:14 +00:00
parent 2141dba366
commit 91ad44ba0a
3 changed files with 16 additions and 1 deletions

View File

@ -14,6 +14,7 @@ Fixed bug 2056318 - False positive for AvoidInstantiatingObjectsInLoops
Optimizations and false positive fixes in PreserveStackTrace Optimizations and false positive fixes in PreserveStackTrace
@SuppressWarnings("all") disables all warnings @SuppressWarnings("all") disables all warnings
All comment types are now stored in ASTCompilationUnit, not just formal ones All comment types are now stored in ASTCompilationUnit, not just formal ones
Fixed false negative in UselessOverridingMethod
New rule: New rule:
Basic ruleset: EmptyInitializer Basic ruleset: EmptyInitializer

View File

@ -229,6 +229,20 @@ public class Foo extends Bar
public Object clone() throws CloneNotSupportedException { public Object clone() throws CloneNotSupportedException {
return super.clone(); return super.clone();
} }
}
]]></code>
</test-code>
<test-code>
<description><![CDATA[
clone method with arguments should not be ignored
]]></description>
<expected-problems>1</expected-problems>
<code><![CDATA[
public class Foo extends Bar
{
public Object clone(Object o) throws CloneNotSupportedException {
return super.clone(o);
}
} }
]]></code> ]]></code>
</test-code> </test-code>

View File

@ -97,7 +97,7 @@ public class UselessOverridingMethod extends AbstractRule {
try try
{ {
List parameters = node.findChildNodesWithXPath("./MethodDeclarator/FormalParameters/*"); List parameters = node.findChildNodesWithXPath("./MethodDeclarator/FormalParameters/*");
if ( parameters != null && parameters.size() < 0 ) { if ( parameters != null && parameters.size() > 0 ) {
result = true; result = true;
} }
} catch (JaxenException e) { } catch (JaxenException e) {