Skip to content

chore: exclude PMD InvalidLogMessageFormat (SLF4J trailing-Throwable convention)#1334

Closed
joaodinissf wants to merge 1 commit into
dsldevkit:masterfrom
joaodinissf:fix/pmd-invalid-log-message-format
Closed

chore: exclude PMD InvalidLogMessageFormat (SLF4J trailing-Throwable convention)#1334
joaodinissf wants to merge 1 commit into
dsldevkit:masterfrom
joaodinissf:fix/pmd-invalid-log-message-format

Conversation

@joaodinissf
Copy link
Copy Markdown
Collaborator

@joaodinissf joaodinissf commented May 6, 2026

PMD's InvalidLogMessageFormat rule flags the SLF4J idiom LOGGER.x("...{}...", arg, throwable) as an argument-count mismatch (1 placeholder vs 2 args). Per SLF4J's FAQ this is the documented and intended way to log a parameterized message together with an exception — SLF4J trims the trailing Throwable, uses the remaining args for placeholders, and attaches the Throwable to the log event for stack-trace rendering. Excluding the rule in ddk-configuration/pmd/ruleset.xml removes the per-site // NOPMD noise that would otherwise be needed.

🤖 Generated with Claude Code

…ling-Throwable convention)

PMD's InvalidLogMessageFormat rule flags the SLF4J idiom `LOGGER.x("...{}...", arg, throwable)` as having an argument-count mismatch (1 placeholder vs 2 args). Per SLF4J's FAQ (https://www.slf4j.org/faq.html#paramException) this is the documented and intended way to log a parameterized message together with an exception — SLF4J trims the trailing Throwable, uses the remaining args for placeholders, and attaches the Throwable to the log event for stack-trace rendering.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@joaodinissf joaodinissf force-pushed the fix/pmd-invalid-log-message-format branch from 66eeb1a to 60b5d93 Compare May 6, 2026 22:36
@joaodinissf joaodinissf marked this pull request as ready for review May 6, 2026 22:41
@joaodinissf joaodinissf requested review from KrisLimbo and rubenporras and removed request for KrisLimbo May 6, 2026 22:41
Copy link
Copy Markdown
Member

@rubenporras rubenporras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not make much sense, according to the documentation PMD LOGGER.x("...{}...", arg, throwable) is correct: https://pmd.github.io/pmd/pmd_rules_java_errorprone.html

Is there a particular code where PMD is failing?

@joaodinissf
Copy link
Copy Markdown
Collaborator Author

(Comment left by Claude at João's request.)

You were right — the PMD docs are accurate. Closing this in favour of the real fix in #1333.

The root cause was that our CI invoked pmd:check as a separate mvn command from compile, so PMD's aux-classpath was empty and InvalidLogMessageFormat couldn't resolve LOGGER's type → false positives on the SLF4J trailing-Throwable idiom. Confirmed by running mvn compile pmd:check (single invocation) on master: 0 violations, exactly as the docs describe.

Fix in #1333: every analysis step now runs compile in the same mvn invocation as the analyzer (cheap with Tycho's incremental compile). No rule exclude needed.

@joaodinissf joaodinissf closed this May 7, 2026
@joaodinissf joaodinissf deleted the fix/pmd-invalid-log-message-format branch May 7, 2026 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants