From b24f10b6f8ed4a914172c9b187519c08dc59e264 Mon Sep 17 00:00:00 2001 From: Taz03 Date: Sat, 25 Feb 2023 03:59:04 +0530 Subject: [PATCH 1/9] updated spotless files --- build.gradle | 4 +- meta/formatting/google-style-eclipse.xml | 329 +++-------------------- 2 files changed, 37 insertions(+), 296 deletions(-) diff --git a/build.gradle b/build.gradle index c3a1c194f1..eb1d047a60 100644 --- a/build.gradle +++ b/build.gradle @@ -80,9 +80,9 @@ subprojects { // empty string '' covers all imports that aren't explicitly specified, // we use it as catch-all for external dependencies like JDA // '\\#` is prefix for static imports - importOrder('','org.togetherjava', 'javax', 'java', '\\#') + 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.0').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..1d76f98577 100644 --- a/meta/formatting/google-style-eclipse.xml +++ b/meta/formatting/google-style-eclipse.xml @@ -1,336 +1,77 @@ - - - - - - - - + + + + + + + + - - - - - - - - - - - - - - + + + + + - - - - - - + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + + + + + + + + + - \ No newline at end of file + From dc94e76d25089f253270a290744316e51c59a964 Mon Sep 17 00:00:00 2001 From: Tanish <73871477+Taz03@users.noreply.github.com> Date: Wed, 8 Mar 2023 19:47:02 +0530 Subject: [PATCH 2/9] updated profile version --- meta/formatting/google-style-eclipse.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/meta/formatting/google-style-eclipse.xml b/meta/formatting/google-style-eclipse.xml index 1d76f98577..d68fb664f6 100644 --- a/meta/formatting/google-style-eclipse.xml +++ b/meta/formatting/google-style-eclipse.xml @@ -1,6 +1,6 @@ - - + + From ea18f5aa30db2583f7b3605ac4c51651cf5e673c Mon Sep 17 00:00:00 2001 From: Taz03 Date: Tue, 14 Mar 2023 00:23:48 +0530 Subject: [PATCH 3/9] fixed config --- .../java/org/togetherjava/tjbot/features/Routine.java | 3 +-- .../features/bookmarks/BookmarksListRemoveHandler.java | 6 +++--- .../tjbot/features/code/CodeMessageManualDetection.java | 3 ++- .../tjbot/features/componentids/ComponentId.java | 3 +-- .../componentids/InvalidComponentIdFormatException.java | 3 ++- .../features/filesharing/FileSharingMessageListener.java | 3 ++- .../mathcommands/wolframalpha/WolframAlphaHandler.java | 3 +-- .../tjbot/features/moderation/ModerationUtils.java | 3 +-- .../moderation/RejoinModerationRoleListener.java | 3 +-- .../tjbot/features/tophelper/TopHelpersCommand.java | 9 +++------ .../togetherjava/tjbot/features/utils/LinkPreviews.java | 3 +-- .../tjbot/logging/discord/DiscordLogAppender.java | 3 ++- .../tjbot/features/utils/MessageUtilsTest.java | 6 ++---- .../tjbot/features/utils/StringDistancesTest.java | 9 +++------ .../tjbot/jda/SlashCommandInteractionEventBuilder.java | 3 +-- build.gradle | 1 - meta/formatting/google-style-eclipse.xml | 4 ++-- 17 files changed, 28 insertions(+), 40 deletions(-) diff --git a/application/src/main/java/org/togetherjava/tjbot/features/Routine.java b/application/src/main/java/org/togetherjava/tjbot/features/Routine.java index b5d2f614af..094efa3f08 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/Routine.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/Routine.java @@ -44,8 +44,7 @@ public interface Routine extends Feature { * @param unit the time unit for both, {@link #initialDuration} and {@link #duration}, e.g. * seconds */ - record Schedule(ScheduleMode mode, long initialDuration, long duration, TimeUnit unit) { - } + record Schedule(ScheduleMode mode, long initialDuration, long duration, TimeUnit unit) {} /** * Whether subsequent executions of a routine are executed at a fixed rate or are delayed. 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 909b9b7f57..d51158974f 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 @@ -140,7 +140,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); @@ -293,8 +294,7 @@ private enum RequestType { REMOVE } - private record PageEntry(int bookmarkNumber, BookmarksRecord bookmark) { - } + private record PageEntry(int bookmarkNumber, BookmarksRecord bookmark) {} private record Request(RequestType type, String componentName, int pageToDisplayIndex, Set bookmarkIdsToRemove) { diff --git a/application/src/main/java/org/togetherjava/tjbot/features/code/CodeMessageManualDetection.java b/application/src/main/java/org/togetherjava/tjbot/features/code/CodeMessageManualDetection.java index 3f7dcf6503..c164786dc6 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/code/CodeMessageManualDetection.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/code/CodeMessageManualDetection.java @@ -12,7 +12,8 @@ * {@link CodeMessageHandler} for further processing. */ public final class CodeMessageManualDetection extends BotCommandAdapter - implements MessageContextCommand { + implements + MessageContextCommand { private final CodeMessageHandler codeMessageHandler; /** diff --git a/application/src/main/java/org/togetherjava/tjbot/features/componentids/ComponentId.java b/application/src/main/java/org/togetherjava/tjbot/features/componentids/ComponentId.java index d77edfb132..d6f45484b5 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/componentids/ComponentId.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/componentids/ComponentId.java @@ -13,5 +13,4 @@ * this component ID, when triggered * @param elements the additional elements to carry along this component ID, empty if not desired */ -public record ComponentId(String userInteractorName, List elements) { -} +public record ComponentId(String userInteractorName, List elements) {} diff --git a/application/src/main/java/org/togetherjava/tjbot/features/componentids/InvalidComponentIdFormatException.java b/application/src/main/java/org/togetherjava/tjbot/features/componentids/InvalidComponentIdFormatException.java index 01200f6357..2605eb9811 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/componentids/InvalidComponentIdFormatException.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/componentids/InvalidComponentIdFormatException.java @@ -14,7 +14,8 @@ public final class InvalidComponentIdFormatException extends RuntimeException { /** * Creates a new instance. */ - public InvalidComponentIdFormatException() {} + public InvalidComponentIdFormatException() { + } /** * Creates a new instance with a given cause. diff --git a/application/src/main/java/org/togetherjava/tjbot/features/filesharing/FileSharingMessageListener.java b/application/src/main/java/org/togetherjava/tjbot/features/filesharing/FileSharingMessageListener.java index 3f511bda8f..2a57fb23f1 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/filesharing/FileSharingMessageListener.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/filesharing/FileSharingMessageListener.java @@ -41,7 +41,8 @@ * {@link FileSharingMessageListener#extensionFilter}. */ public final class FileSharingMessageListener extends MessageReceiverAdapter - implements UserInteractor { + implements + UserInteractor { private static final Logger logger = LoggerFactory.getLogger(FileSharingMessageListener.class); private final ComponentIdInteractor componentIdInteractor = diff --git a/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/WolframAlphaHandler.java b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/WolframAlphaHandler.java index ca17d32346..c4f0329037 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/WolframAlphaHandler.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/WolframAlphaHandler.java @@ -230,8 +230,7 @@ private String buildTitle() { return query + " - " + SERVICE_NAME; } - record HandlerResponse(List embeds, List attachments) { - } + record HandlerResponse(List embeds, List attachments) {} record Attachment(String name, byte[] data) { @Override diff --git a/application/src/main/java/org/togetherjava/tjbot/features/moderation/ModerationUtils.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/ModerationUtils.java index f8408a520f..5e3f54ee12 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/moderation/ModerationUtils.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/ModerationUtils.java @@ -434,6 +434,5 @@ static RestAction sendModActionDm(RestAction embedBuilder * @param duration a human-readable text representing the duration of the temporary action, such * as {@code "1 day"}. */ - record TemporaryData(Instant expiresAt, String duration) { - } + record TemporaryData(Instant expiresAt, String duration) {} } diff --git a/application/src/main/java/org/togetherjava/tjbot/features/moderation/RejoinModerationRoleListener.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/RejoinModerationRoleListener.java index 35645e7ae7..f6d5e819e3 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/moderation/RejoinModerationRoleListener.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/RejoinModerationRoleListener.java @@ -107,6 +107,5 @@ private static void applyModerationRole(ModerationRole moderationRole, Member me } private record ModerationRole(String actionName, ModerationAction applyAction, - ModerationAction revokeAction, Function guildToRole) { - } + ModerationAction revokeAction, Function guildToRole) {} } diff --git a/application/src/main/java/org/togetherjava/tjbot/features/tophelper/TopHelpersCommand.java b/application/src/main/java/org/togetherjava/tjbot/features/tophelper/TopHelpersCommand.java index 52692f139b..e75eac796b 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/tophelper/TopHelpersCommand.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/tophelper/TopHelpersCommand.java @@ -188,12 +188,9 @@ private static String dataTableToAsciiTable(Collection> dataTable, return AsciiTable.getTable(AsciiTable.BASIC_ASCII_NO_DATA_SEPARATORS, dataTable, columns); } - private record TimeRange(Instant start, Instant end, String description) { - } + private record TimeRange(Instant start, Instant end, String description) {} - private record TopHelperResult(long authorId, BigDecimal messageLengths) { - } + private record TopHelperResult(long authorId, BigDecimal messageLengths) {} - private record ColumnSetting(String headerName, HorizontalAlign alignment) { - } + private record ColumnSetting(String headerName, HorizontalAlign alignment) {} } diff --git a/application/src/main/java/org/togetherjava/tjbot/features/utils/LinkPreviews.java b/application/src/main/java/org/togetherjava/tjbot/features/utils/LinkPreviews.java index f5bbb5f353..8b5ecbe0dd 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/utils/LinkPreviews.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/utils/LinkPreviews.java @@ -165,8 +165,7 @@ private static CompletableFuture> readLinkContent(String l }); } - private record HttpContent(String type, InputStream dataStream) { - } + private record HttpContent(String type, InputStream dataStream) {} private static CompletableFuture> parseWebsite(String link, String attachmentName, InputStream websiteContent) { diff --git a/application/src/main/java/org/togetherjava/tjbot/logging/discord/DiscordLogAppender.java b/application/src/main/java/org/togetherjava/tjbot/logging/discord/DiscordLogAppender.java index c826e5066e..f44ac26e7e 100644 --- a/application/src/main/java/org/togetherjava/tjbot/logging/discord/DiscordLogAppender.java +++ b/application/src/main/java/org/togetherjava/tjbot/logging/discord/DiscordLogAppender.java @@ -37,7 +37,8 @@ static DiscordLogAppenderBuilder newBuilder() { static final class DiscordLogAppenderBuilder extends AbstractAppender.Builder - implements org.apache.logging.log4j.core.util.Builder { + implements + org.apache.logging.log4j.core.util.Builder { @PluginBuilderAttribute @Required diff --git a/application/src/test/java/org/togetherjava/tjbot/features/utils/MessageUtilsTest.java b/application/src/test/java/org/togetherjava/tjbot/features/utils/MessageUtilsTest.java index a9777cab0a..23bb2fee4f 100644 --- a/application/src/test/java/org/togetherjava/tjbot/features/utils/MessageUtilsTest.java +++ b/application/src/test/java/org/togetherjava/tjbot/features/utils/MessageUtilsTest.java @@ -170,8 +170,7 @@ void escapeMarkdown() { } } - private record TestCaseEscape(String testName, String escapedMessage, String originalMessage) { - } + private record TestCaseEscape(String testName, String escapedMessage, String originalMessage) {} @Test void abbreviate() { @@ -192,8 +191,7 @@ void abbreviate() { } private record TestCaseAbbreviate(String testName, String abbreviatedMessage, - String originalMessage, int limit) { - } + String originalMessage, int limit) {} private static List provideExtractCodeTests() { List tests = new ArrayList<>(); diff --git a/application/src/test/java/org/togetherjava/tjbot/features/utils/StringDistancesTest.java b/application/src/test/java/org/togetherjava/tjbot/features/utils/StringDistancesTest.java index 6454ca2bbb..5e17e6de32 100644 --- a/application/src/test/java/org/togetherjava/tjbot/features/utils/StringDistancesTest.java +++ b/application/src/test/java/org/togetherjava/tjbot/features/utils/StringDistancesTest.java @@ -12,8 +12,7 @@ final class StringDistancesTest { @Test void closeMatches() { record TestCase(String name, Collection expectedSuggestions, String prefix, - Collection candidates, int limit) { - } + Collection candidates, int limit) {} List candidates = List.of("c", "c#", "c++", "emacs", "foo", "hello", "java", "js", "key", "nvim", "py", "tag", "taz", "vi", "vim"); @@ -38,8 +37,7 @@ record TestCase(String name, Collection expectedSuggestions, String pref @Test void editDistance() { - record TestCase(String name, int expectedDistance, String source, String destination) { - } + record TestCase(String name, int expectedDistance, String source, String destination) {} List tests = List.of(new TestCase("identity", 0, "-", "-"), new TestCase("empty_identity", 0, "", ""), new TestCase("empty_remove", 1, "a", ""), new TestCase("empty_add", 1, "", "a"), new TestCase("basic", 4, "bloed", "doof"), @@ -57,8 +55,7 @@ record TestCase(String name, int expectedDistance, String source, String destina @Test void prefixEditDistance() { - record TestCase(String name, int expectedDistance, String source, String destination) { - } + record TestCase(String name, int expectedDistance, String source, String destination) {} List tests = List.of(new TestCase("identity", 0, "-", "-"), new TestCase("empty_identity", 0, "", ""), new TestCase("empty_remove", 1, "a", ""), new TestCase("empty_add", 0, "", "a"), new TestCase("basic", 4, "bloed", "doof"), 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 f926ecf69e..10f30653e6 100644 --- a/application/src/test/java/org/togetherjava/tjbot/jda/SlashCommandInteractionEventBuilder.java +++ b/application/src/test/java/org/togetherjava/tjbot/jda/SlashCommandInteractionEventBuilder.java @@ -409,6 +409,5 @@ 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 eb1d047a60..b663a0bc16 100644 --- a/build.gradle +++ b/build.gradle @@ -81,7 +81,6 @@ 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().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 d68fb664f6..1bd9463ac8 100644 --- a/meta/formatting/google-style-eclipse.xml +++ b/meta/formatting/google-style-eclipse.xml @@ -67,8 +67,8 @@ - - + + From 995c4ccfd48fb4408bdb10aaee203491ee38381d Mon Sep 17 00:00:00 2001 From: Taz03 Date: Tue, 14 Mar 2023 00:59:18 +0530 Subject: [PATCH 4/9] lambda --- .../features/basic/SuggestionsUpDownVoter.java | 3 +-- .../tjbot/features/code/CodeMessageHandler.java | 17 +++++++++-------- .../mediaonly/MediaOnlyChannelListener.java | 5 +++-- .../features/moderation/scam/ScamBlocker.java | 9 +++++---- .../temp/TemporaryModerationRoutine.java | 3 +-- .../tjbot/features/reminder/RemindRoutine.java | 3 +-- meta/formatting/google-style-eclipse.xml | 2 ++ 7 files changed, 22 insertions(+), 20 deletions(-) diff --git a/application/src/main/java/org/togetherjava/tjbot/features/basic/SuggestionsUpDownVoter.java b/application/src/main/java/org/togetherjava/tjbot/features/basic/SuggestionsUpDownVoter.java index 0a5add113b..7256423c95 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/basic/SuggestionsUpDownVoter.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/basic/SuggestionsUpDownVoter.java @@ -77,8 +77,7 @@ private static void reactWith(String emojiName, Emoji fallbackEmoji, Guild guild "Unable to vote on a suggestion with the configured emoji ('{}'), using fallback instead.", emojiName); return message.addReaction(fallbackEmoji); - }).queue(ignored -> { - }, exception -> { + }).queue(ignored -> {}, exception -> { if (exception instanceof ErrorResponseException responseException && responseException.getErrorResponse() == ErrorResponse.REACTION_BLOCKED) { // User blocked the bot, hence the bot can not add reactions to their messages. diff --git a/application/src/main/java/org/togetherjava/tjbot/features/code/CodeMessageHandler.java b/application/src/main/java/org/togetherjava/tjbot/features/code/CodeMessageHandler.java index 3073d665ee..67592e81f0 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/code/CodeMessageHandler.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/code/CodeMessageHandler.java @@ -220,10 +220,10 @@ public void onMessageUpdated(MessageUpdateEvent event) { // Re-apply the current action return codeReplyMessage.editMessageEmbeds(maybeCodeAction.orElseThrow().apply(code)); - }).queue(any -> { - }, failure -> logger.warn( - "Attempted to update a code-reply-message ({}), but failed. The original code-message was {}", - codeReplyMessageId, originalMessageId, failure)); + }) + .queue(any -> {}, failure -> logger.warn( + "Attempted to update a code-reply-message ({}), but failed. The original code-message was {}", + codeReplyMessageId, originalMessageId, failure)); } private Optional getCurrentActionFromCodeReply(Message codeReplyMessage) { @@ -249,10 +249,11 @@ public void onMessageDeleted(MessageDeleteEvent event) { // Delete the code reply as well originalMessageToCodeReply.invalidate(originalMessageId); - event.getChannel().deleteMessageById(codeReplyMessageId).queue(any -> { - }, failure -> logger.warn( - "Attempted to delete a code-reply-message ({}), but failed. The original code-message was {}", - codeReplyMessageId, originalMessageId, failure)); + event.getChannel() + .deleteMessageById(codeReplyMessageId) + .queue(any -> {}, failure -> logger.warn( + "Attempted to delete a code-reply-message ({}), but failed. The original code-message was {}", + codeReplyMessageId, originalMessageId, failure)); } private static CodeFence extractCodeOrFallback(String content) { diff --git a/application/src/main/java/org/togetherjava/tjbot/features/mediaonly/MediaOnlyChannelListener.java b/application/src/main/java/org/togetherjava/tjbot/features/mediaonly/MediaOnlyChannelListener.java index 083dd193ec..08d03a8111 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/mediaonly/MediaOnlyChannelListener.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/mediaonly/MediaOnlyChannelListener.java @@ -46,8 +46,9 @@ public void onMessageReceived(MessageReceivedEvent event) { } if (messageHasNoMediaAttached(message)) { - message.delete().flatMap(any -> dmUser(message)).queue(any -> { - }, failure -> tempNotifyUserInChannel(message)); + message.delete() + .flatMap(any -> dmUser(message)) + .queue(any -> {}, failure -> tempNotifyUserInChannel(message)); } } 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 7f5b4d816c..13ac10811b 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 @@ -255,10 +255,11 @@ private void dmUser(MessageReceivedEvent event) { } private void dmUser(Guild guild, long userId, JDA jda) { - jda.openPrivateChannelById(userId).flatMap(channel -> dmUser(guild, channel)).queue(any -> { - }, failure -> logger.debug( - "Unable to send dm message to user {} in guild {} to inform them about a scam message being blocked", - userId, guild.getId(), failure)); + jda.openPrivateChannelById(userId) + .flatMap(channel -> dmUser(guild, channel)) + .queue(any -> {}, failure -> logger.debug( + "Unable to send dm message to user {} in guild {} to inform them about a scam message being blocked", + userId, guild.getId(), failure)); } private RestAction dmUser(Guild guild, PrivateChannel channel) { diff --git a/application/src/main/java/org/togetherjava/tjbot/features/moderation/temp/TemporaryModerationRoutine.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/temp/TemporaryModerationRoutine.java index 4ba0f85967..e38142e501 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/moderation/temp/TemporaryModerationRoutine.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/temp/TemporaryModerationRoutine.java @@ -119,8 +119,7 @@ private void revokeAction(RevocationGroupIdentifier groupIdentifier) { jda.retrieveUserById(groupIdentifier.targetId) .flatMap(target -> executeRevocation(guild, target, groupIdentifier.type)) - .queue(result -> { - }, failure -> handleFailure(failure, groupIdentifier)); + .queue(result -> {}, failure -> handleFailure(failure, groupIdentifier)); } private RestAction executeRevocation(Guild guild, User target, diff --git a/application/src/main/java/org/togetherjava/tjbot/features/reminder/RemindRoutine.java b/application/src/main/java/org/togetherjava/tjbot/features/reminder/RemindRoutine.java index ada8de8bae..fefeb05712 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/reminder/RemindRoutine.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/reminder/RemindRoutine.java @@ -121,8 +121,7 @@ private static MessageEmbed createReminderEmbed(CharSequence content, } private static Consumer doNothing() { - return a -> { - }; + return a -> {}; } private record ReminderRoute(MessageChannel channel, @Nullable User target, diff --git a/meta/formatting/google-style-eclipse.xml b/meta/formatting/google-style-eclipse.xml index 1bd9463ac8..d7c632496d 100644 --- a/meta/formatting/google-style-eclipse.xml +++ b/meta/formatting/google-style-eclipse.xml @@ -69,6 +69,8 @@ + + From 7b72eaba4c24a5f3768a9083d9e1c04adefa4eb8 Mon Sep 17 00:00:00 2001 From: Taz03 Date: Tue, 14 Mar 2023 01:09:48 +0530 Subject: [PATCH 5/9] removed extra lines --- .../java/org/togetherjava/tjbot/features/UserInteractor.java | 2 -- .../tjbot/features/moderation/modmail/ModMailCommand.java | 2 -- .../java/org/togetherjava/tjbot/features/system/BotCore.java | 2 -- .../tjbot/logging/discord/DiscordLogForwarder.java | 1 - .../features/tophelper/TopHelperMessageListenerTest.java | 5 ----- meta/formatting/google-style-eclipse.xml | 3 +-- 6 files changed, 1 insertion(+), 14 deletions(-) diff --git a/application/src/main/java/org/togetherjava/tjbot/features/UserInteractor.java b/application/src/main/java/org/togetherjava/tjbot/features/UserInteractor.java index 6adaf1d0e7..6cdead427b 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/UserInteractor.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/UserInteractor.java @@ -32,7 +32,6 @@ public interface UserInteractor extends Feature { */ String getName(); - /** * Gets the type of interactors this interactor allows. *

@@ -78,7 +77,6 @@ public interface UserInteractor extends Feature { */ void onSelectMenuSelection(SelectMenuInteractionEvent event, List args); - /** * Triggered by the core system when a modal corresponding to this implementation (based on * {@link #getName()}) has been clicked. diff --git a/application/src/main/java/org/togetherjava/tjbot/features/moderation/modmail/ModMailCommand.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/modmail/ModMailCommand.java index 71f1c018af..6e635f4eef 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/moderation/modmail/ModMailCommand.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/modmail/ModMailCommand.java @@ -36,7 +36,6 @@ import java.util.function.Predicate; import java.util.regex.Pattern; - /** * Implements the /modmail command, which allows users to contact a moderator within the server * which forwards messages to moderators in a dedicated channel given by @@ -57,7 +56,6 @@ public final class ModMailCommand extends SlashCommandAdapter { private final Predicate configModGroupPattern; private final String configModMailChannelPattern; - /** * Creates a new instance. * 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 efa539db49..e5c71ba2be 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 @@ -104,7 +104,6 @@ public BotCore(JDA jda, Database database, Config config) { .getPrefixedName(userInteractor.getName()), Function.identity())); - // Component Id Store componentIdStore = new ComponentIdStore(database); componentIdStore.addComponentIdRemovedListener(BotCore::onComponentIdRemoved); @@ -410,7 +409,6 @@ private T requireUserInteractor(String prefixedName, return typeToken.cast(userInteractor); } - @SuppressWarnings("EmptyMethod") private static void onComponentIdRemoved(ComponentId componentId) { // NOTE As of now, we do not act on this event, but we could use it diff --git a/application/src/main/java/org/togetherjava/tjbot/logging/discord/DiscordLogForwarder.java b/application/src/main/java/org/togetherjava/tjbot/logging/discord/DiscordLogForwarder.java index ece1a49a5a..ca7a217b4f 100644 --- a/application/src/main/java/org/togetherjava/tjbot/logging/discord/DiscordLogForwarder.java +++ b/application/src/main/java/org/togetherjava/tjbot/logging/discord/DiscordLogForwarder.java @@ -83,7 +83,6 @@ final class DiscordLogForwarder { SERVICE.scheduleWithFixedDelay(this::processPendingLogs, 5, 5, TimeUnit.SECONDS); } - /** * Forwards the given log message to Discord. *

diff --git a/application/src/test/java/org/togetherjava/tjbot/features/tophelper/TopHelperMessageListenerTest.java b/application/src/test/java/org/togetherjava/tjbot/features/tophelper/TopHelperMessageListenerTest.java index e4cb316a6e..a37d96a029 100644 --- a/application/src/test/java/org/togetherjava/tjbot/features/tophelper/TopHelperMessageListenerTest.java +++ b/application/src/test/java/org/togetherjava/tjbot/features/tophelper/TopHelperMessageListenerTest.java @@ -101,7 +101,6 @@ void ignoresWrongChannels() { assertTrue(ignoresWrongParentNames, "Failed to ignore wrong parent channel names"); } - MessageReceivedEvent createMessageReceivedEvent(boolean isBot, boolean isWebhook, boolean isThread, String parentChannelName) { try (MessageCreateData message = new MessageCreateBuilder().setContent("Any").build()) { @@ -116,7 +115,6 @@ MessageReceivedEvent createMessageReceivedEvent(boolean isBot, boolean isWebhook } } - @ParameterizedTest @MethodSource("provideInvalidCharactersWithDescription") void excludesInvalidCharacters(String invalidChars, String description) { @@ -130,7 +128,6 @@ void excludesInvalidCharacters(String invalidChars, String description) { "Characters [%s] were not fully ignored".formatted(description)); } - @ParameterizedTest @MethodSource("provideValidCharacters") void countsValidCharacters(String validChars) { @@ -144,7 +141,6 @@ void countsValidCharacters(String validChars) { "Characters [%s] were not fully ignored".formatted(validChars)); } - private static Stream provideInvalidCharactersWithDescription() { return Stream.of( // Invalid characters Arguments.of("\u061C", "Arabic Letter Mark"), @@ -157,7 +153,6 @@ private static Stream provideInvalidCharactersWithDescription() { Arguments.of("\u200F", "Right-to-Left Mark")); } - private static List provideValidCharacters() { return List.of( // Valid characters "a", "A", "b", "B", "c", "C", "x", "X,", "y", "Y", "z", "Z", // Latin alphabet diff --git a/meta/formatting/google-style-eclipse.xml b/meta/formatting/google-style-eclipse.xml index d7c632496d..e102e48cd7 100644 --- a/meta/formatting/google-style-eclipse.xml +++ b/meta/formatting/google-style-eclipse.xml @@ -70,10 +70,9 @@ - - + From 4c9e57128a69e88a1661063f8507c14c1f74af48 Mon Sep 17 00:00:00 2001 From: Taz03 Date: Tue, 14 Mar 2023 01:14:10 +0530 Subject: [PATCH 6/9] fixed superinterfaces --- .../tjbot/features/code/CodeMessageManualDetection.java | 3 +-- .../tjbot/features/filesharing/FileSharingMessageListener.java | 3 +-- .../togetherjava/tjbot/logging/discord/DiscordLogAppender.java | 3 +-- meta/formatting/google-style-eclipse.xml | 1 + 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/application/src/main/java/org/togetherjava/tjbot/features/code/CodeMessageManualDetection.java b/application/src/main/java/org/togetherjava/tjbot/features/code/CodeMessageManualDetection.java index c164786dc6..3f7dcf6503 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/code/CodeMessageManualDetection.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/code/CodeMessageManualDetection.java @@ -12,8 +12,7 @@ * {@link CodeMessageHandler} for further processing. */ public final class CodeMessageManualDetection extends BotCommandAdapter - implements - MessageContextCommand { + implements MessageContextCommand { private final CodeMessageHandler codeMessageHandler; /** diff --git a/application/src/main/java/org/togetherjava/tjbot/features/filesharing/FileSharingMessageListener.java b/application/src/main/java/org/togetherjava/tjbot/features/filesharing/FileSharingMessageListener.java index 2a57fb23f1..3f511bda8f 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/filesharing/FileSharingMessageListener.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/filesharing/FileSharingMessageListener.java @@ -41,8 +41,7 @@ * {@link FileSharingMessageListener#extensionFilter}. */ public final class FileSharingMessageListener extends MessageReceiverAdapter - implements - UserInteractor { + implements UserInteractor { private static final Logger logger = LoggerFactory.getLogger(FileSharingMessageListener.class); private final ComponentIdInteractor componentIdInteractor = diff --git a/application/src/main/java/org/togetherjava/tjbot/logging/discord/DiscordLogAppender.java b/application/src/main/java/org/togetherjava/tjbot/logging/discord/DiscordLogAppender.java index f44ac26e7e..c826e5066e 100644 --- a/application/src/main/java/org/togetherjava/tjbot/logging/discord/DiscordLogAppender.java +++ b/application/src/main/java/org/togetherjava/tjbot/logging/discord/DiscordLogAppender.java @@ -37,8 +37,7 @@ static DiscordLogAppenderBuilder newBuilder() { static final class DiscordLogAppenderBuilder extends AbstractAppender.Builder - implements - org.apache.logging.log4j.core.util.Builder { + implements org.apache.logging.log4j.core.util.Builder { @PluginBuilderAttribute @Required diff --git a/meta/formatting/google-style-eclipse.xml b/meta/formatting/google-style-eclipse.xml index e102e48cd7..e4b081474a 100644 --- a/meta/formatting/google-style-eclipse.xml +++ b/meta/formatting/google-style-eclipse.xml @@ -61,6 +61,7 @@ + From ff56da9a5c2d5f6f493e932a8680bf183e0fbe76 Mon Sep 17 00:00:00 2001 From: Taz03 Date: Tue, 14 Mar 2023 01:17:43 +0530 Subject: [PATCH 7/9] moat superinterface --- .../tjbot/logging/discord/DiscordLogForwarder.java | 4 ++-- meta/formatting/google-style-eclipse.xml | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/application/src/main/java/org/togetherjava/tjbot/logging/discord/DiscordLogForwarder.java b/application/src/main/java/org/togetherjava/tjbot/logging/discord/DiscordLogForwarder.java index ca7a217b4f..8699eecf7e 100644 --- a/application/src/main/java/org/togetherjava/tjbot/logging/discord/DiscordLogForwarder.java +++ b/application/src/main/java/org/togetherjava/tjbot/logging/discord/DiscordLogForwarder.java @@ -156,8 +156,8 @@ private List validateBatch(List logBatch) { return new ArrayList<>(logBatch); } - private record LogMessage(WebhookEmbed embed, - Instant timestamp) implements Comparable { + private record LogMessage(WebhookEmbed embed, Instant timestamp) + implements Comparable { private static LogMessage ofEvent(LogEvent event) { String authorName = event.getLoggerName(); diff --git a/meta/formatting/google-style-eclipse.xml b/meta/formatting/google-style-eclipse.xml index e4b081474a..9d3e1602d0 100644 --- a/meta/formatting/google-style-eclipse.xml +++ b/meta/formatting/google-style-eclipse.xml @@ -62,6 +62,8 @@ + + From b999d853fbb511be74543f8cb5846a7af6f3b312 Mon Sep 17 00:00:00 2001 From: Taz03 Date: Tue, 14 Mar 2023 01:55:37 +0530 Subject: [PATCH 8/9] upgraded version --- meta/formatting/google-style-eclipse.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/meta/formatting/google-style-eclipse.xml b/meta/formatting/google-style-eclipse.xml index 9d3e1602d0..c5a50d9c42 100644 --- a/meta/formatting/google-style-eclipse.xml +++ b/meta/formatting/google-style-eclipse.xml @@ -2,9 +2,9 @@ - - - + + + From 3622fa640f9e0fb79b08e0c7490041bc4d2b8524 Mon Sep 17 00:00:00 2001 From: Tanish Azad Date: Mon, 4 Dec 2023 15:49:05 +0530 Subject: [PATCH 9/9] spotless --- .../tjbot/config/HelperPruneConfig.java | 4 +--- .../tjbot/config/JShellConfig.java | 1 - .../features/bookmarks/BookmarksCommand.java | 6 +++--- .../bookmarks/BookmarksListRemoveHandler.java | 4 ++-- .../features/help/HelpThreadAutoArchiver.java | 3 +-- .../features/help/HelpThreadCommand.java | 4 ++-- .../tjbot/features/jshell/JShellCommand.java | 20 +++++++++---------- .../features/jshell/backend/JShellApi.java | 12 +++++++---- .../backend/dto/JShellExceptionResult.java | 3 +-- .../backend/dto/JShellResultWithId.java | 3 +-- .../wolframalpha/WolframAlphaImages.java | 1 - .../tjbot/features/moderation/BanCommand.java | 12 +++++++---- .../moderation/TransferQuestionCommand.java | 7 +++---- .../features/moderation/WhoIsCommand.java | 5 +++-- .../moderation/audit/AuditCommand.java | 12 +++++++---- .../features/moderation/scam/ScamBlocker.java | 4 ++-- .../temp/RevocableRoleBasedAction.java | 6 +++--- .../features/reminder/ReminderCommand.java | 6 +++--- .../tjbot/features/system/BotCore.java | 12 +++++++---- .../tjbot/features/tags/TagManageCommand.java | 12 +++++------ .../tjbot/features/utils/RateLimiter.java | 4 ++-- .../tjbot/features/utils/ResponseUtils.java | 3 ++- .../features/reminder/RemindRoutineTest.java | 2 +- .../org/togetherjava/tjbot/jda/JdaTester.java | 4 ++-- .../SlashCommandInteractionEventBuilder.java | 16 +++++++-------- 25 files changed, 87 insertions(+), 79 deletions(-) diff --git a/application/src/main/java/org/togetherjava/tjbot/config/HelperPruneConfig.java b/application/src/main/java/org/togetherjava/tjbot/config/HelperPruneConfig.java index 6f451b491f..7ecb3652c9 100644 --- a/application/src/main/java/org/togetherjava/tjbot/config/HelperPruneConfig.java +++ b/application/src/main/java/org/togetherjava/tjbot/config/HelperPruneConfig.java @@ -1,6 +1,5 @@ package org.togetherjava.tjbot.config; - /** * Config for automatic pruning of helper roles, see * {@link org.togetherjava.tjbot.features.help.AutoPruneHelperRoutine}. @@ -15,5 +14,4 @@ * protected from pruning */ public record HelperPruneConfig(int roleFullLimit, int roleFullThreshold, int pruneMemberAmount, - int inactivateAfterDays, int recentlyJoinedDays) { -} + int inactivateAfterDays, int recentlyJoinedDays) {} diff --git a/application/src/main/java/org/togetherjava/tjbot/config/JShellConfig.java b/application/src/main/java/org/togetherjava/tjbot/config/JShellConfig.java index 91b85eb2d8..75944a4142 100644 --- a/application/src/main/java/org/togetherjava/tjbot/config/JShellConfig.java +++ b/application/src/main/java/org/togetherjava/tjbot/config/JShellConfig.java @@ -1,6 +1,5 @@ package org.togetherjava.tjbot.config; - import org.togetherjava.tjbot.features.utils.RateLimiter; import java.util.Objects; 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 d391ac299f..28bcbd3d96 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 d51158974f..42024a3294 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 @@ -140,8 +140,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/HelpThreadAutoArchiver.java b/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadAutoArchiver.java index f1bdf20c2a..e3b25ded0e 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadAutoArchiver.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadAutoArchiver.java @@ -133,7 +133,6 @@ private void handleArchiveFlow(ThreadChannel threadChannel, MessageEmbed embed) .retrieveMemberById(threadChannel.getOwnerIdLong()) .flatMap(author -> threadChannel.sendMessage(author.getAsMention()).addEmbeds(embed)) .flatMap(any -> threadChannel.getManager().setArchived(true)) - .queue(any -> { - }, handleFailure); + .queue(any -> {}, handleFailure); } } 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 44bb6ba37f..3be2f1c5e5 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 @@ -68,16 +68,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.")); } @@ -90,8 +90,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/JShellExceptionResult.java b/application/src/main/java/org/togetherjava/tjbot/features/jshell/backend/dto/JShellExceptionResult.java index dbffefda69..3bfc702002 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/jshell/backend/dto/JShellExceptionResult.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/jshell/backend/dto/JShellExceptionResult.java @@ -6,5 +6,4 @@ * @param exceptionClass the class of the exception * @param exceptionMessage the message of the exception */ -public record JShellExceptionResult(String exceptionClass, String exceptionMessage) { -} +public record JShellExceptionResult(String exceptionClass, String exceptionMessage) {} diff --git a/application/src/main/java/org/togetherjava/tjbot/features/jshell/backend/dto/JShellResultWithId.java b/application/src/main/java/org/togetherjava/tjbot/features/jshell/backend/dto/JShellResultWithId.java index 2cd862e9b7..bce89c8e04 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/jshell/backend/dto/JShellResultWithId.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/jshell/backend/dto/JShellResultWithId.java @@ -6,5 +6,4 @@ * @param id the session of the id * @param result the JShell eval result */ -public record JShellResultWithId(String id, JShellResult result) { -} +public record JShellResultWithId(String id, JShellResult result) {} diff --git a/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/WolframAlphaImages.java b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/WolframAlphaImages.java index 3bad6ee03e..d386b60efd 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/WolframAlphaImages.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/WolframAlphaImages.java @@ -67,7 +67,6 @@ static BufferedImage renderSubPod(SubPod subPod) throws IOException, URISyntaxEx graphics.drawImage(ImageIO.read(new URI(sourceImage.getSource()).toURL()), IMAGE_MARGIN_PX, IMAGE_MARGIN_PX, null); - return destinationImage; } 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 a298a8e1ed..156d0b4474 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 @@ -66,7 +66,10 @@ public BanCommand(ModerationActionsStore actionsStore) { .addOption(OptionType.STRING, REASON_OPTION, "Why the user should be banned", true) .addOptions(new OptionData(OptionType.INTEGER, DELETE_HISTORY_OPTION, "the amount of days of the message history to delete, none means no messages are deleted.", - true).addChoice("none", 0).addChoice("recent", 1).addChoice("all", 7)); + true) + .addChoice("none", 0) + .addChoice("recent", 1) + .addChoice("all", 7)); this.actionsStore = Objects.requireNonNull(actionsStore); } @@ -133,7 +136,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); } @@ -208,8 +212,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 84f07e2747..2a01d86794 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 @@ -66,7 +66,6 @@ public final class TransferQuestionCommand extends BotCommandAdapter private final Predicate isHelpForumName; private final List tags; - /** * Creates a new instance. * @@ -165,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(); } @@ -282,8 +282,7 @@ private MessageEmbed makeEmbedForPost(User originalUser, String originalMessage) .build(); } - private record ForumPostData(ForumPost forumPost, User author) { - } + private record ForumPostData(ForumPost forumPost, User author) {} private boolean isBotMessageTransfer(User author) { return author.isBot(); diff --git a/application/src/main/java/org/togetherjava/tjbot/features/moderation/WhoIsCommand.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/WhoIsCommand.java index 5460e0e102..029ee351ab 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/moderation/WhoIsCommand.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/WhoIsCommand.java @@ -78,8 +78,9 @@ private static ReplyCallbackAction handleWhoIsUser(final IReplyCallback event, f + DATE_TIME_FORMAT.format(user.getTimeCreated()); EmbedBuilder embedBuilder = - generateEmbedBuilder(event, user, profile, profile.getAccentColor()).setAuthor( - user.getName(), user.getEffectiveAvatarUrl(), user.getEffectiveAvatarUrl()) + generateEmbedBuilder(event, user, profile, profile.getAccentColor()) + .setAuthor(user.getName(), user.getEffectiveAvatarUrl(), + user.getEffectiveAvatarUrl()) .setDescription(description); return sendEmbedWithProfileAction(event, embedBuilder.build(), user.getId()); 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 da0517556f..5a5fd32bba 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 e297804b63..2eef06cdd8 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 @@ -154,8 +154,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 e5c71ba2be..f56e9775a9 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 @@ -239,7 +239,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 @@ -250,7 +251,8 @@ public void onCommandAutoCompleteInteraction(final CommandAutoCompleteInteractio event.getCommandPath(), event.getId(), event.getGuild()); COMMAND_SERVICE.execute( () -> requireUserInteractor(UserInteractionType.SLASH_COMMAND.getPrefixedName(name), - SlashCommand.class).onAutoComplete(event)); + SlashCommand.class) + .onAutoComplete(event)); } @Override @@ -299,7 +301,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 @@ -310,7 +313,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 8d957fedfb..edb15642bd 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 @@ -81,23 +81,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/main/java/org/togetherjava/tjbot/features/utils/ResponseUtils.java b/application/src/main/java/org/togetherjava/tjbot/features/utils/ResponseUtils.java index c2ab8675fb..7cf5f4cb5a 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/utils/ResponseUtils.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/utils/ResponseUtils.java @@ -12,7 +12,8 @@ * Handle the parsing of json in a http request. */ public class ResponseUtils { - private ResponseUtils() {} + private ResponseUtils() { + } /** * Creates a body handler which will parse the body of the request. If the parsing fails, an 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 e20655264a..daa874ea0e 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 a634c93165..679bce89b9 100644 --- a/application/src/test/java/org/togetherjava/tjbot/jda/JdaTester.java +++ b/application/src/test/java/org/togetherjava/tjbot/jda/JdaTester.java @@ -673,8 +673,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 10f30653e6..107158268c 100644 --- a/application/src/test/java/org/togetherjava/tjbot/jda/SlashCommandInteractionEventBuilder.java +++ b/application/src/test/java/org/togetherjava/tjbot/jda/SlashCommandInteractionEventBuilder.java @@ -50,16 +50,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(); * } * */ @@ -409,5 +409,5 @@ private SubcommandData requireSubcommand(String name) { }); } - private record Option (String name, T value, OptionType type) {} + private record Option(String name, T value, OptionType type) {} }