org.codenarc.rule
Interface Rule

All Known Implementing Classes:
AbcComplexityRule, AbcMetricRule, AbstractAstVisitorRule, AbstractClassNameRule, AbstractClassWithoutAbstractMethodRule, AbstractClassWithPublicConstructorRule, AbstractImportRule, AbstractRule, AbstractSharedAstVisitorRule, AddEmptyStringRule, AssertWithinFinallyBlockRule, AssignCollectionSortRule, AssignCollectionUniqueRule, AssignmentInConditionalRule, BigDecimalInstantiationRule, BitwiseOperatorInConditionalRule, BooleanGetBooleanRule, BooleanMethodReturnsNullRule, BracesForClassRule, BracesForForLoopRule, BracesForIfElseRule, BracesForMethodRule, BracesForTryCatchFinallyRule, BrokenNullCheckRule, BrokenOddnessCheckRule, BuilderMethodWithSideEffectsRule, BusyWaitRule, CatchArrayIndexOutOfBoundsExceptionRule, CatchErrorRule, CatchExceptionRule, CatchIllegalMonitorStateExceptionRule, CatchIndexOutOfBoundsExceptionRule, CatchNullPointerExceptionRule, CatchRuntimeExceptionRule, CatchThrowableRule, ChainedTestRule, ClassForNameRule, ClassJavadocRule, ClassNameRule, ClassNameSameAsFilenameRule, ClassSizeRule, CloneableWithoutCloneRule, CloneWithoutCloneableRule, 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, DuplicateImportRule, DuplicateListLiteralRule, DuplicateMapKeyRule, DuplicateMapLiteralRule, DuplicateNumberLiteralRule, DuplicateSetValueRule, DuplicateStringLiteralRule, ElseBlockBracesRule, EmptyCatchBlockRule, EmptyClassRule, EmptyElseBlockRule, EmptyFinallyBlockRule, EmptyForStatementRule, EmptyIfStatementRule, EmptyInstanceInitializerRule, EmptyMethodInAbstractClassRule, EmptyMethodRule, EmptyStaticInitializerRule, EmptySwitchStatementRule, EmptySynchronizedStatementRule, EmptyTryBlockRule, EmptyWhileStatementRule, EnumCustomSerializationIgnoredRule, EqualsAndHashCodeRule, EqualsOverloadedRule, ExceptionExtendsErrorRule, ExceptionNotThrownRule, 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, GrailsDomainReservedSqlKeywordNameRule, GrailsDomainWithServiceReferenceRule, GrailsDuplicateConstraintRule, GrailsDuplicateMappingRule, GrailsPublicControllerMethodRule, GrailsServletContextReferenceRule, GrailsSessionReferenceRule, GrailsStatelessServiceRule, GroovyLangImmutableRule, GStringAsMapKeyRule, GStringExpressionWithinStringRule, HardCodedWindowsFileSeparatorRule, HardCodedWindowsRootDirectoryRule, HashtableIsObsoleteRule, IfStatementBracesRule, IfStatementCouldBeTernaryRule, IllegalClassMemberRule, IllegalClassReferenceRule, IllegalPackageReferenceRule, IllegalRegexRule, ImplementationAsTypeRule, ImportFromSamePackageRule, ImportFromSunPackagesRule, InconsistentPropertyLockingRule, InconsistentPropertySynchronizationRule, InsecureRandomRule, IntegerGetIntegerRule, InterfaceNameRule, InvertedIfElseRule, JavaIoPackageAccessRule, JdbcConnectionReferenceRule, JdbcResultSetReferenceRule, JdbcStatementReferenceRule, JUnitAssertAlwaysFailsRule, JUnitAssertAlwaysSucceedsRule, JUnitAssertEqualsConstantActualValueRule, JUnitFailWithoutMessageRule, JUnitLostTestRule, JUnitPublicFieldRule, JUnitPublicNonTestMethodRule, JUnitSetUpCallsSuperRule, JUnitStyleAssertionsRule, JUnitTearDownCallsSuperRule, JUnitTestMethodWithoutAssertRule, JUnitUnnecessarySetUpRule, JUnitUnnecessaryTearDownRule, JUnitUnnecessaryThrowsExceptionRule, LineLengthRule, LoggerForDifferentClassRule, LoggerWithWrongModifiersRule, LoggingSwallowsStacktraceRule, LongLiteralWithLowerCaseLRule, MethodCountRule, MethodNameRule, MethodSizeRule, MisorderedStaticImportsRule, MissingNewInThrowStatementRule, MultipleLoggersRule, NestedBlockDepthRule, NestedSynchronizationRule, NonFinalPublicFieldRule, NonFinalSubclassOfSensitiveInterfaceRule, ObjectFinalizeRule, ObjectOverrideMisspelledMethodNameRule, PackageNameRule, ParameterNameRule, ParameterReassignmentRule, PrintlnRule, PrintStackTraceRule, PrivateFieldCouldBeFinalRule, PropertyNameRule, PublicFinalizeMethodRule, PublicInstanceFieldRule, RandomDoubleCoercedToZeroRule, RemoveAllOnSelfRule, RequiredRegexRule, RequiredStringRule, ReturnFromFinallyBlockRule, ReturnNullFromCatchBlockRule, ReturnsNullInsteadOfEmptyArrayRule, ReturnsNullInsteadOfEmptyCollectionRule, SerializableClassMustDefineSerialVersionUIDRule, SerialPersistentFieldsRule, SerialVersionUIDRule, SimpleDateFormatMissingLocaleRule, SpaceAfterCatchRule, SpaceAfterClosingBraceRule, SpaceAfterCommaRule, SpaceAfterForRule, SpaceAfterIfRule, SpaceAfterOpeningBraceRule, SpaceAfterSemicolonRule, SpaceAfterSwitchRule, SpaceAfterWhileRule, SpaceAroundClosureArrowRule, SpaceAroundOperatorRule, SpaceBeforeClosingBraceRule, SpaceBeforeOpeningBraceRule, SpockIgnoreRestUsedRule, StatelessClassRule, StatelessSingletonRule, StaticCalendarFieldRule, StaticConnectionRule, StaticDateFormatFieldRule, StaticMatcherFieldRule, StaticSimpleDateFormatFieldRule, StubRule, SwallowThreadDeathRule, SynchronizedMethodRule, SynchronizedOnBoxedPrimitiveRule, SynchronizedOnGetClassRule, SynchronizedOnReentrantLockRule, SynchronizedOnStringRule, SynchronizedOnThisRule, SynchronizedReadObjectMethodRule, SystemErrPrintRule, SystemExitRule, SystemOutPrintRule, SystemRunFinalizersOnExitRule, TernaryCouldBeElvisRule, ThisReferenceEscapesConstructorRule, 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, UnnecessaryGroovyImportRule, UnnecessaryGStringRule, UnnecessaryIfStatementRule, UnnecessaryInstanceOfCheckRule, UnnecessaryInstantiationToGetClassRule, UnnecessaryIntegerInstantiationRule, UnnecessaryLongInstantiationRule, UnnecessaryModOneRule, UnnecessaryNullCheckBeforeInstanceOfRule, UnnecessaryNullCheckRule, UnnecessaryObjectReferencesRule, UnnecessaryOverridingMethodRule, UnnecessaryPackageReferenceRule, UnnecessaryParenthesesForMethodCallWithClosureRule, UnnecessaryPublicModifierRule, UnnecessaryReturnKeywordRule, UnnecessarySelfAssignmentRule, UnnecessarySemicolonRule, UnnecessaryStringInstantiationRule, UnnecessarySubstringRule, UnnecessaryTernaryExpressionRule, UnnecessaryTransientModifierRule, UnsafeArrayDeclarationRule, UnsafeImplementationAsMapRule, UnusedArrayRule, UnusedImportRule, UnusedMethodParameterRule, UnusedObjectRule, UnusedPrivateFieldRule, UnusedPrivateMethodParameterRule, UnusedPrivateMethodRule, UnusedVariableRule, UseAssertEqualsInsteadOfAssertTrueRule, UseAssertFalseInsteadOfNegationRule, UseAssertNullInsteadOfAssertEqualsRule, UseAssertSameInsteadOfAssertTrueRule, UseAssertTrueInsteadOfAssertEqualsRule, UseAssertTrueInsteadOfNegationRule, UseCollectManyRule, UseCollectNestedRule, UseOfNotifyMethodRule, VariableNameRule, VectorIsObsoleteRule, VolatileArrayFieldRule, VolatileLongOrDoubleFieldRule, WaitOutsideOfWhileLoopRule, WhileStatementBracesRule

public interface Rule

Represents a source code analysis rule .

Author:
Chris Mair

Method Summary
 List<Violation> applyTo(SourceCode sourceCode)
          Apply this rule to the specified source and return a list of violations (or an empty List)
 int getCompilerPhase()
           
 String getName()
           
 int getPriority()
           
 

Method Detail

applyTo

List<Violation> applyTo(SourceCode sourceCode)
                        throws Throwable
Apply this rule to the specified source and return a list of violations (or an empty List)

Parameters:
sourceCode - - the source to apply this rule to
Returns:
the List of violations; may be empty
Throws:
Throwable - could throw anything

getPriority

int getPriority()
Returns:
the priority of this rule; must be 1, 2 or 3

getName

String getName()
Returns:
the unique id for this rule

getCompilerPhase

int getCompilerPhase()
Returns:
the required compiler phase (as in Phases) of the AST of the SourceCode handed to the rule via applyTo(SourceCode sourceCode)


Copyright © 2013. All Rights Reserved.