GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [java] InvalidLogMessageFormat detection failing when String.format used in a variable · Issue #3165 · pmd/pmd

[java] InvalidLogMessageFormat detection failing when String.format used in a variable #3165

New issue
Copy link
New issue
Copy link
Closed
#3170
Closed
[java] InvalidLogMessageFormat detection failing when String.format used in a variable#3165
#3170
Copy link
Assignees
adangel
Labels
a:bugPMD crashes or fails to analyse a file.
Milestone
6.33.0

Description

@kris-scheibe
kris-scheibe
opened on Mar 19, 2021
Issue body actions

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

Activity

  1. kris-scheibe
    added
    a:bugPMD crashes or fails to analyse a file.
    on Mar 19, 2021
  2. adangel
    self-assigned this
    on Mar 25, 2021
  3. adangel
    added this to the 6.33.0 milestone on Mar 25, 2021
  4. adangel commented on Mar 26, 2021

    @adangel
    adangel
    on Mar 26, 2021
    Member
    More actions

    Thanks for testing and reporting!

  5. adangel
    added a commit that references this issue on Mar 26, 2021

    [java] InvalidLogMessageFormat more String.format detection

    This issue will close once commit d11f1a0 is merged into the 'main' branch.
    d11f1a0
  6. adangel
    closed this as completedin #3170on Mar 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @adangel
    adangel

Labels

a:bugPMD crashes or fails to analyse a file.

Type

No type

Projects

No projects

    Milestone

    • 6.33.0

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.