A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/issues/1291 below:

too many arguments with string concatenation operator · Issue #1291 · pmd/pmd · GitHub

Affects PMD Version: 6.6.0

Rule: InvalidSlf4jMessageFormat

Description:

Splitting a String with + (often done for readability or not exceeding a certain line length) causes slf4j argument placeholder "{}" only to be counted on the first line which can lead to InvalidSlf4jMessageFormat Priority:5 Too many arguments, expected 1 argument but have 2.

Code Sample demonstrating the issue:

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public final class Main {
    private static final Logger LOGGER = LoggerFactory.getLogger(Main.class);

    private Main() {
    }

    public static void main(String[] args) {
        String string0 = "a";
        String string1 = "b";
        LOGGER.trace("first line {}"
                + "second line {}",
                string0,
                string1);
    }
}

whereas the following works:

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public final class Main {
    private static final Logger LOGGER = LoggerFactory.getLogger(Main.class);

    private Main() {
    }

    public static void main(String[] args) {
        String string0 = "a";
        String string1 = "b";
        LOGGER.trace("first line {} second line {}",
                string0,
                string1);
    }
}

An SSCCE can be found at https://gitlab.com/krichter/pmd-invalid-slf4j-message-format.

Running PMD through: Maven


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4