Files
DependencyCheck/dependency-check-core/dc-rules/dcrules.xml
Will Stranathan b0d6070d28 Added PMD rule to find Loggers that weren't fields and corrected existing instances.
Former-commit-id: fac6dba1050e2c82a4ce090845c66bc284ce2966
2014-04-19 22:08:17 -04:00

29 lines
1012 B
XML

<?xml version="1.0" encoding="utf-8" ?>
<ruleset name="DependencyCheck Rules"
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0
http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
<rule name="LoggerChaining"
message="Logger should be a field, don't chain it"
class="net.sourceforge.pmd.lang.rule.XPathRule"
language="java">
<description><![CDATA[
Loggers should be created as fields within the class for general
use, rather than chaining the call to getLogger() followed by
the work on the Logger.
]]></description>
<properties>
<property name="xpath">
<value><![CDATA[
//PrimaryPrefix[Name/@Image = 'Logger.getLogger' and count(following-sibling::PrimarySuffix) > 2]
]]></value>
</property>
</properties>
<example><![CDATA[
Logger.getLogger(Foo.class).log(Level.FINEST, "Don't do this");
]]></example>
</rule>
</ruleset>