Skip to content

[cli] Add the missing exit code 5 to the CLI help - #7090

Merged
adangel merged 3 commits into
pmd:mainfrom
NotAFlightRisk:fix/cli-help-exit-code-5
Sep 24, 2026
Merged

adangel merged 3 commits into
pmd:mainfrom
NotAFlightRisk:fix/cli-help-exit-code-5

Conversation

@NotAFlightRisk

@NotAFlightRisk NotAFlightRisk commented Sep 21, 2026 •

Copy link
Copy Markdown

Describe the PR

The Exit Codes: block in the CLI help lists 0, 1, 2 and 4. PMD has returned 5 since 7.3.0 and 7.27 is out now, so the help is the last place still describing the 7.0.0 set.

The exit code itself is fine, it's the annotation on the root command that went stale. #4991 added code 5 and updated the enum, the CLI reference, the CPD page and the ant docs, and the four-entry list in the help was the one place it didn't reach. Nothing in the repo asserts that text, so nothing went red. That's a bit more annoying than a missing line usually is, because 5 is the default: it takes --no-fail-on-error to turn it off, so one unparsable file gets you an exit code the help doesn't mention.

I've gone with 5:Analysis finished, at least 1 recoverable error occurred so it reads alongside the code-4 line. The docs table words it "At least one recoverable error has occurred", which would do just as well, so don't treat the exact string as settled. I havent built PMD locally, so that wording is read off the annotation rather than off real help output.

I've left release_notes.md alone too, since every line under Fixed Issues hangs off an issue number and there isnt one here.

Output before:

$ pmd --help
Usage: pmd [-hV] [COMMAND]
  -h, --help      Show this help message and exit.
  -V, --version   Print version information and exit.
Commands:
  check                The PMD standard source code analyzer
  cpd                  Copy/Paste Detector - find duplicate code
  designer             The PMD visual rule designer
  cpd-gui              GUI for the Copy/Paste Detector
                         Warning: May not support the full CPD feature set
  ast-dump             Dumps the AST of parsing source code
  generate-completion  Generate bash/zsh completion script for pmd.
Exit Codes:
  0   Successful analysis, no violations found
  1   An unexpected error occurred during execution
  2   Usage error, please refer to the command help
  4   Successful analysis, at least 1 violation found

Output with this PR:

$ pmd --help
Usage: pmd [-hV] [COMMAND]
  -h, --help      Show this help message and exit.
  -V, --version   Print version information and exit.
Commands:
  check                The PMD standard source code analyzer
  cpd                  Copy/Paste Detector - find duplicate code
  designer             The PMD visual rule designer
  cpd-gui              GUI for the Copy/Paste Detector
                         Warning: May not support the full CPD feature set
  ast-dump             Dumps the AST of parsing source code
  generate-completion  Generate bash/zsh completion script for pmd.
Exit Codes:
  0   Successful analysis, no violations found
  1   An unexpected error occurred during execution
  2   Usage error, please refer to the command help
  4   Successful analysis, at least 1 violation found
  5   Analysis finished, at least 1 recoverable error occurred

Related issues

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by github actions)
  • Added (in-code) documentation (if needed)

@adangel adangel added the in:documentation Affects the documentation [doc] label Sep 24, 2026
@adangel adangel added this to the 7.28.0 milestone Sep 24, 2026
@pmd-actions-helper

pmd-actions-helper Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Documentation Preview

Compared to main:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
There are 0 changed duplications, 0 new duplications and 0 removed duplications.
There are 0 changed CPD errors, 0 new CPD errors and 0 removed CPD errors.

Regression Tester Report

(comment created at 2026-09-24 15:06:50+00:00 for 9ac7f39)

@adangel adangel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@adangel
adangel merged commit 251ef73 into pmd:main Sep 24, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in:documentation Affects the documentation [doc]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants