RuleSet-for-SLF4J.0.1.source-code.slf4j.xml Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of RuleSet-for-SLF4J Show documentation
Show all versions of RuleSet-for-SLF4J Show documentation
a simple PMD ruleset for SLF4J
<?xml version="1.0"?> <ruleset name="SLF4J" xmlns="http://pmd.sf.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" xsi:noNamespaceSchemaLocation="http://pmd.sourceforge.net/ruleset_2_0_0.xsd"> <description> Rulesets for SLF4J. </description> <rule name="DontPassOtherClassToLoggerFactory" message="You have to pass the Class which you're coding about to LoggerFactory#getLogger(Class)." class="jp.skypencil.pmd.slf4j.DontPassOtherClassToLoggerFactory"> <priority>1</priority> <description> You have to pass the Class which you're coding about to LoggerFactory#getLogger(Class). </description> <example><![CDATA[ class Foo { // You have to avoid passing Bar.class in Foo.class private final Logger logger = LoggerFactory.getLogger(Bar.class); } ]]></example> </rule> <rule name="DontPublishLogger" message="You have to make your all logger to private." class="jp.skypencil.pmd.slf4j.DontPublishLogger"> <priority>1</priority> <description> You have to make your all logger to private. </description> <example><![CDATA[ class Foo { // You have to avoid publishing Logger public final Logger logger = LoggerFactory.getLogger(Foo.class); } ]]></example> </rule> <rule name="LoggerShouldBeFinal" message="Your all logger should be final." class="jp.skypencil.pmd.slf4j.LoggerShouldBeFinal"> <priority>1</priority> <description> Your all logger should be final. </description> <example><![CDATA[ class Foo { // Logger should be final private Logger bad = LoggerFactory.getLogger(Foo.class); } ]]></example> </rule> <rule name="DontUseStaticLogger" message="Don't use static logger." class="jp.skypencil.pmd.slf4j.DontUseStaticLogger"> <priority>3</priority> <description> The SLF4J community recommends to use non-static logger. See official FAQ at http://www.slf4j.org/faq.html#declared_static </description> <example><![CDATA[ class Foo { // Logger has to be non-static private final static Logger bad = LoggerFactory.getLogger(Foo.class); } ]]></example> </rule> </ruleset>
© 2015 - 2025 Weber Informatics LLC | Privacy Policy