public abstract class AbstractRule extends java.lang.Object implements Rule
name
property (String) and a priority
property
(integer 1..3).Constructor and Description |
---|
AbstractRule() |
Modifier and Type | Method and Description |
---|---|
java.util.List<org.codenarc.rule.Violation> |
applyTo(org.codenarc.source.SourceCode sourceCode)
Apply this rule to the specified source and return a list of violations (or an empty List).
|
abstract void |
applyTo(org.codenarc.source.SourceCode sourceCode,
java.util.List<org.codenarc.rule.Violation> violations)
Apply this rule to the specified source and return a list of violations (or an empty List)
|
protected org.codenarc.rule.Violation |
createViolation(java.lang.Integer lineNumber)
Deprecated.
|
protected org.codenarc.rule.Violation |
createViolation(java.lang.Integer lineNumber,
java.lang.String message)
Deprecated.
|
protected org.codenarc.rule.Violation |
createViolation(java.lang.Integer lineNumber,
java.lang.String sourceLine,
java.lang.String message)
Create and return a new Violation for this rule and the specified values
|
protected org.codenarc.rule.Violation |
createViolation(org.codenarc.source.SourceCode sourceCode,
org.codehaus.groovy.ast.ASTNode node)
Deprecated.
|
protected org.codenarc.rule.Violation |
createViolation(org.codenarc.source.SourceCode sourceCode,
org.codehaus.groovy.ast.ASTNode node,
java.lang.String message)
Create a new Violation for the AST node.
|
protected org.codenarc.rule.Violation |
createViolationForImport(org.codenarc.source.SourceCode sourceCode,
org.codehaus.groovy.ast.ImportNode importNode)
Deprecated.
|
protected org.codenarc.rule.Violation |
createViolationForImport(org.codenarc.source.SourceCode sourceCode,
org.codehaus.groovy.ast.ImportNode importNode,
java.lang.String message)
Create and return a new Violation for this rule and the specified import
|
protected org.codenarc.rule.Violation |
createViolationForImport(org.codenarc.source.SourceCode sourceCode,
java.lang.String className,
java.lang.String alias,
java.lang.String violationMessage)
Create and return a new Violation for this rule and the specified import className and alias
|
java.lang.String |
getApplyToFileNames() |
java.lang.String |
getApplyToFilesMatching() |
java.lang.String |
getDescription() |
java.lang.String |
getDoNotApplyToFileNames() |
java.lang.String |
getDoNotApplyToFilesMatching() |
abstract java.lang.String |
getName() |
abstract int |
getPriority() |
java.lang.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(java.lang.String applyToFileNames) |
void |
setApplyToFilesMatching(java.lang.String applyToFilesMatching) |
void |
setDescription(java.lang.String description) |
void |
setDoNotApplyToFileNames(java.lang.String doNotApplyToFileNames) |
void |
setDoNotApplyToFilesMatching(java.lang.String doNotApplyToFilesMatching) |
void |
setEnabled(boolean enabled) |
abstract void |
setName(java.lang.String name)
Set the unique name for this rule
|
abstract void |
setPriority(int priority)
Set the priority for this rule
|
void |
setViolationMessage(java.lang.String violationMessage) |
java.lang.String |
toString() |
void |
validate()
Allows rules to perform validation.
|
public abstract java.lang.String getName()
public abstract void setName(java.lang.String name)
name
- - the name for this rule; this should be uniquepublic abstract int getPriority()
getPriority
in interface Rule
public abstract void setPriority(int priority)
priority
- - the priority of this rule, between 1 (highest priority) and 3 (lowest priority), inclusive.public abstract void applyTo(org.codenarc.source.SourceCode sourceCode, java.util.List<org.codenarc.rule.Violation> violations)
sourceCode
- - the source to apply this rule toviolations
- - the List of violations to which new violations from this rule are to be addedpublic java.util.List<org.codenarc.rule.Violation> applyTo(org.codenarc.source.SourceCode sourceCode) throws java.lang.Throwable
public boolean isReady()
public void validate()
assert
calls to verify required preconditions.public java.lang.String toString()
toString
in class java.lang.Object
protected org.codenarc.rule.Violation createViolation(java.lang.Integer lineNumber, java.lang.String sourceLine, java.lang.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 protected org.codenarc.rule.Violation createViolation(java.lang.Integer lineNumber, java.lang.String message)
lineNumber
- - the line number for the violation; may be null@Deprecated protected org.codenarc.rule.Violation createViolation(java.lang.Integer lineNumber)
lineNumber
- - the line number for the violation; may be nullprotected org.codenarc.rule.Violation createViolation(org.codenarc.source.SourceCode sourceCode, org.codehaus.groovy.ast.ASTNode node, java.lang.String message)
sourceCode
- - the SourceCodenode
- - the Groovy AST Nodemessage
- - the message for the violation; defaults to null@Deprecated protected org.codenarc.rule.Violation createViolation(org.codenarc.source.SourceCode sourceCode, org.codehaus.groovy.ast.ASTNode node)
sourceCode
- - the SourceCodenode
- - the Groovy AST Nodeprotected org.codenarc.rule.Violation createViolationForImport(org.codenarc.source.SourceCode sourceCode, org.codehaus.groovy.ast.ImportNode importNode, java.lang.String message)
sourceCode
- - the SourceCodeimportNode
- - the ImportNode for the import triggering the violation@Deprecated protected org.codenarc.rule.Violation createViolationForImport(org.codenarc.source.SourceCode sourceCode, org.codehaus.groovy.ast.ImportNode importNode)
sourceCode
- - the SourceCodeimportNode
- - the ImportNode for the import triggering the violationprotected org.codenarc.rule.Violation createViolationForImport(org.codenarc.source.SourceCode sourceCode, java.lang.String className, java.lang.String alias, java.lang.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 nullpublic boolean isEnabled()
public void setEnabled(boolean enabled)
public java.lang.String getApplyToFilesMatching()
public void setApplyToFilesMatching(java.lang.String applyToFilesMatching)
public java.lang.String getDoNotApplyToFilesMatching()
public void setDoNotApplyToFilesMatching(java.lang.String doNotApplyToFilesMatching)
public java.lang.String getApplyToFileNames()
public void setApplyToFileNames(java.lang.String applyToFileNames)
public java.lang.String getDoNotApplyToFileNames()
public void setDoNotApplyToFileNames(java.lang.String doNotApplyToFileNames)
public java.lang.String getViolationMessage()
public void setViolationMessage(java.lang.String violationMessage)
public java.lang.String getDescription()
public void setDescription(java.lang.String description)
Copyright © 2016. All rights reserved