Fixed no-method case.

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@135 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
David Dixon-Peugh
2002-06-28 18:38:17 +00:00
parent e37a0ceefb
commit 164825993b

View File

@ -10,7 +10,8 @@ import net.sourceforge.pmd.ast.ASTMethodDeclaration;
public class UseSingletonRule
extends AbstractRule
{
public boolean isOK = false;
private boolean isOK = false;
private int methodCount = 0;
public UseSingletonRule() { }
@ -19,6 +20,7 @@ public class UseSingletonRule
}
public Object visit( ASTMethodDeclaration decl, Object data ) {
methodCount ++;
if (isOK) return data;
if (!decl.isStatic()) {
@ -32,7 +34,7 @@ public class UseSingletonRule
Object RC = cu.childrenAccept( this, data );
if (!isOK) {
if ((!isOK) && (methodCount > 0)) {
(((RuleContext) data).getReport()).
addRuleViolation( new RuleViolation( this, cu.getBeginLine() ));
}