Subscribed unsubscribe Subscribe Subscribe

Kengo's blog

Technical articles about original projects, JVM, Static Analysis and JavaScript.

FindBugs plugin for SLF4J might be stable

I tested my FindBugs plugin for SLF4J by hands, and I think it is now stable. I will release it next week.

Currently this plugin helps you to check the count of placeholder. For instance:

class Foo {
    private final Logger logger = LoggerFactory.getLogger(getClass());
    void method() {
        // invalid: this logging method has 2 placeholders, but given parameter is only 1.
        logger.info("{}, {}.", "Hello");

        // valid
        logger.info("{}, {}.", "Hello", "World");

        // invalid: Throwable instance does not need placeholder
        logger.error("{}, {}", "Hello", new RuntimeException());

        // valid
        logger.error("{}", "Hello", new RuntimeException());
    }
}

You can use this plugin from command line, findbugs-maven-plugin and IDE. I will modify README to introduce the way to use it with findbugs-maven-plugin.