A RetroSearch Logo

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

Search Query:

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

[java] InvalidLogMessageFormat may examine the value of a different but identically named String variable · Issue #3284 · pmd/pmd · GitHub

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


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