CodeNarc Report: My Sample Code

Report timestamp: Aug 25, 2009 9:38:58 PM

Summary by Package

PackageTotal FilesFiles with ViolationsPriority 1Priority 2Priority 3
All Packages752115
org/codenarc/sample/domain22132
org/codenarc/sample/other10000
org/codenarc/sample/service43183

org/codenarc/sample/domain

org/codenarc/sample/domain/OtherDomain.groovy

Rule NamePriorityLine #Source Line / Message
MyStaticField27

[SRC]static final MAX_COUNT = 10

org/codenarc/sample/domain/SampleDomain.groovy

Rule NamePriorityLine #Source Line / Message
DuplicateImport15

[SRC]import org.codenarc.sample.other.Other

EmptyElseBlock224

[SRC]else {

EmptyIfStatement221

[SRC]if (name) {

ImportFromSamePackage34

[SRC]import org.codenarc.sample.domain.OtherDomain

UnnecessaryGroovyImport33

[SRC]import java.util.Map

org/codenarc/sample/service

org/codenarc/sample/service/NewService.groovy

Rule NamePriorityLine #Source Line / Message
EmptyForStatement212

[SRC]for(int i=0; i < values.size(); i++) {

EmptyWhileStatement218

[SRC]while (!values.empty) {

MyStaticField27

[SRC]static final DEFAULT_ID = 999

org/codenarc/sample/service/OtherService.groovy

Rule NamePriorityLine #Source Line / Message
ReturnFromFinallyBlock124

[SRC]return

EmptyFinallyBlock213

[SRC]finally {

EmptyTryBlock210

[SRC]try {

org/codenarc/sample/service/SampleService.groovy

Rule NamePriorityLine #Source Line / Message
BooleanInstantiation217

[SRC]def shouldRun = new Boolean(true)

EmptyCatchBlock220

[SRC]} catch(Throwable t) {

ThrowExceptionFromFinallyBlock231

[SRC]throw new Exception('bad stuff')

UnnecessaryGroovyImport33

[SRC]import java.util.Map

UnusedImport34

[SRC]import org.codenarc.sample.domain.SampleDomain

AuthorTagNotAllowed38

[SRC]@author

Rule Descriptions

#Rule NameDescription
1AuthorTagNotAllowed[Example Custom Rule Description] The @author tag is not allowed
2BooleanInstantiationUse Boolean.valueOf() for variable values or Boolean.TRUE and Boolean.FALSE for constant values instead of calling the Boolean() constructor directly or calling Boolean.valueOf(true) or Boolean.valueOf(false).
3DuplicateImportDuplicate import statements are unnecessary.
4EmptyCatchBlockIn most cases, exceptions should not be caught and ignored (swallowed).
5EmptyElseBlockEmpty else blocks are confusing and serve no purpose.
6EmptyFinallyBlockEmpty finally blocks are confusing and serve no purpose.
7EmptyForStatementEmpty for statements are confusing and serve no purpose.
8EmptyIfStatementEmpty if statements are confusing and serve no purpose.
9EmptySwitchStatementEmpty switch statements are confusing and serve no purpose.
10EmptySynchronizedStatementEmpty synchronized statements are confusing and serve no purpose.
11EmptyTryBlockEmpty try blocks are confusing and serve no purpose.
12EmptyWhileStatementEmpty while statements are confusing and serve no purpose.
13EqualsAndHashCodeIf either the boolean equals(Object) or the int hashCode() methods are overridden within a class, then both must be overridden.
14ImportFromSamePackageAn import of a class that is within the same package is unnecessary.
15MyStaticField[Example Custom Rule Description] Check for static fields.
16ReturnFromFinallyBlockReturning from a finally block is confusing and can hide the original exception.
17ThrowExceptionFromFinallyBlockThrowing an exception from a finally block is confusing and can hide the original exception.
18UnnecessaryGroovyImportA Groovy file does not need to include an import for classes from java.lang, java.util, java.io, java.net, groovy.lang and groovy.util, as well as the classes java.math.BigDecimal and java.math.BigInteger.
19UnusedImportImports for a class that is never referenced within the source file is unnecessary.

CodeNarc v0.7