diff --git a/pmd/etc/changelog.txt b/pmd/etc/changelog.txt index c672f7b066..d972fecef7 100644 --- a/pmd/etc/changelog.txt +++ b/pmd/etc/changelog.txt @@ -15,7 +15,7 @@ Android ruleset: CallSuperLast rule now also checks for finish() redefinitions New rule: Android: DoNotHardCodeSDCard Controversial : AvoidLiteralsInIfCondition (patch 2591627) - StrictExceptions : AvoidCatchingGenericException + StrictExceptions : AvoidCatchingGenericException, AvoidLosingExceptionInformation February 08, 2009 - 4.2.5: diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/strictexception/StrictExceptionRulesTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/strictexception/StrictExceptionRulesTest.java index 8e583a179e..cb030d6fd9 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/strictexception/StrictExceptionRulesTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/strictexception/StrictExceptionRulesTest.java @@ -11,6 +11,7 @@ public class StrictExceptionRulesTest extends SimpleAggregatorTst { addRule("strictexception", "AvoidCatchingGenericException"); addRule("strictexception", "AvoidCatchingNPE"); addRule("strictexception", "AvoidCatchingThrowable"); + addRule("strictexception", "AvoidLosingExceptionInformation"); addRule("strictexception", "AvoidRethrowingException"); addRule("strictexception", "AvoidThrowingNewInstanceOfSameException"); addRule("strictexception", "AvoidThrowingNullPointerException"); diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/strictexception/xml/AvoidLosingExceptionInformation.xml b/pmd/regress/test/net/sourceforge/pmd/rules/strictexception/xml/AvoidLosingExceptionInformation.xml new file mode 100644 index 0000000000..d99a11755a --- /dev/null +++ b/pmd/regress/test/net/sourceforge/pmd/rules/strictexception/xml/AvoidLosingExceptionInformation.xml @@ -0,0 +1,100 @@ + + + + + 1 + + + + + 0 + + + + + 0 + + + + + 2 + + + + + 5 + + + diff --git a/pmd/rulesets/strictexception.xml b/pmd/rulesets/strictexception.xml index b43024aa20..fb173e0ba6 100644 --- a/pmd/rulesets/strictexception.xml +++ b/pmd/rulesets/strictexception.xml @@ -373,5 +373,48 @@ public class PrimitiveType { + + Statements in a catch block that invoke accessors on the exception without using the information + only add to code size. Either remove the invocation, or use the return result. + 2 + + + + + + + + + + + + diff --git a/pmd/xdocs/credits.xml b/pmd/xdocs/credits.xml index 25cec1f977..021f5019c6 100644 --- a/pmd/xdocs/credits.xml +++ b/pmd/xdocs/credits.xml @@ -86,7 +86,7 @@
  • Peter Van de Voorde - Rewrote the 'create rule XML' functionality in the designer utility
  • Josh Devins - Reported bug with annotation parsing
  • Alan Berg - Reported bug in Ant task
  • -
  • George Thomas - Wrote AvoidRethrowingException rule
  • +
  • George Thomas - Wrote AvoidRethrowingException rule, new AvoidLosingExceptionInformation rule
  • Robert Simmons - Reported bug in optimizations package along with suggestions for fix
  • Brian Remedios - display cleanup of CPD GUI, code cleanup of StringUtil and various rules, cleanup of rule designer, code cleanup of net.sourceforge.pmd.ant.Formatter.java, code improvements to Eclipse plugin, created AbstractPoorMethodCall and refactored UseIndexOfChar
  • Max Tardiveau - A nice XML to HTML stylesheet for CPD.