Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce method order with ArchUnit #2955

Open
wants to merge 5 commits into
base: version/1.x
Choose a base branch
from

Conversation

bvkatwijk
Copy link
Contributor

@bvkatwijk bvkatwijk commented Jan 1, 2025

  • Enforce alphabetical method order within method kinds:
    • static methods
    • non-static methods
    • adjusted return types

Notes:

  • To interpret "adjusted return types" I currently used "All overridden methods", perhaps this is not fully accurate.
  • ArchUnit does not yet have a built-in override predicate so I copied code from Failing to use Override annotaion as a Condition for ArchRule TNG/ArchUnit#359 (comment)
  • Build will fail due to 264 detected violations
  • Not yet done: Validating that entire sections are ordered (static methods > non-static methods > adjusted return types)

Example test output:

Architecture Violation [Priority: MEDIUM] - Rule 'classes should have methods alphabetically ordered in sections' was violated (264 times):
Methods in section 'adjusted return types' of class 'io.vavr.Function1$1' are not alphabetically ordered: [isDefinedAt, apply]

Part of implementing #2924

@bvkatwijk bvkatwijk requested a review from pivovarit as a code owner January 1, 2025 12:36
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