From 93f9d6760b6cf571d837134110807d1a7d3bd8fb Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Mon, 26 Sep 2011 19:49:41 +0000 Subject: [PATCH] patch 3130615: fix xpath rule to consider the correct if-condition. git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@7358 51baf565-9d33-0410-a72c-fc3788e3496d --- .../xml/GuardDebugLogging.xml | 19 +++++++++++++++++++ pmd/rulesets/java/logging-jakarta-commons.xml | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) 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 index 97c8b37386..0d089e5e97 100644 --- 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 @@ -49,6 +49,25 @@ public class Test { __log.debug("bla" + "",e ); } } +} + ]]> + + + + 1 + diff --git a/pmd/rulesets/java/logging-jakarta-commons.xml b/pmd/rulesets/java/logging-jakarta-commons.xml index 864b93a43a..b993c48741 100644 --- a/pmd/rulesets/java/logging-jakarta-commons.xml +++ b/pmd/rulesets/java/logging-jakarta-commons.xml @@ -104,7 +104,7 @@ public class Foo { 0 and count(ancestor::IfStatement/descendant::PrimaryExpression[ends-with(descendant::PrimaryPrefix/Name/@Image, 'isDebugEnabled')]) = 0] + //PrimaryPrefix[ends-with(Name/@Image, '.debug') and count(../descendant::AdditiveExpression) > 0 and count(ancestor::IfStatement/Expression/descendant::PrimaryExpression[ends-with(descendant::PrimaryPrefix/Name/@Image, 'isDebugEnabled')]) = 0] ]]>