View Javadoc
1   /**
2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3    */
4   package net.sourceforge.pmd.lang.rule;
5   
6   import java.util.List;
7   
8   import net.sourceforge.pmd.RuleContext;
9   import net.sourceforge.pmd.RulePriority;
10  import net.sourceforge.pmd.lang.LanguageRegistry;
11  import net.sourceforge.pmd.lang.ast.Node;
12  import net.sourceforge.pmd.lang.rule.properties.IntegerProperty;
13  
14  /**
15   * This is a Rule implementation which can be used in scenarios where an actual
16   * functional Rule is not needed.  For example, during unit testing, or as
17   * an editable surrogate used by IDE plugins.  The Language of this Rule
18   * defaults to Java.
19   */
20  public class MockRule extends AbstractRule {
21  
22      public MockRule() {
23  	super();
24  	setLanguage(LanguageRegistry.getLanguage("Dummy"));
25  	definePropertyDescriptor(new IntegerProperty("testIntProperty", "testIntProperty", 0, 100, 1, 0));
26      }
27  
28      public MockRule(String name, String description, String message, String ruleSetName, RulePriority priority) {
29  	this(name, description, message, ruleSetName);
30  	setPriority(priority);
31      }
32  
33      public MockRule(String name, String description, String message, String ruleSetName) {
34  	this();
35  	setName(name);
36  	setDescription(description);
37  	setMessage(message);
38  	setRuleSetName(ruleSetName);
39      }
40  
41      public void apply(List<? extends Node> nodes, RuleContext ctx) {
42      }
43  }