Skip to content

Commit

Permalink
Merge pull request #719 from bitwiseman/task/deprecated
Browse files Browse the repository at this point in the history
Remove a few long deprecated methods and fully annotate others
  • Loading branch information
bitwiseman authored Mar 2, 2020
2 parents c11c06b + 75d95d8 commit 8b6cf55
Show file tree
Hide file tree
Showing 20 changed files with 187 additions and 136 deletions.
6 changes: 1 addition & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<formatter-maven-plugin.goal>format</formatter-maven-plugin.goal>
<impsort-maven-plugin.goal>sort</impsort-maven-plugin.goal>
<!-- Using this as the minimum bar for code coverage. Adding methods without covering them will fail this. -->
<jacoco.coverage.target.bundle.method>0.556</jacoco.coverage.target.bundle.method>
<jacoco.coverage.target.bundle.method>0.60</jacoco.coverage.target.bundle.method>
<jacoco.coverage.target.class.method>0.25</jacoco.coverage.target.class.method>
<!-- For non-ci builds we'd like the build to still complete if jacoco metrics aren't met. -->
<jacoco.haltOnFailure>false</jacoco.haltOnFailure>
Expand Down Expand Up @@ -146,22 +146,19 @@
<exclude>org.kohsuke.github.example.*</exclude>

<!-- No methods -->
<exclude>org.kohsuke.github.DeleteToken</exclude>
<exclude>org.kohsuke.github.Previews</exclude>

<!-- Deprecated -->
<exclude>org.kohsuke.github.extras.OkHttp3Connector</exclude>
<exclude>org.kohsuke.github.EnforcementLevel</exclude>
<exclude>org.kohsuke.github.GHPerson.1</exclude>
<exclude>org.kohsuke.github.GHPerson.1.1</exclude>

<!-- These fail coverage on windows because tests are disabled -->
<exclude>org.kohsuke.github.GHAsset</exclude>
<exclude>org.kohsuke.github.GHReleaseBuilder</exclude>
<exclude>org.kohsuke.github.GHRelease</exclude>

<!-- TODO: These still need test coverage -->
<exclude>org.kohsuke.github.GitHubClient.GHApiInfo</exclude>
<exclude>org.kohsuke.github.GHBranchProtection.RequiredSignatures</exclude>
<exclude>org.kohsuke.github.GHBranchProtectionBuilder.Restrictions</exclude>
<exclude>org.kohsuke.github.GHBranchProtection.Restrictions</exclude>
Expand Down Expand Up @@ -202,7 +199,6 @@
<exclude>org.kohsuke.github.GHTeam.Role</exclude>
<exclude>org.kohsuke.github.GHUserSearchBuilder.Sort</exclude>
<exclude>org.kohsuke.github.GHVerifiedKey</exclude>
<exclude>org.kohsuke.github.GitHubBuilder.1</exclude>
</excludes>
</rule>
</rules>
Expand Down
34 changes: 0 additions & 34 deletions src/main/java/org/kohsuke/github/DeleteToken.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class GHDeploymentStatusBuilder {
* the state
* @deprecated Use {@link GHDeployment#createStatus(GHDeploymentState)}
*/
@Deprecated
public GHDeploymentStatusBuilder(GHRepository repo, int deploymentId, GHDeploymentState state) {
this(repo, (long) deploymentId, state);
}
Expand Down
13 changes: 2 additions & 11 deletions src/main/java/org/kohsuke/github/GHIssue.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,14 @@ public class GHIssue extends GHObject implements Reactable {
protected int comments;
@SkipFromToString
protected String body;
// for backward compatibility with < 1.63, this collection needs to hold instances of Label, not GHLabel
protected List<Label> labels;
protected List<GHLabel> labels;
protected GHUser user;
protected String title, html_url;
protected GHIssue.PullRequest pull_request;
protected GHMilestone milestone;
protected GHUser closed_by;
protected boolean locked;

/**
* The type Label.
*
* @deprecated use {@link GHLabel}
*/
public static class Label extends GHLabel {
}

GHIssue wrap(GHRepository owner) {
this.owner = owner;
if (milestone != null)
Expand Down Expand Up @@ -172,7 +163,7 @@ public Collection<GHLabel> getLabels() throws IOException {
if (labels == null) {
return Collections.emptyList();
}
return Collections.<GHLabel>unmodifiableList(labels);
return Collections.unmodifiableList(labels);
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/kohsuke/github/GHMyself.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ public PagedIterable<GHRepository> listRepositories(final int pageSize, final Re
* @return the paged iterable
* @deprecated Use {@link #listRepositories()}
*/
@Deprecated
public PagedIterable<GHRepository> listAllRepositories() {
return listRepositories();
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/kohsuke/github/GHOrganization.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ GHOrganization wrapUp(GitHub root) {
* the io exception
* @deprecated Use {@link #createRepository(String)} that uses a builder pattern to let you control every aspect.
*/
@Deprecated
public GHRepository createRepository(String name,
String description,
String homepage,
Expand Down Expand Up @@ -67,6 +68,7 @@ public GHRepository createRepository(String name,
* the io exception
* @deprecated Use {@link #createRepository(String)} that uses a builder pattern to let you control every aspect.
*/
@Deprecated
public GHRepository createRepository(String name,
String description,
String homepage,
Expand Down
57 changes: 24 additions & 33 deletions src/main/java/org/kohsuke/github/GHPerson.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
Expand All @@ -20,7 +19,7 @@ public abstract class GHPerson extends GHObject {
/* package almost final */ GitHub root;

// core data fields that exist even for "small" user data (such as the user info in pull request)
protected String login, avatar_url, gravatar_id;
protected String login, avatar_url;

// other fields (that only show up in full data)
protected String location, blog, email, name, company, type;
Expand Down Expand Up @@ -115,31 +114,27 @@ public PagedIterable<GHRepository> listRepositories(final int pageSize) {
*/
@Deprecated
public synchronized Iterable<List<GHRepository>> iterateRepositories(final int pageSize) {
return new Iterable<List<GHRepository>>() {
public Iterator<List<GHRepository>> iterator() {
final Iterator<GHRepository[]> pager;
try {
pager = GitHubPageIterator.create(root.getClient(),
GHRepository[].class,
root.createRequest().withUrlPath("users", login, "repos").build(),
pageSize);
} catch (MalformedURLException e) {
throw new GHException("Unable to build GitHub API URL", e);
return () -> {
final PagedIterator<GHRepository> pager;
try {
GitHubPageIterator<GHRepository[]> iterator = GitHubPageIterator.create(root.getClient(),
GHRepository[].class,
root.createRequest().withUrlPath("users", login, "repos").build(),
pageSize);
pager = new PagedIterator<>(iterator, item -> item.wrap(root));
} catch (MalformedURLException e) {
throw new GHException("Unable to build GitHub API URL", e);
}

return new Iterator<List<GHRepository>>() {
public boolean hasNext() {
return pager.hasNext();
}

return new Iterator<List<GHRepository>>() {
public boolean hasNext() {
return pager.hasNext();
}

public List<GHRepository> next() {
GHRepository[] batch = pager.next();
for (GHRepository r : batch)
r.root = root;
return Arrays.asList(batch);
}
};
}
public List<GHRepository> next() {
return pager.nextPage();
}
};
};
}

Expand Down Expand Up @@ -178,22 +173,18 @@ public GHRepository getRepository(String name) throws IOException {
* @return the gravatar id
* @deprecated No longer available in the v3 API.
*/
@Deprecated
public String getGravatarId() {
return gravatar_id;
return "";
}

/**
* Returns a string like 'https://secure.gravatar.com/avatar/0cb9832a01c22c083390f3c5dcb64105' that indicates the
* avatar image URL.
* Returns a string of the avatar image URL.
*
* @return the avatar url
*/
public String getAvatarUrl() {
if (avatar_url != null)
return avatar_url;
if (gravatar_id != null)
return "https://secure.gravatar.com/avatar/" + gravatar_id;
return null;
return avatar_url;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/kohsuke/github/GHPullRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ public PagedIterable<GHPullRequestCommitDetail> listCommits() {
* the io exception
* @deprecated Use {@link #createReview()}
*/
@Deprecated
public GHPullRequestReview createReview(String body,
@CheckForNull GHPullRequestReviewState event,
GHPullRequestReviewComment... comments) throws IOException {
Expand All @@ -472,6 +473,7 @@ public GHPullRequestReview createReview(String body,
* the io exception
* @deprecated Use {@link #createReview()}
*/
@Deprecated
public GHPullRequestReview createReview(String body,
@CheckForNull GHPullRequestReviewState event,
List<GHPullRequestReviewComment> comments) throws IOException {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/kohsuke/github/GHPullRequestReview.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ public Date getCreatedAt() throws IOException {
* @deprecated Former preview method that changed when it got public. Left here for backward compatibility. Use
* {@link #submit(String, GHPullRequestReviewEvent)}
*/
@Deprecated
public void submit(String body, GHPullRequestReviewState state) throws IOException {
submit(body, state.toEvent());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public class GHPullRequestReviewComment extends GHObject implements Reactable {
* @return the gh pull request review comment
* @deprecated You should be using {@link GHPullRequestReviewBuilder#comment(String, String, int)}
*/
@Deprecated
public static GHPullRequestReviewComment draft(String body, String path, int position) {
GHPullRequestReviewComment result = new GHPullRequestReviewComment();
result.body = body;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/kohsuke/github/GHRelease.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public boolean isDraft() {
* the io exception
* @deprecated Use {@link #update()}
*/
@Deprecated
public GHRelease setDraft(boolean draft) throws IOException {
return update().draft(draft).update();
}
Expand Down
Loading

0 comments on commit 8b6cf55

Please sign in to comment.