Skip to content

Commit c038ef7

Browse files
committed
Sonar
1 parent d4548dc commit c038ef7

File tree

5 files changed

+18
-12
lines changed

5 files changed

+18
-12
lines changed

core/src/main/java/com/javadiscord/jdi/core/GatewayEventListener.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ public GatewayEventListener(Discord discord) {
3838
}
3939

4040
public static Guild getGuild(Discord discord, Object event) {
41-
if (event instanceof GuildModel) {
41+
if (event instanceof GuildModel guildModel) {
4242
return createGuildFromEvent(
43-
discord, (GuildModel) event
43+
discord, guildModel
4444
);
4545
} else {
4646
return createGuildFromEventObject(discord, event);

core/src/main/java/com/javadiscord/jdi/core/interaction/InteractionEventHandler.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ public void onInteractionCreate(Interaction interaction, Guild guild) {
4949

5050
if (validateParameterCount(method, paramOrder)) {
5151
invokeHandler(handler, method, paramOrder);
52+
} else {
53+
throw new RuntimeException(
54+
"Bound " + paramOrder.size() + " parameters but expected "
55+
+ method.getParameterCount()
56+
);
5257
}
5358

5459
} catch (Exception e) {
@@ -76,13 +81,7 @@ private List<Object> getOrderOfParameters(Method method, Interaction interaction
7681
}
7782

7883
private boolean validateParameterCount(Method method, List<Object> paramOrder) {
79-
if (paramOrder.size() != method.getParameterCount()) {
80-
throw new RuntimeException(
81-
"Bound " + paramOrder.size() + " parameters but expected "
82-
+ method.getParameterCount()
83-
);
84-
}
85-
return true;
84+
return paramOrder.size() == method.getParameterCount();
8685
}
8786

8887
private void invokeHandler(

example/lj-discord-bot/src/main/java/com/javadiscord/bot/utils/Executor.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ public class Executor {
88
private static final ScheduledExecutorService EXECUTOR_SERVICE =
99
Executors.newScheduledThreadPool(Runtime.getRuntime().availableProcessors());
1010

11+
private Executor() {
12+
throw new UnsupportedOperationException("Utility class");
13+
}
14+
1115
public static void execute(Runnable runnable) {
1216
EXECUTOR_SERVICE.submit(runnable);
1317
}

example/lj-discord-bot/src/main/java/com/javadiscord/bot/utils/jshell/JShellService.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ public class JShellService {
2222

2323
private final Map<Long, List<String>> history = new HashMap<>();
2424

25-
public JShellService() {}
26-
2725
public JShellResponse sendRequest(String code) {
2826
record Request(String code) {}
2927
try (HttpClient client = HttpClient.newHttpClient()) {

gateway/src/main/java/com/javadiscord/jdi/internal/gateway/handlers/events/codec/handlers/interaction/InteractionCreateHandler.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,10 @@
88
public class InteractionCreateHandler implements EventHandler<Interaction> {
99

1010
@Override
11-
public void handle(Interaction event, ConnectionMediator connectionMediator, Cache cache) {}
11+
public void handle(Interaction event, ConnectionMediator connectionMediator, Cache cache) {
12+
/*
13+
* Empty because we do not need to do anything with interaction events at the
14+
* gateway level
15+
*/
16+
}
1217
}

0 commit comments

Comments
 (0)