From ffb62dfa022a075008ecaa3ff5673d5052be3897 Mon Sep 17 00:00:00 2001 From: Jonathan Coates Date: Wed, 13 Mar 2024 21:52:09 +0000 Subject: [PATCH] Bump checkstyle, fix warnings from TeaVM upgrade --- config/checkstyle/checkstyle.xml | 6 +++++- gradle/libs.versions.toml | 2 +- .../web/src/main/java/cc/tweaked/web/js/JavascriptConv.java | 4 ++-- .../java/cc/tweaked/web/peripheral/SpeakerPeripheral.java | 4 +++- .../computercraft/core/apis/http/request/THttpRequest.java | 2 +- .../computercraft/core/apis/http/websocket/TWebsocket.java | 4 ++-- 6 files changed, 14 insertions(+), 8 deletions(-) diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml index 0adcb6220a..bf8face88d 100644 --- a/config/checkstyle/checkstyle.xml +++ b/config/checkstyle/checkstyle.xml @@ -13,8 +13,12 @@ SPDX-License-Identifier: MPL-2.0 + + + + - + diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 06f9a2f01c..27a22fa8fe 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -55,7 +55,7 @@ jmh = "1.37" # Build tools cctJavadoc = "1.8.2" -checkstyle = "10.12.6" +checkstyle = "10.14.1" curseForgeGradle = "1.0.14" errorProne-core = "2.23.0" errorProne-plugin = "3.1.0" diff --git a/projects/web/src/main/java/cc/tweaked/web/js/JavascriptConv.java b/projects/web/src/main/java/cc/tweaked/web/js/JavascriptConv.java index 18f2732e07..713fc09348 100644 --- a/projects/web/src/main/java/cc/tweaked/web/js/JavascriptConv.java +++ b/projects/web/src/main/java/cc/tweaked/web/js/JavascriptConv.java @@ -78,11 +78,11 @@ public class JavascriptConv { * @return The wrapped array. */ public static byte[] asByteArray(ArrayBuffer view) { - return asByteArray(Int8Array.create(view)); + return asByteArray(new Int8Array(view)); } public static Int8Array toArray(ByteBuffer buffer) { - var array = Int8Array.create(buffer.remaining()); + var array = new Int8Array(buffer.remaining()); for (var i = 0; i < array.getLength(); i++) array.set(i, buffer.get(i)); return array; } diff --git a/projects/web/src/main/java/cc/tweaked/web/peripheral/SpeakerPeripheral.java b/projects/web/src/main/java/cc/tweaked/web/peripheral/SpeakerPeripheral.java index 5faff07ee9..d4f57ad3b6 100644 --- a/projects/web/src/main/java/cc/tweaked/web/peripheral/SpeakerPeripheral.java +++ b/projects/web/src/main/java/cc/tweaked/web/peripheral/SpeakerPeripheral.java @@ -53,11 +53,13 @@ public void tick() { } @LuaFunction + @SuppressWarnings("DoNotCallSuggester") public final boolean playNote(String instrumentA, Optional volumeA, Optional pitchA) throws LuaException { throw new LuaException("Cannot play notes outside of Minecraft"); } @LuaFunction + @SuppressWarnings("DoNotCallSuggester") public final boolean playSound(String name, Optional volumeA, Optional pitchA) throws LuaException { throw new LuaException("Cannot play sounds outside of Minecraft"); } @@ -70,7 +72,7 @@ public final boolean playAudio(LuaTable audio, Optional volume) th if (length <= 0) throw new LuaException("Cannot play empty audio"); if (length > 128 * 1024) throw new LuaException("Audio data is too large"); - if (audioContext == null) audioContext = AudioContext.create(); + if (audioContext == null) audioContext = new AudioContext(); if (state == null || !state.isPlaying()) state = new AudioState(audioContext); return state.pushBuffer(audio, length, volume); diff --git a/projects/web/src/main/java/dan200/computercraft/core/apis/http/request/THttpRequest.java b/projects/web/src/main/java/dan200/computercraft/core/apis/http/request/THttpRequest.java index d8318ae098..13f9d48eef 100644 --- a/projects/web/src/main/java/dan200/computercraft/core/apis/http/request/THttpRequest.java +++ b/projects/web/src/main/java/dan200/computercraft/core/apis/http/request/THttpRequest.java @@ -92,7 +92,7 @@ public void request(URI uri, HttpMethod method) { if (isClosed()) return; try { - var request = XMLHttpRequest.create(); + var request = new XMLHttpRequest(); request.setOnReadyStateChange(() -> onResponseStateChange(request)); request.setResponseType("arraybuffer"); var address = uri.toASCIIString(); diff --git a/projects/web/src/main/java/dan200/computercraft/core/apis/http/websocket/TWebsocket.java b/projects/web/src/main/java/dan200/computercraft/core/apis/http/websocket/TWebsocket.java index e90e5a4f28..671eeb5069 100644 --- a/projects/web/src/main/java/dan200/computercraft/core/apis/http/websocket/TWebsocket.java +++ b/projects/web/src/main/java/dan200/computercraft/core/apis/http/websocket/TWebsocket.java @@ -40,7 +40,7 @@ public TWebsocket(ResourceGroup limiter, IAPIEnvironment environment public void connect() { if (isClosed()) return; - var client = this.websocket = WebSocket.create(uri.toASCIIString()); + var client = this.websocket = new WebSocket(uri.toASCIIString()); client.setBinaryType("arraybuffer"); client.onOpen(e -> success(Action.ALLOW.toPartial().toOptions())); client.onError(e -> { @@ -50,7 +50,7 @@ public void connect() { client.onMessage(e -> { if (isClosed()) return; if (JavascriptConv.isArrayBuffer(e.getData())) { - var array = Int8Array.create(e.getDataAsArray()); + var array = new Int8Array(e.getDataAsArray()); var contents = new byte[array.getLength()]; for (var i = 0; i < contents.length; i++) contents[i] = array.get(i); environment.queueEvent("websocket_message", address, contents, true);