From 9122c1618fb9635e5c315d474f0a5797439f1b29 Mon Sep 17 00:00:00 2001 From: Tanish Azad Date: Fri, 24 May 2024 03:26:43 +0530 Subject: [PATCH] fix spotless error by pinning the version (#1122) * fix spotless error by pinning the version * added default branch * added comment * remove default --- .../tjbot/features/tags/TagManageCommand.java | 27 +++++++------------ build.gradle | 3 ++- 2 files changed, 11 insertions(+), 19 deletions(-) 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 f24d517229..eb7dbecbe9 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 @@ -318,27 +318,18 @@ private Optional getTagContent(Subcommand subcommand, String id) { * @param event the event to send messages with * @return whether the status of the given tag is not equal to the required status */ - // ToDo: gradle task :application:spotlessJava throws internal exception if this method uses new - // when keyword - @SuppressWarnings("java:S6916") private boolean isWrongTagStatusAndHandle(TagStatus requiredTagStatus, String id, IReplyCallback event) { - switch (requiredTagStatus) { - case TagStatus.EXISTS -> { - return tagSystem.handleIsUnknownTag(id, event); - } - case TagStatus.NOT_EXISTS -> { - if (tagSystem.hasTag(id)) { - event.reply("The tag with id '%s' already exists.".formatted(id)) - .setEphemeral(true) - .queue(); - return true; - } + return switch (requiredTagStatus) { + case TagStatus.EXISTS -> tagSystem.handleIsUnknownTag(id, event); + case TagStatus status when status == TagStatus.NOT_EXISTS && tagSystem.hasTag(id) -> { + event.reply("The tag with id '%s' already exists.".formatted(id)) + .setEphemeral(true) + .queue(); + yield true; } - default -> - throw new AssertionError("Unknown tag status '%s'".formatted(requiredTagStatus)); - } - return false; + case TagStatus.NOT_EXISTS -> false; + }; } private void logAction(Subcommand subcommand, Guild guild, User author, diff --git a/build.gradle b/build.gradle index b4d44a2db1..3f6d5863ff 100644 --- a/build.gradle +++ b/build.gradle @@ -78,7 +78,8 @@ subprojects { // we use it as catch-all for external dependencies like JDA // '\\#` is prefix for static imports importOrder('','org.togetherjava', 'javax', 'java', '\\#') - eclipse().configFile("${rootProject.rootDir}/meta/formatting/google-style-eclipse.xml") + // TODO: pinning version because of spotless error https://github.com/diffplug/spotless/issues/1992 + eclipse("4.31").configFile("${rootProject.rootDir}/meta/formatting/google-style-eclipse.xml") } }