diff --git a/pmd/etc/changelog.txt b/pmd/etc/changelog.txt index b2fd91c04b..97ec6554cc 100644 --- a/pmd/etc/changelog.txt +++ b/pmd/etc/changelog.txt @@ -40,6 +40,7 @@ New rule: StrictExceptions : AvoidCatchingGenericException, AvoidLosingExceptionInformation Naming : GenericsNaming JSP: NoInlineScript + Logging with Jakarta Commons ruleset: GuardDebugLogging February 08, 2009 - 4.2.5: diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/loggingjakartacommons/LoggingJakartaCommonsRulesTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/loggingjakartacommons/LoggingJakartaCommonsRulesTest.java index da8a9a8d53..343f3145c6 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/loggingjakartacommons/LoggingJakartaCommonsRulesTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/loggingjakartacommons/LoggingJakartaCommonsRulesTest.java @@ -10,6 +10,7 @@ public class LoggingJakartaCommonsRulesTest extends SimpleAggregatorTst { public void setUp() { addRule("logging-jakarta-commons", "ProperLogger"); addRule("logging-jakarta-commons", "UseCorrectExceptionLogging"); + addRule("logging-jakarta-commons", "GuardDebugLogging"); } public static junit.framework.Test suite() { diff --git a/pmd/rulesets/logging-jakarta-commons.xml b/pmd/rulesets/logging-jakarta-commons.xml index ed9aa1e1b6..14afbf300f 100644 --- a/pmd/rulesets/logging-jakarta-commons.xml +++ b/pmd/rulesets/logging-jakarta-commons.xml @@ -87,7 +87,53 @@ around, with the restriction that the logger needs to be passed into the constru } ]]> - + + + + + When log messages are composed by concatenating strings, the whole section should be guarded + by a isDebugEnabled() check to avoid performance and memory issues. + + 3 + + + + 0 and count(ancestor::IfStatement/descendant::PrimaryExpression[ends-with(descendant::PrimaryPrefix/Name/@Image, 'isDebugEnabled')]) = 0] + ]]> + + + + + + + diff --git a/pmd/xdocs/credits.xml b/pmd/xdocs/credits.xml index 480fc13ebc..30af4eb157 100644 --- a/pmd/xdocs/credits.xml +++ b/pmd/xdocs/credits.xml @@ -321,6 +321,7 @@
  • Lucian Ciufudean - RedundantFieldInitializerRule
  • Andreas Dangel - GodClass and LawOfDemeter rules, several bugfixes and cleanup
  • Riku Nykanen - patch improving TooManyMethods rule
  • +
  • Tammo van Lessen - new rule GuardDebugLogging for Jakarta Commons Logging ruleset.