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

Add default implementations of deprecated methods of BuilableItem and Item. #3142

Conversation

oleg-nenashev
Copy link
Member

Currently the interface requires the API user to implement already deprecated methods.
It does not make much sense, and the API could be simplified.

Proposed changelog entries

  • N/A or "Developer: Introduce default implementations of deprecated methods of BuilableItem and Item"

Desired reviewers

@reviewbybees

… Item.

Currently the interface requires the API user to implement already deprecated methods.
It does not make much sense, and the API could be simplified.
* @param useDisplayName if true, returns a display name, otherwise returns a name
* @return
* String like "foo » bar"
* String like "foo » bar".
* {@code null} if item is null or if one of its parents is not an {@link ItemGroup}.
Copy link
Member Author

Choose a reason for hiding this comment

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

Just documented it while I was around

@@ -40,13 +40,19 @@
* Use {@link #scheduleBuild(Cause)}. Since 1.283
*/
@Deprecated
boolean scheduleBuild();
default boolean scheduleBuild() {
Copy link
Member Author

Choose a reason for hiding this comment

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

tabs vs spaces :( Should I use tabs or refactor the methods?

@ghost
Copy link

ghost commented Nov 16, 2017

This pull request originates from a CloudBees employee. At CloudBees, we require that all pull requests be reviewed by other CloudBees employees before we seek to have the change accepted. If you want to learn more about our process please see this explanation.

@oleg-nenashev oleg-nenashev requested a review from jglick November 16, 2017 16:36
@jglick
Copy link
Member

jglick commented Nov 17, 2017

Fix your flaky tests. :-)

@@ -1143,11 +1144,14 @@ private static String normalizeURI(String uri) {
*
* @since 1.515
* @param p the Item we want the relative display name
* @param g the ItemGroup used as point of reference for the item
* @param g the ItemGroup used as point of reference for the item.
* If the group is not specified, item's path will be used.
Copy link
Member

Choose a reason for hiding this comment

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

mark it @CheckForNull please

* @param useDisplayName if true, returns a display name, otherwise returns a name
* @return
* String like "foo » bar"
* String like "foo » bar".
* {@code null} if item is null or if one of its parents is not an {@link ItemGroup}.
Copy link
Member

Choose a reason for hiding this comment

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

Huh? A parent by definition is an ItemGroup. I guess you mean is not an Item?

@@ -1194,8 +1198,10 @@ public static String getRelativeNameFrom(Item p, ItemGroup g, boolean useDisplay
* @param p the Item we want the relative display name
* @param g the ItemGroup used as point of reference for the item
* @return
* String like "foo/bar"
* String like "foo/bar".
* {@code null} if the item is {@code null} or if one of its parents is not an {@link ItemGroup}.
Copy link
Member

Choose a reason for hiding this comment

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

ditto

@@ -1208,8 +1214,10 @@ public static String getRelativeNameFrom(Item p, ItemGroup g) {
* @param p the Item we want the relative display name
* @param g the ItemGroup used as point of reference for the item
* @return
* String like "Foo » Bar"
* String like "Foo » Bar".
* {@code null} if the item is {@code null} or if one of its parents is not an {@link ItemGroup}.
Copy link
Member

Choose a reason for hiding this comment

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

ditto

*/
@Nullable
public static String getRelativeNameFrom(Item p, ItemGroup g, boolean useDisplayName) {
Copy link
Member

Choose a reason for hiding this comment

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

Really these methods should have been in Items (cf. #3148). Too late I suppose, unless we deprecate the Functions versions, which seems too intrusive.

* @since 1.419
* @return
* String like "../foo/bar"
* String like "../foo/bar".
* {@code null} if item parents is not an {@link ItemGroup}.
Copy link
Member

Choose a reason for hiding this comment

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

probably s/ItemGroup/Item/

* @param g
* The ItemGroup instance used as context to evaluate the relative name of this AbstractItem
* @return
* The name of the current item, relative to p. Nested ItemGroups are separated by {@code /} character.
Copy link
Member

Choose a reason for hiding this comment

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

use @link

@@ -131,18 +133,28 @@
/**
* Gets the relative name to this item from the specified group.
*
* @param g
* The ItemGroup instance used as context to evaluate the relative name of this AbstractItem
Copy link
Member

Choose a reason for hiding this comment

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

Not necessarily an AbstractItem. Anyway use @link, or plain words.

@@ -207,7 +224,9 @@
*
* @since 1.374
*/
default void onCreatedFromScratch() {}
default void onCreatedFromScratch() {
// do nothing by default
Copy link
Member

Choose a reason for hiding this comment

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

Why would there not be default no-op impls of onLoad and onCopiedFrom then?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was thinking about that, but I decided not to touch it for now since I was unable to find noop implementations.

@oleg-nenashev oleg-nenashev self-assigned this Nov 26, 2017
@oleg-nenashev oleg-nenashev added the work-in-progress The PR is under active development, not ready to the final review label Nov 26, 2017
@oleg-nenashev oleg-nenashev requested a review from jglick November 27, 2017 14:29
@oleg-nenashev oleg-nenashev added needs-more-reviews Complex change, which would benefit from more eyes and removed work-in-progress The PR is under active development, not ready to the final review labels Nov 27, 2017
@oleg-nenashev
Copy link
Member Author

@jglick addressed your comments

*/
default String getRelativeNameFrom(ItemGroup g) {
@Nullable
Copy link
Member

Choose a reason for hiding this comment

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

Not actually sure why these are all @Nullable rather than @CheckForNull. Is there some circumstance where a caller would statically know the return value cannot be null?

Copy link
Member Author

@oleg-nenashev oleg-nenashev Nov 27, 2017

Choose a reason for hiding this comment

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

Yes, generally "in all sane cases" assuming you do not resolve names for things like Promoted Builds plugin PromotionProcess instances or pass nulls. I can add @CheckForNull, but it may become just another Jenkins.getInstance()

@oleg-nenashev oleg-nenashev merged commit 8824857 into jenkinsci:master Dec 1, 2017
jglick added a commit to jglick/maven-plugin that referenced this pull request Jan 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-more-reviews Complex change, which would benefit from more eyes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants