diff --git a/pmd/etc/changelog.txt b/pmd/etc/changelog.txt index 3e95c16b3f..c03ac93617 100644 --- a/pmd/etc/changelog.txt +++ b/pmd/etc/changelog.txt @@ -5,6 +5,7 @@ Fixed bug 2338341 - ArrayIndexOutOfBoundsException in cpd on rails project Fixed bug 2315623 - @SuppressWarnings("PMD.UseSingleton") has no effect Fixed bug 2230809 - False +: ClassWithOnlyPrivateConstructorsShouldBeFinal Fixed bug 2338341 - ArrayIndexOutOfBoundsException in CPD (on Ruby) +Fixed bug 2315599 - False +: UseSingleton with class containing constructor October 12, 2008 - 4.2.4: diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/design/xml/UseSingleton.xml b/pmd/regress/test/net/sourceforge/pmd/rules/design/xml/UseSingleton.xml index 9e3a95a673..653147ae54 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/design/xml/UseSingleton.xml +++ b/pmd/regress/test/net/sourceforge/pmd/rules/design/xml/UseSingleton.xml @@ -116,4 +116,24 @@ public class FooTest { } ]]> + + + + 0 + + + + \ No newline at end of file diff --git a/pmd/src/net/sourceforge/pmd/rules/design/UseSingleton.java b/pmd/src/net/sourceforge/pmd/rules/design/UseSingleton.java index 2cf7175881..c5f7b1b8f9 100644 --- a/pmd/src/net/sourceforge/pmd/rules/design/UseSingleton.java +++ b/pmd/src/net/sourceforge/pmd/rules/design/UseSingleton.java @@ -50,9 +50,12 @@ public class UseSingleton extends AbstractRule { } public Object visit(ASTMethodDeclaration decl, Object data) { - methodCount++; + // Private method does no count + if ( ! decl.isPrivate() ) { + methodCount++; + } - if (!isOK && !decl.isStatic()) { + if (!isOK && !decl.isStatic() ) { isOK = true; }