forked from phoedos/pmd
Applied patch 1573981 - false + in CloneMethodMustImplementCloneable
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@4627 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -10,6 +10,7 @@ Applied patch 1551189 - SingularField false + for initialization blocks
|
||||
Fixed bug 1573795 - PreserveStackTrace doesn't throw CastClassException on exception with 0 args
|
||||
Fixed bug 1573591 - NonThreadSafeSingleton doesn't throw NPE when using this keyword
|
||||
CloseResource rule now checks code without java.sql import.
|
||||
Applied patch 1573981 - false + in CloneMethodMustImplementCloneable
|
||||
|
||||
October 4, 2006 - 3.8:
|
||||
New rules:
|
||||
|
@ -20,6 +20,7 @@ public class CloneMethodMustImplementCloneableTest extends SimpleAggregatorTst {
|
||||
new TestDescriptor(TEST2, "bad, doesn't implement Cloneable", 1, rule),
|
||||
new TestDescriptor(TEST3, "ok, not Object.clone since method has a param", 0, rule),
|
||||
new TestDescriptor(TEST4, "ok, doesn't implement Cloneable but only throw CloneNotSupportedException", 0, rule),
|
||||
new TestDescriptor(TEST5, "ok, inner class implements Cloneable", 0, rule),
|
||||
});
|
||||
}
|
||||
|
||||
@ -41,4 +42,11 @@ public class CloneMethodMustImplementCloneableTest extends SimpleAggregatorTst {
|
||||
"public class Foo {" + PMD.EOL +
|
||||
" final Object clone() { throw new CloneNotSupportedException(); }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST5 =
|
||||
"public class Bar {" + PMD.EOL +
|
||||
" class Foo implements Cloneable {" + PMD.EOL +
|
||||
" void clone() {}" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
}
|
||||
|
@ -98,7 +98,8 @@ The method clone() should only be implemented if the class implements the Clonea
|
||||
//ClassOrInterfaceDeclaration
|
||||
[not(./ImplementsList/ClassOrInterfaceType
|
||||
[@Image='Cloneable'])]
|
||||
[.//MethodDeclaration
|
||||
/ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration
|
||||
[MethodDeclaration
|
||||
[MethodDeclarator[@Image
|
||||
= 'clone' and count(FormalParameters/*) = 0]]
|
||||
[not((../MethodDeclaration[@Final = 'true'])
|
||||
|
Reference in New Issue
Block a user