org.codenarc.rule
Class AbstractAstVisitorRule
java.lang.Object
org.codenarc.rule.AbstractRule
org.codenarc.rule.AbstractAstVisitorRule
- All Implemented Interfaces:
- Rule
- Direct Known Subclasses:
- AbcComplexityRule, AbstractClassNameRule, AbstractClassWithoutAbstractMethodRule, AbstractClassWithPublicConstructorRule, AbstractSharedAstVisitorRule, AddEmptyStringRule, AssertWithinFinallyBlockRule, AssignCollectionSortRule, AssignCollectionUniqueRule, AssignmentInConditionalRule, BigDecimalInstantiationRule, BitwiseOperatorInConditionalRule, BooleanGetBooleanRule, BooleanMethodReturnsNullRule, BracesForForLoopRule, BracesForIfElseRule, BracesForMethodRule, BracesForTryCatchFinallyRule, BrokenNullCheckRule, BrokenOddnessCheckRule, BuilderMethodWithSideEffectsRule, BusyWaitRule, CatchArrayIndexOutOfBoundsExceptionRule, CatchErrorRule, CatchExceptionRule, CatchIllegalMonitorStateExceptionRule, CatchIndexOutOfBoundsExceptionRule, CatchNullPointerExceptionRule, CatchRuntimeExceptionRule, CatchThrowableRule, ChainedTestRule, ClassForNameRule, ClassNameRule, ClassSizeRule, CloneableWithoutCloneRule, CloseWithoutCloseableRule, ClosureAsLastMethodParameterRule, CollectAllIsDeprecatedRule, CompareToWithoutComparableRule, ComparisonOfTwoConstantsRule, ComparisonWithSelfRule, ConfusingClassNamedExceptionRule, ConfusingMethodNameRule, ConfusingMultipleReturnsRule, ConfusingTernaryRule, ConsecutiveLiteralAppendsRule, ConsecutiveStringConcatenationRule, ConstantAssertExpressionRule, ConstantIfExpressionRule, ConstantsOnlyInterfaceRule, ConstantTernaryExpressionRule, CouldBeElvisRule, CoupledTestCaseRule, CrapMetricRule, CyclomaticComplexityRule, DeadCodeRule, DirectConnectionManagementRule, DoubleCheckedLockingRule, DoubleNegativeRule, DuplicateCaseStatementRule, DuplicateListLiteralRule, DuplicateMapKeyRule, DuplicateMapLiteralRule, DuplicateNumberLiteralRule, DuplicateSetValueRule, DuplicateStringLiteralRule, ElseBlockBracesRule, EmptyCatchBlockRule, EmptyElseBlockRule, EmptyFinallyBlockRule, EmptyForStatementRule, EmptyIfStatementRule, EmptyInstanceInitializerRule, EmptyMethodInAbstractClassRule, EmptyMethodRule, EmptyStaticInitializerRule, EmptySwitchStatementRule, EmptySynchronizedStatementRule, EmptyTryBlockRule, EmptyWhileStatementRule, EqualsAndHashCodeRule, EqualsOverloadedRule, ExceptionExtendsErrorRule, ExplicitArrayListInstantiationRule, ExplicitCallToAndMethodRule, ExplicitCallToCompareToMethodRule, ExplicitCallToDivMethodRule, ExplicitCallToEqualsMethodRule, ExplicitCallToGetAtMethodRule, ExplicitCallToLeftShiftMethodRule, ExplicitCallToMinusMethodRule, ExplicitCallToModMethodRule, ExplicitCallToMultiplyMethodRule, ExplicitCallToOrMethodRule, ExplicitCallToPlusMethodRule, ExplicitCallToPowerMethodRule, ExplicitCallToRightShiftMethodRule, ExplicitCallToXorMethodRule, ExplicitGarbageCollectionRule, ExplicitHashMapInstantiationRule, ExplicitHashSetInstantiationRule, ExplicitLinkedHashMapInstantiationRule, ExplicitLinkedListInstantiationRule, ExplicitStackInstantiationRule, ExplicitTreeSetInstantiationRule, FactoryMethodNameRule, FieldNameRule, FileCreateTempFileRule, FinalClassWithProtectedMemberRule, ForLoopShouldBeWhileLoopRule, ForStatementBracesRule, GetterMethodCouldBePropertyRule, GrailsDomainHasEqualsRule, GrailsDomainHasToStringRule, GrailsPublicControllerMethodRule, GrailsServletContextReferenceRule, GrailsSessionReferenceRule, GroovyLangImmutableRule, GStringAsMapKeyRule, HardCodedWindowsFileSeparatorRule, HardCodedWindowsRootDirectoryRule, HashtableIsObsoleteRule, IfStatementBracesRule, IllegalClassReferenceRule, IllegalPackageReferenceRule, ImplementationAsTypeRule, ImportFromSunPackagesRule, InconsistentPropertyLockingRule, InconsistentPropertySynchronizationRule, InsecureRandomRule, IntegerGetIntegerRule, InterfaceNameRule, InvertedIfElseRule, JavaIoPackageAccessRule, JdbcConnectionReferenceRule, JdbcResultSetReferenceRule, JdbcStatementReferenceRule, JUnitAssertAlwaysFailsRule, JUnitAssertAlwaysSucceedsRule, JUnitFailWithoutMessageRule, JUnitPublicNonTestMethodRule, JUnitSetUpCallsSuperRule, JUnitStyleAssertionsRule, JUnitTearDownCallsSuperRule, JUnitTestMethodWithoutAssertRule, JUnitUnnecessarySetUpRule, JUnitUnnecessaryTearDownRule, LineLengthRule, LoggerForDifferentClassRule, LoggerWithWrongModifiersRule, LoggingSwallowsStacktraceRule, LongLiteralWithLowerCaseLRule, MethodCountRule, MethodNameRule, MethodSizeRule, MissingNewInThrowStatementRule, MultipleLoggersRule, NestedBlockDepthRule, NestedSynchronizationRule, NonFinalPublicFieldRule, NonFinalSubclassOfSensitiveInterfaceRule, ObjectFinalizeRule, ObjectOverrideMisspelledMethodNameRule, PackageNameRule, ParameterNameRule, ParameterReassignmentRule, PrintlnRule, PrintStackTraceRule, PropertyNameRule, PublicFinalizeMethodRule, PublicInstanceFieldRule, RandomDoubleCoercedToZeroRule, RemoveAllOnSelfRule, ReturnFromFinallyBlockRule, ReturnNullFromCatchBlockRule, ReturnsNullInsteadOfEmptyArrayRule, ReturnsNullInsteadOfEmptyCollectionRule, SerializableClassMustDefineSerialVersionUIDRule, SerialPersistentFieldsRule, SerialVersionUIDRule, SimpleDateFormatMissingLocaleRule, SpockIgnoreRestUsedRule, StatelessClassRule, StatelessSingletonRule, StaticCalendarFieldRule, StaticConnectionRule, StaticDateFormatFieldRule, StaticMatcherFieldRule, StaticSimpleDateFormatFieldRule, SwallowThreadDeathRule, SynchronizedMethodRule, SynchronizedOnBoxedPrimitiveRule, SynchronizedOnGetClassRule, SynchronizedOnReentrantLockRule, SynchronizedOnStringRule, SynchronizedOnThisRule, SynchronizedReadObjectMethodRule, SystemErrPrintRule, SystemExitRule, SystemOutPrintRule, SystemRunFinalizersOnExitRule, TernaryCouldBeElvisRule, ThreadGroupRule, ThreadLocalNotStaticFinalRule, ThreadYieldRule, ThrowErrorRule, ThrowExceptionFromFinallyBlockRule, ThrowExceptionRule, ThrowNullPointerExceptionRule, ThrowRuntimeExceptionRule, ThrowThrowableRule, UnnecessaryBigDecimalInstantiationRule, UnnecessaryBigIntegerInstantiationRule, UnnecessaryBooleanExpressionRule, UnnecessaryBooleanInstantiationRule, UnnecessaryCallForLastElementRule, UnnecessaryCallToSubstringRule, UnnecessaryCatchBlockRule, UnnecessaryCollectCallRule, UnnecessaryCollectionCallRule, UnnecessaryConstructorRule, UnnecessaryDefInFieldDeclarationRule, UnnecessaryDefInMethodDeclarationRule, UnnecessaryDefInVariableDeclarationRule, UnnecessaryDotClassRule, UnnecessaryDoubleInstantiationRule, UnnecessaryElseStatementRule, UnnecessaryFailRule, UnnecessaryFinalOnPrivateMethodRule, UnnecessaryFloatInstantiationRule, UnnecessaryGetterRule, UnnecessaryGStringRule, UnnecessaryIfStatementRule, UnnecessaryInstanceOfCheckRule, UnnecessaryInstantiationToGetClassRule, UnnecessaryIntegerInstantiationRule, UnnecessaryLongInstantiationRule, UnnecessaryModOneRule, UnnecessaryNullCheckBeforeInstanceOfRule, UnnecessaryNullCheckRule, UnnecessaryObjectReferencesRule, UnnecessaryOverridingMethodRule, UnnecessaryPackageReferenceRule, UnnecessaryParenthesesForMethodCallWithClosureRule, UnnecessaryPublicModifierRule, UnnecessaryReturnKeywordRule, UnnecessarySelfAssignmentRule, UnnecessarySemicolonRule, UnnecessaryStringInstantiationRule, UnnecessarySubstringRule, UnnecessaryTernaryExpressionRule, UnnecessaryTransientModifierRule, UnsafeArrayDeclarationRule, UnusedArrayRule, UnusedMethodParameterRule, UnusedObjectRule, UnusedPrivateMethodParameterRule, UnusedVariableRule, UseAssertEqualsInsteadOfAssertTrueRule, UseAssertFalseInsteadOfNegationRule, UseAssertNullInsteadOfAssertEqualsRule, UseAssertSameInsteadOfAssertTrueRule, UseAssertTrueInsteadOfAssertEqualsRule, UseAssertTrueInsteadOfNegationRule, UseCollectManyRule, UseCollectNestedRule, UseOfNotifyMethodRule, VariableNameRule, VectorIsObsoleteRule, VolatileArrayFieldRule, VolatileLongOrDoubleFieldRule, WaitOutsideOfWhileLoopRule, WhileStatementBracesRule
public abstract class AbstractAstVisitorRule
- extends AbstractRule
Abstract superclass for Rules that use a Groovy AST Visitor.
Each subclass must set the astVisitorClass
property or else define a new
property with the same name, specifying the Class of the AstVisitor
to applied to the specified source code.
- Author:
- Chris Mair, Hamlet D'Arcy
Methods inherited from class org.codenarc.rule.AbstractRule |
applyTo, createViolation, createViolation, createViolation, createViolation, createViolation, createViolationForImport, createViolationForImport, createViolationForImport, getApplyToFileNames, getApplyToFilesMatching, getDescription, getDoNotApplyToFileNames, getDoNotApplyToFilesMatching, getName, getPriority, getViolationMessage, isEnabled, isReady, setApplyToFileNames, setApplyToFilesMatching, setDescription, setDoNotApplyToFileNames, setDoNotApplyToFilesMatching, setEnabled, setName, setPriority, setViolationMessage, toString, validate |
DEFAULT_CONST_NAME
protected static final String DEFAULT_CONST_NAME
- See Also:
- Constant Field Values
DEFAULT_FIELD_NAME
protected static final String DEFAULT_FIELD_NAME
- See Also:
- Constant Field Values
DEFAULT_VAR_NAME
protected static final String DEFAULT_VAR_NAME
- See Also:
- Constant Field Values
DEFAULT_TEST_FILES
protected static final String DEFAULT_TEST_FILES
- See Also:
- Constant Field Values
DEFAULT_TEST_CLASS_NAMES
protected static final String DEFAULT_TEST_CLASS_NAMES
- See Also:
- Constant Field Values
AbstractAstVisitorRule
public AbstractAstVisitorRule()
getAstVisitorClass
protected Class getAstVisitorClass()
- Each concrete subclass must either set this property or define its own property with the same name
getAstVisitor
public AstVisitor getAstVisitor()
applyTo
public void applyTo(SourceCode sourceCode,
List<Violation> violations)
- Description copied from class:
AbstractRule
- Apply this rule to the specified source and return a list of violations (or an empty List)
- Specified by:
applyTo
in class AbstractRule
- Parameters:
sourceCode
- - the source to apply this rule toviolations
- - the List of violations to which new violations from this rule are to be added
shouldApplyThisRuleTo
protected boolean shouldApplyThisRuleTo(org.codehaus.groovy.ast.ClassNode classNode)
- Return true if this rule should be applied for the specified ClassNode, based on the
configuration of this rule.
- Parameters:
classNode
- - the ClassNode
- Returns:
- true if this rule should be applied for the specified ClassNode
getApplyToClassNames
public String getApplyToClassNames()
setApplyToClassNames
public void setApplyToClassNames(String applyToClassNames)
getDoNotApplyToClassNames
public String getDoNotApplyToClassNames()
setDoNotApplyToClassNames
public void setDoNotApplyToClassNames(String doNotApplyToClassNames)
Copyright © 2012. All Rights Reserved.