General
Home
Downloads
GitHub Project
Javadoc
Running
Ant Task
Command-Line
[
Docker
]
Run as a Test
Other Tools/Frameworks
Using
Creating a RuleSet
Creating a Rule
Configuring Rules
Config for Grails, Spock, etc.
Starter RuleSet (All)
Report Types
HTML Report
[
SAMPLE
]
Sortable HTML
[
SAMPLE
]
XML Report
[
SAMPLE
]
JSON Report
[
SAMPLE
]
Text/IDE/Compact Reports
Baseline Report
Rules
Rule Index
[
By Name
]
Basic Rules
Braces Rules
Comments Rules
Concurrency Rules
Convention Rules
Design Rules
DRY Rules
Enhanced Rules
Exceptions Rules
Formatting Rules
Generic Rules
Grails Rules
Groovyism Rules
Import Rules
JDBC Rules
JUnit Rules
Logging Rules
Naming Rules
Size/Complexity Rules
Security Rules
Serialization Rules
Unnecessary Rules
Unused Rules
Developing
Developer Guide
Rule Index
CodeNarc
includes 405 rules.
Basic
AssertWithinFinallyBlock
AssignmentInConditional
BigDecimalInstantiation
BitwiseOperatorInConditional
BooleanGetBoolean
BrokenNullCheck
BrokenOddnessCheck
ClassForName
ComparisonOfTwoConstants
ComparisonWithSelf
ConstantAssertExpression
ConstantIfExpression
ConstantTernaryExpression
DeadCode
DoubleNegative
DuplicateCaseStatement
DuplicateMapKey
DuplicateSetValue
EmptyCatchBlock
EmptyClass
EmptyElseBlock
EmptyFinallyBlock
EmptyForStatement
EmptyIfStatement
EmptyInstanceInitializer
EmptyMethod
EmptyStaticInitializer
EmptySwitchStatement
EmptySynchronizedStatement
EmptyTryBlock
EmptyWhileStatement
EqualsAndHashCode
EqualsOverloaded
ExplicitGarbageCollection
ForLoopShouldBeWhileLoop
HardCodedWindowsFileSeparator
HardCodedWindowsRootDirectory
IntegerGetInteger
MultipleUnaryOperators
ParameterAssignmentInFilterClosure
RandomDoubleCoercedToZero
RemoveAllOnSelf
ReturnFromFinallyBlock
ThrowExceptionFromFinallyBlock
Braces
ElseBlockBraces
ForStatementBraces
IfStatementBraces
WhileStatementBraces
Comments
ClassJavadoc
JavadocConsecutiveEmptyLines
JavadocEmptyAuthorTag
JavadocEmptyExceptionTag
JavadocEmptyFirstLine
JavadocEmptyLastLine
JavadocEmptyParamTag
JavadocEmptyReturnTag
JavadocEmptySeeTag
JavadocEmptySinceTag
JavadocEmptyThrowsTag
JavadocEmptyVersionTag
JavadocMissingExceptionDescription
JavadocMissingParamDescription
JavadocMissingThrowsDescription
SpaceAfterCommentDelimiter
SpaceBeforeCommentDelimiter
Concurrency
BusyWait
DoubleCheckedLocking
InconsistentPropertyLocking
InconsistentPropertySynchronization
NestedSynchronization
NoScriptBindings
StaticCalendarField
StaticConnection
StaticDateFormatField
StaticMatcherField
StaticSimpleDateFormatField
SynchronizedMethod
SynchronizedOnBoxedPrimitive
SynchronizedOnGetClass
SynchronizedOnReentrantLock
SynchronizedOnString
SynchronizedOnThis
SynchronizedReadObjectMethod
SystemRunFinalizersOnExit
ThisReferenceEscapesConstructor
ThreadGroup
ThreadLocalNotStaticFinal
ThreadYield
UseOfNotifyMethod
VolatileArrayField
VolatileLongOrDoubleField
WaitOutsideOfWhileLoop
Convention
CompileStatic
ConfusingTernary
CouldBeElvis
CouldBeSwitchStatement
FieldTypeRequired
HashtableIsObsolete
IfStatementCouldBeTernary
ImplicitClosureParameter
ImplicitReturnStatement
InvertedCondition
InvertedIfElse
LongLiteralWithLowerCaseL
MethodParameterTypeRequired
MethodReturnTypeRequired
NoDef
NoDouble
NoFloat
NoJavaUtilDate
NoTabCharacter
ParameterReassignment
PublicMethodsBeforeNonPublicMethods
StaticFieldsBeforeInstanceFields
StaticMethodsBeforeInstanceMethods
TernaryCouldBeElvis
TrailingComma
VariableTypeRequired
VectorIsObsolete
Design
AbstractClassWithPublicConstructor
AbstractClassWithoutAbstractMethod
AssignmentToStaticFieldFromInstanceMethod
BooleanMethodReturnsNull
BuilderMethodWithSideEffects
CloneableWithoutClone
CloseWithoutCloseable
CompareToWithoutComparable
ConstantsOnlyInterface
EmptyMethodInAbstractClass
FinalClassWithProtectedMember
ImplementationAsType
Instanceof
LocaleSetDefault
NestedForLoop
OptionalCollectionReturnType
OptionalField
OptionalMethodParameter
PrivateFieldCouldBeFinal
PublicInstanceField
ReturnsNullInsteadOfEmptyArray
ReturnsNullInsteadOfEmptyCollection
SimpleDateFormatMissingLocale
StatelessSingleton
ToStringReturnsNull
Dry
DuplicateListLiteral
DuplicateMapLiteral
DuplicateNumberLiteral
DuplicateStringLiteral
Enhanced
CloneWithoutCloneable
JUnitAssertEqualsConstantActualValue
MissingOverrideAnnotation
UnsafeImplementationAsMap
Exceptions
CatchArrayIndexOutOfBoundsException
CatchError
CatchException
CatchIllegalMonitorStateException
CatchIndexOutOfBoundsException
CatchNullPointerException
CatchRuntimeException
CatchThrowable
ConfusingClassNamedException
ExceptionExtendsError
ExceptionExtendsThrowable
ExceptionNotThrown
MissingNewInThrowStatement
ReturnNullFromCatchBlock
SwallowThreadDeath
ThrowError
ThrowException
ThrowNullPointerException
ThrowRuntimeException
ThrowThrowable
Formatting
BlankLineBeforePackage
BlockEndsWithBlankLine
BlockStartsWithBlankLine
BracesForClass
BracesForForLoop
BracesForIfElse
BracesForMethod
BracesForTryCatchFinally
ClassEndsWithBlankLine
ClassStartsWithBlankLine
ClosureStatementOnOpeningLineOfMultipleLineClosure
ConsecutiveBlankLines
FileEndsWithoutNewline
Indentation
LineLength
MissingBlankLineAfterImports
MissingBlankLineAfterPackage
MissingBlankLineBeforeAnnotatedField
SpaceAfterCatch
SpaceAfterClosingBrace
SpaceAfterComma
SpaceAfterFor
SpaceAfterIf
SpaceAfterMethodCallName
SpaceAfterMethodDeclarationName
SpaceAfterNotOperator
SpaceAfterOpeningBrace
SpaceAfterSemicolon
SpaceAfterSwitch
SpaceAfterWhile
SpaceAroundClosureArrow
SpaceAroundMapEntryColon
SpaceAroundOperator
SpaceBeforeClosingBrace
SpaceBeforeOpeningBrace
SpaceInsideParentheses
TrailingWhitespace
Generic
IllegalClassMember
IllegalClassReference
IllegalPackageReference
IllegalRegex
IllegalString
IllegalSubclass
RequiredRegex
RequiredString
StatelessClass
Grails
GrailsDomainGormMethods
GrailsDomainHasEquals
GrailsDomainHasToString
GrailsDomainReservedSqlKeywordName
GrailsDomainStringPropertyMaxSize
GrailsDomainWithServiceReference
GrailsDuplicateConstraint
GrailsDuplicateMapping
GrailsMassAssignment
GrailsPublicControllerMethod
GrailsServletContextReference
GrailsStatelessService
Groovyism
AssignCollectionSort
AssignCollectionUnique
ClosureAsLastMethodParameter
CollectAllIsDeprecated
ConfusingMultipleReturns
ExplicitArrayListInstantiation
ExplicitCallToAndMethod
ExplicitCallToCompareToMethod
ExplicitCallToDivMethod
ExplicitCallToEqualsMethod
ExplicitCallToGetAtMethod
ExplicitCallToLeftShiftMethod
ExplicitCallToMinusMethod
ExplicitCallToModMethod
ExplicitCallToMultiplyMethod
ExplicitCallToOrMethod
ExplicitCallToPlusMethod
ExplicitCallToPowerMethod
ExplicitCallToPutAtMethod
ExplicitCallToRightShiftMethod
ExplicitCallToXorMethod
ExplicitHashMapInstantiation
ExplicitHashSetInstantiation
ExplicitLinkedHashMapInstantiation
ExplicitLinkedListInstantiation
ExplicitStackInstantiation
ExplicitTreeSetInstantiation
GStringAsMapKey
GStringExpressionWithinString
GetterMethodCouldBeProperty
GroovyLangImmutable
UseCollectMany
UseCollectNested
Imports
DuplicateImport
ImportFromSamePackage
ImportFromSunPackages
MisorderedStaticImports
NoWildcardImports
UnnecessaryGroovyImport
UnusedImport
Jdbc
DirectConnectionManagement
JdbcConnectionReference
JdbcResultSetReference
JdbcStatementReference
Jenkins
ClassNotSerializable
ClosureInGString
CpsCallFromNonCpsMethod
ExpressionInCpsMethodNotSerializable
ForbiddenCallInCpsMethod
ObjectOverrideOnlyNonCpsMethods
ParameterOrReturnTypeNotSerializable
Junit
ChainedTest
CoupledTestCase
JUnitAssertAlwaysFails
JUnitAssertAlwaysSucceeds
JUnitFailWithoutMessage
JUnitLostTest
JUnitPublicField
JUnitPublicNonTestMethod
JUnitPublicProperty
JUnitSetUpCallsSuper
JUnitStyleAssertions
JUnitTearDownCallsSuper
JUnitTestMethodWithoutAssert
JUnitUnnecessarySetUp
JUnitUnnecessaryTearDown
JUnitUnnecessaryThrowsException
SpockIgnoreRestUsed
SpockMissingAssert
UnnecessaryFail
UseAssertEqualsInsteadOfAssertTrue
UseAssertFalseInsteadOfNegation
UseAssertNullInsteadOfAssertEquals
UseAssertSameInsteadOfAssertTrue
UseAssertTrueInsteadOfAssertEquals
UseAssertTrueInsteadOfNegation
Logging
LoggerForDifferentClass
LoggerWithWrongModifiers
LoggingSwallowsStacktrace
MultipleLoggers
PrintStackTrace
Println
SystemErrPrint
SystemOutPrint
Naming
AbstractClassName
ClassName
ClassNameSameAsFilename
ClassNameSameAsSuperclass
ConfusingMethodName
FactoryMethodName
FieldName
InterfaceName
InterfaceNameSameAsSuperInterface
MethodName
ObjectOverrideMisspelledMethodName
PackageName
PackageNameMatchesFilePath
ParameterName
PropertyName
VariableName
Security
FileCreateTempFile
InsecureRandom
JavaIoPackageAccess
NonFinalPublicField
NonFinalSubclassOfSensitiveInterface
ObjectFinalize
PublicFinalizeMethod
SystemExit
UnsafeArrayDeclaration
Serialization
EnumCustomSerializationIgnored
NonSerializableFieldInSerializableClass
SerialPersistentFields
SerialVersionUID
SerializableClassMustDefineSerialVersionUID
Size
AbcMetric
(Requires the GMetrics jar)
ClassSize
CrapMetric
(Requires the GMetrics jar and a Cobertura coverage file)
CyclomaticComplexity
(Requires the GMetrics jar)
MethodCount
MethodSize
NestedBlockDepth
ParameterCount
Unnecessary
AddEmptyString
ConsecutiveLiteralAppends
ConsecutiveStringConcatenation
UnnecessaryBigDecimalInstantiation
UnnecessaryBigIntegerInstantiation
UnnecessaryBooleanExpression
UnnecessaryBooleanInstantiation
UnnecessaryCallForLastElement
UnnecessaryCallToSubstring
UnnecessaryCast
UnnecessaryCatchBlock
UnnecessaryCollectCall
UnnecessaryCollectionCall
UnnecessaryConstructor
UnnecessaryDefInFieldDeclaration
UnnecessaryDefInMethodDeclaration
UnnecessaryDefInVariableDeclaration
UnnecessaryDotClass
UnnecessaryDoubleInstantiation
UnnecessaryElseStatement
UnnecessaryFinalOnPrivateMethod
UnnecessaryFloatInstantiation
UnnecessaryGString
UnnecessaryGetter
UnnecessaryIfStatement
UnnecessaryInstanceOfCheck
UnnecessaryInstantiationToGetClass
UnnecessaryIntegerInstantiation
UnnecessaryLongInstantiation
UnnecessaryModOne
UnnecessaryNullCheck
UnnecessaryNullCheckBeforeInstanceOf
UnnecessaryObjectReferences
UnnecessaryOverridingMethod
UnnecessaryPackageReference
UnnecessaryParenthesesForMethodCallWithClosure
UnnecessaryPublicModifier
UnnecessaryReturnKeyword
UnnecessarySafeNavigationOperator
UnnecessarySelfAssignment
UnnecessarySemicolon
UnnecessarySetter
UnnecessaryStringInstantiation
UnnecessaryTernaryExpression
UnnecessaryToString
UnnecessaryTransientModifier
Unused
UnusedArray
UnusedMethodParameter
UnusedObject
UnusedPrivateField
UnusedPrivateMethod
UnusedPrivateMethodParameter
UnusedVariable