diff --git a/pmd/etc/changelog.txt b/pmd/etc/changelog.txt index dbde8e0618..f61639ce39 100644 --- a/pmd/etc/changelog.txt +++ b/pmd/etc/changelog.txt @@ -459,6 +459,7 @@ New Java rules: StrictException ruleset: AvoidThrowingNewInstanceOfSameException, AvoidCatchingGenericException, AvoidLosingExceptionInformation Unnecessary ruleset: UselessParentheses JUnit ruleset: JUnitTestContainsTooManyAsserts, UseAssertTrueInsteadOfAssertEquals + Logging with Jakarta Commons ruleset: GuardDebugLogging New Java ruleset: android.xml: new rules specific to the Android platform diff --git a/pmd/regress/test/net/sourceforge/pmd/lang/java/rule/loggingjakartacommons/LoggingJakartaCommonsRulesTest.java b/pmd/regress/test/net/sourceforge/pmd/lang/java/rule/loggingjakartacommons/LoggingJakartaCommonsRulesTest.java index a13602698e..d07ec82f16 100644 --- a/pmd/regress/test/net/sourceforge/pmd/lang/java/rule/loggingjakartacommons/LoggingJakartaCommonsRulesTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/lang/java/rule/loggingjakartacommons/LoggingJakartaCommonsRulesTest.java @@ -12,6 +12,7 @@ public class LoggingJakartaCommonsRulesTest extends SimpleAggregatorTst { public void setUp() { addRule(RULESET, "ProperLogger"); addRule(RULESET, "UseCorrectExceptionLogging"); + addRule(RULESET, "GuardDebugLogging"); } public static junit.framework.Test suite() { diff --git a/pmd/regress/test/net/sourceforge/pmd/lang/java/rule/loggingjakartacommons/xml/GuardDebugLogging.xml b/pmd/regress/test/net/sourceforge/pmd/lang/java/rule/loggingjakartacommons/xml/GuardDebugLogging.xml new file mode 100644 index 0000000000..97c8b37386 --- /dev/null +++ b/pmd/regress/test/net/sourceforge/pmd/lang/java/rule/loggingjakartacommons/xml/GuardDebugLogging.xml @@ -0,0 +1,55 @@ + + + + + 0 + + + + + 2 + + + diff --git a/pmd/rulesets/java/logging-jakarta-commons.xml b/pmd/rulesets/java/logging-jakarta-commons.xml index fdaa42706b..864b93a43a 100644 --- a/pmd/rulesets/java/logging-jakarta-commons.xml +++ b/pmd/rulesets/java/logging-jakarta-commons.xml @@ -88,5 +88,51 @@ public class Foo { ]]> - + + + + 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] + ]]> + + + + + + + \ No newline at end of file diff --git a/pmd/rulesets/releases/50.xml b/pmd/rulesets/releases/50.xml index f4a61ea024..ba9daf5fc8 100644 --- a/pmd/rulesets/releases/50.xml +++ b/pmd/rulesets/releases/50.xml @@ -40,6 +40,7 @@ This ruleset contains links to rules that are new in PMD v5.0 + diff --git a/pmd/xdocs/credits.xml b/pmd/xdocs/credits.xml index 321c47031c..e3de961fa4 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.