|
Groovy Documentation | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.org.codenarc.rule.AbstractRule
public abstract class AbstractRule
Abstract superclass for Rules.
Each subclass must define anname
property (String) and a priority
property
(integer 1..3).
Method Summary | |
---|---|
void
|
applyTo(SourceCode sourceCode, List violations)
Apply this rule to the specified source and return a list of violations (or an empty List) |
List
|
applyTo(SourceCode sourceCode)
Apply this rule to the specified source and return a list of violations (or an empty List). |
protected Violation
|
createViolation(Integer lineNumber, String sourceLine, String message)
Create and return a new Violation for this rule and the specified values |
protected Violation
|
createViolation(Integer lineNumber, String message)
Create and return a new Violation for this rule and the specified values |
protected Violation
|
createViolation(Integer lineNumber)
Create and return a new Violation for this rule and the specified values |
protected Violation
|
createViolation(SourceCode sourceCode, org.codehaus.groovy.ast.ASTNode node, String message)
Create a new Violation for the AST node. |
protected Violation
|
createViolation(SourceCode sourceCode, org.codehaus.groovy.ast.ASTNode node)
Create a new Violation for the AST node. |
protected Violation
|
createViolationForImport(SourceCode sourceCode, org.codehaus.groovy.ast.ImportNode importNode, String message)
Create and return a new Violation for this rule and the specified import |
protected Violation
|
createViolationForImport(SourceCode sourceCode, org.codehaus.groovy.ast.ImportNode importNode)
Create and return a new Violation for this rule and the specified import |
protected Violation
|
createViolationForImport(SourceCode sourceCode, String className, String alias, String violationMessage)
Create and return a new Violation for this rule and the specified import className and alias |
String
|
getApplyToFileNames()
|
String
|
getApplyToFilesMatching()
|
String
|
getDescription()
|
String
|
getDoNotApplyToFileNames()
|
String
|
getDoNotApplyToFilesMatching()
|
String
|
getName()
@return the unique name for this rule |
int
|
getPriority()
@return the priority of this rule, between 1 (highest priority) and 3 (lowest priority), inclusive. |
String
|
getViolationMessage()
|
boolean
|
isEnabled()
|
boolean
|
isReady()
Allows rules to check whether preconditions are satisfied and short-circuit execution (i.e., do nothing) if those preconditions are not satisfied. |
void
|
setApplyToFileNames(String applyToFileNames)
|
void
|
setApplyToFilesMatching(String applyToFilesMatching)
|
void
|
setDescription(String description)
|
void
|
setDoNotApplyToFileNames(String doNotApplyToFileNames)
|
void
|
setDoNotApplyToFilesMatching(String doNotApplyToFilesMatching)
|
void
|
setEnabled(boolean enabled)
|
void
|
setName(String name)
Set the unique name for this rule |
void
|
setPriority(int priority)
Set the priority for this rule |
void
|
setViolationMessage(String violationMessage)
|
String
|
toString()
|
void
|
validate()
Allows rules to perform validation. |
Methods inherited from class Object | |
---|---|
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
Method Detail |
---|
public void applyTo(SourceCode sourceCode, List violations)
sourceCode
- - the source to apply this rule toviolations
- - the List of violations to which new violations from this rule are to be added
public List applyTo(SourceCode sourceCode)
sourceCode
- - the source to apply this rule to
protected Violation createViolation(Integer lineNumber, String sourceLine, String message)
lineNumber
- - the line number for the violation; may be nullsourceLine
- - the source line for the violation; may be nullmessage
- - the message for the violation; may be null
@Deprecated // should really supply an AST Node protected Violation createViolation(Integer lineNumber, String message)
lineNumber
- - the line number for the violation; may be null
@Deprecated protected Violation createViolation(Integer lineNumber)
lineNumber
- - the line number for the violation; may be null
protected Violation createViolation(SourceCode sourceCode, org.codehaus.groovy.ast.ASTNode node, String message)
sourceCode
- - the SourceCodenode
- - the Groovy AST Nodemessage
- - the message for the violation; defaults to null
@Deprecated // should really supply a message protected Violation createViolation(SourceCode sourceCode, org.codehaus.groovy.ast.ASTNode node)
sourceCode
- - the SourceCodenode
- - the Groovy AST Node
protected Violation createViolationForImport(SourceCode sourceCode, org.codehaus.groovy.ast.ImportNode importNode, String message)
sourceCode
- - the SourceCodeimportNode
- - the ImportNode for the import triggering the violation
@Deprecated // should really supply a message protected Violation createViolationForImport(SourceCode sourceCode, org.codehaus.groovy.ast.ImportNode importNode)
sourceCode
- - the SourceCodeimportNode
- - the ImportNode for the import triggering the violation
protected Violation createViolationForImport(SourceCode sourceCode, String className, String alias, String violationMessage)
sourceCode
- - the SourceCodeclassName
- - the class name (as specified within the import statement)alias
- - the alias for the import statementviolationMessage
- - the violation message; may be null
public String getApplyToFileNames()
public String getApplyToFilesMatching()
public String getDescription()
public String getDoNotApplyToFileNames()
public String getDoNotApplyToFilesMatching()
public String getName()
public int getPriority()
public String getViolationMessage()
public boolean isEnabled()
public boolean isReady()
public void setApplyToFileNames(String applyToFileNames)
public void setApplyToFilesMatching(String applyToFilesMatching)
public void setDescription(String description)
public void setDoNotApplyToFileNames(String doNotApplyToFileNames)
public void setDoNotApplyToFilesMatching(String doNotApplyToFilesMatching)
public void setEnabled(boolean enabled)
public void setName(String name)
name
- - the name for this rule; this should be unique
public void setPriority(int priority)
priority
- - the priority of this rule, between 1 (highest priority) and 3 (lowest priority), inclusive.
public void setViolationMessage(String violationMessage)
public String toString()
public void validate()
assert
calls to verify required preconditions.
Groovy Documentation