Changed to follow coventions

This commit is contained in:
kshantaraman
2015-04-13 17:22:29 -07:00
parent 11470aeb56
commit 5d9ecfc203
4 changed files with 8 additions and 4 deletions

View File

@ -19,7 +19,7 @@ import net.sourceforge.pmd.lang.java.ast.ASTReturnStatement;
import net.sourceforge.pmd.lang.java.ast.ASTVariableDeclaratorId;
import net.sourceforge.pmd.lang.java.rule.AbstractJavaRule;
public class SingleMethodSingletonRule extends AbstractJavaRule {
public class SingleMethodSingleton extends AbstractJavaRule {
private static Map<String, ASTFieldDeclaration> fieldDecls = new HashMap<String, ASTFieldDeclaration>();
private static Set<ASTFieldDeclaration> returnset = new HashSet<ASTFieldDeclaration>();

View File

@ -1298,8 +1298,10 @@ public static Foo getFoo() {
</rule>
<rule name="SingleMethodSingletonRule"
since="5.4"
externalInfoUrl=""
message="Class contains multiple getInstance methods. Please review."
class="net.sourceforge.pmd.lang.java.rule.design.SingleMethodSingletonRule">
class="net.sourceforge.pmd.lang.java.rule.design.SingleMethodSingleton">
<description>
Some classes contain overloaded getInstance. The problem with overloaded getInstance methods
is that the instance created using the overloaded method is not cached and so,
@ -1325,7 +1327,9 @@ public static Singleton getInstance(Object obj){
</example>
</rule>
<rule name="SingletonClassReturningNewInstance"
<rule name="SingletonClassReturningNewInstanceRule"
since="5.4"
externalInfoUrl=""
message="getInstance method always creates a new object and hence does not comply to Singleton Design Pattern behaviour. Please review"
class="net.sourceforge.pmd.lang.java.rule.design.SingletonClassReturningNewInstance">
<description>

View File

@ -46,7 +46,7 @@ public class DesignRulesTest extends SimpleAggregatorTst {
addRule(RULESET, "NonCaseLabelInSwitchStatement");
addRule(RULESET, "NonStaticInitializer");
addRule(RULESET, "NonThreadSafeSingleton");
addRule(RULESET,"SingleMethodSingletonRule");
addRule(RULESET,"SingleMethodSingleton");
addRule(RULESET, "SingletonClassReturningNewInstance");
addRule(RULESET, "OptimizableToArrayCall");
// addRule(RULESET, "PositionalIteratorRule"); This rule does not yet