Package org.codenarc.rule.formatting
Class IndentationRule
- java.lang.Object
-
- org.codenarc.rule.AbstractRule
-
- org.codenarc.rule.AbstractAstVisitorRule
-
- org.codenarc.rule.formatting.IndentationRule
-
- All Implemented Interfaces:
groovy.lang.GroovyObject,Rule
public class IndentationRule extends AbstractAstVisitorRule implements groovy.lang.GroovyObject
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<SourceCode,Map<org.codehaus.groovy.ast.ClassNode,Integer>>classNodeIndentLevels-
Fields inherited from class org.codenarc.rule.AbstractAstVisitorRule
CLOSURE_TEXT, DEFAULT_CONST_NAME, DEFAULT_FIELD_NAME, DEFAULT_TEST_CLASS_NAMES, DEFAULT_TEST_FILES, DEFAULT_VAR_NAME
-
-
Constructor Summary
Constructors Constructor Description IndentationRule()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidapplyTo(SourceCode sourceCode, List<Violation> violations)Apply this rule to the specified source and return a list of violations (or an empty List)ClassgetAstVisitorClass()Each concrete subclass must either set this property or define its own property with the same namegroovy.lang.MetaClassgetMetaClass()StringgetName()intgetPriority()ObjectgetProperty(String property)intgetSpacesPerIndentLevel()ObjectinvokeMethod(String method, Object arguments)voidsetAstVisitorClass(Class value)voidsetMetaClass(groovy.lang.MetaClass mc)voidsetName(String value)Set the unique name for this rulevoidsetPriority(int value)Set the priority for this rulevoidsetProperty(String property, Object value)voidsetSpacesPerIndentLevel(int value)-
Methods inherited from class org.codenarc.rule.AbstractAstVisitorRule
getApplyToClassNames, getAstVisitor, getDoNotApplyToClassNames, setApplyToClassNames, setDoNotApplyToClassNames, shouldApplyThisRuleTo
-
Methods inherited from class org.codenarc.rule.AbstractRule
applyTo, createViolation, createViolation, createViolationForImport, createViolationForImport, getApplyToFileNames, getApplyToFilesMatching, getCompilerPhase, getDescription, getDoNotApplyToFileNames, getDoNotApplyToFilesMatching, getViolationMessage, isEnabled, isReady, setApplyToFileNames, setApplyToFilesMatching, setDescription, setDoNotApplyToFileNames, setDoNotApplyToFilesMatching, setEnabled, setViolationMessage, toString, validate
-
-
-
-
Field Detail
-
classNodeIndentLevels
protected final Map<SourceCode,Map<org.codehaus.groovy.ast.ClassNode,Integer>> classNodeIndentLevels
-
-
Method Detail
-
getMetaClass
public groovy.lang.MetaClass getMetaClass()
- Specified by:
getMetaClassin interfacegroovy.lang.GroovyObject
-
setMetaClass
public void setMetaClass(groovy.lang.MetaClass mc)
- Specified by:
setMetaClassin interfacegroovy.lang.GroovyObject
-
invokeMethod
public Object invokeMethod(String method, Object arguments)
- Specified by:
invokeMethodin interfacegroovy.lang.GroovyObject
-
getProperty
public Object getProperty(String property)
- Specified by:
getPropertyin interfacegroovy.lang.GroovyObject
-
setProperty
public void setProperty(String property, Object value)
- Specified by:
setPropertyin interfacegroovy.lang.GroovyObject
-
getName
public String getName()
- Specified by:
getNamein interfaceRule- Specified by:
getNamein classAbstractRule- Returns:
- the unique name for this rule
-
setName
public void setName(String value)
Description copied from class:AbstractRuleSet the unique name for this rule- Specified by:
setNamein classAbstractRule- Parameters:
value- - the name for this rule; this should be unique
-
getPriority
public int getPriority()
- Specified by:
getPriorityin interfaceRule- Specified by:
getPriorityin classAbstractRule- Returns:
- the priority of this rule, between 1 (highest priority) and 3 (lowest priority), inclusive.
-
setPriority
public void setPriority(int value)
Description copied from class:AbstractRuleSet the priority for this rule- Specified by:
setPriorityin classAbstractRule- Parameters:
value- - the priority of this rule, between 1 (highest priority) and 3 (lowest priority), inclusive.
-
getAstVisitorClass
public Class getAstVisitorClass()
Description copied from class:AbstractAstVisitorRuleEach concrete subclass must either set this property or define its own property with the same name- Overrides:
getAstVisitorClassin classAbstractAstVisitorRule
-
setAstVisitorClass
public void setAstVisitorClass(Class value)
-
getSpacesPerIndentLevel
public int getSpacesPerIndentLevel()
-
setSpacesPerIndentLevel
public void setSpacesPerIndentLevel(int value)
-
applyTo
public void applyTo(SourceCode sourceCode, List<Violation> violations)
Description copied from class:AbstractRuleApply this rule to the specified source and return a list of violations (or an empty List)- Overrides:
applyToin classAbstractAstVisitorRule- Parameters:
sourceCode- - the source to apply this rule toviolations- - the List of violations to which new violations from this rule are to be added
-
-