Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[java] InvalidLogMessageFormat false positive on externally formatted strings #4172

Closed
ctoomey opened this issue Oct 21, 2022 · 1 comment · Fixed by #4213
Closed

[java] InvalidLogMessageFormat false positive on externally formatted strings #4172

ctoomey opened this issue Oct 21, 2022 · 1 comment · Fixed by #4213
Labels
a:false-positive PMD flags a piece of code that is not problematic
Milestone

Comments

@ctoomey
Copy link

ctoomey commented Oct 21, 2022

Affects PMD Version: 6.49.0

Rule: InvalidLogMessageFormat

Description:

Incorrectly flags the following LOGGER line with error "InvalidLogMessageFormat: Missing arguments, expected 2 arguments but have 0"

Code Sample demonstrating the issue:

    String msg = "Got kafka msg, headers=%s, body=%s".formatted(headers, new String(body, UTF_8));
    LOGGER.info(msg);
    return msg;

Expected outcome:

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

Running PMD through: Gradle

@ctoomey ctoomey added the a:false-positive PMD flags a piece of code that is not problematic label Oct 21, 2022
adangel added a commit to adangel/pmd that referenced this issue Nov 12, 2022
@adangel adangel added this to the 6.52.0 milestone Nov 12, 2022
@ctoomey
Copy link
Author

ctoomey commented Nov 26, 2022

Thanks @adangel !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:false-positive PMD flags a piece of code that is not problematic
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants