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

Unify @NonNull and @Override annotation position #9948

Closed
wants to merge 1 commit into from

Conversation

marsboy02
Copy link

Testing done

  • Ran automated tests on all modified lines to ensure that functionality is preserved with the new annotation order.

Proposed changelog entries

  • In this PR, we standardize the use of @nonnull and @OverRide annotations, placing @nonnull above @OverRide as it emphasizes the null-safety aspect of the method, which is crucial for our codebase's stability. This change enhances the readability and clarity for developers, highlighting null-safety constraints first, followed by the overridden method status.

Proposed upgrade guidelines

N/A

Submitter checklist

Desired reviewers

@mention

Before the changes are marked as ready-for-merge:

Maintainer checklist

Copy link

welcome bot commented Nov 6, 2024

Yay, your first pull request towards Jenkins core was created successfully! Thank you so much!

A contributor will provide feedback soon. Meanwhile, you can join the chats and community forums to connect with other Jenkins users, developers, and maintainers.

@basil
Copy link
Member

basil commented Nov 6, 2024

True, it could be argued that null-safety annotations have more importance than override annotations, but how is one to objectively judge the importance of annotations relative to each other in the general case? This seems fairly subjective. Furthermore, how is a developer adding a new annotation going to know that the convention for annotation ordering is importance? This is far from obvious. Simpler to sort alphabetically, which is both obvious and objective.

@marsboy02
Copy link
Author

marsboy02 commented Nov 7, 2024

Looking at my PR now, I realize it lacked solid reasoning. Actually, I noticed some unusual behavior with the default value of the multi-line parameter in Jenkins, which led me to inspect the model directory.

During this process, I observed that in most cases, the @nonnull annotation was placed above other annotations. Therefore, I adjusted the small number of inconsistent cases to follow this pattern. My reasoning was that it is generally preferable to place validation-related annotations, like @nonnull, first, as they indicate logic constraints, while @OverRide is simply a metadata annotation.

Going back, just as I initially reviewed the Jenkins repository for conventions before adding annotations, I was referencing other files to ensure consistency. While doing so, I noticed the variation in annotation placement and ended up standardizing the few outliers. After receiving your feedback, I looked into Java annotation conventions and other open-source projects. I found no universally established rule, with each open-source project applying its own annotation style.

Could you please provide further feedback on this reasoning? If you think this is unsuitable, I’ll tidy up the PR accordingly. Thank you! @basil

@basil
Copy link
Member

basil commented Nov 7, 2024

This response does not actually address any of the points I made in my previous post. If a convention is to be established, then it should be both obvious and objective, which alphabetical sorting accomplishes. The current PR is both subjective (since there is no simple objective measurement for annotation importance) and not obvious to a new contributor.

@marsboy02 marsboy02 closed this Nov 7, 2024
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.

2 participants