Repository navigation
[cli] Print PMD analysis summary - #6823
Conversation
|
Compared to main: (comment created at 2026-07-05 19:06:05+00:00 for 8a4a1ce) |
UncleOwen
left a comment
There was a problem hiding this comment.
I just tried this.
$ ./pmd check --dir=/data/code/pmd/pmd/main/pmd-java/src/main/java -R rulesets/java/quickstart.xml
[WARN] Progressbar rendering conflicts with reporting to STDOUT. No progressbar will be shown. Try running with argument -r <file> to output the report to a file instead.
[WARN] This analysis could be faster, please consider using Incremental Analysis: https://docs.pmd-code.org/latest/pmd_userdocs_incremental_analysis.html
/data/code/pmd/pmd/main/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTAmbiguousName.java:74: CompareObjectsWithEquals: Use equals() to compare object references.
[...]
/data/code/pmd/pmd/main/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/ResolutionFailedException.java:102: LocalVariableNamingConventions: The final local variable name 'PRETTY_PRINTER_CONFIG' doesn't match '[a-z][a-zA-Z0-9]*'
[INFO] Found 101 violations.
$
Works as expected.
$ ./pmd check --dir=/data/code/pmd/pmd/main/pmd-java/src/main/java -R rulesets/java/quickstart.xml --format=text -r out.txt
[WARN] This analysis could be faster, please consider using Incremental Analysis: https://docs.pmd-code.org/latest/pmd_userdocs_incremental_analysis.html
$
Uh... where is the summary?
7d1adbb to
1e17172
Compare
|
Thanks for checking. I moved the summary logging after PMD finishes closing its listeners, so the progress bar cleanup no longer hides it when --report-file is used. I also applied the wording suggestion and added a regression test for this case. |
|
@UncleOwen I updated this PR to match the requested wording and to fix the summary visibility issue: summary logging is now after PMD listener cleanup and I added regression coverage for the progress-bar/report-file path. I also updated the PR description example from |
The progressbar uses JLine to determine the terminal width. Under Windows in git bash (PWD and MSYSTEM are set), JLine uses the exec terminal provider, which runs "tty.exe" with the inherited stdin of the forked surefire JVM. As surefire is reading from stdin (command channel) at the same time, tty.exe doesn't start until that read completes. This made PmdCliTest hang (locally) or take about 9.5 minutes (in the Windows CI build). This happened before and was worked around in d1d10d1 by adding "--no-progress" to the standard arguments of PmdCliTest. The test reportsSummaryAfterProgressBarWithReportFile (added with #6823) needs the progress bar and doesn't use these standard arguments, so the problem came back. The tests don't need a real terminal, so disable the exec provider for all pmd-cli tests instead. Co-authored-by: Claude Opus 5.5 <[email protected]>
Summary
Fixes #1995.
This adds a final PMD CLI summary after analysis using the existing
ReportStatscounts, for example:Found no violations.Found 1 violation.Found no violations. There was 1 processing error.The summary is emitted through the CLI reporter, not stdout, so report output remains unchanged whether reports are rendered to stdout or written with
--report-file. Exit-code behavior is unchanged.Tests
./mvnw -pl pmd-cli -am -DskipTests package./mvnw -pl pmd-cli -am -Dtest=PmdCliTest -Dsurefire.failIfNoSpecifiedTests=false test