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 may examine the value of a different but identically named String variable · Issue #3284 · pmd/pmd

[java] InvalidLogMessageFormat may examine the value of a different but identically named String variable #3284

New issue
Copy link
New issue
Copy link
Closed
#3285
Closed
[java] InvalidLogMessageFormat may examine the value of a different but identically named String variable#3284
#3285
Copy link
Assignees
adangel
Labels
a:false-positivePMD flags a piece of code that is not problematic
Milestone
6.36.0

Description

@krallus
krallus
opened on May 19, 2021
Issue body actions

Affects PMD Version: 6.33.0 (via Eclipse PMD For Eclipse 4.22.0)

Rule: InvalidLogMessageFormat

Description:

InvalidLogMessageFormat does not respect the scope in which a String format variable is declared and may use the value of an identically named variable that has been declared in a different scope.

Code Sample demonstrating the issue:

	public void aTest() {
		if (true) {
			final String logMessage = "A message formatted with three parameters: {}, {}, {}";
		}

		if (true) {
			final String logMessage = "A message formatted with only one parameter: {}";
			final Object param = null;
			logger.trace(logMessage, param);
		}
	}

Expected outcome:

PMD reports a violation at line 8, but that's wrong. That's a false positive.

Specifically, the error is reported as:
InvalidLogMessageFormat: Missing arguments, expected 3 arguments but have 1

Running PMD through: Eclipse

Activity

  1. krallus
    added
    a:false-positivePMD flags a piece of code that is not problematic
    on May 19, 2021
  2. adangel
    self-assigned this
    on May 20, 2021
  3. adangel
    added this to the 6.36.0 milestone on May 20, 2021
  4. adangel
    added a commit that references this issue on May 20, 2021

    [java] InvalidLogMessageFormat may examine the value of a different but

    This issue will close once commit 1bf0754 is merged into the 'main' branch.
    1bf0754
  5. adangel
    closed this as completedin 1bf0754on Jun 24, 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:false-positivePMD flags a piece of code that is not problematic

Type

No type

Projects

No projects

    Milestone

    • 6.36.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.