From 0252a9c905e462db9106fe4a4bf8cb0c786932fd Mon Sep 17 00:00:00 2001 From: Xavier Le Vourch Date: Thu, 27 Nov 2008 17:06:30 +0000 Subject: [PATCH] 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 --- pmd/etc/changelog.txt | 1 + ...thOnlyPrivateConstructorsShouldBeFinal.xml | 58 +++++++++++++++++++ pmd/rulesets/design.xml | 4 +- 3 files changed, 62 insertions(+), 1 deletion(-) diff --git a/pmd/etc/changelog.txt b/pmd/etc/changelog.txt index 544814ed9e..9c70215f54 100644 --- a/pmd/etc/changelog.txt +++ b/pmd/etc/changelog.txt @@ -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: diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/design/xml/ClassWithOnlyPrivateConstructorsShouldBeFinal.xml b/pmd/regress/test/net/sourceforge/pmd/rules/design/xml/ClassWithOnlyPrivateConstructorsShouldBeFinal.xml index ee06e91f04..a1ae547e01 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/design/xml/ClassWithOnlyPrivateConstructorsShouldBeFinal.xml +++ b/pmd/regress/test/net/sourceforge/pmd/rules/design/xml/ClassWithOnlyPrivateConstructorsShouldBeFinal.xml @@ -80,6 +80,64 @@ public class Foo { } public class Bar extends Foo { public Bar() { } +} + ]]> + + + + 0 + + + + + 0 + diff --git a/pmd/rulesets/design.xml b/pmd/rulesets/design.xml index 24bf7a4764..720b7afefe 100644 --- a/pmd/rulesets/design.xml +++ b/pmd/rulesets/design.xml @@ -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)] ]]>