Skip to content

Bug: Desloppify Java PMD detector reports tool_failed_unparsed_output with PMD 7.23.0 #609

Description

@CrusheRDevourer

Java PMD detector reports tool_failed_unparsed_output with PMD 7.23.0

Summary

scan --path . reports reduced PMD coverage for Java:

Coverage reduced (pmd_violation): pmd tooling unavailable (tool_failed_unparsed_output)
Repercussion: Detector results may be under-reported for this scan.
Fix: Install/fix the tool command and rerun scan.

PMD is installed and working, but the Java PMD detector invokes PMD with -f textcolor while declaring the output parser as gnu. PMD 7.23.0 textcolor output is an ANSI-colored multi-line report, so the GNU parser finds zero entries. Because PMD exits non-zero when violations exist, the scanner records this as tool_failed_unparsed_output.

Environment

  • PMD version: PMD 7.23.0
  • Java version reported by PMD: 25.0.3
  • Repository type: Java multi-module Maven project
  • Installed package paths and user-specific paths omitted

Current Java PMD command

The Java plugin currently builds a PMD command equivalent to:

PMD_COMMAND = (
    "pmd check -d . -R rulesets/java/quickstart.xml "
    f"{_pmd_threads_arg()} -f textcolor 2>&1"
)

The tool registration uses:

"fmt": "gnu",

Reproduction

Run a Java scan:

scan --path .

Observed scan warning:

Coverage reduced (pmd_violation): pmd tooling unavailable (tool_failed_unparsed_output)

Run the same PMD format against any Java source file with a known PMD violation:

pmd check -d src/main/java/com/example/ExampleClass.java \
  -R rulesets/java/quickstart.xml --threads 0 -f textcolor 2>&1

Observed shape:

exit_code=4
[WARN] This analysis could be faster, please consider using Incremental Analysis: ...
* file: src/main/java/com/example/ExampleClass.java
    src:  ExampleClass.java:123:123
    rule: UnusedPrivateMethod
    msg:  Avoid unused private methods such as 'unusedHelper(...)'.

That output is not GNU-style file:line: message, so parse_gnu returns no entries.

Run the same PMD check with -f text:

pmd check -d src/main/java/com/example/ExampleClass.java \
  -R rulesets/java/quickstart.xml --threads 0 -f text 2>&1

Observed shape:

exit_code=4
[WARN] This analysis could be faster, please consider using Incremental Analysis: ...
src/main/java/com/example/ExampleClass.java:123:        UnusedPrivateMethod:    Avoid unused private methods such as 'unusedHelper(...)'.

This output matches the GNU parser well enough to produce PMD entries.

Expected Behavior

The Java PMD detector should parse PMD violations successfully when PMD returns violations.

It should not report PMD as unavailable when:

  • the pmd executable exists,
  • PMD runs successfully enough to report violations,
  • the only issue is that the configured PMD output format is incompatible with the parser.

Actual Behavior

The scanner records reduced PMD coverage:

{
  "detector": "pmd_violation",
  "status": "reduced",
  "confidence": 0,
  "summary": "pmd tooling unavailable (tool_failed_unparsed_output)",
  "impact": "Detector results may be under-reported for this scan.",
  "remediation": "Install/fix the tool command and rerun scan.",
  "tool": "pmd",
  "reason": "tool_failed_unparsed_output"
}

Likely Cause

The Java plugin requests PMD textcolor output:

-f textcolor

but registers the parser as GNU:

"fmt": "gnu"

PMD 7.23.0 textcolor is multi-line and colorized; it is not parseable by the GNU parser.

Suggested Fix

Change the Java PMD command to use plain text output:

 PMD_COMMAND = (
     "pmd check -d . -R rulesets/java/quickstart.xml "
-    f"{_pmd_threads_arg()} -f textcolor 2>&1"
+    f"{_pmd_threads_arg()} -f text 2>&1"
 )

Alternative: add a PMD textcolor parser that handles PMD 7's multi-line ANSI output. The smaller fix is to emit text, since the existing GNU parser can parse that shape.

Notes

PMD exits with code 4 when violations are found. The scanner already tolerates non-zero tool exits when parseable entries are returned, so the exit code is not the root problem. The problem is zero parsed entries from an incompatible output format.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions