Skip to content

Commit 9cf8944

Browse files
authored
Fix: Bump spotless to 21 and remove pinned eclipse jdt formatter version. Resolves #605 (#1105)
1 parent 9ff5cb8 commit 9cf8944

File tree

21 files changed

+93
-73
lines changed

21 files changed

+93
-73
lines changed

application/src/main/java/org/togetherjava/tjbot/features/bookmarks/BookmarksCommand.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,12 @@ public BookmarksCommand(BookmarksSystem bookmarksSystem) {
8282

8383
OptionData addNoteOption = new OptionData(OptionType.STRING, ADD_BOOKMARK_NOTE_OPTION,
8484
"Your personal comment on this bookmark")
85-
.setMaxLength(BookmarksSystem.MAX_NOTE_LENGTH)
86-
.setRequired(false);
85+
.setMaxLength(BookmarksSystem.MAX_NOTE_LENGTH)
86+
.setRequired(false);
8787

8888
SubcommandData addSubCommand = new SubcommandData(SUBCOMMAND_ADD,
8989
"Bookmark this help thread, so that you can easily look it up again")
90-
.addOptions(addNoteOption);
90+
.addOptions(addNoteOption);
9191

9292
SubcommandData listSubCommand =
9393
new SubcommandData(SUBCOMMAND_LIST, "List all of your bookmarks");

application/src/main/java/org/togetherjava/tjbot/features/bookmarks/BookmarksListRemoveHandler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ void onButtonClick(ButtonInteractionEvent event, List<String> args) {
145145
removeSelectedBookmarks(bookmarks, event, request);
146146
yield clampPageIndex(bookmarks, request.pageToDisplayIndex);
147147
}
148-
default -> throw new IllegalArgumentException("Unknown button: " + request.componentName);
148+
default ->
149+
throw new IllegalArgumentException("Unknown button: " + request.componentName);
149150
};
150151

151152
updatePagination(event, request.atPage(nextPageIndex), bookmarks);

application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadCommand.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ public HelpThreadCommand(Config config, HelpSystemHelper helper) {
8484
Subcommand.CHANGE_TITLE.toSubcommandData().addOptions(changeTitleOption);
8585

8686
SubcommandGroupData changeCommands = new SubcommandGroupData(CHANGE_SUBCOMMAND_GROUP,
87-
"Change the details of this help thread").addSubcommands(changeCategory,
88-
changeTitle);
87+
"Change the details of this help thread")
88+
.addSubcommands(changeCategory, changeTitle);
8989
getData().addSubcommandGroups(changeCommands);
9090

9191
getData().addSubcommands(Subcommand.CLOSE.toSubcommandData());

application/src/main/java/org/togetherjava/tjbot/features/jshell/JShellCommand.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,16 @@ public JShellCommand(JShellEval jshellEval) {
7070
new SubcommandData(VERSION_SUBCOMMAND, "Get the version of JShell"),
7171
new SubcommandData(EVAL_SUBCOMMAND,
7272
"Evaluate java code in JShell, submit the command without code for inputting longer, multi-line code.")
73-
.addOption(OptionType.STRING, CODE_PARAMETER,
74-
"Code to evaluate. Leave empty to input longer, multi-line code.")
75-
.addOption(OptionType.BOOLEAN, STARTUP_SCRIPT_PARAMETER,
76-
"If the startup script should be loaded, true by default."),
73+
.addOption(OptionType.STRING, CODE_PARAMETER,
74+
"Code to evaluate. Leave empty to input longer, multi-line code.")
75+
.addOption(OptionType.BOOLEAN, STARTUP_SCRIPT_PARAMETER,
76+
"If the startup script should be loaded, true by default."),
7777
new SubcommandData(SNIPPETS_SUBCOMMAND,
7878
"Display your snippets, or the snippets of the specified user if any.")
79-
.addOption(OptionType.USER, USER_PARAMETER,
80-
"User to get the snippets from. If null, get your snippets.")
81-
.addOption(OptionType.BOOLEAN, INCLUDE_STARTUP_SCRIPT_PARAMETER,
82-
"if the startup script should be included, false by default."),
79+
.addOption(OptionType.USER, USER_PARAMETER,
80+
"User to get the snippets from. If null, get your snippets.")
81+
.addOption(OptionType.BOOLEAN, INCLUDE_STARTUP_SCRIPT_PARAMETER,
82+
"if the startup script should be included, false by default."),
8383
new SubcommandData(CLOSE_SUBCOMMAND, "Close your session."),
8484
new SubcommandData(STARTUP_SCRIPT_SUBCOMMAND, "Display the startup script."));
8585
}
@@ -92,8 +92,8 @@ public void onSlashCommand(SlashCommandInteractionEvent event) {
9292
case SNIPPETS_SUBCOMMAND -> handleSnippetsCommand(event);
9393
case CLOSE_SUBCOMMAND -> handleCloseCommand(event);
9494
case STARTUP_SCRIPT_SUBCOMMAND -> handleStartupScriptCommand(event);
95-
default -> throw new AssertionError(
96-
"Unexpected Subcommand: " + event.getSubcommandName());
95+
default ->
96+
throw new AssertionError("Unexpected Subcommand: " + event.getSubcommandName());
9797
}
9898
}
9999

application/src/main/java/org/togetherjava/tjbot/features/jshell/backend/JShellApi.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ public JShellResult evalOnce(String code, boolean startupScript)
7777
baseUrl + "single-eval"
7878
+ (startupScript ? "?startupScriptId=" + STARTUP_SCRIPT_ID : ""),
7979
HttpRequest.newBuilder().POST(BodyPublishers.ofString(code)),
80-
ResponseUtils.ofJson(JShellResult.class, objectMapper)).body();
80+
ResponseUtils.ofJson(JShellResult.class, objectMapper))
81+
.body();
8182
}
8283

8384
/**
@@ -98,7 +99,8 @@ public JShellResult evalSession(String code, String sessionId, boolean startupSc
9899
baseUrl + "eval/" + sessionId
99100
+ (startupScript ? "?startupScriptId=" + STARTUP_SCRIPT_ID : ""),
100101
HttpRequest.newBuilder().POST(BodyPublishers.ofString(code)),
101-
ResponseUtils.ofJson(JShellResult.class, objectMapper)).body();
102+
ResponseUtils.ofJson(JShellResult.class, objectMapper))
103+
.body();
102104
}
103105

104106
/**
@@ -116,7 +118,8 @@ public SnippetList snippetsSession(String sessionId, boolean includeStartupScrip
116118
return send(
117119
baseUrl + "snippets/" + sessionId + "?includeStartupScript=" + includeStartupScript,
118120
HttpRequest.newBuilder().GET(),
119-
ResponseUtils.ofJson(SnippetList.class, objectMapper)).body();
121+
ResponseUtils.ofJson(SnippetList.class, objectMapper))
122+
.body();
120123
}
121124

122125
/**
@@ -144,7 +147,8 @@ public void closeSession(String sessionId)
144147
*/
145148
public String startupScript() throws RequestFailedException, ConnectionFailedException {
146149
return send(baseUrl + "startup_script/" + STARTUP_SCRIPT_ID, HttpRequest.newBuilder().GET(),
147-
BodyHandlers.ofString()).body();
150+
BodyHandlers.ofString())
151+
.body();
148152
}
149153

150154
private <T> HttpResponse<T> send(String url, HttpRequest.Builder builder, BodyHandler<T> body)

application/src/main/java/org/togetherjava/tjbot/features/jshell/backend/dto/JShellEvalAbortionCause.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ record TimeoutAbortionCause() implements JShellEvalAbortionCause {
2626
* @param exceptionMessage the message of the exception
2727
*/
2828
@JsonTypeName("UNCAUGHT_EXCEPTION")
29-
record UnhandledExceptionAbortionCause(String exceptionClass, String exceptionMessage) implements JShellEvalAbortionCause {
29+
record UnhandledExceptionAbortionCause(String exceptionClass,
30+
String exceptionMessage) implements JShellEvalAbortionCause {
3031
}
3132

3233
/**
3334
* The code doesn't compile, but at least the syntax is correct.
35+
*
3436
* @param errors the compilation errors
3537
*/
3638
@JsonTypeName("COMPILE_TIME_ERROR")

application/src/main/java/org/togetherjava/tjbot/features/jshell/renderer/RendererUtils.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,12 @@ private RendererUtils() {}
2424
static String abortionCauseToString(JShellEvalAbortionCause abortionCause) {
2525
return switch (abortionCause) {
2626
case JShellEvalAbortionCause.TimeoutAbortionCause ignored -> "Allowed time exceeded.";
27-
case JShellEvalAbortionCause.UnhandledExceptionAbortionCause c -> "Uncaught exception:\n" + c.exceptionClass() + ":" + c.exceptionMessage();
28-
case JShellEvalAbortionCause.CompileTimeErrorAbortionCause c -> "The code doesn't compile:\n" + String.join("\n", c.errors());
29-
case JShellEvalAbortionCause.SyntaxErrorAbortionCause ignored -> "The code doesn't compile, there are syntax errors in this code.";
27+
case JShellEvalAbortionCause.UnhandledExceptionAbortionCause c ->
28+
"Uncaught exception:\n" + c.exceptionClass() + ":" + c.exceptionMessage();
29+
case JShellEvalAbortionCause.CompileTimeErrorAbortionCause c ->
30+
"The code doesn't compile:\n" + String.join("\n", c.errors());
31+
case JShellEvalAbortionCause.SyntaxErrorAbortionCause ignored ->
32+
"The code doesn't compile, there are syntax errors in this code.";
3033
};
3134
}
3235

application/src/main/java/org/togetherjava/tjbot/features/moderation/BanCommand.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,10 @@ public BanCommand(ModerationActionsStore actionsStore) {
6969
.addOptions(durationData)
7070
.addOption(OptionType.STRING, REASON_OPTION, "Why the user should be banned", true)
7171
.addOptions(new OptionData(OptionType.INTEGER, DELETE_HISTORY_OPTION,
72-
"the message history to delete", true).addChoice("none", 0)
73-
.addChoice("day", 1)
74-
.addChoice("week", 7));
72+
"the message history to delete", true)
73+
.addChoice("none", 0)
74+
.addChoice("day", 1)
75+
.addChoice("week", 7));
7576

7677
this.actionsStore = Objects.requireNonNull(actionsStore);
7778
}
@@ -138,7 +139,8 @@ private RestAction<Message> banUserFlow(User target, Member author,
138139
int deleteHistoryDays, Guild guild, SlashCommandInteractionEvent event) {
139140
return sendDm(target, temporaryData, reason, guild)
140141
.flatMap(hasSentDm -> banUser(target, author, temporaryData, reason, deleteHistoryDays,
141-
guild).map(banResult -> hasSentDm))
142+
guild)
143+
.map(banResult -> hasSentDm))
142144
.map(hasSentDm -> sendFeedback(hasSentDm, target, author, temporaryData, reason))
143145
.flatMap(event.getHook()::sendMessageEmbeds);
144146
}
@@ -213,8 +215,8 @@ public void onSlashCommand(SlashCommandInteractionEvent event) {
213215

214216
return handleNotAlreadyBannedResponse(
215217
Objects.requireNonNull(alreadyBanned.getFailure()), hook, guild, target)
216-
.orElseGet(() -> banUserFlow(target, author, temporaryData.orElse(null),
217-
reason, deleteHistoryDays, guild, event));
218+
.orElseGet(() -> banUserFlow(target, author, temporaryData.orElse(null), reason,
219+
deleteHistoryDays, guild, event));
218220
}).queue();
219221
}
220222
}

application/src/main/java/org/togetherjava/tjbot/features/moderation/TransferQuestionCommand.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ private void transferFlow(ModalInteractionEvent event, String channelId, String
176176
.retrieveUserById(authorId)
177177
.flatMap(fetchedUser -> createForumPost(event, fetchedUser))
178178
.flatMap(createdForumPost -> dmUser(event.getChannel(), createdForumPost,
179-
event.getGuild()).and(sendMessageToTransferrer.apply(createdForumPost)))
179+
event.getGuild())
180+
.and(sendMessageToTransferrer.apply(createdForumPost)))
180181
.flatMap(dmSent -> deleteOriginalMessage(event.getJDA(), channelId, messageId))
181182
.queue();
182183
}

application/src/main/java/org/togetherjava/tjbot/features/moderation/audit/AuditCommand.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,10 @@ public void onSlashCommand(SlashCommandInteractionEvent event) {
8585
}
8686

8787
auditUser(MessageCreateBuilder::new, guild.getIdLong(), target.getIdLong(),
88-
event.getMember().getIdLong(), -1, event.getJDA()).map(MessageCreateBuilder::build)
89-
.flatMap(event::reply)
90-
.queue();
88+
event.getMember().getIdLong(), -1, event.getJDA())
89+
.map(MessageCreateBuilder::build)
90+
.flatMap(event::reply)
91+
.queue();
9192
}
9293

9394
private boolean handleChecks(Member bot, Member author, @Nullable Member target,
@@ -276,6 +277,9 @@ public void onButtonClick(ButtonInteractionEvent event, List<String> args) {
276277
int pageToDisplay = currentPage + turnPageBy;
277278

278279
auditUser(MessageEditBuilder::new, guildId, targetId, buttonUserId, pageToDisplay,
279-
event.getJDA()).map(MessageEditBuilder::build).flatMap(event::editMessage).queue();
280+
event.getJDA())
281+
.map(MessageEditBuilder::build)
282+
.flatMap(event::editMessage)
283+
.queue();
280284
}
281285
}

0 commit comments

Comments
 (0)