CodeNarc Report: Griffon 0.3

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

Summary by Package

PackageTotal FilesFiles with ViolationsPriority 1Priority 2Priority 3
All Packages10336010414
scripts501907610
src/cli/griffon/test11030
src/cli/org/codehaus/griffon10000
src/cli/org/codehaus/griffon/commons11030
src/cli/org/codehaus/griffon/commons/cfg11030
src/cli/org/codehaus/griffon/plugins22021
src/cli/org/codehaus/griffon/plugins/logging11001
src/cli/org/codehaus/griffon/support11010
src/cli/org/codehaus/griffon/test20000
src/cli/org/codehaus/griffon/util10000
src/griffon/griffon-app/conf30000
src/griffon/griffon-app/lifecycle50000
src/rt/griffon/app30000
src/rt/griffon/applet20000
src/rt/griffon/application21010
src/rt/griffon/builder10000
src/rt/griffon/core71010
src/rt/griffon/util82041
test/cli/org/codehaus/griffon/cli650100
test/rt/griffon/builder10000
test/rt/griffon/gui10000
test/rt/griffon/gui/test10000
test/rt/griffon/util10000
test/rt/groovy/util11001

scripts

scripts/CreateScript.groovy

Rule NamePriorityLine #Source Line / Message
UnusedVariable235

[SRC]def (pkg, name) = extractArtifactName(argsMap["params"][0])

scripts/Help_.groovy

Rule NamePriorityLine #Source Line / Message
AbcComplexity2

[MSG]The ABC score for method [run] is [67.9]

NestedBlockDepth284

[SRC]try {

[MSG]The nested block depth is 6

NestedBlockDepth297

[SRC]catch(Throwable t) {

[MSG]The nested block depth is 6

scripts/Package.groovy

Rule NamePriorityLine #Source Line / Message
AbcComplexity2

[MSG]The ABC score for method [run] is [253.5]

CyclomaticComplexity2

[MSG]The cyclomatic complexity for method [run] is [33]

UnusedImport324

[SRC]import org.codehaus.griffon.util.BuildSettings

scripts/ReleasePlugin.groovy

Rule NamePriorityLine #Source Line / Message
EmptyCatchBlock2273

[SRC]catch(SVNException e) {

EmptyCatchBlock2277

[SRC]catch(SVNException e) {

EmptyCatchBlock2281

[SRC]catch(SVNException e) {

AbcComplexity2

[MSG]The ABC score for method [run] is [167.8]

CyclomaticComplexity2

[MSG]The cyclomatic complexity for method [run] is [28]

NestedBlockDepth285

[SRC]if (!repos.info("griffon-$pluginName", -1)) {

[MSG]The nested block depth is 6

NestedBlockDepth288

[SRC]else {

[MSG]The nested block depth is 6

scripts/RunApp.groovy

Rule NamePriorityLine #Source Line / Message
AbcComplexity2

[MSG]The ABC score for method [run] is [84.4]

UnusedImport323

[SRC]import static griffon.util.GriffonApplicationUtils.isLinux

scripts/RunApplet.groovy

Rule NamePriorityLine #Source Line / Message
UnusedImport323

[SRC]import org.codehaus.griffon.commons.ConfigurationHolder

scripts/RunWebstart.groovy

Rule NamePriorityLine #Source Line / Message
UnusedImport324

[SRC]import org.codehaus.griffon.commons.ConfigurationHolder

scripts/Stats.groovy

Rule NamePriorityLine #Source Line / Message
AbcComplexity2

[MSG]The ABC score for method [run] is [61.7]

CyclomaticComplexity2

[MSG]The cyclomatic complexity for method [run] is [23]

scripts/Upgrade.groovy

Rule NamePriorityLine #Source Line / Message
EmptyIfStatement244

[SRC]if (!force) {

AbcComplexity2

[MSG]The ABC score for method [run] is [153.1]

CyclomaticComplexity2

[MSG]The cyclomatic complexity for method [run] is [38]

NestedBlockDepth2113

[SRC]if (!Boolean.valueOf(System.getProperty(GriffonContext.E..DEFAULT))) {

[MSG]The nested block depth is 6

NestedBlockDepth2126

[SRC]if (indent != '') {

[MSG]The nested block depth is 6

NestedBlockDepth2160

[SRC]if (portions.keySet().contains('view')) {

[MSG]The nested block depth is 6

UnusedVariable2230

[SRC]def fileText = it.getFile().getText()

UnnecessaryTernaryExpression336

[SRC]boolean force = args?.indexOf('-force') > -1 ? true : false

scripts/_GriffonClasspath.groovy

Rule NamePriorityLine #Source Line / Message
AbcComplexity2

[MSG]The ABC score for method [run] is [85.6]

scripts/_GriffonCompile.groovy

Rule NamePriorityLine #Source Line / Message
UnusedImport317

[SRC]import org.codehaus.griffon.util.GriffonNameUtils

scripts/_GriffonEvents.groovy

Rule NamePriorityLine #Source Line / Message
EmptyCatchBlock268

[SRC]catch (MissingPropertyException e) {

scripts/_GriffonInit.groovy

Rule NamePriorityLine #Source Line / Message
AbcComplexity2

[MSG]The ABC score for method [run] is [92.5]

UnusedImport326

[SRC]import org.springframework.core.io.FileSystemResource

UnusedImport327

[SRC]import org.codehaus.griffon.util.GriffonNameUtils

scripts/_GriffonPackage.groovy

Rule NamePriorityLine #Source Line / Message
AbcComplexity2

[MSG]The ABC score for method [run] is [423.4]

CyclomaticComplexity2

[MSG]The cyclomatic complexity for method [run] is [88]

NestedBlockDepth2187

[SRC]if(entry.suffix) {

[MSG]The nested block depth is 6

NestedBlockDepth2189

[SRC]} else {

[MSG]The nested block depth is 6

UnusedVariable2308

[SRC]long originalLastMod = targetFile.lastModified()

scripts/_GriffonPluginDev.groovy

Rule NamePriorityLine #Source Line / Message
AbcComplexity2

[MSG]The ABC score for method [run] is [65.0]

scripts/_GriffonPlugins.groovy

Rule NamePriorityLine #Source Line / Message
AbcComplexity2

[MSG]The ABC score for method [run] is [172.0]

CyclomaticComplexity2

[MSG]The cyclomatic complexity for method [run] is [39]

NestedBlockDepth2236

[SRC]plugin.'release'.each {

[MSG]The nested block depth is 6

NestedBlockDepth2252

[SRC]if( release.'title'.text() ) {

[MSG]The nested block depth is 6

NestedBlockDepth2254

[SRC]} else {

[MSG]The nested block depth is 6

NestedBlockDepth2258

[SRC]if( release.'author'.text() ) {

[MSG]The nested block depth is 6

NestedBlockDepth2262

[SRC]if( release.'authorEmail'.text() ) {

[MSG]The nested block depth is 6

NestedBlockDepth2266

[SRC]if( release.'documentation'.text() ) {

[MSG]The nested block depth is 6

NestedBlockDepth2270

[SRC]if( release.'description'.text() ) {

[MSG]The nested block depth is 6

NestedBlockDepth2274

[SRC]if( release.'toolkits'.text() ) {

[MSG]The nested block depth is 6

NestedBlockDepth2277

[SRC]} else {

[MSG]The nested block depth is 6

NestedBlockDepth2281

[SRC]if( release.'platforms'.text() ) {

[MSG]The nested block depth is 6

NestedBlockDepth2284

[SRC]} else {

[MSG]The nested block depth is 6

UnusedVariable2314

[SRC]def displayFullPluginInfo = { pluginName ->

scripts/_GriffonSettings.groovy

Rule NamePriorityLine #Source Line / Message
AbcComplexity2

[MSG]The ABC score for method [run] is [149.1]

CyclomaticComplexity2

[MSG]The cyclomatic complexity for method [run] is [28]

UnusedImport320

[SRC]import org.codehaus.griffon.plugins.GriffonPluginUtils

scripts/_GriffonTest.groovy

Rule NamePriorityLine #Source Line / Message
AbcComplexity2

[MSG]The ABC score for method [run] is [139.6]

scripts/_PluginDependencies.groovy

Rule NamePriorityLine #Source Line / Message
EmptyCatchBlock2827

[SRC]} catch (Exception e) {

EmptyCatchBlock2898

[SRC]} catch (Exception e) {

EmptyCatchBlock2913

[SRC]} catch (Exception e) {

EmptyCatchBlock2920

[SRC]} catch (Exception e) {

AbcComplexity2

[MSG]The ABC score for method [run] is [430.2]

CyclomaticComplexity2

[MSG]The cyclomatic complexity for method [run] is [111]

NestedBlockDepth2214

[SRC]if(griffonContext == null) {

[MSG]The nested block depth is 6

NestedBlockDepth2233

[SRC]for(p in pluginManager.failedLoadPlugins) {

[MSG]The nested block depth is 6

NestedBlockDepth2360

[SRC]line.eachMatch(/<li><a href="griffon-(.+?)">/) {

[MSG]The nested block depth is 6

NestedBlockDepth2554

[SRC]def release = plugin.'release'.find {rel -> rel.'@versio..ginRelease }

[MSG]The nested block depth is 6

NestedBlockDepth2555

[SRC]if (release) {

[MSG]The nested block depth is 6

NestedBlockDepth2557

[SRC]} else {

[MSG]The nested block depth is 6

NestedBlockDepth2691

[SRC]metadata.propertyNames().grep{ it.startsWith('plugins.') }.each { p ->

[MSG]The nested block depth is 6

NestedBlockDepth2691

[SRC]metadata.propertyNames().grep{ it.startsWith('plugins.') }.each { p ->

[MSG]The nested block depth is 6

NestedBlockDepth2699

[SRC]if(supportedToolkitsByPlugin.intersect(unsupportedToolkits)) {

[MSG]The nested block depth is 7

NestedBlockDepth2703

[SRC]if(pluginsToUninstall) {

[MSG]The nested block depth is 6

NestedBlockDepth2709

[SRC]pluginsToUninstall.each { n, v -> uninstallPluginsMessag..n}-${v}\n" }

[MSG]The nested block depth is 7

NestedBlockDepth2712

[SRC]Do you wish to proceed?\n""", {

[MSG]The nested block depth is 7

NestedBlockDepth2713

[SRC]pluginsToUninstall.each { n, v ->

[MSG]The nested block depth is 8

NestedBlockDepth2718

[SRC]},{

[MSG]The nested block depth is 7

NestedBlockDepth2744

[SRC]if (!GriffonPluginUtils.isValidVersion(dependency.@versi..pVersion)) {

[MSG]The nested block depth is 6

NestedBlockDepth2746

[SRC]} else {

[MSG]The nested block depth is 6

NestedBlockDepth2773

[SRC]def providedScripts = resolveResources("file:${pluginsHo..tsWith('_')}

[MSG]The nested block depth is 6

NestedBlockDepth2774

[SRC]if (providedScripts) {

[MSG]The nested block depth is 6

NestedBlockDepth2777

[SRC]providedScripts.file.each {file ->

[MSG]The nested block depth is 7

NestedBlockDepth2784

[SRC]if (pluginEvents.exists()) {

[MSG]The nested block depth is 6

UnusedVariable2205

[SRC]def application

DuplicateImport338

[SRC]import java.util.zip.ZipEntry

src/cli/griffon/test

src/cli/griffon/test/AbstractCliTestCase.groovy

Rule NamePriorityLine #Source Line / Message
EmptyCatchBlock2147

[SRC]catch (InterruptedException ex) {

UnusedPrivateField238

[SRC]private final Condition waiting = lock.newCondition()

UnusedVariable2137

[SRC]final monitor = "monitor"

src/cli/org/codehaus/griffon/commons

src/cli/org/codehaus/griffon/commons/GriffonClassUtils.groovy

Rule NamePriorityLine #Source Line / Message
EmptyCatchBlock2570

[SRC]catch (NoSuchFieldException e)

EmptyCatchBlock2636

[SRC]catch (Exception e)

UnusedVariable2451

[SRC]for (Iterator j = words.iterator(); j.hasNext();) {

src/cli/org/codehaus/griffon/commons/cfg

src/cli/org/codehaus/griffon/commons/cfg/ConfigurationHelper.groovy

Rule NamePriorityLine #Source Line / Message
NestedBlockDepth2110

[SRC]if(classLoader) {

[MSG]The nested block depth is 6

NestedBlockDepth2116

[SRC]if(resource.filename.endsWith('.groovy')) {

[MSG]The nested block depth is 6

NestedBlockDepth2120

[SRC]else if(resource.filename.endsWith('.properties')) {

[MSG]The nested block depth is 6

src/cli/org/codehaus/griffon/plugins

src/cli/org/codehaus/griffon/plugins/GriffonPluginUtils.groovy

Rule NamePriorityLine #Source Line / Message
EqualsAndHashCode2551

[SRC]class VersionComparator implements Comparator{

UnusedVariable2294

[SRC]def userHome = System.getProperty("user.home")

src/cli/org/codehaus/griffon/plugins/PluginInfo.groovy

Rule NamePriorityLine #Source Line / Message
UnusedImport320

[SRC]import groovy.util.slurpersupport.GPathResult

src/cli/org/codehaus/griffon/plugins/logging

src/cli/org/codehaus/griffon/plugins/logging/Log4jConfig.groovy

Rule NamePriorityLine #Source Line / Message
UnusedImport329

[SRC]import org.apache.log4j.net.SMTPAppender

src/cli/org/codehaus/griffon/support

src/cli/org/codehaus/griffon/support/GriffonTestSuite.groovy

Rule NamePriorityLine #Source Line / Message
EmptyCatchBlock254

[SRC]} catch( MissingPropertyException mpe ) {

src/rt/griffon/application

src/rt/griffon/application/SwingApplication.groovy

Rule NamePriorityLine #Source Line / Message
EmptyCatchBlock278

[SRC]} catch (Throwable ignored) {

src/rt/griffon/core

src/rt/griffon/core/BaseGriffonApplication.groovy

Rule NamePriorityLine #Source Line / Message
EmptyCatchBlock286

[SRC]} catch( ignored ) {

src/rt/griffon/util

src/rt/griffon/util/AddonHelper.groovy

Rule NamePriorityLine #Source Line / Message
EmptyCatchBlock2202

[SRC]} catch (MissingPropertyException ignored) {

src/rt/griffon/util/GriffonApplicationHelper.groovy

Rule NamePriorityLine #Source Line / Message
EmptyCatchBlock2359

[SRC]} catch (Throwable ignored) {

EmptyCatchBlock2372

[SRC]} catch (Throwable ignored) {

AbcComplexity2

[MSG]The ABC score for method [buildMVCGroup] is [72.2]

MethodSize3200

[MSG]Method "buildMVCGroup" is 108 lines

test/cli/org/codehaus/griffon/cli

test/cli/org/codehaus/griffon/cli/AbstractCliTests.groovy

Rule NamePriorityLine #Source Line / Message
JUnitSetUpCallsSuper243

[SRC]void setUp() {

JUnitTearDownCallsSuper252

[SRC]void tearDown() {

AbcComplexity2

[MSG]The ABC score for method [gantRun] is [73.8]

test/cli/org/codehaus/griffon/cli/CreateIntegrationTestTests.groovy

Rule NamePriorityLine #Source Line / Message
JUnitPublicNonTestMethod214

[SRC]void tryIntegrationTest(String className) {

JUnitPublicNonTestMethod218

[SRC]void tryIntegrationTest(String scriptArg, String className) {

test/cli/org/codehaus/griffon/cli/CreateMvcTests.groovy

Rule NamePriorityLine #Source Line / Message
JUnitPublicNonTestMethod230

[SRC]void tryMvc(String name) {

test/cli/org/codehaus/griffon/cli/CreateScriptTests.groovy

Rule NamePriorityLine #Source Line / Message
JUnitPublicNonTestMethod213

[SRC]void tryScript(String className) {

JUnitPublicNonTestMethod217

[SRC]void tryScript(String scriptArg, String className) {

test/cli/org/codehaus/griffon/cli/CreateUnitTestTests.groovy

Rule NamePriorityLine #Source Line / Message
JUnitPublicNonTestMethod214

[SRC]void tryUnitTest(String className) {

JUnitPublicNonTestMethod218

[SRC]void tryUnitTest(String scriptArg, String className) {

test/rt/groovy/util

test/rt/groovy/util/GroovySwingTestCase.groovy

Rule NamePriorityLine #Source Line / Message
UnusedImport34

[SRC]import java.lang.reflect.InvocationTargetException

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