forked from phoedos/pmd
Fixed bug in UselessOverridingMethod: false + when adding synchronization
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@4749 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -26,6 +26,7 @@ Fixed false negatives in UseArraysAsList.
|
||||
Fixed several JDK 1.5 parsing bugs.
|
||||
Fixed several rules (exceptions on jdk 1.5 and jdk 1.6 source code).
|
||||
Fixed array handling in AvoidReassigningParameters and UnusedFormalParameter.
|
||||
Fixed bug in UselessOverridingMethod: false + when adding synchronization.
|
||||
Rules can now call RuleContext.getSourceType() if they need to make different checks on JDK 1.4 and 1.5 code.
|
||||
CloseResource rule now checks code without java.sql import.
|
||||
ArrayIsStoredDirectly rule now checks Constructors
|
||||
|
@ -27,7 +27,9 @@ public class UselessOverridingMethodTest extends SimpleAggregatorTst {
|
||||
new TestDescriptor(TEST11, "do not crash on interfaces", 0, rule),
|
||||
new TestDescriptor(TEST12, "do not crash on empty returns", 0, rule),
|
||||
new TestDescriptor(TEST13, "do not crash on super", 0, rule),
|
||||
new TestDescriptor(TEST14, "call super with different argument 4", 0, rule)
|
||||
new TestDescriptor(TEST14, "call super with different argument 4", 0, rule),
|
||||
new TestDescriptor(TEST15, "adding final is OK", 0, rule),
|
||||
new TestDescriptor(TEST16, "adding synchronized is OK", 0, rule),
|
||||
});
|
||||
}
|
||||
|
||||
@ -126,4 +128,18 @@ public class UselessOverridingMethodTest extends SimpleAggregatorTst {
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST15 =
|
||||
"public class Foo extends Bar {" + PMD.EOL +
|
||||
"public final String foo() {" + PMD.EOL +
|
||||
" return super.foo();" + PMD.EOL +
|
||||
"}" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST16 =
|
||||
"public class Foo extends Bar {" + PMD.EOL +
|
||||
"public synchronized String foo() {" + PMD.EOL +
|
||||
" return super.foo();" + PMD.EOL +
|
||||
"}" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ public class UselessOverridingMethod extends AbstractRule {
|
||||
// Can skip abstract methods and methods whose only purpose is to
|
||||
// guarantee that the inherited method is not changed by finalizing
|
||||
// them.
|
||||
if (node.isAbstract() || node.isFinal() || node.isNative()) {
|
||||
if (node.isAbstract() || node.isFinal() || node.isNative() || node.isSynchronized()) {
|
||||
return super.visit(node, data);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user