-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
CodeNarc vs Checkstyle checks
Andrew Epstein edited this page Oct 14, 2016
·
2 revisions
The page contains comparison of Checks from different tools.
Goal: make a list of checks that can be implemented in Checkstyle.
Note: this document is not final. It describes intentions but cannot be treated as roadmap.
Feel free to modify it or create document that compares Checkstyle checks with other tool's checks.
CodeNarc rules http://codenarc.sourceforge.net/codenarc-rule-index.html
Checkstyle rules http://checkstyle.sourceforge.net/checks.html
for additional comments see : google docs
CodeNarc Basic | CheckStyle check or implementation priority |
Comments |
---|---|---|
AssertWithinFinallyBlock | Low | Is it needed? Do we use assert in PROD code? |
AssignmentInConditional | InnerAssignment | |
BigDecimalInstantiation | Medium | Basing on IllegalInstantiation? |
BitwiseOperatorInConditional | Medium | |
BooleanGetBoolean | Medium | Based on IllegalInstantiation? |
BrokenNullCheck | Medium | |
BrokenOddnessCheck | Not planned | Don't like it |
ClassForName | Not planned | Not used on my projects |
ComparisonOfTwoConstants | Not planned | |
ComparisonWithSelf | Not planned | |
ConstantAssertExpression | N/A | Groovy Power Assert specific? |
ConstantIfExpression | Medium | |
ConstantTernaryExpression | Medium | |
DeadCode | N/A | Controlled by compiler |
DoubleNegative | Not planned | |
DuplicateCaseStatement | N/A | Controlled by compiler |
DuplicateMapKey | N/A | Controlled by compiler |
DuplicateSetValue | N/A | Groovy specific |
EmptyCatchBlock | High | We have issue on that in Checkstyle project, will be done soon for cover Google's style |
EmptyClass | Not planned | Strange rule |
EmptyElseBlock | High | Basing on EmptyStatement? |
EmptyFinallyBlock | High | Basing on EmptyStatement? |
EmptyForStatement | High | Basing on EmptyStatement? |
EmptyIfStatement | High | Basing on EmptyStatement? |
EmptyInstanceInitializer | High | Basing on EmptyStatement? |
EmptyMethod | High | Basing on EmptyStatement? |
EmptyStaticInitializer | High | Basing on EmptyStatement? |
EmptySwitchStatement | High | Basing on EmptyStatement? |
EmptySynchronized Statement | High | Basing on EmptyStatement? |
EmptyTryBlock | High | Basing on EmptyStatement? |
EmptyWhileStatement | High | Basing on EmptyStatement? |
EqualsAndHashCode | EqualsHashCode | |
EqualsOverloaded | High | |
ExplicitGarbageCollection | High | |
ForLoopShouldBeWhileLoop | High | |
HardCodedWindowsFileSeparator | High | |
HardCodedWindowsRootDirectory | Medium | |
IntegerGetInteger | High | |
MultipleUnaryOperators | Not planned | Is it needed? |
RandomDoubleCoercedToZero | High | |
RemoveAllOnSelf | High | |
ReturnFromFinallyBlock | High | Exists in sevntu |
ThrowExceptionFromFinallyBlock | High |
CodeNarc Braces | CheckStyle check or implementation priority |
Comments |
---|---|---|
ElseBlockBraces | LeftCurly | |
ForStatementBraces | LeftCurly | |
IfStatementBraces | LeftCurly | |
WhileStatementBraces | LeftCurly |
CodeNarc Concurrency | CheckStyle check or implementation priority |
Comments |
---|---|---|
BusyWait | High | |
DoubleCheckedLocking | High | |
InconsistentPropertyLocking | High | |
InconsistentPropertySynchronization | High | |
NestedSynchronization | High | |
StaticCalendarField | High | |
StaticConnection | High | |
StaticDateFormatField | High | |
StaticMatcherField | High | |
StaticSimpleDateFormatField | High | |
SynchronizedMethod | High | |
SynchronizedOnBoxedPrimitive | High | |
SynchronizedOnGetClass | High | |
SynchronizedOnReentrantLock | High | |
SynchronizedOnString | High | |
SynchronizedOnThis | High | |
SynchronizedReadObjectMethod | High | |
SystemRunFinalizersOnExit | High | |
ThisReferenceEscapesConstructor | High | |
ThreadGroup | High | |
ThreadLocalNotStaticFinal | High | |
ThreadYield | High | |
UseOfNotifyMethod | High | |
VolatileArrayField | High | |
VolatileLongOrDoubleField | High | |
WaitOutsideOfWhileLoop | High |
CodeNark Convention | CheckStyle check or implementation priotiry |
Comments |
---|---|---|
ConfusingTernary | High | Exists in sevntu |
CouldBeElvis | N/A | Groovy specific |
HashtableIsObsolete | High | I think IllegalType could do that |
IfStatementCouldBeTernary | High | |
InvertedIfElse | High | Exists in sevntu |
LongLiteralWithLowerCaseL | UpperEll | |
NoDef | N/A | Groovy specific |
ParameterReassignment | High | I do believe we have it, need to recheck |
TernaryCouldBeElvis | N/A | Groovy specific |
VectorIsObsolete | High | that could be done by IllegalImport , but I think we need to have check that forbid usage of type at all |
CodeNarc Design | CheckStyle check or implementation priority |
Comments |
---|---|---|
AbstractClassWithPublicConstructor | High | Opposite to MissingCtor |
AbstractClassWithoutAbstractMethod | High | |
BooleanMethodReturnsNull | High | Exists in sevntu |
BuilderMethodWithSideEffects | High | |
CloneableWithoutClone | High | |
CloseWithoutCloseable | High | |
CompareToWithoutComparable | High | |
ConstantsOnlyInterface | InterfaceIsType | |
EmptyMethodInAbstractClass | High | |
FinalClassWithProtectedMember | High | |
ImplementationAsType | IllegalType | |
Instanceof | High | |
LocaleSetDefault | High | |
PrivateFieldCouldBeFinal | FinalLocalVariable | |
PublicInstanceField | VisibilityModifier | |
ReturnsNullInsteadOfEmptyArray | High | Exists in sevntu |
ReturnsNullInsteadOfEmptyCollection | High | Exists in sevntu |
SimpleDateFormatMissingLocale | High | |
StatelessSingleton | High | |
ToStringReturnsNull | High | :), that is weird, wecan not predict all stupitity of human |
CodeNarc Dry | CheckStyle check or implementation priority |
Comments |
---|---|---|
DuplicateListLiteral | N/A | Groovy specific |
DuplicateMapLiteral | N/A | Groovy specific |
DuplicateNumberLiteral | MagicNumber | |
DuplicateStringLiteral | High |
CodeNarc Enhanced | CheckStyle check or implementation priority |
Comments |
---|---|---|
CloneWithoutCloneable | High | |
JUnitAssertEqualsConstantActualValue | High | |
UnsafeImplementationAsMap | N/A | Groovy specific |
CodeNarc Exceptions | CheckStyle check or implementation priority |
Comments |
---|---|---|
CatchArrayIndexOutOfBoundsException | IllegalCatch | Can be defined by IllegalCatch. Need to describe configuration in docs. |
CatchError | IllegalCatch | Can be defined by IllegalCatch. Need to describe configuration in docs. |
CatchException | IllegalCatch | Can be defined by IllegalCatch. Need to describe configuration in docs. |
CatchIllegalMonitorStateException | IllegalCatch | Can be defined by IllegalCatch. Need to describe configuration in docs. |
CatchIndexOutOfBoundsException | IllegalCatch | Can be defined by IllegalCatch. Need to describe configuration in docs. |
CatchNullPointerException | IllegalCatch | Can be defined by IllegalCatch. Need to describe configuration in docs. |
CatchRuntimeException | IllegalCatch | Can be defined by IllegalCatch. Need to describe configuration in docs. |
CatchThrowable | IllegalCatch | Can be defined by IllegalCatch. Need to describe configuration in docs. |
ConfusingClassNamedException | High | |
ExceptionExtendsError | High | |
ExceptionExtendsThrowable | High | |
ExceptionNotThrown | High | |
MissingNewInThrowStatement | N/A | Groovy specific |
ReturnNullFromCatchBlock | High | that is questionable , as it should be covered by OneReturn check |
SwallowThreadDeath | Not planned | Strange rule |
ThrowError | IllegalCatch | Can be defined by IllegalCatch. Need to describe configuration in docs. |
ThrowException | IllegalCatch | Can be defined by IllegalCatch. Need to describe configuration in docs. |
ThrowNullPointerException | IllegalCatch | Can be defined by IllegalCatch. Need to describe configuration in docs. |
ThrowRuntimeException | IllegalCatch | Can be defined by IllegalCatch. Need to describe configuration in docs. |
ThrowThrowable | IllegalCatch | Can be defined by IllegalCatch. Need to describe configuration in docs. |
CodeNarc Formatting | CheckStyle check or implementation priority |
Comments |
---|---|---|
BlankLineBeforePackage | EmptyLineSeparator | |
BracesForClass | LeftCurly, RightCurly | |
BracesFor ForLoop | LeftCurly, RightCurly | |
BracesFor IfElse | LeftCurly, RightCurly | |
BracesFor Method | LeftCurly,RightCurly | |
BracesFor TryCatchFinally | LeftCurly, RightCurly | |
ClassJavadoc | JavaDoc* | |
ClosureStatementOnOpeningLineOfMultipleLineClosure | All indentation checks? | |
ConsecutiveBlankLines | Medium | EmptyLineSeparator |
FileEndsWithoutNewline | NewlineAtEndOfFile | |
LineLength | LineLength | |
MissingBlankLineAfterImports | EmptyLineSeparator | |
MissingBlankLineAfterPackage | EmptyLineSeparator | |
SpaceAfterCatch | *Whitespace* | |
SpaceAfterClosingBrace | *Whitespace* | |
SpaceAfterComma | *Whitespace* | |
SpaceAfterFor | *Whitespace* | |
SpaceAfterIf | *Whitespace* | |
SpaceAfterOpeningBrace | *Whitespace* | |
SpaceAfterSemicolon | *Whitespace* | |
SpaceAfterSwitch | *Whitespace* | |
SpaceAfterWhile | *Whitespace* | |
SpaceAroundClosureArrow | *Whitespace* | |
SpaceAroundMapEntryColon | *Whitespace* | |
SpaceAroundOperator | *Whitespace* | |
SpaceBeforeClosingBrace | *Whitespace* | |
SpaceBeforeOpeningBrace | *Whitespace* | |
TrailingWhitespace | *Whitespace* |
CodeNarc Generic | CheckStyle check or implementation priority |
Comments |
---|---|---|
IllegalClassMember | Medium | |
IllegalClassReference | High | |
IllegalPackageReference | High | |
IllegalRegex | Low | |
IllegalString | Low | We have regExp Checks |
IllegalSubclass | Low | |
RequiredRegex | Low | |
RequiredString | Low | |
StatelessClass | Low |
CodeNarc Imports | CheckStyle check or implementation priority |
Comments |
---|---|---|
DuplicateImport | RedundantImport | |
ImportFromSamePackage | RedundantImport | |
ImportFromSunPackages | RedundantImport | |
MisorderedStaticImports | ImportOrder | |
NoWildcardImports | AvoidStarImport | |
UnnecessaryGroovyImport | N/A | Groovy specific |
UnusedImport | UnusedImports |
CodeNarc Jdbc | CheckStyle check or implementation priority |
Comments |
---|---|---|
DirectConnectionManagement | Medium | I am not in favor of specific rules, but we could think about illegalMethodCall, and it will skip a lot of cases where type is created in one file and getConnection is called from another file |
JdbcConnectionReference | N/A | Groovy specific |
JdbcResultSetReference | N/A | Groovy specific |
JdbcStatementReference | N/A | Groovy specific |
CodeNarc Junit | CheckStyle check or implementation priority |
Comments |
---|---|---|
ChainedTest | High | I have never though abuot that group, as I mostly suppress Checks in Test area, as Tests are hacks and most Checks doe snot work in test classes. But we could think about some useful |
CoupledTestCase | High | |
JUnitAssertAlwaysFails | High | |
JUnitAssertAlwaysSucceeds | High | |
JUnitFailWithoutMessage | High | |
JUnitLostTest | High | |
JUnitPublicField | High | |
JUnitPublicNonTestMethod | High | |
JUnitPublicProperty | High | |
JUnitSetUpCallsSuper | High | |
JUnitStyleAssertions | High | |
JUnitTearDownCallsSuper | High | |
JUnitTestMethodWithoutAssert | High | |
JUnitUnnecessarySetUp | High | |
JUnitUnnecessaryTearDown | High | |
JUnitUnnecessaryThrowsException | High | |
SpockIgnoreRestUsed | N/A | Groovy specific |
UnnecessaryFail | High | |
UseAssertEqualsInsteadOfAssertTrue | High | |
UseAssertFalseInsteadOfNegation | High | |
UseAssertNullInsteadOfAssertEquals | High | |
UseAssertSameInsteadOfAssertTrue | High | |
UseAssertTrueInsteadOfAssertEquals | High | |
UseAssertTrueInsteadOfNegation | High |
CodeNarc Logging | CheckStyle check or implementation priority |
Comments |
---|---|---|
LoggerForDifferentClass | High | that is good group of checks |
LoggerWithWrongModifiers | High | |
LoggingSwallowsStacktrace | High | consider sevntu issue 286 |
MultipleLoggers | High | |
PrintStackTrace | High | |
Println | N/A | Groovy specific |
SystemErrPrint | High | [check to detect](http://roman-ivanov.blogspot.com/ 2013/10/checkstyle-check-to-detect.html) |
SystemOutPrint | High |
CodeNarc Naming | CheckStyle check or implementation priority |
Comments |
---|---|---|
AbstractClassName | AbstractClassName? | |
ClassName | TypeName | |
ClassNameSameAsFilename | OuterTypeFilename | |
ConfusingMethodName | High | |
FactoryMethodName | High | |
FieldName | MemberName | |
InterfaceName | TypeName | |
MethodName | MethodName | |
ObjectOverrideMisspelledMethodName | Low | Do we need it? We have EqualsHashCode that partially resolves the issue |
PackageName | EqualsHashCode | |
PackageNameMatchesFilePath | PackageDeclaration | |
ParameterName | ParameterName | |
PropertyName | MemberName | |
VariableName | LocalVariableName |
CodeNarc Security | CheckStyle check or implementation priority |
Comments |
---|---|---|
FileCreateTempFile | High | |
InsecureRandom | High | |
JavaIoPackageAccess | High | |
NonFinalPublicField | High | |
NonFinalSubclassOfSensitiveInterface | High | |
ObjectFinalize | High | |
PublicFinalizeMethod | High | |
SystemExit | High | |
UnsafeArrayDeclaration | High |
CodeNarc Serialization | CheckStyle check or implementation priority |
Comments |
---|---|---|
EnumCustomSerializationIgnored | High | |
SerialPersistentFields | High | |
SerialVersionUID | High | |
SerializableClassMustDefineSerialVersionUID | High |
CodeNarc Size | CheckStyle check or implementation priority |
Comments |
---|---|---|
AbcMetric | N/A | (Requires the GMetrics jar) DEPRECATED |
ClassSize | Similar to FileLength | |
CrapMetric | Low | (Requires the GMetrics jar and a Cobertura coverage file) Hard to implement |
CyclomaticComplexity | Low | (Requires the GMetrics jar) Hard to implement |
MethodCount | MethodCount | |
MethodSize | MethodLength | |
NestedBlock Depth | Nested* |
CodeNarc Unnecessary | CheckStyle check or implementation priority |
Comments |
---|---|---|
AddEmptyString | N/A | It's OK in Java |
ConsecutiveLiteralAppends | N/A | It's OK in Java |
ConsecutiveStringConcatenation | N/A | It's OK in Java |
UnnecessaryBigDecimalInstantiation | N/A | Groovy specific |
UnnecessaryBigIntegerInstantiation | N/A | Groovy specific |
UnnecessaryBooleanExpression | Medium | Need to extend SimplifyBoolean Expression |
UnnecessaryBooleanInstantiation | High | |
UnnecessaryCallForLastElement | N/A | Groovy specific |
UnnecessaryCallToSubstring | Medium | |
UnnecessaryCast | High | |
UnnecessaryCatchBlock | Not planned | Is it really needed? |
UnnecessaryCollectCall | N/A | Groovy specific |
UnnecessaryCollectionCall | Not planned | Is it really needed? |
UnnecessaryConstructor | High | Sevntu |
UnnecessaryDefInFieldDeclaration | N/A | Groovy specific |
UnnecessaryDefInMethodDeclaration | N/A | Groovy specific |
UnnecessaryDefInVariableDeclaration | N/A | Groovy specific |
UnnecessaryDotClass | N/A | Groovy specific |
UnnecessaryDoubleInstantiation | High | |
UnnecessaryElseStatement | High | that refactoring is weird, as it should keep and return as last statement and keep IF-ELSE |
UnnecessaryFinalOnPrivateMethod | High | |
UnnecessaryFloatInstantiation | High | |
UnnecessaryGString | N/A | Groovy specific |
UnnecessaryGetter | N/A | Groovy specific |
UnnecessaryIfStatement | High | |
UnnecessaryInstanceOfCheck | High | |
UnnecessaryInstantiationToGetClass | High | |
UnnecessaryIntegerInstantiation | High | |
UnnecessaryLongInstantiation | High | |
UnnecessaryModOne | Not planned | Is it needed? |
UnnecessaryNullCheck | N/A | Groovy specific |
UnnecessaryNullCheck BeforeInstanceOf | High | |
UnnecessaryObjectReferences | N/A | Groovy specific |
UnnecessaryOverridingMethod | High | |
UnnecessaryPackageReference | High | |
UnnecessaryParenthesesFor MethodCallWithClosure | N/A | Groovy specific |
UnnecessaryPublicModifier | N/A | Groovy specific |
UnnecessaryReturnKeyword | N/A | Groovy specific |
UnnecessarySafeNavigationOperator | N/A | Groovy specific |
UnnecessarySelfAssignment | High | |
UnnecessarySemicolon | N/A | Groovy specific |
UnnecessaryStringInstantiation | High | |
Unnecessary Substring | N/A | Groovy specific |
UnnecessaryTernaryExpression | High | |
UnnecessaryToString | High | |
UnnecessaryTransientModifier | High |
CodeNarc Unused | CheckStyle check or implementation priority |
Comments |
---|---|---|
UnusedArray | High | |
UnusedMethodParameter | High | |
UnusedObject | High | |
UnusedPrivateField | High | |
UnusedPrivateMethod | High | |
UnusedPrivateMethodParameter | High | |
UnusedVariable | High |