Rule Index

CodeNarc includes 206 rules.

Basic

  • AddEmptyString
  • AssignmentInConditional
  • BigDecimalInstantiation
  • BooleanGetBoolean
  • BooleanMethodReturnsNull
  • BrokenOddnessCheck
  • CloneableWithoutClone
  • CompareToWithoutComparable
  • ConfusingTernary
  • ConsecutiveLiteralAppends
  • ConsecutiveStringConcatenation
  • ConstantIfExpression
  • ConstantTernaryExpression
  • DeadCode
  • DoubleNegative
  • DuplicateCaseStatement
  • EmptyCatchBlock
  • EmptyElseBlock
  • EmptyFinallyBlock
  • EmptyForStatement
  • EmptyIfStatement
  • EmptyInstanceInitializer
  • EmptyMethod
  • EmptyStaticInitializer
  • EmptySwitchStatement
  • EmptySynchronizedStatement
  • EmptyTryBlock
  • EmptyWhileStatement
  • EqualsAndHashCode
  • ExplicitArrayListInstantiation
  • ExplicitCallToAndMethod
  • ExplicitCallToCompareToMethod
  • ExplicitCallToDivMethod
  • ExplicitCallToEqualsMethod
  • ExplicitCallToGetAtMethod
  • ExplicitCallToLeftShiftMethod
  • ExplicitCallToMinusMethod
  • ExplicitCallToModMethod
  • ExplicitCallToMultiplyMethod
  • ExplicitCallToOrMethod
  • ExplicitCallToPlusMethod
  • ExplicitCallToPowerMethod
  • ExplicitCallToRightShiftMethod
  • ExplicitCallToXorMethod
  • ExplicitGarbageCollection
  • ExplicitHashMapInstantiation
  • ExplicitHashSetInstantiation
  • ExplicitLinkedListInstantiation
  • ExplicitStackInstantiation
  • ExplicitTreeSetInstantiation
  • GStringAsMapKey
  • GroovyLangImmutable
  • IntegerGetInteger
  • InvertedIfElse
  • RemoveAllOnSelf
  • ReturnFromFinallyBlock
  • ReturnsNullInsteadOfEmptyArray
  • ReturnsNullInsteadOfEmptyCollection
  • SerialVersionUID
  • SerializableClassMustDefineSerialVersionUID
  • SimpleDateFormatMissingLocale
  • ThrowExceptionFromFinallyBlock

Braces

  • ElseBlockBraces
  • ForStatementBraces
  • IfStatementBraces
  • WhileStatementBraces

Concurrency

  • BusyWait
  • DoubleCheckedLocking
  • InconsistentPropertyLocking
  • InconsistentPropertySynchronization
  • NestedSynchronization
  • StaticCalendarField
  • StaticDateFormatField
  • StaticMatcherField
  • SynchronizedMethod
  • SynchronizedOnBoxedPrimitive
  • SynchronizedOnGetClass
  • SynchronizedOnReentrantLock
  • SynchronizedOnString
  • SynchronizedOnThis
  • SynchronizedReadObjectMethod
  • SystemRunFinalizersOnExit
  • ThreadGroup
  • ThreadLocalNotStaticFinal
  • ThreadYield
  • UseOfNotifyMethod
  • VolatileArrayField
  • VolatileLongOrDoubleField
  • WaitOutsideOfWhileLoop

Design

  • AbstractClassWithoutAbstractMethod
  • CloseWithoutCloseable
  • ConstantsOnlyInterface
  • EmptyMethodInAbstractClass
  • FinalClassWithProtectedMember
  • ImplementationAsType

Dry

  • DuplicateNumberLiteral
  • DuplicateStringLiteral

Exceptions

  • CatchArrayIndexOutOfBoundsException
  • CatchError
  • CatchException
  • CatchIllegalMonitorStateException
  • CatchIndexOutOfBoundsException
  • CatchNullPointerException
  • CatchRuntimeException
  • CatchThrowable
  • ConfusingClassNamedException
  • ExceptionExtendsError
  • MissingNewInThrowStatement
  • ReturnNullFromCatchBlock
  • ThrowError
  • ThrowException
  • ThrowNullPointerException
  • ThrowRuntimeException
  • ThrowThrowable

Generic

  • IllegalRegex
  • RequiredRegex
  • StatelessClass

Grails

  • GrailsPublicControllerMethod
  • GrailsServletContextReference
  • GrailsSessionReference
  • GrailsStatelessService

Imports

  • DuplicateImport
  • ImportFromSamePackage
  • UnnecessaryGroovyImport
  • UnusedImport

Logging

  • LoggerForDifferentClass
  • LoggerWithWrongModifiers
  • LoggingSwallowsStacktrace
  • MultipleLoggers
  • PrintStackTrace
  • Println
  • SystemErrPrint
  • SystemOutPrint

Junit

  • ChainedTest
  • CoupledTestCase
  • JUnitAssertAlwaysFails
  • JUnitAssertAlwaysSucceeds
  • JUnitFailWithoutMessage
  • JUnitPublicNonTestMethod
  • JUnitSetUpCallsSuper
  • JUnitStyleAssertions
  • JUnitTearDownCallsSuper
  • JUnitTestMethodWithoutAssert
  • JUnitUnnecessarySetUp
  • JUnitUnnecessaryTearDown
  • UnnecessaryFail
  • UseAssertEqualsInsteadOfAssertTrue
  • UseAssertFalseInsteadOfNegation
  • UseAssertNullInsteadOfAssertEquals
  • UseAssertSameInsteadOfAssertTrue
  • UseAssertTrueInsteadOfAssertEquals
  • UseAssertTrueInsteadOfNegation

Naming

  • AbstractClassName
  • ClassName
  • ConfusingMethodName
  • FieldName
  • InterfaceName
  • MethodName
  • ObjectOverrideMisspelledMethodName
  • PackageName
  • ParameterName
  • PropertyName
  • VariableName

Size

  • AbcComplexity
  • ClassSize
  • CyclomaticComplexity
  • MethodCount
  • MethodSize
  • NestedBlockDepth

Unnecessary

  • UnnecessaryBigDecimalInstantiation
  • UnnecessaryBigIntegerInstantiation
  • UnnecessaryBooleanExpression
  • UnnecessaryBooleanInstantiation
  • UnnecessaryCallForLastElement
  • UnnecessaryCallToSubstring
  • UnnecessaryCatchBlock
  • UnnecessaryCollectCall
  • UnnecessaryCollectionCall
  • UnnecessaryConstructor
  • UnnecessaryDefInMethodDeclaration
  • UnnecessaryDoubleInstantiation
  • UnnecessaryFloatInstantiation
  • UnnecessaryGString
  • UnnecessaryGetter
  • UnnecessaryIfStatement
  • UnnecessaryInstantiationToGetClass
  • UnnecessaryIntegerInstantiation
  • UnnecessaryLongInstantiation
  • UnnecessaryModOne
  • UnnecessaryNullCheck
  • UnnecessaryNullCheckBeforeInstanceOf
  • UnnecessaryObjectReferences
  • UnnecessaryOverridingMethod
  • UnnecessaryPublicModifier
  • UnnecessaryReturnKeyword
  • UnnecessarySelfAssignment
  • UnnecessarySemicolon
  • UnnecessaryStringInstantiation
  • UnnecessaryTernaryExpression
  • UnnecessaryTransientModifier

Unused

  • UnusedArray
  • UnusedObject
  • UnusedPrivateField
  • UnusedPrivateMethod
  • UnusedPrivateMethodParameter
  • UnusedVariable