Rule Name |
Description |
BooleanInstantiation |
Use <em>Boolean.valueOf()</em> for variable values or <em>Boolean.TRUE</em> and <em>Boolean.FALSE</em> for constant values instead of calling the <em>Boolean()</em> constructor directly or calling <em>Boolean.valueOf(true)</em> or <em>Boolean.valueOf(false)</em>. |
CatchError |
Catching <em>Error</em> is dangerous; it can catch exceptions such as <em>ThreadDeath</em> and <em>OutOfMemoryError</em>. |
CatchException |
Catching <em>Exception</em> is often too broad or general. It should usually be restricted to framework or infrastructure code, rather than application code. |
CatchNullPointerException |
Catching <em>NullPointerException</em> is never appropriate. It should be avoided in the first place with proper null checking, and it can mask underlying errors. |
CatchRuntimeException |
Catching <em>RuntimeException</em> is often too broad or general. It should usually be restricted to framework or infrastructure code, rather than application code. |
CatchThrowable |
Catching <em>Throwable</em> is dangerous; it can catch exceptions such as <em>ThreadDeath</em> and <em>OutOfMemoryError</em>. |
DuplicateImport |
Duplicate import statements are unnecessary. |
EmptyCatchBlock |
In most cases, exceptions should not be caught and ignored (swallowed). |
EmptyElseBlock |
Empty <em>else</em> blocks are confusing and serve no purpose. |
EmptyFinallyBlock |
Empty <em>finally</em> blocks are confusing and serve no purpose. |
EmptyForStatement |
Empty <em>for</em> statements are confusing and serve no purpose. |
EmptyIfStatement |
Empty <em>if</em> statements are confusing and serve no purpose. |
EmptySwitchStatement |
Empty <em>switch</em> statements are confusing and serve no purpose. |
EmptySynchronizedStatement |
Empty <em>synchronized</em> statements are confusing and serve no purpose. |
EmptyTryBlock |
Empty <em>try</em> blocks are confusing and serve no purpose. |
EmptyWhileStatement |
Empty <em>while</em> statements are confusing and serve no purpose. |
EqualsAndHashCode |
If either the <em>boolean equals(Object)</em> or the <em>int hashCode()</em> methods are overridden within a class, then both must be overridden. |
ImportFromSamePackage |
An import of a class that is within the same package is unnecessary. |
ReturnFromFinallyBlock |
Returning from a <em>finally</em> block is confusing and can hide the original exception. |
StringInstantiation |
Use a String literal (e.g., "...") instead of calling the corresponding String constructor (new String("..")) directly. |
ThrowError |
Checks for throwing an instance of <em>java.lang.Error</em>. |
ThrowException |
Checks for throwing an instance of <em>java.lang.Exception</em>. |
ThrowExceptionFromFinallyBlock |
Throwing an exception from a <em>finally</em> block is confusing and can hide the original exception. |
ThrowNullPointerException |
Checks for throwing an instance of <em>java.lang.NullPointerException</em>. |
ThrowRuntimeException |
Checks for throwing an instance of <em>java.lang.RuntimeException</em>. |
ThrowThrowable |
Checks for throwing an instance of <em>java.lang.Throwable</em>. |
UnnecessaryGroovyImport |
A Groovy file does not need to include an import for classes from <em>java.lang</em>, <em>java.util</em>, <em>java.io</em>, <em>java.net</em>, <em>groovy.lang</em> and <em>groovy.util</em>, as well as the classes <em>java.math.BigDecimal</em> and <em>java.math.BigInteger</em>. |
UnusedImport |
Imports for a class that is never referenced within the source file is unnecessary. |