Fixed bug 1977230 - false positive: UselessOverridingMethod

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@6204 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Xavier Le Vourch committed 2008-06-14 00:36:58 +00:00
1 parent 08452a42f4
commit fadb13fefb
3 files changed
+29 -2

No files matched your search

+1
View File
@@ -263,6 +263,7 @@ Fixed bug 1928009 - Error using migration ruleset in PMD 4.2
Fixed bug 1808110 - PreserveStackTrace
Fixed bug 1988829 - Violation reported without source file name (actually a fix to ConsecutiveLiteralAppends)
Fixed bug 1989814 - false +: ConsecutiveLiteralAppends
Fixed bug 1977230 - false positive: UselessOverridingMethod
ruleset.dtd and ruleset_xml_schema.xsd added to jar file in rulesets directory
bin and java14/bin scripts:
retroweaver version was not correct in java14/bin scripts
@@ -263,6 +263,28 @@ private static class ExposingSerializer extends Serializer {
public void exposedWriteAttributeValue(String text) throws IOException {
writeAttributeValue(text);
}
}
]]></code>
</test-code>
<test-code>
<description>
<![CDATA[
[ 1977230 ] false positive: UselessOverridingMethod
]]>
</description>
<expected-problems>0</expected-problems>
<code>
<![CDATA[
public class Foo extends Bar {
public BigDecimal getBalance(Date date) {
return super.getBalance(date).negate();
}
}
class Bar {
public BigDecimal getBalance(Date date) {
}
}
]]></code>
</test-code>
@@ -158,9 +158,13 @@ public class UselessOverridingMethodRule extends AbstractJavaRule {
return super.visit(node, data);
}
List<ASTPrimarySuffix> primarySuffixList = findFirstDegreeChildrenOfType(primaryExpression, ASTPrimarySuffix.class);
if (primarySuffixList.size() != 1) {
// extra method call on result of super method
return super.visit(node, data);
}
//Process arguments
ASTPrimarySuffix primarySuffix = findFirstDegreeChildrenOfType(primaryExpression, ASTPrimarySuffix.class)
.get(0);
ASTPrimarySuffix primarySuffix = primarySuffixList.get(0);
ASTArguments arguments = (ASTArguments) primarySuffix.jjtGetChild(0);
ASTFormalParameters formalParameters = (ASTFormalParameters) methodDeclarator.jjtGetChild(0);
if (formalParameters.jjtGetNumChildren() != arguments.jjtGetNumChildren()) {