resources.report.rules.pmd.Strict_Exception_Rules.html Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sanity4j Show documentation
Show all versions of sanity4j Show documentation
Sanity4J was created to simplify running multiple static code
analysis tools on the Java projects. It provides a single entry
point to run all the selected tools and produce a consolidated
report, which presents all findings in an easily accessible
manner.
Strict_Exception_Rules
Strict_Exception_Rules
ict_Exception_Rules">Strict Exception Rules
AvoidCatchingThrowable:
This is dangerous because it casts too wide a net; it can catch things like OutOfMemoryError.
SignatureDeclareThrowsException:
It is unclear which exceptions that can be thrown from the methods.
It might be difficult to document and understand the vague interfaces.
Use either a class derived from RuntimeException or a checked exception.
ExceptionAsFlowControl:
Using Exceptions as flow control leads to GOTOish code and obscures true exceptions when debugging.
AvoidCatchingNPE:
Code should never throw NPE under normal circumstances. A catch block may hide the original error, causing other more subtle errors in its wake.
AvoidThrowingRawExceptionTypes:
Avoid throwing certain exception types. Rather than throw a raw RuntimeException, Throwable,
Exception, or Error, use a subclassed exception or error instead.
AvoidThrowingNullPointerException:
Avoid throwing a NullPointerException - it's confusing because most people will assume that the
virtual machine threw it. Consider using an IllegalArgumentException instead; this will be
clearly seen as a programmer-initiated exception.
AvoidRethrowingException:
Catch blocks that merely rethrow a caught exception only add to code size and runtime complexity.
DoNotExtendJavaLangError:
[
Errors are system exceptions. Do not extend them.
DoNotThrowExceptionInFinally:
[
Throwing exception in a finally block is confusing. It may mask exception or a defect of the code,
it also render code cleanup uninstable.
Note: This is a PMD implementation of the Lint4j rule "A throw in a finally block"
© 2015 - 2024 Weber Informatics LLC | Privacy Policy