CodeNarc Report

Report timestamp: Oct 18, 2010 8:12:30 PM

Summary by Package

PackageTotal FilesFiles with ViolationsPriority 1Priority 2Priority 3
All Packages110158
src/groovy110158

src/groovy

src/groovy/A.groovy

Rule NamePriorityLine #Source Line / Message
ConstantIfExpression21

[SRC]if(true){

UnnecessaryBooleanExpression36

[SRC]x = true && true

UnnecessaryBooleanExpression37

[SRC]x = true && true

UnnecessaryBooleanExpression38

[SRC]x = true && true

UnnecessaryBooleanExpression39

[SRC]x = true && true

UnnecessaryBooleanExpression310

[SRC]x = true && true

UnnecessaryBooleanExpression311

[SRC]x = true && true

UnnecessaryBooleanExpression312

[SRC]x = true && true

UnnecessaryBooleanExpression313

[SRC]x = true && true

UnnecessaryBooleanExpression314

[SRC]x = true && true

UnnecessaryBooleanExpression315

[SRC]x = true && true

UnnecessaryBooleanExpression316

[SRC]x = true && true

UnnecessaryBooleanExpression317

[SRC]x = true && true

UnnecessaryBooleanExpression318

[SRC]x = true && true

UnnecessaryBooleanExpression319

[SRC]x = true && true

UnnecessaryBooleanExpression320

[SRC]x = true && true

UnnecessaryBooleanExpression321

[SRC]x = true && true

UnnecessaryBooleanExpression322

[SRC]x = true && true

UnnecessaryBooleanExpression323

[SRC]x = true && true

UnnecessaryBooleanExpression324

[SRC]x = true && true

UnnecessaryBooleanExpression325

[SRC]x = true && true

UnnecessaryBooleanExpression326

[SRC]x = true && true

UnnecessaryBooleanExpression327

[SRC]x = true && true

UnnecessaryBooleanExpression328

[SRC]x = true && true

UnnecessaryBooleanExpression329

[SRC]x = true && true

UnnecessaryBooleanExpression330

[SRC]x = true && true

UnnecessaryBooleanExpression331

[SRC]x = true && true

UnnecessaryBooleanExpression332

[SRC]x = true && true

UnnecessaryBooleanExpression333

[SRC]x = true && true

UnnecessaryBooleanExpression334

[SRC]x = true && true

UnnecessaryBooleanExpression335

[SRC]x = true && true

UnnecessaryBooleanExpression336

[SRC]x = true && true

UnnecessaryBooleanExpression337

[SRC]x = true && true

UnnecessaryBooleanExpression338

[SRC]x = true && true

UnnecessaryBooleanExpression339

[SRC]x = true && true

UnnecessaryBooleanExpression340

[SRC]x = true && true

UnnecessaryBooleanExpression341

[SRC]x = true && true

UnnecessaryBooleanExpression342

[SRC]x = true && true

UnnecessaryBooleanExpression343

[SRC]x = true && true

UnnecessaryBooleanExpression344

[SRC]x = true && true

UnnecessaryBooleanExpression345

[SRC]x = true && true

UnnecessaryBooleanExpression346

[SRC]x = true && true

UnnecessaryBooleanExpression347

[SRC]x = true && true

UnnecessaryBooleanExpression348

[SRC]x = true && true

UnnecessaryBooleanExpression349

[SRC]x = true && true

UnnecessaryBooleanExpression350

[SRC]x = true && true

UnnecessaryBooleanExpression351

[SRC]x = true && true

UnnecessaryBooleanExpression352

[SRC]x = true && true

UnnecessaryBooleanExpression353

[SRC]x = true && true

UnnecessaryBooleanExpression354

[SRC]x = true && true

UnnecessaryBooleanExpression355

[SRC]x = true && true

UnnecessaryBooleanExpression356

[SRC]x = true && true

UnnecessaryBooleanExpression357

[SRC]x = true && true

UnnecessaryBooleanExpression358

[SRC]x = true && true

UnnecessaryBooleanExpression359

[SRC]x = true && true

UnnecessaryBooleanExpression360

[SRC]x = true && true

UnnecessaryBooleanExpression361

[SRC]x = true && true

UnnecessaryBooleanExpression362

[SRC]x = true && true

UnnecessaryBooleanExpression363

[SRC]x = true && true

Rule Descriptions

#Rule NameDescription
1BigDecimalInstantiationChecks for calls to the BigDecimal constructors that take a double parameter, which may result in an unexpected BigDecimal value.
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).
3CatchErrorCatching Error is dangerous; it can catch exceptions such as ThreadDeath and OutOfMemoryError.
4CatchExceptionCatching Exception is often too broad or general. It should usually be restricted to framework or infrastructure code, rather than application code.
5CatchNullPointerExceptionCatching NullPointerException is never appropriate. It should be avoided in the first place with proper null checking, and it can mask underlying errors.
6CatchRuntimeExceptionCatching RuntimeException is often too broad or general. It should usually be restricted to framework or infrastructure code, rather than application code.
7CatchThrowableCatching Throwable is dangerous; it can catch exceptions such as ThreadDeath and OutOfMemoryError.
8CloneableWithoutCloneA class that implements java.lang.Cloneable should define a clone() method.
9ConstantIfExpressionChecks for if statements with a constant value for the if expression, such as true, false, null, or a literal constant value.
10ConstantTernaryExpressionChecks for ternary expressions with a constant value for the boolean expression, such as true, false, null, or a literal constant value.
11DuplicateImportDuplicate import statements are unnecessary.
12EmptyCatchBlockIn most cases, exceptions should not be caught and ignored (swallowed).
13EmptyElseBlockEmpty else blocks are confusing and serve no purpose.
14EmptyFinallyBlockEmpty finally blocks are confusing and serve no purpose.
15EmptyForStatementEmpty for statements are confusing and serve no purpose.
16EmptyIfStatementEmpty if statements are confusing and serve no purpose.
17EmptySwitchStatementEmpty switch statements are confusing and serve no purpose.
18EmptySynchronizedStatementEmpty synchronized statements are confusing and serve no purpose.
19EmptyTryBlockEmpty try blocks are confusing and serve no purpose.
20EmptyWhileStatementEmpty while statements are confusing and serve no purpose.
21EqualsAndHashCodeIf either the boolean equals(Object) or the int hashCode() methods are overridden within a class, then both must be overridden.
22GrailsPublicControllerMethodChecks for public methods on Grails controller classes. Static methods are ignored.
23GrailsServletContextReferenceChecks for references to the servletContext object from within Grails controller and taglib classes.
24GrailsStatelessServiceChecks for fields on Grails service classes. Grails service classes are singletons, by default, and so they should be reentrant and typically stateless. The ignoreFieldNames property specifies one or more field names that should be ignored. The ignoreFieldTypes property specifies one or more field type names that should be ignored. Both can optionally contain wildcard characters ('*' or '?').
25ImportFromSamePackageAn import of a class that is within the same package is unnecessary.
26ReturnFromFinallyBlockReturning from a finally block is confusing and can hide the original exception.
27StringInstantiationUse a String literal (e.g., "...") instead of calling the corresponding String constructor (new String("..")) directly.
28ThrowErrorChecks for throwing an instance of java.lang.Error.
29ThrowExceptionChecks for throwing an instance of java.lang.Exception.
30ThrowExceptionFromFinallyBlockThrowing an exception from a finally block is confusing and can hide the original exception.
31ThrowNullPointerExceptionChecks for throwing an instance of java.lang.NullPointerException.
32ThrowRuntimeExceptionChecks for throwing an instance of java.lang.RuntimeException.
33ThrowThrowableChecks for throwing an instance of java.lang.Throwable.
34UnnecessaryBooleanExpressionChecks for unnecessary boolean expressions, including ANDing (&&) or ORing (||) with true, false, null, or a Map/List/String/Number literal. Also checks for negation (!) of true, false, null, or a Map/List/String/Number literal.
35UnnecessaryGroovyImportA 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.
36UnnecessaryIfStatementChecks for if statements where the if and else blocks are merely returning true and false constants. These cases can be replaced by a simple return statement.
37UnnecessaryTernaryExpressionChecks 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.
38UnusedArrayChecks for array allocations that are not assigned or used, unless it is the last statement within a block.
39UnusedImportImports for a class that is never referenced within the source file is unnecessary.
40UnusedObjectChecks for object allocations that are not assigned or used, unless it is the last statement within a block
41UnusedPrivateFieldChecks for private fields that are not referenced within the same class.
42UnusedPrivateMethodChecks for private methods that are not referenced within the same class.
43UnusedVariableChecks for variables that are never referenced.

CodeNarc v0.10