net.sourceforge.pmd

Interface Rule

public interface Rule

This is the basic Rule interface for PMD rules.
Field Summary
static intLOWEST_PRIORITY
static String[]PRIORITIES
Method Summary
voidaddExample(String example)
Add a single example for this Rule.
voidaddProperties(Properties properties)
Add a set of properties to this Rule.
voidaddProperty(String name, String property)
Add a specific property to this Rule.
voidaddRuleChainVisit(String astNodeName)
Adds an AST node name to be visited by the Rule on the RuleChain.
voidapply(List<?> astCompilationUnits, RuleContext ctx)
Apply this rule to the given collection of compilation units, using the given context.
voidend(RuleContext ctx)
End processing.
booleangetBooleanProperty(String name)
Get the boolean value for the given property.
StringgetDescription()
Get the description of this Rule.
doublegetDoubleProperty(String name)
Get the double value for the given property.
StringgetExample()
Still used by the JDeveloper plugin
List<String>getExamples()
Get the list of examples for this Rule.
StringgetExternalInfoUrl()
Get a URL for external information about this Rule.
intgetIntProperty(String name)
Get the int value for the given property.
StringgetMessage()
Get the message to show when this Rule identifies a violation.
StringgetName()
Get the name of this Rule.
intgetPriority()
Get the priority of this Rule.
StringgetPriorityName()
Get a name for the priority of this Rule.
PropertiesgetProperties()
Get all properties for this Rule.
List<String>getRuleChainVisits()
Gets the collection of AST node names visited by the Rule on the RuleChain.
StringgetRuleClass()
Get the class of this Rule.
StringgetRuleSetName()
Get the name of the RuleSet containing this Rule.
StringgetSince()
Get the version of PMD in which this Rule was added.
StringgetStringProperty(String name)
Get the java.util.String value for the given property.
booleanhasProperty(String name)
Get whether this Rule has a property of the given name.
booleaninclude()
TODO What is this?
PropertyDescriptorpropertyDescriptorFor(String name)
Get the PropertyDescriptor for the given property.
voidsetDescription(String description)
Set the description of this Rule.
voidsetExternalInfoUrl(String externalInfoUrl)
Set a URL for external information about this Rule.
voidsetInclude(boolean include)
TODO What is this?
voidsetMessage(String message)
Set the message to show when this Rule identifies a violation.
voidsetName(String name)
Set the name of this Rule.
voidsetPriority(int priority)
Set the priority of this Rule.
voidsetRuleClass(String ruleClass)
Set the class of this Rule.
voidsetRuleSetName(String name)
Set the name of the RuleSet containing this Rule.
voidsetSince(String since)
Set the version of PMD in which this Rule was added.
voidsetUsesDFA()
Sets whether this Rule uses Data Flow Analysis.
voidsetUsesTypeResolution()
Sets whether this Rule uses Type Resolution.
voidstart(RuleContext ctx)
Start processing.
booleanusesDFA()
Gets whether this Rule uses Data Flow Analysis.
booleanusesRuleChain()
Gets whether this Rule uses the RuleChain.
booleanusesTypeResolution()
Gets whether this Rule uses Type Resolution.

Field Detail

LOWEST_PRIORITY

public static final int LOWEST_PRIORITY

PRIORITIES

public static final String[] PRIORITIES

Method Detail

addExample

public void addExample(String example)
Add a single example for this Rule.

addProperties

public void addProperties(Properties properties)
Add a set of properties to this Rule.

addProperty

public void addProperty(String name, String property)
Add a specific property to this Rule.

addRuleChainVisit

public void addRuleChainVisit(String astNodeName)
Adds an AST node name to be visited by the Rule on the RuleChain.

apply

public void apply(List<?> astCompilationUnits, RuleContext ctx)
Apply this rule to the given collection of compilation units, using the given context.

end

public void end(RuleContext ctx)
End processing. Called once, after apply() is last called.

getBooleanProperty

public boolean getBooleanProperty(String name)
Get the boolean value for the given property.

getDescription

public String getDescription()
Get the description of this Rule.

getDoubleProperty

public double getDoubleProperty(String name)
Get the double value for the given property.

getExample

public String getExample()

Deprecated: use getExamples(), since we now support multiple examples

Still used by the JDeveloper plugin

getExamples

public List<String> getExamples()
Get the list of examples for this Rule.

getExternalInfoUrl

public String getExternalInfoUrl()
Get a URL for external information about this Rule.

getIntProperty

public int getIntProperty(String name)
Get the int value for the given property.

getMessage

public String getMessage()
Get the message to show when this Rule identifies a violation.

getName

public String getName()
Get the name of this Rule.

getPriority

public int getPriority()
Get the priority of this Rule.

getPriorityName

public String getPriorityName()
Get a name for the priority of this Rule.

getProperties

public Properties getProperties()
Get all properties for this Rule.

Returns: the properties for the rule

getRuleChainVisits

public List<String> getRuleChainVisits()
Gets the collection of AST node names visited by the Rule on the RuleChain.

getRuleClass

public String getRuleClass()
Get the class of this Rule.

getRuleSetName

public String getRuleSetName()
Get the name of the RuleSet containing this Rule.

See Also: RuleSet

getSince

public String getSince()
Get the version of PMD in which this Rule was added. Return null if not applicable.

getStringProperty

public String getStringProperty(String name)
Get the java.util.String value for the given property.

hasProperty

public boolean hasProperty(String name)
Get whether this Rule has a property of the given name.

include

public boolean include()

Deprecated: Don't know what this is for, so deprecating it.

TODO What is this?

propertyDescriptorFor

public PropertyDescriptor propertyDescriptorFor(String name)
Get the PropertyDescriptor for the given property.

setDescription

public void setDescription(String description)
Set the description of this Rule.

setExternalInfoUrl

public void setExternalInfoUrl(String externalInfoUrl)
Set a URL for external information about this Rule.

setInclude

public void setInclude(boolean include)

Deprecated: Don't know what this is for, so deprecating it.

TODO What is this?

setMessage

public void setMessage(String message)
Set the message to show when this Rule identifies a violation.

setName

public void setName(String name)
Set the name of this Rule.

setPriority

public void setPriority(int priority)
Set the priority of this Rule.

setRuleClass

public void setRuleClass(String ruleClass)
Set the class of this Rule.

setRuleSetName

public void setRuleSetName(String name)
Set the name of the RuleSet containing this Rule.

See Also: RuleSet

setSince

public void setSince(String since)
Set the version of PMD in which this Rule was added.

setUsesDFA

public void setUsesDFA()
Sets whether this Rule uses Data Flow Analysis.

setUsesTypeResolution

public void setUsesTypeResolution()
Sets whether this Rule uses Type Resolution.

start

public void start(RuleContext ctx)
Start processing. Called once, before apply() is first called.

usesDFA

public boolean usesDFA()
Gets whether this Rule uses Data Flow Analysis.

usesRuleChain

public boolean usesRuleChain()
Gets whether this Rule uses the RuleChain.

usesTypeResolution

public boolean usesTypeResolution()
Gets whether this Rule uses Type Resolution.