CodeNarc Report: Gradle 0.8

Report timestamp: May 10, 2010 10:17:28 PM

Summary by Package

PackageTotal FilesFiles with ViolationsPriority 1Priority 2Priority 3
All Packages8580100
src/org/gradle/api10000
src/org/gradle/api/internal11030
src/org/gradle/api/internal/artifacts/dsl30000
src/org/gradle/api/internal/artifacts/dsl/dependencies20000
src/org/gradle/api/internal/artifacts/publish/maven/deploy/groovy30000
src/org/gradle/api/internal/file30000
src/org/gradle/api/internal/plugins10000
src/org/gradle/api/internal/project50000
src/org/gradle/api/internal/tasks20000
src/org/gradle/api/plugins51010
src/org/gradle/api/plugins/quality50000
src/org/gradle/api/plugins/scala10000
src/org/gradle/api/tasks20000
src/org/gradle/api/tasks/bundling142020
src/org/gradle/api/tasks/compile91010
src/org/gradle/api/tasks/javadoc20000
src/org/gradle/api/tasks/scala52020
src/org/gradle/api/tasks/testing30000
src/org/gradle/api/tasks/testing/junit30000
src/org/gradle/api/tasks/testing/testng20000
src/org/gradle/api/tasks/util50000
src/org/gradle/configuration10000
src/org/gradle/groovy/scripts10000
src/org/gradle/initialization30000
src/org/gradle/util31010

src/org/gradle/api/internal

src/org/gradle/api/internal/AutoCreateDomainObjectContainerDelegate.groovy

Rule NamePriorityLine #Source Line / Message
EmptyCatchBlock227

[SRC]} catch (groovy.lang.MissingMethodException e) {

EmptyCatchBlock248

[SRC]} catch (groovy.lang.MissingPropertyException e) {

EmptyCatchBlock255

[SRC]} catch (groovy.lang.MissingPropertyException e) {

src/org/gradle/api/plugins

src/org/gradle/api/plugins/JavaPluginConvention.groovy

Rule NamePriorityLine #Source Line / Message
UnusedPrivateMethod282

[SRC]private File getReportsDir() {

src/org/gradle/api/tasks/bundling

src/org/gradle/api/tasks/bundling/Jar.groovy

Rule NamePriorityLine #Source Line / Message
UnusedPrivateField228

[SRC]private static Logger logger = LoggerFactory.getLogger(Jar)

src/org/gradle/api/tasks/bundling/War.groovy

Rule NamePriorityLine #Source Line / Message
UnusedPrivateField234

[SRC]private static Logger logger = LoggerFactory.getLogger(Jar)

src/org/gradle/api/tasks/compile

src/org/gradle/api/tasks/compile/AntGroovyc.groovy

Rule NamePriorityLine #Source Line / Message
UnusedPrivateField233

[SRC]private static Logger logger = LoggerFactory.getLogger(AntGroovyc)

src/org/gradle/api/tasks/scala

src/org/gradle/api/tasks/scala/AntScalaCompile.groovy

Rule NamePriorityLine #Source Line / Message
UnusedPrivateField223

[SRC]private static Logger logger = LoggerFactory.getLogger(A..calaCompile)

src/org/gradle/api/tasks/scala/AntScalaDoc.groovy

Rule NamePriorityLine #Source Line / Message
UnusedPrivateField223

[SRC]private static Logger logger = LoggerFactory.getLogger(AntScalaDoc)

src/org/gradle/util

src/org/gradle/util/GradleUtil.groovy

Rule NamePriorityLine #Source Line / Message
UnusedPrivateField227

[SRC]private static Logger logger = LoggerFactory.getLogger(GradleUtil)

Rule Descriptions

#Rule NameDescription
1AbcComplexityChecks the ABC metric of size/complexity for methods/classes.A method (or "closure field") with an ABC complexity value (score) greater than the maxMethodComplexity property (which defaults to 60) causes a violation. Likewise, a class that has an (average method) ABC complexityvalue greater than the maxClassAverageMethodComplexity property (which defaults to 60) causes a violation.
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).
3ClassSizeChecks if the size of a class exceeds the number of lines specified by the maxLines property, which defaults to 1000.
4CloneableWithoutCloneA class that implements java.lang.Cloneable should define a clone() method.
5ConstantIfExpressionChecks for if statements with a constant value for the if expression, such as true, false, null, or a literal constant value.
6ConstantTernaryExpressionChecks for ternary expressions with a constant value for the boolean expression, such as true, false, null, or a literal constant value.
7CyclomaticComplexityChecks the cyclomatic complexity for methods/classes.A method (or "closure field") with a cyclomatic complexity value greater than the maxMethodComplexity property (which defaults to 20) causes a violation. Likewise, a class that has an (average method) cyclomatic complexityvalue greater than the maxClassAverageMethodComplexity property (which defaults to 20) causes a violation.
8DuplicateImportDuplicate import statements are unnecessary.
9EmptyCatchBlockIn most cases, exceptions should not be caught and ignored (swallowed).
10EmptyElseBlockEmpty else blocks are confusing and serve no purpose.
11EmptyFinallyBlockEmpty finally blocks are confusing and serve no purpose.
12EmptyForStatementEmpty for statements are confusing and serve no purpose.
13EmptyIfStatementEmpty if statements are confusing and serve no purpose.
14EmptySwitchStatementEmpty switch statements are confusing and serve no purpose.
15EmptySynchronizedStatementEmpty synchronized statements are confusing and serve no purpose.
16EmptyTryBlockEmpty try blocks are confusing and serve no purpose.
17EmptyWhileStatementEmpty while statements are confusing and serve no purpose.
18EqualsAndHashCodeIf either the boolean equals(Object) or the int hashCode() methods are overridden within a class, then both must be overridden.
19ImportFromSamePackageAn import of a class that is within the same package is unnecessary.
20JUnitAssertAlwaysFailsChecks for JUnit assert() method calls with constant arguments such that the assertion always fails. This includes: assertTrue(false), assertFalse(true) and assertNull(CONSTANT).
21JUnitAssertAlwaysSucceedsChecks for JUnit assert() method calls with constant arguments such that the assertion always succeeds. This includes: assertTrue(true), assertFalse(false) and assertNull(null).
22JUnitPublicNonTestMethodChecks if a JUnit test class contains public methods other than standard test methods, JUnit framework methods or methods with JUnit annotations.
23JUnitSetUpCallsSuperChecks that if the JUnit setUp() method is defined, that it includes a call to super.setUp().
24JUnitTearDownCallsSuperChecks that if the JUnit tearDown() method is defined, that it includes a call to super.tearDown().
25MethodSizeChecks if the size of a method exceeds the number of lines specified by the maxLines property, which defaults to 100.
26NestedBlockDepthChecks for blocks or closures nested more than maxNestedBlockDepth levels deep, which defaults to 5.
27ReturnFromFinallyBlockReturning from a finally block is confusing and can hide the original exception.
28StringInstantiationUse a String literal (e.g., "...") instead of calling the corresponding String constructor (new String("..")) directly.
29ThrowExceptionFromFinallyBlockThrowing an exception from a finally block is confusing and can hide the original exception.
30UnnecessaryGroovyImportA 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.
31UnnecessaryTernaryExpressionChecks for ternary expressions where the conditional expression always evaluates to a boolean and the true and false expressions are merely returning true and false constants. Also checks for ternary expressions where both expressions are the same constant or variable.
32UnusedImportImports for a class that is never referenced within the source file is unnecessary.
33UnusedPrivateFieldChecks for private fields that are not referenced within the same class.
34UnusedPrivateMethodChecks for private methods that are not referenced within the same class.
35UnusedVariableChecks for variables that are never referenced.

CodeNarc v0.9