forked from phoedos/pmd
add missing test file for new rule GuardDebugLogging
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/branches/pmd/4.3.x@7360 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
parent
791ddbef0b
commit
ee246222ae
@ -0,0 +1,55 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<test-data>
|
||||||
|
<test-code>
|
||||||
|
<description><![CDATA[
|
||||||
|
ok
|
||||||
|
]]></description>
|
||||||
|
<expected-problems>0</expected-problems>
|
||||||
|
<code><![CDATA[
|
||||||
|
public class Test {
|
||||||
|
private static final Log __log = LogFactory.getLog(Test.class);
|
||||||
|
public void test() {
|
||||||
|
// okay:
|
||||||
|
__log.debug("log something");
|
||||||
|
|
||||||
|
// okay:
|
||||||
|
__log.debug("log something with exception", e);
|
||||||
|
|
||||||
|
// good:
|
||||||
|
if (__log.isDebugEnabled()) {
|
||||||
|
__log.debug("bla" + "",e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]]></code>
|
||||||
|
</test-code>
|
||||||
|
<test-code>
|
||||||
|
<description><![CDATA[
|
||||||
|
Complex logging without guard
|
||||||
|
]]></description>
|
||||||
|
<expected-problems>2</expected-problems>
|
||||||
|
<code><![CDATA[
|
||||||
|
public class Test {
|
||||||
|
private static final Log __log = LogFactory.getLog(Test.class);
|
||||||
|
public void test() {
|
||||||
|
// okay:
|
||||||
|
__log.debug("log something");
|
||||||
|
|
||||||
|
// okay:
|
||||||
|
__log.debug("log something with exception", e);
|
||||||
|
|
||||||
|
// bad:
|
||||||
|
__log.debug("log something" + " and " + "concat strings");
|
||||||
|
|
||||||
|
// bad:
|
||||||
|
__log.debug("log something" + " and " + "concat strings", e);
|
||||||
|
|
||||||
|
// good:
|
||||||
|
if (__log.isDebugEnabled()) {
|
||||||
|
__log.debug("bla" + "",e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]]></code>
|
||||||
|
</test-code>
|
||||||
|
</test-data>
|
Loading…
x
Reference in New Issue
Block a user