forked from phoedos/pmd
Fix patch 3130615: fix xpath rule to consider the correct if-condition.
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/branches/pmd/4.3.x@7362 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
parent
66ef2399e3
commit
0496cc8fc5
@ -49,6 +49,25 @@ public class Test {
|
|||||||
__log.debug("bla" + "",e );
|
__log.debug("bla" + "",e );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
]]></code>
|
||||||
|
</test-code>
|
||||||
|
<test-code>
|
||||||
|
<description><![CDATA[
|
||||||
|
Complex logging wit misplaced guard
|
||||||
|
]]></description>
|
||||||
|
<expected-problems>1</expected-problems>
|
||||||
|
<code><![CDATA[
|
||||||
|
public class Test {
|
||||||
|
private static final Log __log = LogFactory.getLog(Test.class);
|
||||||
|
public void test() {
|
||||||
|
if (true) {
|
||||||
|
// bad:
|
||||||
|
__log.debug("log something" + " and " + "concat strings");
|
||||||
|
// this is useless:
|
||||||
|
__log.isDebugEnabled();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]]></code>
|
]]></code>
|
||||||
</test-code>
|
</test-code>
|
||||||
|
@ -103,7 +103,7 @@ around, with the restriction that the logger needs to be passed into the constru
|
|||||||
<property name="xpath">
|
<property name="xpath">
|
||||||
<value>
|
<value>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
//PrimaryPrefix[ends-with(Name/@Image, '.debug') and count(../descendant::AdditiveExpression) > 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]
|
||||||
]]>
|
]]>
|
||||||
</value>
|
</value>
|
||||||
</property>
|
</property>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user