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:
Reproduction
Run a Java scan:
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:
but registers the parser as 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.
Java PMD detector reports
tool_failed_unparsed_outputwith PMD 7.23.0Summary
scan --path .reports reduced PMD coverage for Java:PMD is installed and working, but the Java PMD detector invokes PMD with
-f textcolorwhile declaring the output parser asgnu. PMD 7.23.0textcoloroutput 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 astool_failed_unparsed_output.Environment
PMD 7.23.025.0.3Current Java PMD command
The Java plugin currently builds a PMD command equivalent to:
The tool registration uses:
Reproduction
Run a Java scan:
scan --path .Observed scan warning:
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>&1Observed shape:
That output is not GNU-style
file:line: message, soparse_gnureturns 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>&1Observed shape:
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:
pmdexecutable exists,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
textcoloroutput:but registers the parser as GNU:
PMD 7.23.0
textcoloris 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
textcolorparser that handles PMD 7's multi-line ANSI output. The smaller fix is to emittext, since the existing GNU parser can parse that shape.Notes
PMD exits with code
4when 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.