blob: 2534597afe9a579dd83816ff05585ee44f150b5b [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
ruleset {
description '''
OFBiz ruleset adapted from basic one from https://codenarc.org/StarterRuleSet-AllRulesByCategory.groovy.txt
Each rule is commented and priority qualified.
'''
// rulesets/basic.xml
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
RandomDoubleCoercedToZero
RemoveAllOnSelf
ReturnFromFinallyBlock
ThrowExceptionFromFinallyBlock
// rulesets/braces.xml
ElseBlockBraces
ForStatementBraces
IfStatementBraces
WhileStatementBraces
// rulesets/comments.xml
JavadocConsecutiveEmptyLines
JavadocEmptyAuthorTag
JavadocEmptyExceptionTag
JavadocEmptyFirstLine
JavadocEmptyLastLine
JavadocEmptyParamTag
JavadocEmptyReturnTag
JavadocEmptySeeTag
JavadocEmptySinceTag
JavadocEmptyThrowsTag
JavadocEmptyVersionTag
JavadocMissingExceptionDescription
JavadocMissingParamDescription
JavadocMissingThrowsDescription
// rulesets/concurrency.xml
BusyWait
DoubleCheckedLocking
InconsistentPropertyLocking
InconsistentPropertySynchronization
NestedSynchronization
StaticCalendarField
StaticConnection
StaticDateFormatField
StaticMatcherField
StaticSimpleDateFormatField
SynchronizedMethod
SynchronizedOnBoxedPrimitive
SynchronizedOnGetClass
SynchronizedOnReentrantLock
SynchronizedOnString
SynchronizedOnThis
SynchronizedReadObjectMethod
SystemRunFinalizersOnExit
ThisReferenceEscapesConstructor
ThreadGroup
ThreadLocalNotStaticFinal
ThreadYield
UseOfNotifyMethod
VolatileArrayField
VolatileLongOrDoubleField
WaitOutsideOfWhileLoop
// rulesets/convention.xml
//CompileStatic
ConfusingTernary
CouldBeElvis
CouldBeSwitchStatement
FieldTypeRequired
HashtableIsObsolete
IfStatementCouldBeTernary
// TODO : ImplicitClosureParameter
InvertedCondition
InvertedIfElse
LongLiteralWithLowerCaseL
MethodParameterTypeRequired
MethodReturnTypeRequired
NoDef
NoDouble
NoFloat
NoJavaUtilDate
NoTabCharacter
// TODO ParameterReassignment : need discussion since var modification through reference is done in 40+ groovy location.
PublicMethodsBeforeNonPublicMethods
StaticFieldsBeforeInstanceFields
StaticMethodsBeforeInstanceMethods
TernaryCouldBeElvis
VariableTypeRequired
VectorIsObsolete
// rulesets/design.xml
AbstractClassWithPublicConstructor
AbstractClassWithoutAbstractMethod
AssignmentToStaticFieldFromInstanceMethod
BooleanMethodReturnsNull
BuilderMethodWithSideEffects
CloneableWithoutClone
CloseWithoutCloseable
CompareToWithoutComparable
ConstantsOnlyInterface
EmptyMethodInAbstractClass
FinalClassWithProtectedMember
ImplementationAsType
LocaleSetDefault
NestedForLoop
PrivateFieldCouldBeFinal
PublicInstanceField
ReturnsNullInsteadOfEmptyArray
ReturnsNullInsteadOfEmptyCollection
SimpleDateFormatMissingLocale
StatelessSingleton
ToStringReturnsNull
// rulesets/exceptions.xml
CatchArrayIndexOutOfBoundsException
CatchError
// TODO : need to discuss about execption CatchException for scripting (allow global Exception catching)
CatchIllegalMonitorStateException
CatchIndexOutOfBoundsException
CatchNullPointerException
CatchRuntimeException
CatchThrowable
ConfusingClassNamedException
ExceptionExtendsError
ExceptionExtendsThrowable
ExceptionNotThrown
MissingNewInThrowStatement
ReturnNullFromCatchBlock
SwallowThreadDeath
ThrowError
ThrowException
ThrowNullPointerException
ThrowRuntimeException
ThrowThrowable
// rulesets/formatting.xml
BlankLineBeforePackage
BlockEndsWithBlankLine
BlockStartsWithBlankLine
BracesForClass
BracesForForLoop
BracesForIfElse
BracesForMethod
BracesForTryCatchFinally
ClassEndsWithBlankLine
ClassStartsWithBlankLine
ClosureStatementOnOpeningLineOfMultipleLineClosure
ConsecutiveBlankLines
FileEndsWithoutNewline
Indentation
LineLength(length: 150)
MissingBlankLineAfterImports
MissingBlankLineAfterPackage
SpaceAfterCatch
SpaceAfterClosingBrace
SpaceAfterComma
SpaceAfterFor
SpaceAfterIf
SpaceAfterOpeningBrace
SpaceAfterSemicolon
SpaceAfterSwitch
SpaceAfterWhile
SpaceAroundClosureArrow
SpaceAroundMapEntryColon(characterAfterColonRegex: /\s/)
SpaceAroundOperator
SpaceBeforeClosingBrace
SpaceBeforeOpeningBrace
TrailingWhitespace
// rulesets/generic.xml
IllegalClassMember
IllegalClassReference
IllegalPackageReference
IllegalRegex
IllegalString
IllegalSubclass
RequiredRegex
RequiredString
StatelessClass
// rulesets/grails.xml
GrailsDomainHasEquals
GrailsDomainHasToString
GrailsDomainReservedSqlKeywordName
GrailsDomainStringPropertyMaxSize
GrailsDomainWithServiceReference
GrailsDuplicateConstraint
GrailsDuplicateMapping
GrailsMassAssignment
GrailsPublicControllerMethod
GrailsServletContextReference
GrailsStatelessService
// rulesets/groovyism.xml
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
// rulesets/imports.xml
DuplicateImport
ImportFromSamePackage
ImportFromSunPackages
MisorderedStaticImports
NoWildcardImports
UnnecessaryGroovyImport
UnusedImport
// rulesets/jdbc.xml
DirectConnectionManagement
JdbcConnectionReference
JdbcStatementReference
// rulesets/junit.xml
ChainedTest
CoupledTestCase
JUnitAssertAlwaysFails
JUnitAssertAlwaysSucceeds
JUnitFailWithoutMessage
JUnitLostTest
JUnitPublicField
JUnitPublicNonTestMethod
JUnitPublicProperty
JUnitSetUpCallsSuper
JUnitStyleAssertions
JUnitTearDownCallsSuper
JUnitTestMethodWithoutAssert
JUnitUnnecessarySetUp
JUnitUnnecessaryTearDown
JUnitUnnecessaryThrowsException
SpockIgnoreRestUsed
UnnecessaryFail
UseAssertEqualsInsteadOfAssertTrue
UseAssertFalseInsteadOfNegation
UseAssertNullInsteadOfAssertEquals
UseAssertSameInsteadOfAssertTrue
UseAssertTrueInsteadOfAssertEquals
UseAssertTrueInsteadOfNegation
// rulesets/logging.xml
LoggerForDifferentClass
LoggerWithWrongModifiers
LoggingSwallowsStacktrace
MultipleLoggers
PrintStackTrace
Println
SystemErrPrint
SystemOutPrint
// rulesets/naming.xml
AbstractClassName
ClassName
ClassNameSameAsFilename
ClassNameSameAsSuperclass
ConfusingMethodName
FieldName
InterfaceName
InterfaceNameSameAsSuperInterface
MethodName
ObjectOverrideMisspelledMethodName
PackageName
PackageNameMatchesFilePath
ParameterName
PropertyName
VariableName
// rulesets/security.xml
FileCreateTempFile
InsecureRandom
NonFinalPublicField
NonFinalSubclassOfSensitiveInterface
ObjectFinalize
PublicFinalizeMethod
SystemExit
UnsafeArrayDeclaration
// rulesets/serialization.xml
EnumCustomSerializationIgnored
SerialPersistentFields
SerialVersionUID
SerializableClassMustDefineSerialVersionUID
// rulesets/size.xml
// TODO : need refactoring AbcMetric // Requires the GMetrics jar
ClassSize
CrapMetric // Requires the GMetrics jar and a Cobertura coverage file
// TODO : need refactoring CyclomaticComplexity // Requires the GMetrics jar
MethodCount
// TODO : need refactoring MethodSize
// TODO : need serious refactoring NestedBlockDepth
// TODO : need refactoring ParameterCount
// rulesets/unnecessary.xml
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(maxReferencesAllowed: 8)
UnnecessaryOverridingMethod
UnnecessaryPackageReference
UnnecessaryParenthesesForMethodCallWithClosure
UnnecessaryPublicModifier
//UnnecessaryReturnKeyword
UnnecessarySafeNavigationOperator
UnnecessarySelfAssignment
UnnecessarySemicolon
//UnnecessarySetter
UnnecessaryStringInstantiation
UnnecessaryTernaryExpression
UnnecessaryToString
UnnecessaryTransientModifier
// rulesets/unused.xml
UnusedArray
UnusedMethodParameter
UnusedObject
UnusedPrivateField
UnusedPrivateMethod
UnusedPrivateMethodParameter
UnusedVariable
}