public RuleSetLoader()
Create a new RuleSetLoader with a default configuration. The defaults are described on each configuration method of this class.
public RuleSetLoader loadResourcesWith(ClassLoader classLoader)
Specify that the given classloader should be used to resolve paths to external ruleset references. The default uses PMD's own classpath.
public RuleSetLoader withLanguages(LanguageRegistry languageRegistry)
public RuleSetLoader filterAbovePriority(RulePriority minimumPriority)
Filter loaded rules to only those that match or are above the given priority. The default is
RulePriority.LOW
, ie, no filtering occurs.
public RuleSetLoader warnDeprecated(boolean warn)
Log a warning when referencing a deprecated rule. This is enabled by default.
public RuleSetLoader enableCompatibility(boolean enable)
Enable translating old rule references to newer ones, if they have been moved or renamed. This is enabled by default, if disabled, unresolved references will not be translated and will produce an error.
public RuleSetLoader includeDeprecatedRuleReferences(boolean enable)
Follow deprecated rule references. By default this is off, and those references will be ignored (with a warning depending on
enableCompatibility(boolean)
).
@Deprecated public net.sourceforge.pmd.RuleSetFactory toFactory()
Create a new rule set factory, if you have to (that class is deprecated). That factory will use the configuration that was set using the setters of this.
public RuleSet loadFromResource(String rulesetPath)
rulesetPath
- A reference to a single ruleset
RuleSetLoadException
- If any error occurs (eg, invalid syntax, or resource not found)
public RuleSet loadFromString(String filename, String rulesetXmlContent)
Parses and returns a ruleset from string content.
filename
- The symbolic "file name", for error messages.
rulesetXmlContent
- Xml file contents
RuleSetLoadException
- If any error occurs (eg, invalid syntax)
public List<RuleSet> loadFromResources(Collection<String> paths)
Parses several resources into a list of rulesets.
paths
- Paths
RuleSetLoadException
- If any error occurs (eg, invalid syntax, or resource not found), for any of the parameters
NullPointerException
- If the parameter, or any component is null
@InternalApi public List<RuleSet> loadRuleSetsWithoutException(List<String> rulesetPaths)
Internal API: might be published later, or maybe in PMD 7 this will be the default behaviour of every method of this class.
public List<RuleSet> loadFromResources(String first, String... rest)
Parses several resources into a list of rulesets.
first
- First path
rest
- Paths
RuleSetLoadException
- If any error occurs (eg, invalid syntax, or resource not found), for any of the parameters
NullPointerException
- If the parameter, or any component is null
public static RuleSetLoader fromPmdConfig(PMDConfiguration configuration)
Configure a new ruleset factory builder according to the parameters of the given PMD configuration.
public List<RuleSet> getStandardRuleSets()
Returns an Iterator of RuleSet objects loaded from descriptions from the "categories.properties" resource for each language. This uses the classpath of the resource loader (
loadResourcesWith(ClassLoader)
).
RuleSetLoadException
- If a standard ruleset cannot be loaded. This is a corner case, that probably should not be caught by clients. The standard rulesets are well-formed, at least in stock PMD distributions.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4