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

21 files changed

+93
-73
lines changed

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

+3-3
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

+2-1
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

+2-2
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

+10-10
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

+8-4
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

+3-1
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

+6-3
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

+8-6
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

+2-1
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

+8-4
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
}

application/src/main/java/org/togetherjava/tjbot/features/moderation/scam/ScamBlocker.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ private void takeAction(MessageReceivedEvent event) {
152152
"The OFF-mode should be detected earlier already to prevent expensive computation");
153153
case ONLY_LOG -> takeActionLogOnly(event);
154154
case APPROVE_FIRST -> takeActionApproveFirst(event);
155-
case AUTO_DELETE_BUT_APPROVE_QUARANTINE -> takeActionAutoDeleteButApproveQuarantine(
156-
event);
155+
case AUTO_DELETE_BUT_APPROVE_QUARANTINE ->
156+
takeActionAutoDeleteButApproveQuarantine(event);
157157
case AUTO_DELETE_AND_QUARANTINE -> takeActionAutoDeleteAndQuarantine(event);
158158
default -> throw new IllegalArgumentException("Mode not supported: " + mode);
159159
}

application/src/main/java/org/togetherjava/tjbot/features/moderation/temp/RevocableRoleBasedAction.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ public FailureIdentification handleRevokeFailure(Throwable failure, long targetI
3939
case UNKNOWN_ROLE -> logger.warn(
4040
"Attempted to revoke a temporary {} but the {} role can not be found.",
4141
actionName, actionName);
42-
case MISSING_PERMISSIONS -> logger.warn(
43-
"Attempted to revoke a temporary {} but the bot lacks permission.",
44-
actionName);
42+
case MISSING_PERMISSIONS ->
43+
logger.warn("Attempted to revoke a temporary {} but the bot lacks permission.",
44+
actionName);
4545
default -> {
4646
return FailureIdentification.UNKNOWN;
4747
}

application/src/main/java/org/togetherjava/tjbot/features/reminder/ReminderCommand.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public ReminderCommand(Database database) {
9494
// "/remind at" next to "/remind in" and use subcommands then
9595
OptionData timeAmount = new OptionData(OptionType.INTEGER, TIME_AMOUNT_OPTION,
9696
"period to remind you in, the amount of time (e.g. [5] weeks)", true)
97-
.setRequiredRange(MIN_TIME_AMOUNT, MAX_TIME_AMOUNT);
97+
.setRequiredRange(MIN_TIME_AMOUNT, MAX_TIME_AMOUNT);
9898
OptionData timeUnit = new OptionData(OptionType.STRING, TIME_UNIT_OPTION,
9999
"period to remind you in, the unit of time (e.g. 5 [weeks])", true);
100100
TIME_UNITS.forEach(unit -> timeUnit.addChoice(unit, unit));
@@ -118,8 +118,8 @@ public void onSlashCommand(SlashCommandInteractionEvent event) {
118118
case CREATE_SUBCOMMAND -> handleCreateCommand(event);
119119
case CANCEL_COMMAND -> handleCancelCommand(event);
120120
case LIST_SUBCOMMAND -> handleListCommand(event);
121-
default -> throw new AssertionError(
122-
"Unexpected Subcommand: " + event.getSubcommandName());
121+
default ->
122+
throw new AssertionError("Unexpected Subcommand: " + event.getSubcommandName());
123123
}
124124
}
125125

application/src/main/java/org/togetherjava/tjbot/features/system/BotCore.java

+8-4
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,8 @@ public void onSlashCommandInteraction(SlashCommandInteractionEvent event) {
256256
event.getGuild());
257257
COMMAND_SERVICE.execute(
258258
() -> requireUserInteractor(UserInteractionType.SLASH_COMMAND.getPrefixedName(name),
259-
SlashCommand.class).onSlashCommand(event));
259+
SlashCommand.class)
260+
.onSlashCommand(event));
260261
}
261262

262263
@Override
@@ -267,7 +268,8 @@ public void onCommandAutoCompleteInteraction(final CommandAutoCompleteInteractio
267268
event.getFullCommandName(), event.getId(), event.getGuild());
268269
COMMAND_SERVICE.execute(
269270
() -> requireUserInteractor(UserInteractionType.SLASH_COMMAND.getPrefixedName(name),
270-
SlashCommand.class).onAutoComplete(event));
271+
SlashCommand.class)
272+
.onAutoComplete(event));
271273
}
272274

273275
@Override
@@ -324,7 +326,8 @@ public void onMessageContextInteraction(final MessageContextInteractionEvent eve
324326
event.getId(), event.getGuild());
325327
COMMAND_SERVICE.execute(() -> requireUserInteractor(
326328
UserInteractionType.MESSAGE_CONTEXT_COMMAND.getPrefixedName(name),
327-
MessageContextCommand.class).onMessageContext(event));
329+
MessageContextCommand.class)
330+
.onMessageContext(event));
328331
}
329332

330333
@Override
@@ -335,7 +338,8 @@ public void onUserContextInteraction(final UserContextInteractionEvent event) {
335338
event.getGuild());
336339
COMMAND_SERVICE.execute(() -> requireUserInteractor(
337340
UserInteractionType.USER_CONTEXT_COMMAND.getPrefixedName(name),
338-
UserContextCommand.class).onUserContext(event));
341+
UserContextCommand.class)
342+
.onUserContext(event));
339343
}
340344

341345
/**

application/src/main/java/org/togetherjava/tjbot/features/tags/TagManageCommand.java

+5-7
Original file line numberDiff line numberDiff line change
@@ -87,23 +87,21 @@ public TagManageCommand(TagSystem tagSystem, ModAuditLogWriter modAuditLogWriter
8787
// 'delete'
8888
getData().addSubcommands(new SubcommandData(Subcommand.RAW.name,
8989
"View the raw content of a tag, without Discord interpreting any of its content")
90-
.addOption(OptionType.STRING, ID_OPTION, ID_DESCRIPTION, true),
90+
.addOption(OptionType.STRING, ID_OPTION, ID_DESCRIPTION, true),
9191
new SubcommandData(Subcommand.CREATE.name, "Creates a new tag")
9292
.addOption(OptionType.STRING, ID_OPTION, ID_DESCRIPTION, true)
9393
.addOption(OptionType.STRING, CONTENT_OPTION, CONTENT_DESCRIPTION, true),
9494
new SubcommandData(Subcommand.CREATE_WITH_MESSAGE.name,
9595
"Creates a new tag. Content is retrieved from the given message.")
96-
.addOption(OptionType.STRING, ID_OPTION, ID_DESCRIPTION, true)
97-
.addOption(OptionType.STRING, MESSAGE_ID_OPTION, MESSAGE_ID_DESCRIPTION,
98-
true),
96+
.addOption(OptionType.STRING, ID_OPTION, ID_DESCRIPTION, true)
97+
.addOption(OptionType.STRING, MESSAGE_ID_OPTION, MESSAGE_ID_DESCRIPTION, true),
9998
new SubcommandData(Subcommand.EDIT.name, "Edits a tag, the old content is replaced")
10099
.addOption(OptionType.STRING, ID_OPTION, ID_DESCRIPTION, true)
101100
.addOption(OptionType.STRING, CONTENT_OPTION, CONTENT_DESCRIPTION, true),
102101
new SubcommandData(Subcommand.EDIT_WITH_MESSAGE.name,
103102
"Edits a tag, the old content is replaced. Content is retrieved from the given message.")
104-
.addOption(OptionType.STRING, ID_OPTION, ID_DESCRIPTION, true)
105-
.addOption(OptionType.STRING, MESSAGE_ID_OPTION, MESSAGE_ID_DESCRIPTION,
106-
true),
103+
.addOption(OptionType.STRING, ID_OPTION, ID_DESCRIPTION, true)
104+
.addOption(OptionType.STRING, MESSAGE_ID_OPTION, MESSAGE_ID_DESCRIPTION, true),
107105
new SubcommandData(Subcommand.DELETE.name, "Deletes a tag")
108106
.addOption(OptionType.STRING, ID_OPTION, ID_DESCRIPTION, true));
109107
}

application/src/main/java/org/togetherjava/tjbot/features/utils/RateLimiter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ public class RateLimiter {
2121
* Creates a rate limiter.
2222
* <p>
2323
* Defines a window and a number of request, for example, if 10 requests should be allowed per 5
24-
* seconds, so 10/5s, the following should be called: {@snippet java: new
25-
* RateLimit(Duration.of(5, TimeUnit.SECONDS), 10) }
24+
* seconds, so 10/5s, the following should be called:
25+
* {@snippet java: new RateLimit(Duration.of(5, TimeUnit.SECONDS), 10) }
2626
*
2727
* @param duration the duration of window
2828
* @param allowedRequests the number of requests to allow in the window

application/src/test/java/org/togetherjava/tjbot/features/reminder/RemindRoutineTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ private TextChannel createAndSetupUnknownChannel() {
8585
TextChannel channel = jdaTester.createTextChannelSpy(unknownChannelId);
8686
when(jdaTester.getJdaMock()
8787
.getChannelById(ArgumentMatchers.<Class<MessageChannel>>any(), eq(unknownChannelId)))
88-
.thenReturn(null);
88+
.thenReturn(null);
8989

9090
return channel;
9191
}

0 commit comments

Comments
 (0)