Package net.sourceforge.pmd
Class RuleSet
- java.lang.Object
- 
- net.sourceforge.pmd.RuleSet
 
- 
- All Implemented Interfaces:
- ChecksumAware
 
 public class RuleSet extends java.lang.Object implements ChecksumAware This class represents a collection of rules along with some optional filter patterns that can preclude their application on specific files.- See Also:
- Rule
 
- 
- 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanapplies(java.io.File file)Check if a given source file should be checked by rules in this RuleSet.static booleanapplies(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.voidapply(java.util.List<? extends Node> acuList, RuleContext ctx)Executes the rules in this ruleset against each of the given nodes.voidend(RuleContext ctx)Triggers the end lifecycle event on each rule in the ruleset.booleanequals(java.lang.Object o)Two rulesets are equals, if they have the same name and contain the same rules.longgetChecksum()Retrieves the current instance checksumjava.lang.StringgetDescription()java.util.List<java.lang.String>getExcludePatterns()java.lang.StringgetFileName()java.util.List<java.lang.String>getIncludePatterns()java.lang.StringgetName()RulegetRuleByName(java.lang.String ruleName)Returns the first Rule found with the given name (case-sensitive).java.util.Collection<Rule>getRules()Returns the actual Collection of rules in this rulesetinthashCode()voidremoveDysfunctionalRules(java.util.Collection<Rule> collector)Remove and collect any misconfigured rules.intsize()Returns the number of rules in this rulesetvoidstart(RuleContext ctx)Triggers that start lifecycle event on each rule in this ruleset.booleanusesDFA(Language language)Deprecated.SeeRule.isDfa()booleanusesMultifile(Language language)Deprecated.booleanusesTypeResolution(Language language)Deprecated.
 
- 
- 
- 
Constructor Detail- 
RuleSetpublic RuleSet(RuleSet rs) 
 
- 
 - 
Method Detail- 
sizepublic int size() Returns the number of rules in this ruleset- Returns:
- an int representing the number of rules
 
 - 
getRulespublic java.util.Collection<Rule> getRules() Returns the actual Collection of rules in this ruleset- Returns:
- a Collection with the rules. All objects are of type Rule
 
 - 
getRuleByNamepublic Rule getRuleByName(java.lang.String ruleName) Returns the first Rule found with the given name (case-sensitive). Note: Since we support multiple languages, rule names are not expected to be unique within any specific ruleset.- Parameters:
- ruleName- the exact name of the rule to find
- Returns:
- the rule or null if not found
 
 - 
appliespublic boolean applies(java.io.File file) Check if a given source file should be checked by rules in this RuleSet. A file should not be checked if there is anexcludepattern which matches the file, unless there is anincludepattern which also matches the file. In other words,includepatterns overrideexcludepatterns.- Parameters:
- file- the source file to check
- Returns:
- trueif the file should be checked,- falseotherwise
 
 - 
startpublic void start(RuleContext ctx) Triggers that start lifecycle event on each rule in this ruleset. Some rules perform initialization tasks on start.- Parameters:
- ctx- the current context
 
 - 
applypublic void apply(java.util.List<? extends Node> acuList, RuleContext ctx) Executes the rules in this ruleset against each of the given nodes.- Parameters:
- acuList- the node list, usually the root nodes like compilation units
- ctx- the current context
 
 - 
appliespublic 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.- Parameters:
- rule- The rule.
- languageVersion- The language version.
- Returns:
- trueif the given rule matches the given language, which means, that the rule would be executed.
 
 - 
endpublic void end(RuleContext ctx) Triggers the end lifecycle event on each rule in the ruleset. Some rules perform a final summary calculation or cleanup in the end.- Parameters:
- ctx- the current context
 
 - 
equalspublic boolean equals(java.lang.Object o) Two rulesets are equals, if they have the same name and contain the same rules.- Overrides:
- equalsin class- java.lang.Object
- Parameters:
- o- the other ruleset to compare with
- Returns:
- trueif o is a ruleset with the same name and rules,- falseotherwise
 
 - 
hashCodepublic int hashCode() - Overrides:
- hashCodein class- java.lang.Object
 
 - 
getFileNamepublic java.lang.String getFileName() 
 - 
getNamepublic java.lang.String getName() 
 - 
getDescriptionpublic java.lang.String getDescription() 
 - 
getExcludePatternspublic java.util.List<java.lang.String> getExcludePatterns() 
 - 
getIncludePatternspublic java.util.List<java.lang.String> getIncludePatterns() 
 - 
usesDFA@Deprecated public boolean usesDFA(Language language) Deprecated.SeeRule.isDfa()Does any Rule for the given Language use the DFA layer?- Parameters:
- language- The Language.
- Returns:
- trueif a Rule for the Language uses the DFA layer,- falseotherwise.
 
 - 
usesTypeResolution@Deprecated public boolean usesTypeResolution(Language language) Deprecated.Does any Rule for the given Language use Type Resolution?- Parameters:
- language- The Language.
- Returns:
- trueif a Rule for the Language uses Type Resolution,- falseotherwise.
 
 - 
usesMultifile@Deprecated public boolean usesMultifile(Language language) Deprecated.Does any Rule for the given Language use multi-file analysis?- Parameters:
- language- The Language.
- Returns:
- trueif a Rule for the Language uses multi file analysis,- falseotherwise.
 
 - 
removeDysfunctionalRulespublic void removeDysfunctionalRules(java.util.Collection<Rule> collector) Remove and collect any misconfigured rules.- Parameters:
- collector- the removed rules will be added to this collection
 
 - 
getChecksumpublic long getChecksum() Description copied from interface:ChecksumAwareRetrieves the current instance checksum- Specified by:
- getChecksumin interface- ChecksumAware
- Returns:
- The current checksum
 
 
- 
 
-