forked from phoedos/pmd
Fixed bug 1977230 - false positive: UselessOverridingMethod
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/branches/pmd/4.2.x@6205 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
parent
f663b9773a
commit
d951795634
@ -5,6 +5,7 @@ Updates to RuleChain to honor RuleSet exclude-pattern
|
||||
Upgrading UselessOperationOnImmutable to detect more use cases, especially on String
|
||||
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
|
||||
|
||||
New rule:
|
||||
Basic ruleset: EmptyInitializer
|
||||
|
@ -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>
|
||||
|
@ -156,8 +156,13 @@ public class UselessOverridingMethod extends AbstractRule {
|
||||
if (!primaryPrefix.hasImageEqualTo(methodDeclarator.getImage()))
|
||||
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())
|
||||
|
Loading…
x
Reference in New Issue
Block a user