|
Groovy Documentation | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | PROPERTY | CONSTR | METHOD | DETAIL: FIELD | PROPERTY | CONSTR | METHOD |
java.lang.Objectorg.codenarc.rule.AbstractRule
class AbstractRule
Abstract superclass for Rules.
Each subclass must define anname
property (String) and a priority
property
(integer 1..3).
Property Summary | |
---|---|
static def |
LOG
|
String |
applyToFileNames
This rule is only applied to source code (file) names matching this value. |
String |
applyToFilesMatching
This rule is only applied to source code (file) pathnames matching this regular expression. |
String |
description
If not null, this is used as the description text for this rule, overriding any description text found in the i18n resource bundles. |
String |
doNotApplyToFileNames
This rule is NOT applied to source code (file) names matching this value. |
String |
doNotApplyToFilesMatching
This rule is NOT applied to source code (file) pathnames matching this regular expression. |
boolean |
enabled
Flag indicating whether this rule should be enabled (applied). |
String |
violationMessage
If not null, this is used as the message for all violations of this rule, overriding any message generated by the concrete rule subclass. |
Constructor Summary | |
AbstractRule()
|
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 = null, String message = null)
Create and return a new Violation for this rule and the specified values |
protected Violation
|
createViolation(SourceCode sourceCode, ASTNode node, def message = null)
Create a new Violation for the AST node. |
protected Violation
|
createViolationForImport(SourceCode sourceCode, ImportNode importNode)
Create and return a new Violation for this rule and the specified import |
protected Violation
|
createViolationForImport(SourceCode sourceCode, String className, String alias)
Create and return a new Violation for this rule and the specified import className and alias |
String
|
getApplyToFilenames()
Throws UnsupportedOperationException |
String
|
getDoNotApplyToFilenames()
Throws UnsupportedOperationException |
protected List
|
getImportsSortedByLineNumber(def sourceCode)
|
String
|
getName()
|
int
|
getPriority()
|
boolean
|
isReady()
Allows rules to check whether preconditions are satisfied and short-circuit execution (i.e., do nothing) if those preconditions are not satisfied. |
protected String
|
packageNameForImport(ImportNode importNode)
Return the package name for the specified import statement or else an empty String or an empty String if the import contains no package component |
void
|
setApplyToFilenames(String applyTo)
Throws UnsupportedOperationException |
void
|
setDoNotApplyToFilenames(String doNotApply)
Throws UnsupportedOperationException |
void
|
setName(String name)
Set the unique name for this rule |
void
|
setPriority(int priority)
Set the priority for this rule |
protected def
|
sourceLineAndNumberForImport(SourceCode sourceCode, String className, String alias)
Return the source line and line number for the specified import class name and alias |
protected def
|
sourceLineAndNumberForImport(SourceCode sourceCode, ImportNode importNode)
Return the source line and line number for the specified import |
String
|
toString()
|
void
|
validate()
Allows rules to perform validation. |
Methods inherited from class Object | |
---|---|
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
Property Detail |
---|
static final def LOG
String applyToFileNames
String applyToFilesMatching
String description
String doNotApplyToFileNames
String doNotApplyToFilesMatching
boolean enabled
String violationMessage
Constructor Detail |
---|
AbstractRule()
Method Detail |
---|
public void applyTo(SourceCode sourceCode, List violations)
List applyTo(SourceCode sourceCode)
protected Violation createViolation(Integer lineNumber, String sourceLine = null, String message = null)
protected Violation createViolation(SourceCode sourceCode, ASTNode node, def message = null)
protected Violation createViolationForImport(SourceCode sourceCode, ImportNode importNode)
protected Violation createViolationForImport(SourceCode sourceCode, String className, String alias)
String getApplyToFilenames()
String getDoNotApplyToFilenames()
protected List getImportsSortedByLineNumber(def sourceCode)
public String getName()
public int getPriority()
boolean isReady()
protected String packageNameForImport(ImportNode importNode)
void setApplyToFilenames(String applyTo)
void setDoNotApplyToFilenames(String doNotApply)
public void setName(String name)
public void setPriority(int priority)
protected def sourceLineAndNumberForImport(SourceCode sourceCode, String className, String alias)
protected def sourceLineAndNumberForImport(SourceCode sourceCode, ImportNode importNode)
String toString()
void validate()
assert
calls to verify required preconditions.
Groovy Documentation