PropertySource
CodeClimateRule
, DFAGraphRule
, StatisticalRule
AbstractDelegateRule
, AbstractRule
, MockRule
, RuleReference
, XPathRule
public interface Rule extends PropertySource
Thread safety: PMD will create one instance of a rule per thread. The instances are not shared across different threads. However, a single rule instance is reused for analyzing multiple files.
Modifier and Type | Field | Description |
---|---|---|
static StringProperty |
VIOLATION_SUPPRESS_REGEX_DESCRIPTOR |
The property descriptor to universally suppress violations with messages
matching a regular expression.
|
static StringProperty |
VIOLATION_SUPPRESS_XPATH_DESCRIPTOR |
Name of the property to universally suppress violations on nodes which
match a given relative XPath expression.
|
Modifier and Type | Method | Description |
---|---|---|
void |
addExample(java.lang.String example) |
Add a single example for this Rule.
|
void |
addRuleChainVisit(java.lang.Class<? extends Node> nodeClass) |
Adds an AST node by class to be visited by the Rule on the RuleChain.
|
void |
addRuleChainVisit(java.lang.String astNodeName) |
Adds an AST node by name to be visited by the Rule on the RuleChain.
|
void |
apply(java.util.List<? extends Node> nodes,
RuleContext ctx) |
Apply this rule to the given collection of nodes, using the given
context.
|
Rule |
deepCopy() |
Creates a new copy of this rule.
|
void |
end(RuleContext ctx) |
End processing.
|
java.lang.String |
getDescription() |
Get the description of this Rule.
|
java.util.List<java.lang.String> |
getExamples() |
Get the list of examples for this Rule.
|
java.lang.String |
getExternalInfoUrl() |
Get a URL for external information about this Rule.
|
Language |
getLanguage() |
Get the Language of this Rule.
|
LanguageVersion |
getMaximumLanguageVersion() |
Get the maximum LanguageVersion to which this Rule applies.
|
java.lang.String |
getMessage() |
Get the message to show when this Rule identifies a violation.
|
LanguageVersion |
getMinimumLanguageVersion() |
Get the minimum LanguageVersion to which this Rule applies.
|
java.lang.String |
getName() |
Get the name of this Rule.
|
ParserOptions |
getParserOptions() |
Get the parser options for this Rule.
|
RulePriority |
getPriority() |
Get the priority of this Rule.
|
java.util.List<java.lang.String> |
getRuleChainVisits() |
Gets the collection of AST node names visited by the Rule on the
RuleChain.
|
java.lang.String |
getRuleClass() |
Get the implementation class of this Rule.
|
java.lang.String |
getRuleSetName() |
Get the name of the RuleSet containing this Rule.
|
java.lang.String |
getSince() |
Get the version of PMD in which this Rule was added.
|
boolean |
isDeprecated() |
Gets whether this Rule is deprecated.
|
boolean |
isDfa() |
Gets whether this Rule uses Data Flow Analysis.
|
boolean |
isMultifile() |
Gets whether this Rule uses multi-file analysis.
|
boolean |
isRuleChain() |
Gets whether this Rule uses the RuleChain.
|
boolean |
isTypeResolution() |
Gets whether this Rule uses Type Resolution.
|
void |
setDeprecated(boolean deprecated) |
Sets whether this Rule is deprecated.
|
void |
setDescription(java.lang.String description) |
Set the description of this Rule.
|
void |
setDfa(boolean isDfa) |
Sets whether this Rule uses Data Flow Analysis.
|
void |
setExternalInfoUrl(java.lang.String externalInfoUrl) |
Set a URL for external information about this Rule.
|
void |
setLanguage(Language language) |
Set the Language of this Rule.
|
void |
setMaximumLanguageVersion(LanguageVersion maximumLanguageVersion) |
Set the maximum LanguageVersion to which this Rule applies.
|
void |
setMessage(java.lang.String message) |
Set the message to show when this Rule identifies a violation.
|
void |
setMinimumLanguageVersion(LanguageVersion minimumLanguageVersion) |
Set the minimum LanguageVersion to which this Rule applies.
|
void |
setMultifile(boolean multifile) |
Sets whether this Rule uses multi-file analysis.
|
void |
setName(java.lang.String name) |
Set the name of this Rule.
|
void |
setPriority(RulePriority priority) |
Set the priority of this Rule.
|
void |
setRuleClass(java.lang.String ruleClass) |
Set the class of this Rule.
|
void |
setRuleSetName(java.lang.String name) |
Set the name of the RuleSet containing this Rule.
|
void |
setSince(java.lang.String since) |
Set the version of PMD in which this Rule was added.
|
void |
setTypeResolution(boolean usingTypeResolution) |
Sets whether this Rule uses Type Resolution.
|
void |
setUsesDFA() |
Deprecated.
Use
setDfa(boolean) instead. |
void |
setUsesMultifile() |
Deprecated.
use
setMultifile(boolean) instead. |
void |
setUsesTypeResolution() |
Deprecated.
Use
setTypeResolution(boolean) instead. |
void |
start(RuleContext ctx) |
Start processing.
|
boolean |
usesDFA() |
Deprecated.
Use
isDfa() instead. |
boolean |
usesMultifile() |
Deprecated.
Use
isMultifile() instead. |
boolean |
usesRuleChain() |
Deprecated.
USe
isRuleChain() instead. |
boolean |
usesTypeResolution() |
Deprecated.
Use
isTypeResolution() instead |
definePropertyDescriptor, dysfunctionReason, getPropertiesByPropertyDescriptor, getProperty, getPropertyDescriptor, getPropertyDescriptors, hasDescriptor, ignoredProperties, setProperty, setProperty, useDefaultValueFor, usesDefaultValues
static final StringProperty VIOLATION_SUPPRESS_REGEX_DESCRIPTOR
static final StringProperty VIOLATION_SUPPRESS_XPATH_DESCRIPTOR
Language getLanguage()
void setLanguage(Language language)
language
- the languageLanguageVersion getMinimumLanguageVersion()
null
it indicates there is no minimum bound.void setMinimumLanguageVersion(LanguageVersion minimumLanguageVersion)
minimumLanguageVersion
- the minimum language versionLanguageVersion getMaximumLanguageVersion()
null
it indicates there is no maximum bound.void setMaximumLanguageVersion(LanguageVersion maximumLanguageVersion)
maximumLanguageVersion
- the maximum language versionboolean isDeprecated()
true
if this rule is deprecatedvoid setDeprecated(boolean deprecated)
deprecated
- whether this rule is deprecatedjava.lang.String getName()
void setName(java.lang.String name)
name
- the namejava.lang.String getSince()
null
if not applicable.void setSince(java.lang.String since)
since
- the version of PMD since when this rule was addedjava.lang.String getRuleClass()
void setRuleClass(java.lang.String ruleClass)
ruleClass
- the class name of this rule.java.lang.String getRuleSetName()
RuleSet
void setRuleSetName(java.lang.String name)
name
- the name of the ruleset containing this rule.RuleSet
java.lang.String getMessage()
void setMessage(java.lang.String message)
message
- the message to show for a violation.java.lang.String getDescription()
void setDescription(java.lang.String description)
description
- the descriptionjava.util.List<java.lang.String> getExamples()
void addExample(java.lang.String example)
example
- a single example to addjava.lang.String getExternalInfoUrl()
void setExternalInfoUrl(java.lang.String externalInfoUrl)
externalInfoUrl
- the URL for external information about this rule.RulePriority getPriority()
void setPriority(RulePriority priority)
priority
- the priorityParserOptions getParserOptions()
Parser
to create an AST in
the form the Rule is expecting. Because ParserOptions are mutable, a Rule
should return a new instance on each call.@Deprecated void setUsesDFA()
setDfa(boolean)
instead.void setDfa(boolean isDfa)
@Deprecated boolean usesDFA()
isDfa()
instead.true
if Data Flow Analysis is used.boolean isDfa()
true
if Data Flow Analysis is used.@Deprecated void setUsesTypeResolution()
setTypeResolution(boolean)
instead.void setTypeResolution(boolean usingTypeResolution)
@Deprecated boolean usesTypeResolution()
isTypeResolution()
insteadtrue
if Type Resolution is used.boolean isTypeResolution()
true
if Type Resolution is used.@Deprecated void setUsesMultifile()
setMultifile(boolean)
instead.void setMultifile(boolean multifile)
@Deprecated boolean usesMultifile()
isMultifile()
instead.true
if the multi file analysis is used.boolean isMultifile()
true
if the multi file analysis is used.@Deprecated boolean usesRuleChain()
isRuleChain()
instead.true
if RuleChain is used.boolean isRuleChain()
true
if RuleChain is used.java.util.List<java.lang.String> getRuleChainVisits()
void addRuleChainVisit(java.lang.Class<? extends Node> nodeClass)
nodeClass
- the AST node to add to the RuleChain visit listvoid addRuleChainVisit(java.lang.String astNodeName)
astNodeName
- the AST node to add to the RuleChain visit list as stringvoid start(RuleContext ctx)
ctx
- the rule contextvoid apply(java.util.List<? extends Node> nodes, RuleContext ctx)
nodes
- the nodesctx
- the rule contextvoid end(RuleContext ctx)
ctx
- the rule contextRule deepCopy()
Copyright © 2002–2018 PMD. All rights reserved.