|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sourceforge.pmd.RuleSet
public class RuleSet
This class represents a collection of rules along with some optional filter patterns that can preclude their application on specific files.
Rule| Constructor Summary | |
|---|---|
RuleSet()
|
|
| Method Summary | |
|---|---|
void |
addExcludePattern(String aPattern)
Adds a new file exclusion pattern. |
void |
addExcludePatterns(Collection<String> someExcludePatterns)
Adds new file exclusion patterns. |
void |
addIncludePattern(String aPattern)
Adds a new inclusion pattern. |
void |
addIncludePatterns(Collection<String> someIncludePatterns)
Adds new inclusion patterns. |
void |
addRule(Rule rule)
Add a new rule to this ruleset. |
void |
addRuleByReference(String ruleSetFileName,
Rule rule)
Add a new rule by reference to this ruleset. |
boolean |
addRuleIfNotExists(Rule rule)
Only adds a rule to the ruleset if no rule with the same name for the same language was added before, so that the existent rule configuration won't be overridden. |
boolean |
addRuleReplaceIfExists(Rule rule)
Adds a rule. |
void |
addRuleSet(RuleSet ruleSet)
Add a whole RuleSet to this RuleSet |
void |
addRuleSetByReference(RuleSet ruleSet,
boolean allRules)
Add all rules by reference from one RuleSet to this RuleSet. |
void |
addRuleSetByReference(RuleSet ruleSet,
boolean allRules,
String... excludes)
Add all rules by reference from one RuleSet to this RuleSet. |
boolean |
applies(File file)
Check if a given source file should be checked by rules in this RuleSet. |
static boolean |
applies(Rule rule,
LanguageVersion languageVersion)
Does the given Rule apply to the given LanguageVersion? If so, the Language must be the same and be between the minimum and maximums versions on the Rule. |
void |
apply(List<? extends Node> acuList,
RuleContext ctx)
Executes the rules in this ruleset against each of the given nodes. |
static RuleSet |
createFor(String name,
Rule... theRules)
A convenience constructor |
void |
end(RuleContext ctx)
Triggers the end lifecycle event on each rule in the ruleset. |
boolean |
equals(Object o)
Two rulesets are equals, if they have the same name and contain the same rules. |
String |
getDescription()
|
List<String> |
getExcludePatterns()
|
String |
getFileName()
|
List<String> |
getIncludePatterns()
|
String |
getName()
|
Rule |
getRuleByName(String ruleName)
Returns the first Rule found with the given name (case-sensitive). |
Collection<Rule> |
getRules()
Returns the actual Collection of rules in this ruleset |
int |
hashCode()
|
void |
removeDysfunctionalRules(Collection<Rule> collector)
Remove and collect any misconfigured rules. |
void |
setDescription(String description)
|
void |
setExcludePatterns(Collection<String> theExcludePatterns)
Replaces the existing exclusion patterns with the given patterns. |
void |
setFileName(String fileName)
|
void |
setIncludePatterns(Collection<String> theIncludePatterns)
Replaces the existing inclusion patterns with the given patterns. |
void |
setName(String name)
|
int |
size()
Returns the number of rules in this ruleset |
void |
start(RuleContext ctx)
Triggers that start lifecycle event on each rule in this ruleset. |
boolean |
usesDFA(Language language)
Does any Rule for the given Language use the DFA layer? |
boolean |
usesTypeResolution(Language language)
Does any Rule for the given Language use Type Resolution? |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public RuleSet()
| Method Detail |
|---|
public static RuleSet createFor(String name,
Rule... theRules)
name - the rule set nametheRules - the rules to add to the rule set
public int size()
public void addRule(Rule rule)
rule - the rule to be addedpublic boolean addRuleReplaceIfExists(Rule rule)
rule - the new rule to add
true if the new rule replaced an existing one,
otherwise false.public boolean addRuleIfNotExists(Rule rule)
rule - the new rule to add
true if the rule was added, false
otherwise
public void addRuleByReference(String ruleSetFileName,
Rule rule)
ruleSetFileName - the ruleset which contains the rulerule - the rule to be addedpublic Collection<Rule> getRules()
Rulepublic boolean usesDFA(Language language)
language - The Language.
true if a Rule for the Language uses the DFA layer,
false otherwise.public Rule getRuleByName(String ruleName)
ruleName - the exact name of the rule to find
public void addRuleSet(RuleSet ruleSet)
ruleSet - the RuleSet to add
public void addRuleSetByReference(RuleSet ruleSet,
boolean allRules)
ruleSet - the RuleSet to addallRules - true if the ruleset should be added
collectively or false to add individual
references for each rule.
public void addRuleSetByReference(RuleSet ruleSet,
boolean allRules,
String... excludes)
ruleSet - the RuleSet to addallRules - true if the ruleset should be added
collectively or false to add individual
references for each rule.excludes - names of the rules that should be excluded.public boolean applies(File file)
exclude pattern
which matches the file, unless there is an include pattern
which also matches the file. In other words, include
patterns override exclude patterns.
file - the source file to check
true if the file should be checked,
false otherwisepublic void start(RuleContext ctx)
ctx - the current context
public void apply(List<? extends Node> acuList,
RuleContext ctx)
acuList - the node list, usually the root nodes like compilation
unitsctx - the current context
public static boolean applies(Rule rule,
LanguageVersion languageVersion)
rule - The rule.languageVersion - The language version.
true if the given rule matches the given language,
which means, that the rule would be executed.public void end(RuleContext ctx)
ctx - the current contextpublic boolean equals(Object o)
equals in class Objecto - the other ruleset to compare with
true if o is a ruleset with the same name and rules,
false otherwisepublic int hashCode()
hashCode in class Objectpublic String getFileName()
public void setFileName(String fileName)
public String getName()
public void setName(String name)
public String getDescription()
public void setDescription(String description)
public List<String> getExcludePatterns()
public void addExcludePattern(String aPattern)
aPattern - the patternpublic void addExcludePatterns(Collection<String> someExcludePatterns)
someExcludePatterns - the patternspublic void setExcludePatterns(Collection<String> theExcludePatterns)
theExcludePatterns - the new patternspublic List<String> getIncludePatterns()
public void addIncludePattern(String aPattern)
aPattern - the patternpublic void addIncludePatterns(Collection<String> someIncludePatterns)
someIncludePatterns - the patternspublic void setIncludePatterns(Collection<String> theIncludePatterns)
theIncludePatterns - the new patternspublic boolean usesTypeResolution(Language language)
language - The Language.
true if a Rule for the Language uses Type
Resolution, false otherwise.public void removeDysfunctionalRules(Collection<Rule> collector)
collector - the removed rules will be added to this collection
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||