diff --git a/application/src/main/java/org/togetherjava/tjbot/features/bookmarks/BookmarksCommand.java b/application/src/main/java/org/togetherjava/tjbot/features/bookmarks/BookmarksCommand.java index 8122dc5172..3922c2ec1c 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/bookmarks/BookmarksCommand.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/bookmarks/BookmarksCommand.java @@ -82,12 +82,12 @@ public BookmarksCommand(BookmarksSystem bookmarksSystem) { OptionData addNoteOption = new OptionData(OptionType.STRING, ADD_BOOKMARK_NOTE_OPTION, "Your personal comment on this bookmark") - .setMaxLength(BookmarksSystem.MAX_NOTE_LENGTH) - .setRequired(false); + .setMaxLength(BookmarksSystem.MAX_NOTE_LENGTH) + .setRequired(false); SubcommandData addSubCommand = new SubcommandData(SUBCOMMAND_ADD, "Bookmark this help thread, so that you can easily look it up again") - .addOptions(addNoteOption); + .addOptions(addNoteOption); SubcommandData listSubCommand = new SubcommandData(SUBCOMMAND_LIST, "List all of your bookmarks"); diff --git a/application/src/main/java/org/togetherjava/tjbot/features/bookmarks/BookmarksListRemoveHandler.java b/application/src/main/java/org/togetherjava/tjbot/features/bookmarks/BookmarksListRemoveHandler.java index 4832e1ef4f..7760fd9e9b 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/bookmarks/BookmarksListRemoveHandler.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/bookmarks/BookmarksListRemoveHandler.java @@ -141,7 +141,8 @@ void onButtonClick(ButtonInteractionEvent event, List args) { removeSelectedBookmarks(bookmarks, event, request); yield clampPageIndex(bookmarks, request.pageToDisplayIndex); } - default -> throw new IllegalArgumentException("Unknown button: " + request.componentName); + default -> + throw new IllegalArgumentException("Unknown button: " + request.componentName); }; updatePagination(event, request.atPage(nextPageIndex), bookmarks); diff --git a/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadCommand.java b/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadCommand.java index a2b1a123a3..5913be53b4 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadCommand.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadCommand.java @@ -76,8 +76,8 @@ public HelpThreadCommand(Config config, HelpSystemHelper helper) { Subcommand.CHANGE_TITLE.toSubcommandData().addOptions(changeTitleOption); SubcommandGroupData changeCommands = new SubcommandGroupData(CHANGE_SUBCOMMAND_GROUP, - "Change the details of this help thread").addSubcommands(changeCategory, - changeTitle); + "Change the details of this help thread") + .addSubcommands(changeCategory, changeTitle); getData().addSubcommandGroups(changeCommands); getData().addSubcommands(Subcommand.CLOSE.toSubcommandData()); diff --git a/application/src/main/java/org/togetherjava/tjbot/features/jshell/JShellCommand.java b/application/src/main/java/org/togetherjava/tjbot/features/jshell/JShellCommand.java index fbadddc9f2..629ff3acd9 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/jshell/JShellCommand.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/jshell/JShellCommand.java @@ -70,16 +70,16 @@ public JShellCommand(JShellEval jshellEval) { new SubcommandData(VERSION_SUBCOMMAND, "Get the version of JShell"), new SubcommandData(EVAL_SUBCOMMAND, "Evaluate java code in JShell, submit the command without code for inputting longer, multi-line code.") - .addOption(OptionType.STRING, CODE_PARAMETER, - "Code to evaluate. Leave empty to input longer, multi-line code.") - .addOption(OptionType.BOOLEAN, STARTUP_SCRIPT_PARAMETER, - "If the startup script should be loaded, true by default."), + .addOption(OptionType.STRING, CODE_PARAMETER, + "Code to evaluate. Leave empty to input longer, multi-line code.") + .addOption(OptionType.BOOLEAN, STARTUP_SCRIPT_PARAMETER, + "If the startup script should be loaded, true by default."), new SubcommandData(SNIPPETS_SUBCOMMAND, "Display your snippets, or the snippets of the specified user if any.") - .addOption(OptionType.USER, USER_PARAMETER, - "User to get the snippets from. If null, get your snippets.") - .addOption(OptionType.BOOLEAN, INCLUDE_STARTUP_SCRIPT_PARAMETER, - "if the startup script should be included, false by default."), + .addOption(OptionType.USER, USER_PARAMETER, + "User to get the snippets from. If null, get your snippets.") + .addOption(OptionType.BOOLEAN, INCLUDE_STARTUP_SCRIPT_PARAMETER, + "if the startup script should be included, false by default."), new SubcommandData(CLOSE_SUBCOMMAND, "Close your session."), new SubcommandData(STARTUP_SCRIPT_SUBCOMMAND, "Display the startup script.")); } @@ -92,8 +92,8 @@ public void onSlashCommand(SlashCommandInteractionEvent event) { case SNIPPETS_SUBCOMMAND -> handleSnippetsCommand(event); case CLOSE_SUBCOMMAND -> handleCloseCommand(event); case STARTUP_SCRIPT_SUBCOMMAND -> handleStartupScriptCommand(event); - default -> throw new AssertionError( - "Unexpected Subcommand: " + event.getSubcommandName()); + default -> + throw new AssertionError("Unexpected Subcommand: " + event.getSubcommandName()); } } diff --git a/application/src/main/java/org/togetherjava/tjbot/features/jshell/backend/JShellApi.java b/application/src/main/java/org/togetherjava/tjbot/features/jshell/backend/JShellApi.java index cd961a00c6..04fe0d53cd 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/jshell/backend/JShellApi.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/jshell/backend/JShellApi.java @@ -77,7 +77,8 @@ public JShellResult evalOnce(String code, boolean startupScript) baseUrl + "single-eval" + (startupScript ? "?startupScriptId=" + STARTUP_SCRIPT_ID : ""), HttpRequest.newBuilder().POST(BodyPublishers.ofString(code)), - ResponseUtils.ofJson(JShellResult.class, objectMapper)).body(); + ResponseUtils.ofJson(JShellResult.class, objectMapper)) + .body(); } /** @@ -98,7 +99,8 @@ public JShellResult evalSession(String code, String sessionId, boolean startupSc baseUrl + "eval/" + sessionId + (startupScript ? "?startupScriptId=" + STARTUP_SCRIPT_ID : ""), HttpRequest.newBuilder().POST(BodyPublishers.ofString(code)), - ResponseUtils.ofJson(JShellResult.class, objectMapper)).body(); + ResponseUtils.ofJson(JShellResult.class, objectMapper)) + .body(); } /** @@ -116,7 +118,8 @@ public SnippetList snippetsSession(String sessionId, boolean includeStartupScrip return send( baseUrl + "snippets/" + sessionId + "?includeStartupScript=" + includeStartupScript, HttpRequest.newBuilder().GET(), - ResponseUtils.ofJson(SnippetList.class, objectMapper)).body(); + ResponseUtils.ofJson(SnippetList.class, objectMapper)) + .body(); } /** @@ -144,7 +147,8 @@ public void closeSession(String sessionId) */ public String startupScript() throws RequestFailedException, ConnectionFailedException { return send(baseUrl + "startup_script/" + STARTUP_SCRIPT_ID, HttpRequest.newBuilder().GET(), - BodyHandlers.ofString()).body(); + BodyHandlers.ofString()) + .body(); } private HttpResponse send(String url, HttpRequest.Builder builder, BodyHandler body) diff --git a/application/src/main/java/org/togetherjava/tjbot/features/jshell/backend/dto/JShellEvalAbortionCause.java b/application/src/main/java/org/togetherjava/tjbot/features/jshell/backend/dto/JShellEvalAbortionCause.java index a696c685e3..fed5b9cba9 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/jshell/backend/dto/JShellEvalAbortionCause.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/jshell/backend/dto/JShellEvalAbortionCause.java @@ -26,11 +26,13 @@ record TimeoutAbortionCause() implements JShellEvalAbortionCause { * @param exceptionMessage the message of the exception */ @JsonTypeName("UNCAUGHT_EXCEPTION") - record UnhandledExceptionAbortionCause(String exceptionClass, String exceptionMessage) implements JShellEvalAbortionCause { + record UnhandledExceptionAbortionCause(String exceptionClass, + String exceptionMessage) implements JShellEvalAbortionCause { } /** * The code doesn't compile, but at least the syntax is correct. + * * @param errors the compilation errors */ @JsonTypeName("COMPILE_TIME_ERROR") diff --git a/application/src/main/java/org/togetherjava/tjbot/features/jshell/renderer/RendererUtils.java b/application/src/main/java/org/togetherjava/tjbot/features/jshell/renderer/RendererUtils.java index 48dfe416e1..c05200e14d 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/jshell/renderer/RendererUtils.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/jshell/renderer/RendererUtils.java @@ -22,9 +22,12 @@ private RendererUtils() {} static String abortionCauseToString(JShellEvalAbortionCause abortionCause) { return switch (abortionCause) { case JShellEvalAbortionCause.TimeoutAbortionCause ignored -> "Allowed time exceeded."; - case JShellEvalAbortionCause.UnhandledExceptionAbortionCause c -> "Uncaught exception:\n" + c.exceptionClass() + ":" + c.exceptionMessage(); - case JShellEvalAbortionCause.CompileTimeErrorAbortionCause c -> "The code doesn't compile:\n" + String.join("\n", c.errors()); - case JShellEvalAbortionCause.SyntaxErrorAbortionCause ignored -> "The code doesn't compile, there are syntax errors in this code."; + case JShellEvalAbortionCause.UnhandledExceptionAbortionCause c -> + "Uncaught exception:\n" + c.exceptionClass() + ":" + c.exceptionMessage(); + case JShellEvalAbortionCause.CompileTimeErrorAbortionCause c -> + "The code doesn't compile:\n" + String.join("\n", c.errors()); + case JShellEvalAbortionCause.SyntaxErrorAbortionCause ignored -> + "The code doesn't compile, there are syntax errors in this code."; }; } diff --git a/application/src/main/java/org/togetherjava/tjbot/features/moderation/BanCommand.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/BanCommand.java index f5032c7118..8b2bcb9fb7 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/moderation/BanCommand.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/BanCommand.java @@ -65,9 +65,10 @@ public BanCommand(ModerationActionsStore actionsStore) { .addOptions(durationData) .addOption(OptionType.STRING, REASON_OPTION, "Why the user should be banned", true) .addOptions(new OptionData(OptionType.INTEGER, DELETE_HISTORY_OPTION, - "the message history to delete", true).addChoice("none", 0) - .addChoice("day", 1) - .addChoice("week", 7)); + "the message history to delete", true) + .addChoice("none", 0) + .addChoice("day", 1) + .addChoice("week", 7)); this.actionsStore = Objects.requireNonNull(actionsStore); } @@ -134,7 +135,8 @@ private RestAction banUserFlow(User target, Member author, int deleteHistoryDays, Guild guild, SlashCommandInteractionEvent event) { return sendDm(target, temporaryData, reason, guild) .flatMap(hasSentDm -> banUser(target, author, temporaryData, reason, deleteHistoryDays, - guild).map(banResult -> hasSentDm)) + guild) + .map(banResult -> hasSentDm)) .map(hasSentDm -> sendFeedback(hasSentDm, target, author, temporaryData, reason)) .flatMap(event.getHook()::sendMessageEmbeds); } @@ -209,8 +211,8 @@ public void onSlashCommand(SlashCommandInteractionEvent event) { return handleNotAlreadyBannedResponse( Objects.requireNonNull(alreadyBanned.getFailure()), hook, guild, target) - .orElseGet(() -> banUserFlow(target, author, temporaryData.orElse(null), - reason, deleteHistoryDays, guild, event)); + .orElseGet(() -> banUserFlow(target, author, temporaryData.orElse(null), reason, + deleteHistoryDays, guild, event)); }).queue(); } } diff --git a/application/src/main/java/org/togetherjava/tjbot/features/moderation/TransferQuestionCommand.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/TransferQuestionCommand.java index aadf9ab61a..ba49c56d47 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/moderation/TransferQuestionCommand.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/TransferQuestionCommand.java @@ -164,7 +164,8 @@ private void transferFlow(ModalInteractionEvent event, String channelId, String .retrieveUserById(authorId) .flatMap(fetchedUser -> createForumPost(event, fetchedUser)) .flatMap(createdForumPost -> dmUser(event.getChannel(), createdForumPost, - event.getGuild()).and(sendMessageToTransferrer.apply(createdForumPost))) + event.getGuild()) + .and(sendMessageToTransferrer.apply(createdForumPost))) .flatMap(dmSent -> deleteOriginalMessage(event.getJDA(), channelId, messageId)) .queue(); } diff --git a/application/src/main/java/org/togetherjava/tjbot/features/moderation/audit/AuditCommand.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/audit/AuditCommand.java index c9191f5760..0ac24225b6 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/moderation/audit/AuditCommand.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/audit/AuditCommand.java @@ -81,9 +81,10 @@ public void onSlashCommand(SlashCommandInteractionEvent event) { } auditUser(MessageCreateBuilder::new, guild.getIdLong(), target.getIdLong(), - event.getMember().getIdLong(), -1, event.getJDA()).map(MessageCreateBuilder::build) - .flatMap(event::reply) - .queue(); + event.getMember().getIdLong(), -1, event.getJDA()) + .map(MessageCreateBuilder::build) + .flatMap(event::reply) + .queue(); } private boolean handleChecks(Member bot, Member author, @Nullable Member target, @@ -272,6 +273,9 @@ public void onButtonClick(ButtonInteractionEvent event, List args) { int pageToDisplay = currentPage + turnPageBy; auditUser(MessageEditBuilder::new, guildId, targetId, buttonUserId, pageToDisplay, - event.getJDA()).map(MessageEditBuilder::build).flatMap(event::editMessage).queue(); + event.getJDA()) + .map(MessageEditBuilder::build) + .flatMap(event::editMessage) + .queue(); } } diff --git a/application/src/main/java/org/togetherjava/tjbot/features/moderation/scam/ScamBlocker.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/scam/ScamBlocker.java index f60dc91b41..1aff65d603 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/moderation/scam/ScamBlocker.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/scam/ScamBlocker.java @@ -142,8 +142,8 @@ private void takeAction(MessageReceivedEvent event) { "The OFF-mode should be detected earlier already to prevent expensive computation"); case ONLY_LOG -> takeActionLogOnly(event); case APPROVE_FIRST -> takeActionApproveFirst(event); - case AUTO_DELETE_BUT_APPROVE_QUARANTINE -> takeActionAutoDeleteButApproveQuarantine( - event); + case AUTO_DELETE_BUT_APPROVE_QUARANTINE -> + takeActionAutoDeleteButApproveQuarantine(event); case AUTO_DELETE_AND_QUARANTINE -> takeActionAutoDeleteAndQuarantine(event); default -> throw new IllegalArgumentException("Mode not supported: " + mode); } diff --git a/application/src/main/java/org/togetherjava/tjbot/features/moderation/temp/RevocableRoleBasedAction.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/temp/RevocableRoleBasedAction.java index c3fbb30efb..220ba5a249 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/moderation/temp/RevocableRoleBasedAction.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/temp/RevocableRoleBasedAction.java @@ -39,9 +39,9 @@ public FailureIdentification handleRevokeFailure(Throwable failure, long targetI case UNKNOWN_ROLE -> logger.warn( "Attempted to revoke a temporary {} but the {} role can not be found.", actionName, actionName); - case MISSING_PERMISSIONS -> logger.warn( - "Attempted to revoke a temporary {} but the bot lacks permission.", - actionName); + case MISSING_PERMISSIONS -> + logger.warn("Attempted to revoke a temporary {} but the bot lacks permission.", + actionName); default -> { return FailureIdentification.UNKNOWN; } diff --git a/application/src/main/java/org/togetherjava/tjbot/features/reminder/ReminderCommand.java b/application/src/main/java/org/togetherjava/tjbot/features/reminder/ReminderCommand.java index 273e832988..3919e95467 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/reminder/ReminderCommand.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/reminder/ReminderCommand.java @@ -90,7 +90,7 @@ public ReminderCommand(Database database) { // "/remind at" next to "/remind in" and use subcommands then OptionData timeAmount = new OptionData(OptionType.INTEGER, TIME_AMOUNT_OPTION, "period to remind you in, the amount of time (e.g. [5] weeks)", true) - .setRequiredRange(MIN_TIME_AMOUNT, MAX_TIME_AMOUNT); + .setRequiredRange(MIN_TIME_AMOUNT, MAX_TIME_AMOUNT); OptionData timeUnit = new OptionData(OptionType.STRING, TIME_UNIT_OPTION, "period to remind you in, the unit of time (e.g. 5 [weeks])", true); TIME_UNITS.forEach(unit -> timeUnit.addChoice(unit, unit)); @@ -114,8 +114,8 @@ public void onSlashCommand(SlashCommandInteractionEvent event) { case CREATE_SUBCOMMAND -> handleCreateCommand(event); case CANCEL_COMMAND -> handleCancelCommand(event); case LIST_SUBCOMMAND -> handleListCommand(event); - default -> throw new AssertionError( - "Unexpected Subcommand: " + event.getSubcommandName()); + default -> + throw new AssertionError("Unexpected Subcommand: " + event.getSubcommandName()); } } diff --git a/application/src/main/java/org/togetherjava/tjbot/features/system/BotCore.java b/application/src/main/java/org/togetherjava/tjbot/features/system/BotCore.java index 83f7496496..6b612eb3fb 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/system/BotCore.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/system/BotCore.java @@ -241,7 +241,8 @@ public void onSlashCommandInteraction(SlashCommandInteractionEvent event) { event.getGuild()); COMMAND_SERVICE.execute( () -> requireUserInteractor(UserInteractionType.SLASH_COMMAND.getPrefixedName(name), - SlashCommand.class).onSlashCommand(event)); + SlashCommand.class) + .onSlashCommand(event)); } @Override @@ -252,7 +253,8 @@ public void onCommandAutoCompleteInteraction(final CommandAutoCompleteInteractio event.getFullCommandName(), event.getId(), event.getGuild()); COMMAND_SERVICE.execute( () -> requireUserInteractor(UserInteractionType.SLASH_COMMAND.getPrefixedName(name), - SlashCommand.class).onAutoComplete(event)); + SlashCommand.class) + .onAutoComplete(event)); } @Override @@ -309,7 +311,8 @@ public void onMessageContextInteraction(final MessageContextInteractionEvent eve event.getId(), event.getGuild()); COMMAND_SERVICE.execute(() -> requireUserInteractor( UserInteractionType.MESSAGE_CONTEXT_COMMAND.getPrefixedName(name), - MessageContextCommand.class).onMessageContext(event)); + MessageContextCommand.class) + .onMessageContext(event)); } @Override @@ -320,7 +323,8 @@ public void onUserContextInteraction(final UserContextInteractionEvent event) { event.getGuild()); COMMAND_SERVICE.execute(() -> requireUserInteractor( UserInteractionType.USER_CONTEXT_COMMAND.getPrefixedName(name), - UserContextCommand.class).onUserContext(event)); + UserContextCommand.class) + .onUserContext(event)); } /** diff --git a/application/src/main/java/org/togetherjava/tjbot/features/tags/TagManageCommand.java b/application/src/main/java/org/togetherjava/tjbot/features/tags/TagManageCommand.java index c6b327ecf2..36c9558c15 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/tags/TagManageCommand.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/tags/TagManageCommand.java @@ -80,23 +80,21 @@ public TagManageCommand(TagSystem tagSystem, ModAuditLogWriter modAuditLogWriter // 'delete' getData().addSubcommands(new SubcommandData(Subcommand.RAW.name, "View the raw content of a tag, without Discord interpreting any of its content") - .addOption(OptionType.STRING, ID_OPTION, ID_DESCRIPTION, true), + .addOption(OptionType.STRING, ID_OPTION, ID_DESCRIPTION, true), new SubcommandData(Subcommand.CREATE.name, "Creates a new tag") .addOption(OptionType.STRING, ID_OPTION, ID_DESCRIPTION, true) .addOption(OptionType.STRING, CONTENT_OPTION, CONTENT_DESCRIPTION, true), new SubcommandData(Subcommand.CREATE_WITH_MESSAGE.name, "Creates a new tag. Content is retrieved from the given message.") - .addOption(OptionType.STRING, ID_OPTION, ID_DESCRIPTION, true) - .addOption(OptionType.STRING, MESSAGE_ID_OPTION, MESSAGE_ID_DESCRIPTION, - true), + .addOption(OptionType.STRING, ID_OPTION, ID_DESCRIPTION, true) + .addOption(OptionType.STRING, MESSAGE_ID_OPTION, MESSAGE_ID_DESCRIPTION, true), new SubcommandData(Subcommand.EDIT.name, "Edits a tag, the old content is replaced") .addOption(OptionType.STRING, ID_OPTION, ID_DESCRIPTION, true) .addOption(OptionType.STRING, CONTENT_OPTION, CONTENT_DESCRIPTION, true), new SubcommandData(Subcommand.EDIT_WITH_MESSAGE.name, "Edits a tag, the old content is replaced. Content is retrieved from the given message.") - .addOption(OptionType.STRING, ID_OPTION, ID_DESCRIPTION, true) - .addOption(OptionType.STRING, MESSAGE_ID_OPTION, MESSAGE_ID_DESCRIPTION, - true), + .addOption(OptionType.STRING, ID_OPTION, ID_DESCRIPTION, true) + .addOption(OptionType.STRING, MESSAGE_ID_OPTION, MESSAGE_ID_DESCRIPTION, true), new SubcommandData(Subcommand.DELETE.name, "Deletes a tag") .addOption(OptionType.STRING, ID_OPTION, ID_DESCRIPTION, true)); } diff --git a/application/src/main/java/org/togetherjava/tjbot/features/utils/RateLimiter.java b/application/src/main/java/org/togetherjava/tjbot/features/utils/RateLimiter.java index 8dda5c8c91..87e4abb783 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/utils/RateLimiter.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/utils/RateLimiter.java @@ -21,8 +21,8 @@ public class RateLimiter { * Creates a rate limiter. *

* Defines a window and a number of request, for example, if 10 requests should be allowed per 5 - * seconds, so 10/5s, the following should be called: {@snippet java: new - * RateLimit(Duration.of(5, TimeUnit.SECONDS), 10) } + * seconds, so 10/5s, the following should be called: + * {@snippet java: new RateLimit(Duration.of(5, TimeUnit.SECONDS), 10) } * * @param duration the duration of window * @param allowedRequests the number of requests to allow in the window diff --git a/application/src/test/java/org/togetherjava/tjbot/features/reminder/RemindRoutineTest.java b/application/src/test/java/org/togetherjava/tjbot/features/reminder/RemindRoutineTest.java index 96e83aebd7..d68ac698a3 100644 --- a/application/src/test/java/org/togetherjava/tjbot/features/reminder/RemindRoutineTest.java +++ b/application/src/test/java/org/togetherjava/tjbot/features/reminder/RemindRoutineTest.java @@ -79,7 +79,7 @@ private TextChannel createAndSetupUnknownChannel() { TextChannel channel = jdaTester.createTextChannelSpy(unknownChannelId); when(jdaTester.getJdaMock() .getChannelById(ArgumentMatchers.>any(), eq(unknownChannelId))) - .thenReturn(null); + .thenReturn(null); return channel; } diff --git a/application/src/test/java/org/togetherjava/tjbot/jda/JdaTester.java b/application/src/test/java/org/togetherjava/tjbot/jda/JdaTester.java index 944a978f51..44cd096f33 100644 --- a/application/src/test/java/org/togetherjava/tjbot/jda/JdaTester.java +++ b/application/src/test/java/org/togetherjava/tjbot/jda/JdaTester.java @@ -174,7 +174,9 @@ public JdaTester() { when(jda.getRateLimitPool()).thenReturn(RATE_LIMIT_POOL); when(jda.getSessionController()).thenReturn(new ConcurrentSessionController()); doReturn(new Requester(jda, new AuthorizationConfig(TEST_TOKEN), new RestConfig(), - rateLimiter)).when(jda).getRequester(); + rateLimiter)) + .when(jda) + .getRequester(); replyAction = mock(ReplyCallbackActionImpl.class); when(replyAction.setEphemeral(anyBoolean())).thenReturn(replyAction); @@ -680,8 +682,8 @@ private void mockMessage(Message message, ChannelType channelType) { MessageChannelUnion channel = switch (channelType) { case TEXT -> textChannel; case GUILD_PUBLIC_THREAD -> threadChannel; - default -> throw new IllegalArgumentException( - "Unsupported channel type: " + channelType); + default -> + throw new IllegalArgumentException("Unsupported channel type: " + channelType); }; doReturn(messageCreateAction).when(message).reply(anyString()); diff --git a/application/src/test/java/org/togetherjava/tjbot/jda/SlashCommandInteractionEventBuilder.java b/application/src/test/java/org/togetherjava/tjbot/jda/SlashCommandInteractionEventBuilder.java index 62ed9a81cd..3a468b3f6a 100644 --- a/application/src/test/java/org/togetherjava/tjbot/jda/SlashCommandInteractionEventBuilder.java +++ b/application/src/test/java/org/togetherjava/tjbot/jda/SlashCommandInteractionEventBuilder.java @@ -51,16 +51,16 @@ * * // /days start:10.01.2021 end:13.01.2021 * jdaTester.createSlashCommandInteractionEvent(command) - * .setOption("start", "10.01.2021") - * .setOption("end", "13.01.2021") - * .build(); + * .setOption("start", "10.01.2021") + * .setOption("end", "13.01.2021") + * .build(); * * // /db put key:foo value:bar * jdaTester.createSlashCommandInteractionEvent(command) - * .setSubcommand("put") - * .setOption("key", "foo") - * .setOption("value", "bar") - * .build(); + * .setSubcommand("put") + * .setOption("key", "foo") + * .setOption("value", "bar") + * .build(); * } * */ @@ -411,6 +411,6 @@ private SubcommandData requireSubcommand(String name) { }); } - private record Option (String name, T value, OptionType type) { + private record Option(String name, T value, OptionType type) { } } diff --git a/build.gradle b/build.gradle index 1601f8e921..4f5771682f 100644 --- a/build.gradle +++ b/build.gradle @@ -78,8 +78,7 @@ subprojects { // we use it as catch-all for external dependencies like JDA // '\\#` is prefix for static imports importOrder('','org.togetherjava', 'javax', 'java', '\\#') - // TODO Use latest eclipse jdt formatter, issue tracking this: https://github.com/Together-Java/TJ-Bot/issues/605 - eclipse('4.19').configFile("${rootProject.rootDir}/meta/formatting/google-style-eclipse.xml") + eclipse().configFile("${rootProject.rootDir}/meta/formatting/google-style-eclipse.xml") } } diff --git a/meta/formatting/google-style-eclipse.xml b/meta/formatting/google-style-eclipse.xml index c3fb303c9d..3336eaf2cd 100644 --- a/meta/formatting/google-style-eclipse.xml +++ b/meta/formatting/google-style-eclipse.xml @@ -1,6 +1,9 @@ + + + @@ -58,7 +61,6 @@ - @@ -201,7 +203,6 @@ - @@ -284,7 +285,6 @@ -