diff --git a/.github/workflows/basic-checks.yml b/.github/workflows/basic-checks.yml index 4c487294c7..6c393cde80 100644 --- a/.github/workflows/basic-checks.yml +++ b/.github/workflows/basic-checks.yml @@ -3,7 +3,7 @@ name: Basic checks on: [pull_request] env: - JAVA_VERSION: 21 + JAVA_VERSION: 22 jobs: spotless: diff --git a/.github/workflows/code-analysis.yml b/.github/workflows/code-analysis.yml index 1122f4c27f..42bc4fb05e 100644 --- a/.github/workflows/code-analysis.yml +++ b/.github/workflows/code-analysis.yml @@ -8,7 +8,7 @@ on: - cron: '0 20 * * 4' env: - JAVA_VERSION: 21 + JAVA_VERSION: 22 jobs: sonar: diff --git a/.github/workflows/docker-publish.yaml b/.github/workflows/docker-publish.yaml index 9544b6e31a..90c3294145 100644 --- a/.github/workflows/docker-publish.yaml +++ b/.github/workflows/docker-publish.yaml @@ -7,7 +7,7 @@ on: - 'master' env: - JAVA_VERSION: 21 + JAVA_VERSION: 22 jobs: docker: diff --git a/.github/workflows/docker-verify.yaml b/.github/workflows/docker-verify.yaml index b1a5fc0294..1220597190 100644 --- a/.github/workflows/docker-verify.yaml +++ b/.github/workflows/docker-verify.yaml @@ -3,7 +3,7 @@ name: Docker Verify on: [pull_request] env: - JAVA_VERSION: 21 + JAVA_VERSION: 22 jobs: docker: diff --git a/.github/workflows/releases.yaml b/.github/workflows/releases.yaml index 399f00ca4d..5b3e9b272a 100644 --- a/.github/workflows/releases.yaml +++ b/.github/workflows/releases.yaml @@ -10,7 +10,7 @@ defaults: shell: bash env: - JAVA_VERSION: 21 + JAVA_VERSION: 22 jobs: diff --git a/README.md b/README.md index 846e897549..8223d3d0e8 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # TJ-Bot [![codefactor](https://img.shields.io/codefactor/grade/github/together-java/tj-bot)](https://www.codefactor.io/repository/github/together-java/tj-bot) -![Java](https://img.shields.io/badge/Java-21-ff696c) +![Java](https://img.shields.io/badge/Java-22-ff696c) [![license](https://img.shields.io/github/license/Together-Java/TJ-Bot)](https://github.com/Together-Java/TJ-Bot/blob/master/LICENSE) ![GitHub release (latest by date)](https://img.shields.io/github/v/release/Together-Java/TJ-Bot?label=release) diff --git a/application/build.gradle b/application/build.gradle index 320ccc6f19..66dfcfe5c9 100644 --- a/application/build.gradle +++ b/application/build.gradle @@ -18,7 +18,7 @@ repositories { var outputImage = 'togetherjava.org:5001/togetherjava/tjbot:' + System.getenv('BRANCH_NAME') ?: 'latest' jib { - from.image = 'eclipse-temurin:21' + from.image = 'eclipse-temurin:22' to { image = outputImage auth { @@ -46,7 +46,7 @@ dependencies { implementation project(':utils') implementation project(':formatter') - implementation 'net.dv8tion:JDA:5.0.0-beta.21' + implementation 'net.dv8tion:JDA:5.1.0' implementation 'org.apache.logging.log4j:log4j-core:2.23.0' runtimeOnly 'org.apache.logging.log4j:log4j-slf4j18-impl:2.18.0' 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 5e9e7b69d9..601f91663f 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 @@ -224,7 +224,7 @@ public void onMessageUpdated(MessageUpdateEvent event) { // Re-apply the current action return codeReplyMessage.editMessageEmbeds(maybeCodeAction.orElseThrow().apply(code)); - }).queue(any -> { + }).queue(_ -> { }, failure -> logger.warn( "Attempted to update a code-reply-message ({}), but failed. The original code-message was {}", codeReplyMessageId, originalMessageId, failure)); @@ -253,7 +253,7 @@ public void onMessageDeleted(MessageDeleteEvent event) { // Delete the code reply as well originalMessageToCodeReply.invalidate(originalMessageId); - event.getChannel().deleteMessageById(codeReplyMessageId).queue(any -> { + event.getChannel().deleteMessageById(codeReplyMessageId).queue(_ -> { }, failure -> logger.warn( "Attempted to delete a code-reply-message ({}), but failed. The original code-message was {}", codeReplyMessageId, originalMessageId, failure)); diff --git a/application/src/main/java/org/togetherjava/tjbot/features/github/GitHubReference.java b/application/src/main/java/org/togetherjava/tjbot/features/github/GitHubReference.java index 5592e04592..960587e8a4 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/github/GitHubReference.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/github/GitHubReference.java @@ -236,7 +236,7 @@ Optional findIssue(int id, String targetIssueTitle) { if (issue.getTitle().equals(targetIssueTitle)) { return Optional.of(issue); } - } catch (FileNotFoundException ignored) { + } catch (FileNotFoundException _) { return Optional.empty(); } catch (IOException ex) { throw new UncheckedIOException(ex); @@ -255,7 +255,7 @@ Optional findIssue(int id, long defaultRepoId) { issue = repository.getPullRequest(id); } return Optional.of(issue); - } catch (FileNotFoundException ignored) { + } catch (FileNotFoundException _) { return Optional.empty(); } catch (IOException ex) { throw new UncheckedIOException(ex); diff --git a/application/src/main/java/org/togetherjava/tjbot/features/help/GuildLeaveCloseThreadListener.java b/application/src/main/java/org/togetherjava/tjbot/features/help/GuildLeaveCloseThreadListener.java index 0e4cff2eba..5d1a4d7260 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/help/GuildLeaveCloseThreadListener.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/help/GuildLeaveCloseThreadListener.java @@ -36,7 +36,7 @@ public void onGuildMemberRemove(GuildMemberRemoveEvent event) { .filter(thread -> thread.getOwnerIdLong() == event.getUser().getIdLong()) .filter(thread -> thread.getParentChannel().getName().matches(helpForumPattern)) .forEach(thread -> thread.sendMessageEmbeds(embed) - .flatMap(any -> thread.getManager().setArchived(true)) + .flatMap(_ -> thread.getManager().setArchived(true)) .queue())); } } diff --git a/application/src/main/java/org/togetherjava/tjbot/features/help/HelpSystemHelper.java b/application/src/main/java/org/togetherjava/tjbot/features/help/HelpSystemHelper.java index 70a96aea7c..b10d8fd0db 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/help/HelpSystemHelper.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/help/HelpSystemHelper.java @@ -165,7 +165,7 @@ RestAction constructChatGptAttempt(ThreadChannel threadChannel, } MessageEmbed responseEmbed = generateGptResponseEmbed(answer, selfUser, originalQuestion); - return message.flatMap(any -> threadChannel.sendMessageEmbeds(responseEmbed) + return message.flatMap(_ -> threadChannel.sendMessageEmbeds(responseEmbed) .addActionRow( generateDismissButton(componentIdInteractor, idForDismissButton.toString()))); } 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 4b0b6a317a..41792957ff 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 @@ -151,7 +151,7 @@ private void triggerArchiveFlow(ThreadChannel threadChannel, long authorId, return sendEmbedWithMention.apply(authorResults.get()); }) - .flatMap(any -> threadChannel.getManager().setArchived(true)) + .flatMap(_ -> threadChannel.getManager().setArchived(true)) .queue(); } 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 0adcd14a22..9acd2d0fb4 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 @@ -102,7 +102,7 @@ public HelpThreadCommand(Config config, HelpSystemHelper helper) { .collect(Collectors.toMap(Subcommand::getCommandName, Function.identity())); subcommandToCooldownCache = new EnumMap<>(streamSubcommands() .filter(Subcommand::hasCooldown) - .collect(Collectors.toMap(Function.identity(), any -> createCooldownCache.get()))); + .collect(Collectors.toMap(Function.identity(), _ -> createCooldownCache.get()))); subcommandToEventHandler = new EnumMap<>(Map.of(Subcommand.CHANGE_CATEGORY, this::changeCategory, Subcommand.CHANGE_TITLE, this::changeTitle, Subcommand.CLOSE, this::closeThread, Subcommand.RESET_ACTIVITY, this::resetActivity)); @@ -158,7 +158,7 @@ private void changeCategory(SlashCommandInteractionEvent event, ThreadChannel he refreshCooldownFor(Subcommand.CHANGE_CATEGORY, helpThread); helper.changeChannelCategory(helpThread, category) - .flatMap(any -> sendCategoryChangedMessage(helpThread.getGuild(), event.getHook(), + .flatMap(_ -> sendCategoryChangedMessage(helpThread.getGuild(), event.getHook(), helpThread, category)) .queue(); } @@ -185,7 +185,7 @@ private RestAction sendCategoryChangedMessage(Guild guild, InteractionH String headsUpPattern = "%s please have a look, thanks."; String headsUpWithoutRole = headsUpPattern.formatted(""); String headsUpWithRole = headsUpPattern.formatted(helperRole.orElseThrow().getAsMention()); - return action.flatMap(any -> helpThread.sendMessage(headsUpWithoutRole) + return action.flatMap(_ -> helpThread.sendMessage(headsUpWithoutRole) .flatMap(message -> message.editMessage(headsUpWithRole))); } @@ -195,7 +195,7 @@ private void changeTitle(SlashCommandInteractionEvent event, ThreadChannel helpT refreshCooldownFor(Subcommand.CHANGE_TITLE, helpThread); helper.renameChannel(helpThread, title) - .flatMap(any -> event.reply("Changed the title to **%s**.".formatted(title))) + .flatMap(_ -> event.reply("Changed the title to **%s**.".formatted(title))) .queue(); } @@ -206,7 +206,7 @@ private void closeThread(SlashCommandInteractionEvent event, ThreadChannel helpT .setColor(HelpSystemHelper.AMBIENT_COLOR) .build(); - event.replyEmbeds(embed).flatMap(any -> helpThread.getManager().setArchived(true)).queue(); + event.replyEmbeds(embed).flatMap(_ -> helpThread.getManager().setArchived(true)).queue(); } private void resetActivity(SlashCommandInteractionEvent event, ThreadChannel helpThread) { diff --git a/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadCreatedListener.java b/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadCreatedListener.java index e01a879e82..e5e4c9d6c4 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadCreatedListener.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadCreatedListener.java @@ -76,7 +76,7 @@ private boolean wasThreadAlreadyHandled(long threadChannelId) { // the threads we already handled Instant now = Instant.now(); // NOTE It is necessary to do the "check if exists, otherwise insert" atomic - Instant createdAt = threadIdToCreatedAtCache.get(threadChannelId, any -> now); + Instant createdAt = threadIdToCreatedAtCache.get(threadChannelId, _ -> now); return createdAt != now; } @@ -84,9 +84,9 @@ private void handleHelpThreadCreated(ThreadChannel threadChannel) { threadChannel.retrieveStartMessage().flatMap(message -> { registerThreadDataInDB(message, threadChannel); return sendHelperHeadsUp(threadChannel) - .flatMap(any -> HelpThreadCreatedListener.isContextSufficient(message), - any -> createAIResponse(threadChannel, message)) - .flatMap(any -> pinOriginalQuestion(message)); + .flatMap(_ -> HelpThreadCreatedListener.isContextSufficient(message), + _ -> createAIResponse(threadChannel, message)) + .flatMap(_ -> pinOriginalQuestion(message)); }).queue(); } 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..11f666beaa 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,7 +46,7 @@ public void onMessageReceived(MessageReceivedEvent event) { } if (messageHasNoMediaAttached(message)) { - message.delete().flatMap(any -> dmUser(message)).queue(any -> { + message.delete().flatMap(_ -> dmUser(message)).queue(_ -> { }, failure -> tempNotifyUserInChannel(message)); } } 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 58ad3a5766..5009af4907 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 @@ -150,7 +150,7 @@ public void onModalSubmitted(ModalInteractionEvent event, List args) { // Has been handled if original message was deleted by now. // Deleted messages cause retrieveMessageById to fail. Consumer notHandledAction = - any -> transferFlow(event, channelId, authorId, messageId); + _ -> transferFlow(event, channelId, authorId, messageId); Consumer handledAction = failure -> { if (failure instanceof ErrorResponseException errorResponseException diff --git a/application/src/main/java/org/togetherjava/tjbot/features/moderation/attachment/BlacklistedAttachmentListener.java b/application/src/main/java/org/togetherjava/tjbot/features/moderation/attachment/BlacklistedAttachmentListener.java index db1060aefb..c7cd224f18 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/moderation/attachment/BlacklistedAttachmentListener.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/moderation/attachment/BlacklistedAttachmentListener.java @@ -49,7 +49,7 @@ public void onMessageReceived(MessageReceivedEvent event) { } private void handleBadMessage(Message message) { - message.delete().flatMap(any -> dmUser(message)).queue(any -> warnMods(message)); + message.delete().flatMap(_ -> dmUser(message)).queue(_ -> warnMods(message)); } private RestAction dmUser(Message 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 5330ffd351..981324fb0d 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,7 +255,7 @@ private void dmUser(MessageReceivedEvent event) { } private void dmUser(Guild guild, long userId, JDA jda) { - jda.openPrivateChannelById(userId).flatMap(channel -> dmUser(guild, channel)).queue(any -> { + jda.openPrivateChannelById(userId).flatMap(channel -> dmUser(guild, channel)).queue(_ -> { }, 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)); 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 1da5871a1d..0f2f0417d2 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 @@ -154,7 +154,7 @@ Failed to send a reminder with (authorID '{}') skipping it. This can be due to a int failureAttempts = pendingReminder.getFailureAttempts() + 1; Instant remindAt = Instant.now().plus(1, ChronoUnit.MINUTES); - database.write(any -> { + database.write(_ -> { pendingReminder.setRemindAt(remindAt); pendingReminder.setFailureAttempts(failureAttempts); pendingReminder.insert(); 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 cc84fa3083..6b8e4a58f5 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 @@ -63,7 +63,7 @@ public static CompletableFuture> createLinkPreviews(List extractResults(tasks)).exceptionally(e -> { + return allDoneTask.thenApply(_ -> extractResults(tasks)).exceptionally(e -> { logger.error("Unknown error during link preview creation", e); return List.of(); }); diff --git a/build.gradle b/build.gradle index 3f6d5863ff..eb98d9df84 100644 --- a/build.gradle +++ b/build.gradle @@ -1,8 +1,8 @@ plugins { id 'java' id "com.diffplug.spotless" version "6.25.0" - id "org.sonarqube" version "5.0.0.4638" - id "name.remal.sonarlint" version "4.2.2" + id "org.sonarqube" version "5.1.0.4882" + id "name.remal.sonarlint" version "4.2.8" } group 'org.togetherjava' @@ -55,16 +55,16 @@ subprojects { java { toolchain { // Nails the Java-Version of every Subproject - languageVersion = JavaLanguageVersion.of(21) + languageVersion = JavaLanguageVersion.of(22) } } // sonarlint configuration, not to be confused with sonarqube/sonarcloud. sonarLint { rules { - disable( - 'java:S1135' // Disables "Track uses of "TO-DO" tags" rule. - ) + disable('java:S1135') // Disables "Track uses of "TO-DO" tags" rule. + disable('java:S1190') + disable('java:S117') } } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index d64cd49177..e6441136f3 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1af9e0930b..a4413138c9 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index 1aa94a4269..b740cf1339 100755 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. diff --git a/gradlew.bat b/gradlew.bat index 93e3f59f13..25da30dbde 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail