A RetroSearch Logo

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

Search Query:

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

[java] InvalidLogMessageFormat detection failing when String.format used in a variable · Issue #3165 · pmd/pmd · GitHub

Affects PMD Version: 6.32, also 6.33.0-SNAPSHOT

Description:
The problem described in #3133 and initially fixed in #3146 still exists, if the result of String.format is stored in a variable.

Code Sample demonstrating the issue:

    <test-code>
        <description>[java] InvalidLogMessageFormat detection failing when String.format used in a variable</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static java.lang.String.format;

class TestInvalidLogMessageFormat {
    private static final Logger LOGGER = LoggerFactory.getLogger(TestInvalidLogMessageFormat.class);
    public void testPMD() {
        String message = String.format("Skipping file %s because no parser could be found", getName());
        LOGGER.info(message);
    }

    private String getName() { return "the-name"; }
}
        ]]></code>
    </test-code>
Test Failure: [java] InvalidLogMessageFormat detection failing when String.format used in a variable
 -> Expected 0 problem(s), 1 problem(s) found.
 -> Expected messages: []
 -> Expected line numbers: []

n/a:9:	InvalidLogMessageFormat:	Missing arguments, expected 1 argument but have 0

Running PMD through: Other


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