Skip to content

Commit

Permalink
Apply and enforce code formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
jmini committed Oct 13, 2024
1 parent b77103f commit 6e5e2e6
Show file tree
Hide file tree
Showing 374 changed files with 27,376 additions and 22,040 deletions.
9 changes: 9 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

plugins {
id 'java-library'
id 'com.diffplug.spotless' version '6.2.0'
id 'signing'
id 'maven-publish'
id 'de.marcphilipp.nexus-publish' version '0.4.0'
Expand Down Expand Up @@ -54,6 +55,14 @@ repositories {
mavenCentral()
}

spotless {
java {
palantirJavaFormat()
importOrder 'java', 'javax', 'jakarta', 'org', 'com', ''
removeUnusedImports()
}
}

nexusPublishing {
repositories {
sonatype {
Expand Down
133 changes: 90 additions & 43 deletions src/main/java/org/gitlab4j/api/AbstractApi.java

Large diffs are not rendered by default.

74 changes: 38 additions & 36 deletions src/main/java/org/gitlab4j/api/ApplicationSettingsApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

import javax.ws.rs.core.Response;

import org.gitlab4j.api.models.Setting;
import org.gitlab4j.api.models.ApplicationSettings;
import org.gitlab4j.api.models.Setting;
import org.gitlab4j.api.utils.ISO8601;

import com.fasterxml.jackson.databind.JsonNode;
Expand Down Expand Up @@ -53,7 +53,7 @@ public ApplicationSettings updateApplicationSettings(ApplicationSettings appSett
}

final GitLabApiForm form = new GitLabApiForm();
appSettings.getSettings().forEach((s, v) -> form.withParam(s, v));
appSettings.getSettings().forEach((s, v) -> form.withParam(s, v));
Response response = put(Response.Status.OK, form.asMap(), "application", "settings");
JsonNode root = response.readEntity(JsonNode.class);
return (parseApplicationSettings(root));
Expand Down Expand Up @@ -116,40 +116,42 @@ public static final ApplicationSettings parseApplicationSettings(JsonNode root)

String fieldName = fieldNames.next();
switch (fieldName) {
case "id":
appSettings.setId(root.path(fieldName).asLong());
break;

case "created_at":
try {
String value = root.path(fieldName).asText();
appSettings.setCreatedAt(ISO8601.toDate(value));
} catch (ParseException pe) {
throw new GitLabApiException(pe);
}
break;

case "updated_at":
try {
String value = root.path(fieldName).asText();
appSettings.setUpdatedAt(ISO8601.toDate(value));
} catch (ParseException pe) {
throw new GitLabApiException(pe);
}
break;

default:

Setting setting = Setting.forValue(fieldName);
if (setting != null) {
appSettings.addSetting(setting, root.path(fieldName));
} else {
GitLabApi.getLogger().warning(String.format("Unknown setting: %s, type: %s",
fieldName, root.path(fieldName).getClass().getSimpleName()));
appSettings.addSetting(fieldName, root.path(fieldName));
}

break;
case "id":
appSettings.setId(root.path(fieldName).asLong());
break;

case "created_at":
try {
String value = root.path(fieldName).asText();
appSettings.setCreatedAt(ISO8601.toDate(value));
} catch (ParseException pe) {
throw new GitLabApiException(pe);
}
break;

case "updated_at":
try {
String value = root.path(fieldName).asText();
appSettings.setUpdatedAt(ISO8601.toDate(value));
} catch (ParseException pe) {
throw new GitLabApiException(pe);
}
break;

default:
Setting setting = Setting.forValue(fieldName);
if (setting != null) {
appSettings.addSetting(setting, root.path(fieldName));
} else {
GitLabApi.getLogger()
.warning(String.format(
"Unknown setting: %s, type: %s",
fieldName,
root.path(fieldName).getClass().getSimpleName()));
appSettings.addSetting(fieldName, root.path(fieldName));
}

break;
}
}

Expand Down
8 changes: 5 additions & 3 deletions src/main/java/org/gitlab4j/api/ApplicationsApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ public Stream<Application> getApplicationsStream() throws GitLabApiException {
* @return the created Application instance
* @throws GitLabApiException if any exception occurs
*/
public Application createApplication(String name, String redirectUri, ApplicationScope[] scopes) throws GitLabApiException {
public Application createApplication(String name, String redirectUri, ApplicationScope[] scopes)
throws GitLabApiException {

if (scopes == null || scopes.length == 0) {
throw new GitLabApiException("scopes cannot be null or empty");
Expand All @@ -103,7 +104,8 @@ public Application createApplication(String name, String redirectUri, Applicatio
* @return the created Application instance
* @throws GitLabApiException if any exception occurs
*/
public Application createApplication(String name, String redirectUri, List<ApplicationScope> scopes) throws GitLabApiException {
public Application createApplication(String name, String redirectUri, List<ApplicationScope> scopes)
throws GitLabApiException {

if (scopes == null || scopes.isEmpty()) {
throw new GitLabApiException("scopes cannot be null or empty");
Expand All @@ -113,7 +115,7 @@ public Application createApplication(String name, String redirectUri, List<Appli
GitLabApiForm formData = new GitLabApiForm()
.withParam("name", name, true)
.withParam("redirect_uri", redirectUri, true)
.withParam("scopes", scopesString, true);
.withParam("scopes", scopesString, true);
Response response = post(Response.Status.CREATED, formData, "applications");
return (response.readEntity(Application.class));
}
Expand Down
13 changes: 9 additions & 4 deletions src/main/java/org/gitlab4j/api/AuditEventApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ public AuditEventApi(GitLabApi gitLabApi) {
* @return a List of group Audit events
* @throws GitLabApiException if any exception occurs
*/
public List<AuditEvent> getAuditEvents(Date created_after, Date created_before, String entityType, Long entityId) throws GitLabApiException {
return (getAuditEvents(created_after, created_before, entityType, entityId, getDefaultPerPage()).all());
public List<AuditEvent> getAuditEvents(Date created_after, Date created_before, String entityType, Long entityId)
throws GitLabApiException {
return (getAuditEvents(created_after, created_before, entityType, entityId, getDefaultPerPage())
.all());
}

/**
Expand All @@ -49,7 +51,9 @@ public List<AuditEvent> getAuditEvents(Date created_after, Date created_before,
* @return a Pager of group Audit events
* @throws GitLabApiException if any exception occurs
*/
public Pager<AuditEvent> getAuditEvents(Date created_after, Date created_before, String entityType, Long entityId, int itemsPerPage) throws GitLabApiException {
public Pager<AuditEvent> getAuditEvents(
Date created_after, Date created_before, String entityType, Long entityId, int itemsPerPage)
throws GitLabApiException {
Form form = new GitLabApiForm()
.withParam("created_before", ISO8601.toString(created_before, false))
.withParam("created_after", ISO8601.toString(created_after, false))
Expand All @@ -70,7 +74,8 @@ public Pager<AuditEvent> getAuditEvents(Date created_after, Date created_before,
* @return a Stream of group Audit events
* @throws GitLabApiException if any exception occurs
*/
public Stream<AuditEvent> getAuditEventsStream(Date created_after, Date created_before, String entityType, Long entityId) throws GitLabApiException {
public Stream<AuditEvent> getAuditEventsStream(
Date created_after, Date created_before, String entityType, Long entityId) throws GitLabApiException {
return (getAuditEvents(created_after, created_before, entityType, entityId, getDefaultPerPage()).stream());
}

Expand Down
Loading

0 comments on commit 6e5e2e6

Please sign in to comment.