Skip to content

Commit e41a341

Browse files
authored
Merge pull request hub4j#609 from bitwiseman/task/style
Code style fixes
2 parents 20e796c + a3b1262 commit e41a341

170 files changed

Lines changed: 4472 additions & 4606 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/maven-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ jobs:
1919
- name: Maven Download all dependencies
2020
run: mvn -B org.apache.maven.plugins:maven-dependency-plugin:3.1.1:go-offline
2121
- name: Maven Build
22-
run: mvn -B install site --file pom.xml
22+
run: mvn -B install site -P ci --file pom.xml

pom.xml

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
<hamcrest.version>2.2</hamcrest.version>
3636
<okhttp3.version>4.2.2</okhttp3.version>
3737
<okio.version>2.4.1</okio.version>
38+
<formatter-maven-plugin.goal>format</formatter-maven-plugin.goal>
3839
<jacoco.coverage.target.class>.80</jacoco.coverage.target.class>
3940
<jacoco.coverage.target.method>0.20</jacoco.coverage.target.method>
4041
<jacoco.coverage.target.line>0.50</jacoco.coverage.target.line>
@@ -152,17 +153,29 @@
152153
</execution>
153154
</executions>
154155
</plugin>
155-
<plugin>
156-
<groupId>com.infradna.tool</groupId>
157-
<artifactId>bridge-method-injector</artifactId>
158-
<version>1.18</version>
159-
<executions>
160-
<execution>
161-
<goals>
162-
<goal>process</goal>
163-
</goals>
164-
</execution>
165-
</executions>
156+
<plugin>
157+
<groupId>com.infradna.tool</groupId>
158+
<artifactId>bridge-method-injector</artifactId>
159+
<version>1.18</version>
160+
<executions>
161+
<execution>
162+
<goals>
163+
<goal>process</goal>
164+
</goals>
165+
</execution>
166+
</executions>
167+
</plugin>
168+
<plugin>
169+
<groupId>net.revelc.code.formatter</groupId>
170+
<artifactId>formatter-maven-plugin</artifactId>
171+
<version>2.11.0</version>
172+
<executions>
173+
<execution>
174+
<goals>
175+
<goal>${formatter-maven-plugin.goal}</goal>
176+
</goals>
177+
</execution>
178+
</executions>
166179
</plugin>
167180
<plugin>
168181
<groupId>com.github.spotbugs</groupId>
@@ -338,6 +351,14 @@
338351
</pluginRepository>
339352
</pluginRepositories>
340353
<profiles>
354+
<profile>
355+
<id>ci</id>
356+
<properties>
357+
<formatter-maven-plugin.goal>validate</formatter-maven-plugin.goal>
358+
</properties>
359+
<build>
360+
</build>
361+
</profile>
341362
<profile>
342363
<id>jacoco</id>
343364
<activation>

src/main/java/org/kohsuke/github/AbuseLimitHandler.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,18 @@ public abstract class AbuseLimitHandler {
1717
* Called when the library encounters HTTP error indicating that the API abuse limit is reached.
1818
*
1919
* <p>
20-
* Any exception thrown from this method will cause the request to fail, and the caller of github-api
21-
* will receive an exception. If this method returns normally, another request will be attempted.
22-
* For that to make sense, the implementation needs to wait for some time.
20+
* Any exception thrown from this method will cause the request to fail, and the caller of github-api will receive
21+
* an exception. If this method returns normally, another request will be attempted. For that to make sense, the
22+
* implementation needs to wait for some time.
2323
*
2424
* @see <a href="https://developer.github.com/v3/#abuse-rate-limits">API documentation from GitHub</a>
2525
* @param e
26-
* Exception from Java I/O layer. If you decide to fail the processing, you can throw
27-
* this exception (or wrap this exception into another exception and throw it).
26+
* Exception from Java I/O layer. If you decide to fail the processing, you can throw this exception (or
27+
* wrap this exception into another exception and throw it).
2828
* @param uc
29-
* Connection that resulted in an error. Useful for accessing other response headers.
29+
* Connection that resulted in an error. Useful for accessing other response headers.
3030
* @throws IOException
31+
* on failure
3132
*/
3233
public abstract void onError(IOException e, HttpURLConnection uc) throws IOException;
3334

@@ -40,15 +41,16 @@ public void onError(IOException e, HttpURLConnection uc) throws IOException {
4041
try {
4142
Thread.sleep(parseWaitTime(uc));
4243
} catch (InterruptedException ex) {
43-
throw (InterruptedIOException)new InterruptedIOException().initCause(e);
44+
throw (InterruptedIOException) new InterruptedIOException().initCause(e);
4445
}
4546
}
4647

4748
private long parseWaitTime(HttpURLConnection uc) {
4849
String v = uc.getHeaderField("Retry-After");
49-
if (v==null) return 60 * 1000; // can't tell, return 1 min
50+
if (v == null)
51+
return 60 * 1000; // can't tell, return 1 min
5052

51-
return Math.max(1000, Long.parseLong(v)*1000);
53+
return Math.max(1000, Long.parseLong(v) * 1000);
5254
}
5355
};
5456

@@ -58,7 +60,7 @@ private long parseWaitTime(HttpURLConnection uc) {
5860
public static final AbuseLimitHandler FAIL = new AbuseLimitHandler() {
5961
@Override
6062
public void onError(IOException e, HttpURLConnection uc) throws IOException {
61-
throw (IOException)new IOException("Abuse limit reached").initCause(e);
63+
throw (IOException) new IOException("Abuse limit reached").initCause(e);
6264
}
6365
};
6466
}

src/main/java/org/kohsuke/github/DeleteToken.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@
2828
/**
2929
* @author Kohsuke Kawaguchi
3030
*/
31-
@SuppressFBWarnings(value = "UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD",
32-
justification = "Being constructed by JSON deserialization")
31+
@SuppressFBWarnings(value = "UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD", justification = "Being constructed by JSON deserialization")
3332
class DeleteToken {
3433
public String delete_token;
3534
}

src/main/java/org/kohsuke/github/GHApp.java

Lines changed: 59 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,13 @@ public class GHApp extends GHObject {
2525
private String description;
2626
@JsonProperty("external_url")
2727
private String externalUrl;
28-
private Map<String,String> permissions;
28+
private Map<String, String> permissions;
2929
private List<GHEvent> events;
3030
@JsonProperty("installations_count")
3131
private long installationsCount;
3232
@JsonProperty("html_url")
3333
private String htmlUrl;
3434

35-
3635
public GHUser getOwner() {
3736
return owner;
3837
}
@@ -93,80 +92,105 @@ public void setPermissions(Map<String, String> permissions) {
9392
this.permissions = permissions;
9493
}
9594

96-
/*package*/ GHApp wrapUp(GitHub root) {
95+
GHApp wrapUp(GitHub root) {
9796
this.root = root;
9897
return this;
9998
}
10099

101100
/**
102101
* Obtains all the installations associated with this app.
103-
*
102+
* <p>
104103
* You must use a JWT to access this endpoint.
105104
*
106-
* @see <a href="https://developer.github.com/v3/apps/#list-installations">List installations</a>
107105
* @return a list of App installations
106+
* @see <a href="https://developer.github.com/v3/apps/#list-installations">List installations</a>
108107
*/
109-
@Preview @Deprecated
108+
@Preview
109+
@Deprecated
110110
public PagedIterable<GHAppInstallation> listInstallations() {
111-
return root.retrieve().withPreview(MACHINE_MAN)
112-
.asPagedIterable(
113-
"/app/installations",
114-
GHAppInstallation[].class,
115-
item -> item.wrapUp(root) );
111+
return root.retrieve().withPreview(MACHINE_MAN).asPagedIterable("/app/installations", GHAppInstallation[].class,
112+
item -> item.wrapUp(root));
116113
}
117114

118115
/**
119-
* Obtain an installation associated with this app
120-
* @param id - Installation Id
121-
*
116+
* Obtain an installation associated with this app.
117+
* <p>
122118
* You must use a JWT to access this endpoint.
123119
*
120+
* @param id
121+
* Installation Id
122+
* @return a GHAppInstallation
123+
* @throws IOException
124+
* on error
124125
* @see <a href="https://developer.github.com/v3/apps/#get-an-installation">Get an installation</a>
125126
*/
126-
@Preview @Deprecated
127+
@Preview
128+
@Deprecated
127129
public GHAppInstallation getInstallationById(long id) throws IOException {
128-
return root.retrieve().withPreview(MACHINE_MAN).to(String.format("/app/installations/%d", id), GHAppInstallation.class).wrapUp(root);
130+
return root.retrieve().withPreview(MACHINE_MAN)
131+
.to(String.format("/app/installations/%d", id), GHAppInstallation.class).wrapUp(root);
129132
}
130133

131134
/**
132-
* Obtain an organization installation associated with this app
133-
* @param name - Organization name
134-
*
135+
* Obtain an organization installation associated with this app.
136+
* <p>
135137
* You must use a JWT to access this endpoint.
136138
*
137-
* @see <a href="https://developer.github.com/v3/apps/#get-an-organization-installation">Get an organization installation</a>
139+
* @param name
140+
* Organization name
141+
* @return a GHAppInstallation
142+
* @throws IOException
143+
* on error
144+
* @see <a href="https://developer.github.com/v3/apps/#get-an-organization-installation">Get an organization
145+
* installation</a>
138146
*/
139-
@Preview @Deprecated
147+
@Preview
148+
@Deprecated
140149
public GHAppInstallation getInstallationByOrganization(String name) throws IOException {
141-
return root.retrieve().withPreview(MACHINE_MAN).to(String.format("/orgs/%s/installation", name), GHAppInstallation.class).wrapUp(root);
150+
return root.retrieve().withPreview(MACHINE_MAN)
151+
.to(String.format("/orgs/%s/installation", name), GHAppInstallation.class).wrapUp(root);
142152
}
143153

144154
/**
145-
* Obtain an repository installation associated with this app
146-
* @param ownerName - Organization or user name
147-
* @param repositoryName - Repository name
148-
*
155+
* Obtain an repository installation associated with this app.
156+
* <p>
149157
* You must use a JWT to access this endpoint.
150158
*
151-
* @see <a href="https://developer.github.com/v3/apps/#get-a-repository-installation">Get a repository installation</a>
159+
* @param ownerName
160+
* Organization or user name
161+
* @param repositoryName
162+
* Repository name
163+
* @return a GHAppInstallation
164+
* @throws IOException
165+
* on error
166+
* @see <a href="https://developer.github.com/v3/apps/#get-a-repository-installation">Get a repository
167+
* installation</a>
152168
*/
153-
@Preview @Deprecated
169+
@Preview
170+
@Deprecated
154171
public GHAppInstallation getInstallationByRepository(String ownerName, String repositoryName) throws IOException {
155-
return root.retrieve().withPreview(MACHINE_MAN).to(String.format("/repos/%s/%s/installation", ownerName, repositoryName), GHAppInstallation.class).wrapUp(root);
172+
return root.retrieve().withPreview(MACHINE_MAN)
173+
.to(String.format("/repos/%s/%s/installation", ownerName, repositoryName), GHAppInstallation.class)
174+
.wrapUp(root);
156175
}
157176

158177
/**
159-
* Obtain a user installation associated with this app
160-
* @param name - user name
161-
*
178+
* Obtain a user installation associated with this app.
179+
* <p>
162180
* You must use a JWT to access this endpoint.
163181
*
182+
* @param name
183+
* user name
184+
* @return a GHAppInstallation
185+
* @throws IOException
186+
* on error
164187
* @see <a href="https://developer.github.com/v3/apps/#get-a-user-installation">Get a user installation</a>
165188
*/
166-
@Preview @Deprecated
189+
@Preview
190+
@Deprecated
167191
public GHAppInstallation getInstallationByUser(String name) throws IOException {
168-
return root.retrieve().withPreview(MACHINE_MAN).to(String.format("/users/%s/installation", name), GHAppInstallation.class).wrapUp(root);
192+
return root.retrieve().withPreview(MACHINE_MAN)
193+
.to(String.format("/users/%s/installation", name), GHAppInstallation.class).wrapUp(root);
169194
}
170195

171196
}
172-

src/main/java/org/kohsuke/github/GHAppCreateTokenBuilder.java

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,36 +18,46 @@ public class GHAppCreateTokenBuilder {
1818
protected final Requester builder;
1919
private final String apiUrlTail;
2020

21-
@Preview @Deprecated
22-
/*package*/ GHAppCreateTokenBuilder(GitHub root, String apiUrlTail, Map<String, GHPermissionType> permissions) {
21+
@Preview
22+
@Deprecated
23+
GHAppCreateTokenBuilder(GitHub root, String apiUrlTail, Map<String, GHPermissionType> permissions) {
2324
this.root = root;
2425
this.apiUrlTail = apiUrlTail;
2526
this.builder = new Requester(root);
26-
this.builder.withPermissions("permissions",permissions);
27+
this.builder.withPermissions("permissions", permissions);
2728
}
2829

2930
/**
3031
* By default the installation token has access to all repositories that the installation can access. To restrict
3132
* the access to specific repositories, you can provide the repository_ids when creating the token. When you omit
3233
* repository_ids, the response does not contain neither the repositories nor the permissions key.
3334
*
34-
* @param repositoryIds - Array containing the repositories Ids
35+
* @param repositoryIds
36+
* Array containing the repositories Ids
3537
*
38+
* @return a GHAppCreateTokenBuilder
3639
*/
37-
@Preview @Deprecated
40+
@Preview
41+
@Deprecated
3842
public GHAppCreateTokenBuilder repositoryIds(List<Long> repositoryIds) {
39-
this.builder.with("repository_ids",repositoryIds);
43+
this.builder.with("repository_ids", repositoryIds);
4044
return this;
4145
}
4246

4347
/**
4448
* Creates an app token with all the parameters.
4549
*
4650
* You must use a JWT to access this endpoint.
51+
*
52+
* @return a GHAppInstallationToken
53+
* @throws IOException
54+
* on error
4755
*/
48-
@Preview @Deprecated
56+
@Preview
57+
@Deprecated
4958
public GHAppInstallationToken create() throws IOException {
50-
return builder.method("POST").withPreview(MACHINE_MAN).to(apiUrlTail, GHAppInstallationToken.class).wrapUp(root);
59+
return builder.method("POST").withPreview(MACHINE_MAN).to(apiUrlTail, GHAppInstallationToken.class)
60+
.wrapUp(root);
5161
}
5262

5363
}

src/main/java/org/kohsuke/github/GHAppInstallation.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public void setRepositorySelection(GHRepositorySelection repositorySelection) {
135135
this.repositorySelection = repositorySelection;
136136
}
137137

138-
/*package*/ GHAppInstallation wrapUp(GitHub root) {
138+
GHAppInstallation wrapUp(GitHub root) {
139139
this.root = root;
140140
return this;
141141
}
@@ -145,23 +145,30 @@ public void setRepositorySelection(GHRepositorySelection repositorySelection) {
145145
*
146146
* You must use a JWT to access this endpoint.
147147
*
148+
* @throws IOException
149+
* on error
148150
* @see <a href="https://developer.github.com/v3/apps/#delete-an-installation">Delete an installation</a>
149151
*/
150-
@Preview @Deprecated
152+
@Preview
153+
@Deprecated
151154
public void deleteInstallation() throws IOException {
152155
root.retrieve().method("DELETE").withPreview(GAMBIT).to(String.format("/app/installations/%d", id));
153156
}
154157

155-
156158
/**
157159
* Starts a builder that creates a new App Installation Token.
158160
*
159161
* <p>
160-
* You use the returned builder to set various properties, then call {@link GHAppCreateTokenBuilder#create()}
161-
* to finally create an access token.
162+
* You use the returned builder to set various properties, then call {@link GHAppCreateTokenBuilder#create()} to
163+
* finally create an access token.
164+
*
165+
* @param permissions
166+
* map of permissions for the created token
167+
* @return a GHAppCreateTokenBuilder on error
162168
*/
163-
@Preview @Deprecated
164-
public GHAppCreateTokenBuilder createToken(Map<String,GHPermissionType> permissions){
165-
return new GHAppCreateTokenBuilder(root,String.format("/app/installations/%d/access_tokens", id), permissions);
169+
@Preview
170+
@Deprecated
171+
public GHAppCreateTokenBuilder createToken(Map<String, GHPermissionType> permissions) {
172+
return new GHAppCreateTokenBuilder(root, String.format("/app/installations/%d/access_tokens", id), permissions);
166173
}
167174
}

0 commit comments

Comments
 (0)