PropertySource
, Rule
public abstract class AbstractRule extends AbstractPropertySource implements Rule
Basic abstract implementation of all parser-independent methods of the Rule interface.
propertyDescriptors, propertyValuesByDescriptor
VIOLATION_SUPPRESS_REGEX_DESCRIPTOR, VIOLATION_SUPPRESS_XPATH_DESCRIPTOR
void
addExample(String example)
Add a single example for this Rule.
void
addRuleChainVisit(Class<? extends Node> nodeClass)
Adds an AST node by class to be visited by the Rule on the RuleChain.
void
addRuleChainVisit(String astNodeName)
Adds an AST node by name to be visited by the Rule on the RuleChain.
void
addViolation(Object data, Node node)
Deprecated. void
addViolation(Object data, Node node, Object... args)
Deprecated. void
addViolation(Object data, Node node, String arg)
Deprecated. void
addViolationWithMessage(Object data, Node node, String message)
Deprecated. void
addViolationWithMessage(Object data, Node node, String message, int beginLine, int endLine)
Deprecated. void
addViolationWithMessage(Object data, Node node, String message, Object[] args)
Deprecated. protected RuleContext
asCtx(Object ctx)
Cast the argument to a
RuleContext
.
Rule
deepCopy()
Creates a new copy of this rule.
void
deepCopyValuesTo(AbstractRule otherRule)
Deprecated. void
end(RuleContext ctx)
End processing.
boolean
equals(Object o)
Rules are equal if: They have the same implementation class. They have the same name. They have the same priority. They share the same properties.
String
getDescription()
Get the description of this Rule.
List<String>
getExamples()
Get the list of examples for this Rule.
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.
String
getMessage()
Get the message to show when this Rule identifies a violation.
LanguageVersion
getMinimumLanguageVersion()
Get the minimum LanguageVersion to which this Rule applies.
String
getName()
Get the name of this Rule.
ParserOptions
getParserOptions()
Deprecated.
RulePriority
getPriority()
Get the priority of this Rule.
protected String
getPropertySourceType()
List<String>
getRuleChainVisits()
Gets the collection of AST node names visited by the Rule on the RuleChain.
String
getRuleClass()
Get the implementation class of this Rule.
String
getRuleSetName()
Get the name of the RuleSet containing this Rule.
String
getSince()
Get the version of PMD in which this Rule was added.
int
hashCode()
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(String description)
Set the description of this Rule.
void
setDfa(boolean isDfa)
Sets whether this Rule uses Data Flow Analysis.
void
setExternalInfoUrl(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(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(String name)
Set the name of this Rule.
void
setPriority(RulePriority priority)
Set the priority of this Rule.
void
setRuleClass(String ruleClass)
Set the class of this Rule.
void
setRuleSetName(String ruleSetName)
Set the name of the RuleSet containing this Rule.
void
setSince(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.
void
setUsesMultifile()
Deprecated.
void
setUsesTypeResolution()
Deprecated.
void
start(RuleContext ctx)
Start processing.
boolean
usesDFA()
Deprecated.
boolean
usesMultifile()
Deprecated.
boolean
usesRuleChain()
Deprecated.
boolean
usesTypeResolution()
Deprecated.
copyPropertyDescriptors, copyPropertyValues, definePropertyDescriptor, dysfunctionReason, getOverriddenPropertiesByPropertyDescriptor, getOverriddenPropertyDescriptors, getPropertiesByPropertyDescriptor, getProperty, getPropertyDescriptor, getPropertyDescriptors, hasDescriptor, ignoredProperties, isPropertyOverridden, setProperty, setProperty, useDefaultValueFor, usesDefaultValues
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
definePropertyDescriptor, dysfunctionReason, getOverriddenPropertiesByPropertyDescriptor, getOverriddenPropertyDescriptors, getPropertiesByPropertyDescriptor, getProperty, getPropertyDescriptor, getPropertyDescriptors, hasDescriptor, ignoredProperties, isPropertyOverridden, setProperty, setProperty, useDefaultValueFor, usesDefaultValues
protected String getPropertySourceType()
getPropertySourceType
in class AbstractPropertySource
@Deprecated public void deepCopyValuesTo(AbstractRule otherRule)
public Language getLanguage()Description copied from interface:
Rule
Get the Language of this Rule.
getLanguage
in interface Rule
public void setLanguage(Language language)Description copied from interface:
Rule
Set the Language of this Rule.
setLanguage
in interface Rule
language
- the language
public LanguageVersion getMinimumLanguageVersion()Description copied from interface:
Rule
Get the minimum LanguageVersion to which this Rule applies. If this value is null
it indicates there is no minimum bound.
getMinimumLanguageVersion
in interface Rule
public void setMinimumLanguageVersion(LanguageVersion minimumLanguageVersion)Description copied from interface:
Rule
Set the minimum LanguageVersion to which this Rule applies.
setMinimumLanguageVersion
in interface Rule
minimumLanguageVersion
- the minimum language version
public LanguageVersion getMaximumLanguageVersion()Description copied from interface:
Rule
Get the maximum LanguageVersion to which this Rule applies. If this value is null
it indicates there is no maximum bound.
getMaximumLanguageVersion
in interface Rule
public void setMaximumLanguageVersion(LanguageVersion maximumLanguageVersion)Description copied from interface:
Rule
Set the maximum LanguageVersion to which this Rule applies.
setMaximumLanguageVersion
in interface Rule
maximumLanguageVersion
- the maximum language version
public boolean isDeprecated()Description copied from interface:
Rule
Gets whether this Rule is deprecated. A deprecated Rule is one which:
isDeprecated
in interface Rule
true
if this rule is deprecated
public void setDeprecated(boolean deprecated)Description copied from interface:
Rule
Sets whether this Rule is deprecated.
setDeprecated
in interface Rule
deprecated
- whether this rule is deprecated
public String getName()Description copied from interface:
Rule
Get the name of this Rule.
getName
in interface PropertySource
getName
in interface Rule
public void setName(String name)Description copied from interface:
Rule
Set the name of this Rule.
public String getSince()Description copied from interface:
Rule
Get the version of PMD in which this Rule was added. Return null
if not applicable.
public void setSince(String since)Description copied from interface:
Rule
Set the version of PMD in which this Rule was added.
public String getRuleClass()Description copied from interface:
Rule
Get the implementation class of this Rule.
getRuleClass
in interface Rule
public void setRuleClass(String ruleClass)Description copied from interface:
Rule
Set the class of this Rule.
setRuleClass
in interface Rule
ruleClass
- the class name of this rule.
public String getRuleSetName()Description copied from interface:
Rule
Get the name of the RuleSet containing this Rule.
getRuleSetName
in interface Rule
RuleSet
public void setRuleSetName(String ruleSetName)Description copied from interface:
Rule
Set the name of the RuleSet containing this Rule.
setRuleSetName
in interface Rule
ruleSetName
- the name of the ruleset containing this rule.
RuleSet
public String getMessage()Description copied from interface:
Rule
Get the message to show when this Rule identifies a violation.
getMessage
in interface Rule
public void setMessage(String message)Description copied from interface:
Rule
Set the message to show when this Rule identifies a violation.
setMessage
in interface Rule
message
- the message to show for a violation.
public String getDescription()Description copied from interface:
Rule
Get the description of this Rule.
getDescription
in interface Rule
public void setDescription(String description)Description copied from interface:
Rule
Set the description of this Rule.
setDescription
in interface Rule
description
- the description
public List<String> getExamples()Description copied from interface:
Rule
Get the list of examples for this Rule.
getExamples
in interface Rule
public void addExample(String example)Description copied from interface:
Rule
Add a single example for this Rule.
addExample
in interface Rule
example
- a single example to add
public String getExternalInfoUrl()Description copied from interface:
Rule
Get a URL for external information about this Rule.
getExternalInfoUrl
in interface Rule
public void setExternalInfoUrl(String externalInfoUrl)Description copied from interface:
Rule
Set a URL for external information about this Rule.
setExternalInfoUrl
in interface Rule
externalInfoUrl
- the URL for external information about this rule.
public RulePriority getPriority()Description copied from interface:
Rule
Get the priority of this Rule.
getPriority
in interface Rule
public void setPriority(RulePriority priority)Description copied from interface:
Rule
Set the priority of this Rule.
setPriority
in interface Rule
priority
- the priority
@Deprecated public ParserOptions getParserOptions()
Deprecated.
This implementation returns a new instance of
ParserOptions
using default settings.
getParserOptions
in interface Rule
Rule.setPriority(RulePriority)
@Deprecated public void setUsesDFA()
Deprecated.
Description copied from interface:Rule
Sets whether this Rule uses Data Flow Analysis.
setUsesDFA
in interface Rule
public void setDfa(boolean isDfa)Description copied from interface:
Rule
Sets whether this Rule uses Data Flow Analysis.
@Deprecated public boolean usesDFA()
Deprecated.
Description copied from interface:Rule
Gets whether this Rule uses Data Flow Analysis.
public boolean isDfa()Description copied from interface:
Rule
Gets whether this Rule uses Data Flow Analysis.
@Deprecated public void setUsesTypeResolution()
Deprecated.
Description copied from interface:Rule
Sets whether this Rule uses Type Resolution.
setUsesTypeResolution
in interface Rule
public void setTypeResolution(boolean usingTypeResolution)Description copied from interface:
Rule
Sets whether this Rule uses Type Resolution.
setTypeResolution
in interface Rule
@Deprecated public boolean usesTypeResolution()
Deprecated.
Description copied from interface:Rule
Gets whether this Rule uses Type Resolution.
usesTypeResolution
in interface Rule
true
if Type Resolution is used.
public boolean isTypeResolution()Description copied from interface:
Rule
Gets whether this Rule uses Type Resolution.
isTypeResolution
in interface Rule
true
if Type Resolution is used.
@Deprecated public void setUsesMultifile()
Deprecated.
Description copied from interface:Rule
Sets whether this Rule uses multi-file analysis.
setUsesMultifile
in interface Rule
public void setMultifile(boolean multifile)Description copied from interface:
Rule
Sets whether this Rule uses multi-file analysis.
setMultifile
in interface Rule
@Deprecated public boolean usesMultifile()
Deprecated.
Description copied from interface:Rule
Gets whether this Rule uses multi-file analysis.
usesMultifile
in interface Rule
true
if the multi file analysis is used.
public boolean isMultifile()Description copied from interface:
Rule
Gets whether this Rule uses multi-file analysis.
isMultifile
in interface Rule
true
if the multi file analysis is used.
@Deprecated public boolean usesRuleChain()
Deprecated.
Description copied from interface:Rule
Gets whether this Rule uses the RuleChain.
usesRuleChain
in interface Rule
true
if RuleChain is used.
public boolean isRuleChain()Description copied from interface:
Rule
Gets whether this Rule uses the RuleChain.
isRuleChain
in interface Rule
true
if RuleChain is used.
public List<String> getRuleChainVisits()Description copied from interface:
Rule
Gets the collection of AST node names visited by the Rule on the RuleChain.
getRuleChainVisits
in interface Rule
public void addRuleChainVisit(Class<? extends Node> nodeClass)Description copied from interface:
Rule
Adds an AST node by class to be visited by the Rule on the RuleChain.
addRuleChainVisit
in interface Rule
nodeClass
- the AST node to add to the RuleChain visit list
public void addRuleChainVisit(String astNodeName)Description copied from interface:
Rule
Adds an AST node by name to be visited by the Rule on the RuleChain.
addRuleChainVisit
in interface Rule
astNodeName
- the AST node to add to the RuleChain visit list as string
public void start(RuleContext ctx)Description copied from interface:
Rule
Start processing. Called once, before apply() is first called.
public void end(RuleContext ctx)Description copied from interface:
Rule
End processing. Called once, after apply() is last called.
protected final RuleContext asCtx(Object ctx)
Cast the argument to a
RuleContext
. Use it to report violations:
asCtx(data).addViolation(node);
asCtx(data).addViolationWithMessage(node, "Some message");
In PMD 7, rules will have type-safe access to a RuleContext, and this will be deprecated as useless. In PMD 6, you can use this to stop using the deprecated
addViolation(Object, Node)
overloads of this class.
public void addViolation(Object data, Node node)
RuleContext.addViolation(Node)
public void addViolation(Object data, Node node, String arg)
RuleContext.addViolation(Node, Object[])
public void addViolation(Object data, Node node, Object... args)
RuleContext.addViolation(Node, Object[])
public void addViolationWithMessage(Object data, Node node, String message)
public void addViolationWithMessage(Object data, Node node, String message, int beginLine, int endLine)
public void addViolationWithMessage(Object data, Node node, String message, Object[] args)
public boolean equals(Object o)
Rules are equal if:
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