
RuleSet-for-SLF4J.0.4.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
The newest version!
<?xml version="1.0"?> <ruleset name="SLF4J" xmlns="http://pmd.sf.net/ruleset/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd" xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.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"> <description> Given argument for LoggerFactory#getLogger(Class) is wrong. You have to provide the Class which you're coding. </description> <priority>1</priority> <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"> <description> Logger should be private. </description> <priority>1</priority> <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"> <description> Logger should be final. </description> <priority>1</priority> <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"> <description> Sometimes using non-static logger is better than using static one. See official FAQ(http://www.slf4j.org/faq.html#declared_static) for detail. If you want to keep your logger static, please use default logging rule(http://pmd.sourceforge.net/pmd-5.0.0/rules/java/logging-java.html#LoggerIsNotStaticFinal) instead. </description> <priority>3</priority> <example><![CDATA[ class Foo { // Logger has to be non-static private final static Logger bad = LoggerFactory.getLogger(Foo.class); } ]]></example> </rule> <rule name="NumberOfPlaceholderShouldBeEqualToNumberOfArgument" message="Number of placeholder does not match to number of argument." class="jp.skypencil.pmd.slf4j.NumberOfPlaceholderShouldBeEqualToNumberOfArgument"> <description> Number of placeholder({}) should be equal to number of argument. </description> <priority>3</priority> <example><![CDATA[ class Foo { private final Logger logger = LoggerFactory.getLogger(getClass()); void method() { logger.info("{}, {}.", new Object[]{ "Hello" }); } } ]]></example> </rule> </ruleset>
© 2015 - 2025 Weber Informatics LLC | Privacy Policy