Skip to content

test: add ArchUnit architecture rules and move EXIT_* constants to ExitException#2532

Closed
maxandersen wants to merge 3 commits into
mainfrom
test/archunit-rules
Closed

test: add ArchUnit architecture rules and move EXIT_* constants to ExitException#2532
maxandersen wants to merge 3 commits into
mainfrom
test/archunit-rules

Conversation

@maxandersen

Copy link
Copy Markdown
Collaborator

Summary

Replaces the old primitive-options ArchUnit rule (from #2517, no longer needed after #2519) with useful architecture rules that enforce codebase conventions.

Architecture rules added

Rule Type Status
CLI commands must extend BaseCommand ArchUnit ✅ Active
Non-CLI packages must not depend on dev.jbang.cli (except ExitException) ArchUnit ✅ Active
ExitException must use named EXIT_* constants, not raw integers Source scan ✅ Active
No wildcard imports Source scan ⏸️ Disabled (fix incrementally)

EXIT_* constant refactor

Moved EXIT_OK, EXIT_GENERIC_ERROR, EXIT_INVALID_INPUT, EXIT_UNEXPECTED_STATE, EXIT_INTERNAL_ERROR, and EXIT_EXECUTE from BaseCommand to ExitException. BaseCommand delegates for backward compatibility.

This enables clean package layering — non-CLI code no longer needs to import BaseCommand just for exit code constants. All ~16 raw integer literals in new ExitException(N, ...) replaced with named constants.

Why two test approaches?

  • ArchUnit for structural rules (bytecode-level: inheritance, package dependencies)
  • Source-scanning JUnit tests for conventions that javac erases (wildcard imports are resolved at compile time; static final int constants are inlined into bytecode)

Add EXIT_OK, EXIT_GENERIC_ERROR, EXIT_INVALID_INPUT, EXIT_UNEXPECTED_STATE,
EXIT_INTERNAL_ERROR, and EXIT_EXECUTE constants directly to ExitException.

BaseCommand now delegates to ExitException for backward compatibility.

All non-cli code updated to reference ExitException.EXIT_* instead of
BaseCommand.EXIT_*, removing the dependency from domain/util packages
onto the CLI layer.

Also replaced raw integer literals in ExitException constructor calls with
named constants in: TrustedSources, Util, JarUtil, RemoteResourceResolver,
NativeBuildStep, CompileBuildStep, Cache, ArtifactResolver, DependencyUtil.
@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one) (1)
  • ai-review

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b95b6677-4ddc-4b24-9eec-dfe4c35016fa

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@maxandersen

Copy link
Copy Markdown
Collaborator Author

blah - too figgity.

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.

1 participant