forked from phoedos/pmd
Fixed bug 2230809 - False +: ClassWithOnlyPrivateConstructorsShouldBeFinal
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/branches/pmd/4.2.x@6703 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
parent
8f8afde50b
commit
0252a9c905
@ -3,6 +3,7 @@
|
||||
Enhanced logging in the ClassTypeResolver to provide more detailed messaging.
|
||||
Fixed bug 2338341 - ArrayIndexOutOfBoundsException in cpd on rails project
|
||||
Fixed bug 2315623 - @SuppressWarnings("PMD.UseSingleton") has no effect
|
||||
Fixed bug 2230809 - False +: ClassWithOnlyPrivateConstructorsShouldBeFinal
|
||||
|
||||
October 12, 2008 - 4.2.4:
|
||||
|
||||
|
@ -80,6 +80,64 @@ public class Foo {
|
||||
}
|
||||
public class Bar extends Foo {
|
||||
public Bar() { }
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description><![CDATA[
|
||||
One protected constructor, not required to be final
|
||||
]]></description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
class ClassWithOnlyPrivateConstructorsShouldBeFinal {
|
||||
private String string;
|
||||
|
||||
protected ClassWithOnlyPrivateConstructorsShouldBeFinal(final Object object) {
|
||||
this(object.toString());
|
||||
}
|
||||
|
||||
private ClassWithOnlyPrivateConstructorsShouldBeFinal(final String string) {
|
||||
super();
|
||||
|
||||
setString(string);
|
||||
}
|
||||
|
||||
public final void setString(final String string) {
|
||||
this.string = string;
|
||||
}
|
||||
|
||||
public String getString() {
|
||||
return string;
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description><![CDATA[
|
||||
One package private constructor, not required to be final
|
||||
]]></description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
class ClassWithOnlyPrivateConstructorsShouldBeFinal {
|
||||
private String string;
|
||||
|
||||
ClassWithOnlyPrivateConstructorsShouldBeFinal(final Object object) {
|
||||
this(object.toString());
|
||||
}
|
||||
|
||||
private ClassWithOnlyPrivateConstructorsShouldBeFinal(final String string) {
|
||||
super();
|
||||
|
||||
setString(string);
|
||||
}
|
||||
|
||||
public final void setString(final String string) {
|
||||
this.string = string;
|
||||
}
|
||||
|
||||
public String getString() {
|
||||
return string;
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
@ -1407,7 +1407,9 @@ constructor is called by a inner class.
|
||||
TypeDeclaration[count(../TypeDeclaration) = 1]/ClassOrInterfaceDeclaration
|
||||
[@Final = 'false']
|
||||
[count(./ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration/ConstructorDeclaration[@Private = 'true']) >= 1 ]
|
||||
[count(./ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration/ConstructorDeclaration[@Public = 'true']) = 0 ]
|
||||
[count(./ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration/ConstructorDeclaration[@Public = 'true']) +
|
||||
count(./ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration/ConstructorDeclaration[@Protected = 'true']) +
|
||||
count(./ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration/ConstructorDeclaration[@PackagePrivate = 'true']) = 0 ]
|
||||
[not(.//ClassOrInterfaceDeclaration)]
|
||||
]]></value>
|
||||
</property>
|
||||
|
Loading…
x
Reference in New Issue
Block a user