Skip to content

Commit

Permalink
style: Super Linter recommendations
Browse files Browse the repository at this point in the history
  • Loading branch information
wyvrtn authored Dec 16, 2024
1 parent 519d91a commit 08162ac
Show file tree
Hide file tree
Showing 24 changed files with 90 additions and 86 deletions.
4 changes: 2 additions & 2 deletions src/main/java/jospi/client/MultiApiClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import lombok.experimental.Delegate;

public final class MultiApiClient<K> {
@Delegate(excludes=OsuApiClientDelgationExclusions.class)
@Delegate(excludes = OsuApiClientDelgationExclusions.class)
private final OsuApiClient client;

@Getter
Expand All @@ -35,6 +35,6 @@ public void switchInstance(K key) {
}

private interface OsuApiClientDelgationExclusions {
public void updateAuthorization(AbstractApiAuthorization newAuth);
void updateAuthorization(AbstractApiAuthorization newAuth);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ private <T> T simpleJsonRequest(HttpRequest request, TypeReference<T> typeRefere

private String buildUri(String... pathArgs) {
StringBuilder sb = new StringBuilder(GATEWAY);
for (String arg : pathArgs) sb.append(arg);
for (String arg : pathArgs) {
sb.append(arg);
}
return new String(sb);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/jospi/endpoints/BeatmapPacks.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ public CompletableFuture<BeatmapPack> getBeatmapPack(String tag) {
}

public CompletableFuture<BeatmapPack> getBeatmapPack(String tag, boolean legacyOnly) {
return client.getJsonAsync(BASE + "packs/"+ tag + "?" + (legacyOnly? 1:0), BeatmapPack.class);
return client.getJsonAsync(BASE + "packs/" + tag + "?" + (legacyOnly ? 1 : 0), BeatmapPack.class);
}
}
4 changes: 2 additions & 2 deletions src/main/java/jospi/endpoints/BeatmapSets.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ protected BeatmapSets(OsuApiClient client) {
}

public CompletableFuture<BeatmapSetExtended> lookupBeatmapSet(int beatmapId) {
return client.getJsonAsync(BASE+"lookup?beatmap_id="+beatmapId, BeatmapSetExtended.class);
return client.getJsonAsync(BASE + "lookup?beatmap_id=" + beatmapId, BeatmapSetExtended.class);
}

public CompletableFuture<BeatmapSetExtended> getBeatmapSet(int beatmapSetId) {
return client.getJsonAsync(BASE+beatmapSetId, BeatmapSetExtended.class);
return client.getJsonAsync(BASE + beatmapSetId, BeatmapSetExtended.class);
}
}
12 changes: 6 additions & 6 deletions src/main/java/jospi/endpoints/Beatmaps.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,26 @@ public CompletableFuture<Beatmap> lookupBeatmapId(String id) {
}

private CompletableFuture<Beatmap> lookupBeatmapInternal(String query) {
return client.getJsonAsync(BASE+"lookup?" + query, Beatmap.class);
return client.getJsonAsync(BASE + "lookup?" + query, Beatmap.class);
}

public CompletableFuture<UserBeatmapScore> getUserBeatmapScore(int beatmapId, int userId, Ruleset ruleset, String mods) {
return client.getJsonAsync(BASE+beatmapId+"/scores/users/"
return client.getJsonAsync(BASE + beatmapId + "/scores/users/"
+userId, map -> {
map.put("mode", ruleset);
map.put("mods", mods);
}, UserBeatmapScore.class);
}

public CompletableFuture<Score[]> getUserBeatmapScores(int beatmapId, int userId, Ruleset ruleset) {
return client.getJsonAsync(BASE+beatmapId+"/scores/users/"
return client.getJsonAsync(BASE + beatmapId + "/scores/users/"
+userId+"/all", map -> {
map.put("map", ruleset);
}, Score[].class);
}

public CompletableFuture<BeatmapScores> getBeatmapScores(int beatmapId, Ruleset ruleset, String mods) {
return client.getJsonAsync(BASE+beatmapId+"/scores", map -> {
return client.getJsonAsync(BASE + beatmapId + "/scores", map -> {
map.put("mode", ruleset);
map.put("mods", mods);
}, BeatmapScores.class);
Expand All @@ -74,10 +74,10 @@ public CompletableFuture<BeatmapExtended[]> getBeatmaps(int[] ids) {
}

public CompletableFuture<BeatmapExtended> getBeatmap(int id) {
return client.getJsonAsync(BASE+id, BeatmapExtended.class);
return client.getJsonAsync(BASE + id, BeatmapExtended.class);
}

public CompletableFuture<DifficultyAttributes> getDifficultyAttributes(int id) {
return client.getJsonAsync(BASE+id+"/attributes", HttpMethod.POST, DifficultyAttributes.class);
return client.getJsonAsync(BASE + id + "/attributes", HttpMethod.POST, DifficultyAttributes.class);
}
}
6 changes: 3 additions & 3 deletions src/main/java/jospi/endpoints/Changelogs.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ protected Changelogs(OsuApiClient client) {
}

public CompletableFuture<Build> getBuild(String stream, String build) {
return client.getJsonAsync(BASE+stream+"/"+build, Build.class);
return client.getJsonAsync(BASE + stream + "/" + build, Build.class);
}

public CompletableFuture<ChangelogListing> getChangelogListing(String stream, String fromBuild, String toBuild, int maxBuildId) {
Expand All @@ -29,10 +29,10 @@ public CompletableFuture<ChangelogListing> getChangelogListing(String stream, St
}

public CompletableFuture<Build> lookupBuildId(int buildId) {
return client.getJsonAsync(BASE+buildId+"?key=id", Build.class);
return client.getJsonAsync(BASE + buildId + "?key=id", Build.class);
}

public CompletableFuture<Build> lookupLatestBuild(String stream) {
return client.getJsonAsync(BASE+stream, Build.class);
return client.getJsonAsync(BASE + stream, Build.class);
}
}
10 changes: 5 additions & 5 deletions src/main/java/jospi/endpoints/Comments.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected Comments(OsuApiClient client) {
}

public CompletableFuture<CommentBundle> getComment(int commentId) {
return client.getJsonAsync(BASE+commentId, CommentBundle.class);
return client.getJsonAsync(BASE + commentId, CommentBundle.class);
}

public AsyncLazyEnumerable<Cursor, CommentBundle> getComments(int after, CommentableType type,
Expand All @@ -32,18 +32,18 @@ public AsyncLazyEnumerable<Cursor, CommentBundle> getComments(int after, Comment
Function<ExitToken<Cursor>, CompletableFuture<CommentBundle>> func = t ->
CompletableFuture.supplyAsync(() -> {
CommentBundle bundle = client.getJson(BASE, map -> {
map.put("cursor[id]", t.getToken().id==0? null : t.getToken().id);
map.put("cursor[created_at]", t.getToken().createdAt==null? null : t.getToken().createdAt);
map.put("cursor[id]", t.getToken().id == 0 ? null : t.getToken().id);
map.put("cursor[created_at]", t.getToken().createdAt == null ? null : t.getToken().createdAt);
map.put("after", after);
map.put("commentable_type", type);
map.put("commentable_id", commentableId);
map.put("parent_id", parentId);
map.put("sort", sort);
}, CommentBundle.class);
if (bundle==null) {
if (bundle == null) {
throw new OsuApiException("An error occured while requesting the comment bundle. (bundle is null)");
}
token.setNext(bundle==null? null : bundle.getCursor());
token.setNext(bundle == null ? null : bundle.getCursor());
return bundle;
});
return new AsyncLazyEnumerable<>(func, token);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/jospi/endpoints/Events.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import jospi.models.events.Event;
import jospi.models.generic.CursorResponse;

public class Events {
public final class Events {
private static final String BASE = "/events/";

private final OsuApiClient client;
Expand All @@ -32,7 +32,7 @@ public AsyncLazyEnumerable<String, Event[]> getEvents(PostSort sort) {
CursorResponse<Event> events = client.getJson(BASE, map -> {
map.put("sort", sort);
map.put("cursor_string", token.getToken());
}, new TypeReference<CursorResponse<Event>>() {});
}, new TypeReference<CursorResponse<Event>>() { });
token.setNext(events.getCursorString());
return events.getData();
});
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/jospi/endpoints/Home.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import jospi.models.users.User;
import jospi.models.wikis.WikiPage;

public class Home {
public final class Home {
private static final String BASE = "/search/";

private final OsuApiClient client;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/jospi/endpoints/Matches.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import jospi.models.matches.MatchBundle;
import jospi.models.matches.MatchesBundle;

public class Matches {
public final class Matches {
private static final String BASE = "/matches/";

private final OsuApiClient client;
Expand All @@ -35,7 +35,7 @@ public AsyncLazyEnumerable<String, Match[]> getMatches(int limit, MatchBundleSor
}

public CompletableFuture<MatchBundle> getMatch(int matchId, int before, int after, int limit) {
return client.getJsonAsync(BASE+matchId, map -> {
return client.getJsonAsync(BASE + matchId, map -> {
map.put("before", before);
map.put("after", after);
map.put("limit", limit);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/jospi/endpoints/Multiplayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import jospi.iterator.ExitToken;
import jospi.models.multiplayer.MultiplayerScores;

public class Multiplayer {
public final class Multiplayer {
private static final String BASE = "/rooms/";

private final OsuApiClient client;
Expand All @@ -27,7 +27,7 @@ public AsyncLazyEnumerable<String, MultiplayerScores> getMultiplayerScores(int r
ExitToken<String> token = new ExitToken<>("");
Function<ExitToken<String>, CompletableFuture<MultiplayerScores>> func = tkn ->
CompletableFuture.supplyAsync(() -> {
MultiplayerScores multiplayerScores = client.getJson(BASE+roomId+"/playlist/"+playlistId+"/scores", map -> {
MultiplayerScores multiplayerScores = client.getJson(BASE + roomId + "/playlist/" + playlistId + "/scores", map -> {
map.put("limit", limit);
map.put("sort", sort);
map.put("cursor_string", tkn.getToken());
Expand All @@ -46,6 +46,6 @@ public <T> CompletableFuture<T> getRooms(int limit, MultiplayerRoomMode mode, St
map.put("season_id", seasonId);
map.put("sort", sort);
map.put("type_group", typeGroup);
}, new TypeReference<T>() {});
}, new TypeReference<T>() { });
}
}
2 changes: 1 addition & 1 deletion src/main/java/jospi/endpoints/News.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public AsyncLazyEnumerable<String, NewsPost[]> getNewsPosts() {
}

public CompletableFuture<NewsPost> getNewsPost(String slug) {
return client.getJsonAsync(BASE+slug, NewsPost.class);
return client.getJsonAsync(BASE + slug, NewsPost.class);
}

public CompletableFuture<NewsPost> getNewsPost(int id) {
Expand Down
14 changes: 10 additions & 4 deletions src/main/java/jospi/endpoints/Rankings.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ protected Rankings(OsuApiClient client) {
}

public CompletableFuture<User[]> getKudosuRanking(int page) {
return client.getJsonAsync("/rankings/kudosu?page"+page, User[].class);
return client.getJsonAsync("/rankings/kudosu?page" + page, User[].class);
}

public CompletableFuture<Spotlight[]> getSpotlights() {
Expand All @@ -48,7 +48,9 @@ public AsyncLazyEnumerable<String, RankingsBundle> getRanking(Ruleset ruleset, U
// REQUIRES USER

public AsyncLazyEnumerable<String, UserStatistics[]> getPerformanceRanking(Ruleset ruleset, String countryCode, RankingFilter filter, String variant) {
if (filter.equals(RankingFilter.FRIENDS)) client.requiresUser();
if (filter.equals(RankingFilter.FRIENDS)) {
client.requiresUser();
}
AsyncLazyEnumerable<String, RankingsBundle> enumerableBundle = getRankingInternal(ruleset, UserRankingType.PERFORMANCE, countryCode, filter, null, variant);
Function<CompletableFuture<RankingsBundle>, CompletableFuture<UserStatistics[]>> func = (CompletableFuture<RankingsBundle> bundle) -> {
return CompletableFuture.supplyAsync(() -> ClientUtil.awaitTask(bundle).getRankings());
Expand All @@ -57,7 +59,9 @@ public AsyncLazyEnumerable<String, UserStatistics[]> getPerformanceRanking(Rules
}

public AsyncLazyEnumerable<String, SpotlightRankings> getSpotlightRanking(Ruleset ruleset, RankingFilter filter, String spotlightId) {
if (filter.equals(RankingFilter.FRIENDS)) client.requiresUser();
if (filter.equals(RankingFilter.FRIENDS)) {
client.requiresUser();
}
AsyncLazyEnumerable<String, RankingsBundle> enumerableBundle = getRankingInternal(ruleset, UserRankingType.PERFORMANCE, null, filter, spotlightId, null);
Function<CompletableFuture<RankingsBundle>, CompletableFuture<SpotlightRankings>> func = (CompletableFuture<RankingsBundle> bundle) -> {
return CompletableFuture.supplyAsync(() -> (new SpotlightRankings(ClientUtil.awaitTask(bundle))));
Expand All @@ -66,7 +70,9 @@ public AsyncLazyEnumerable<String, SpotlightRankings> getSpotlightRanking(Rulese
}

public AsyncLazyEnumerable<String, RankingsBundle> getRanking(Ruleset ruleset, UserRankingType type, RankingFilter filter) {
if (filter.equals(RankingFilter.FRIENDS)) client.requiresUser();
if (filter.equals(RankingFilter.FRIENDS)) {
client.requiresUser();
}
return getRankingInternal(ruleset, type, null, filter, null, null);
}

Expand Down
20 changes: 11 additions & 9 deletions src/main/java/jospi/endpoints/Users.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ public CompletableFuture<UserExtended> getOwnData() {

public CompletableFuture<UserExtended> getOwnData(Ruleset ruleset) {
client.requiresUser();
return client.getJsonAsync("/me/"+ClientUtil.nullishCoalesce(ruleset, ""), UserExtended.class);
return client.getJsonAsync("/me/" + ClientUtil.nullishCoalesce(ruleset, ""), UserExtended.class);
}

public CompletableFuture<KudosuHistoryEntry[]> getKudosuHistory(int userId, UserResultParams params) {
return client.getJsonAsync(BASE+userId+"/kudosu", params.convert(), KudosuHistoryEntry[].class);
return client.getJsonAsync(BASE + userId + "/kudosu", params.convert(), KudosuHistoryEntry[].class);
}

public CompletableFuture<Score[]> getUserScores(int userId, UserScoreType type, boolean legacyOnly,
boolean includeFails, Ruleset ruleset, UserResultParams usrParams) {
return client.getJsonAsync(BASE+userId+"/scores/"+type.getDescription(), map -> {
return client.getJsonAsync(BASE + userId + "/scores/" + type.getDescription(), map -> {
map.put("legacy_only", legacyOnly);
map.put("include_fails", includeFails);
map.put("mode", ruleset);
Expand All @@ -48,35 +48,37 @@ public CompletableFuture<Score[]> getUserScores(int userId, UserScoreType type,
}

public CompletableFuture<BeatmapPlaycount[]> getUserMostPlayed(int userId, UserResultParams params) {
return client.getJsonAsync(BASE+userId+"/beatmapsets/"+BeatmapType.MOST_PLAYED.getDescription(), params.convert(), BeatmapPlaycount[].class);
return client.getJsonAsync(BASE + userId + "/beatmapsets/" + BeatmapType.MOST_PLAYED.getDescription(), params.convert(), BeatmapPlaycount[].class);
}

public CompletableFuture<BeatmapSetExtended[]> getUserBeatmaps(int userId, BeatmapType type, UserResultParams params) {
if (type==BeatmapType.MOST_PLAYED) {
throw new IllegalArgumentException("Please use GetUserMostPlayed(), as the response type differs.");
}
return client.getJsonAsync(BASE+userId+"/beatmapsets/"+type.getDescription(), params.convert(), BeatmapSetExtended[].class);
return client.getJsonAsync(BASE + userId + "/beatmapsets/" + type.getDescription(), params.convert(), BeatmapSetExtended[].class);
}

public CompletableFuture<User> getUser(int userId, Ruleset ruleset) {
return getUserInternal(Integer.toString(userId), ruleset);
}

public CompletableFuture<User> getUser(String username, Ruleset ruleset) {
return getUserInternal("@"+username, ruleset);
return getUserInternal("@" + username, ruleset);
}

private CompletableFuture<User> getUserInternal(String userIdentifier, Ruleset ruleset) {
return client.getJsonAsync(BASE+userIdentifier+"/"+ClientUtil.nullishCoalesce(ruleset, ""), User.class);
return client.getJsonAsync(BASE + userIdentifier + "/" + ClientUtil.nullishCoalesce(ruleset, ""), User.class);
}

public CompletableFuture<User[]> getUsers(int[] ids, boolean includeVariantStatistics) {
if (ids.length>50) {
if (ids.length > 50) {
throw new IndexOutOfBoundsException("Parameter 'ids' can only have an array length of 50 or less");
}
return client.getJsonAsync(BASE, map -> {
map.put("include_variant_statistics", includeVariantStatistics);
for (int id : ids) map.put("ids[]", id);
for (int id : ids) {
map.put("ids[]", id);
}
}, User[].class);
}
}
2 changes: 1 addition & 1 deletion src/main/java/jospi/endpoints/Wikis.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ protected Wikis(OsuApiClient client) {
}

public CompletableFuture<WikiPage> getWikiPage(String locale, String path) {
return client.getJsonAsync("/wiki/"+locale+"/"+path, WikiPage.class);
return client.getJsonAsync("/wiki/" + locale + "/" + path, WikiPage.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public enum ChangelogEntryCategory implements DescriptionEnum {

private String description;

private ChangelogEntryCategory(String description) {
ChangelogEntryCategory(String description) {
this.description = description;
}

Expand Down
Loading

0 comments on commit 08162ac

Please sign in to comment.