From 96a66dabaa1b225f01f9a2361c695484148c27b9 Mon Sep 17 00:00:00 2001 From: Davide Angelocola Date: Fri, 19 Jun 2026 20:43:32 +0200 Subject: [PATCH] refactor: document intentionally empty blocks (Sonar S108) Add explanatory comments to empty catch blocks and no-op switch arms so the intent (acceptable exception / fall-through / non-type decl) is explicit. Co-Authored-By: Claude Opus 4.8 --- .../main/java/io/github/dfa1/vortex/cli/FilterCommand.java | 4 ++-- .../io/github/dfa1/vortex/cli/tui/VortexInspectorTui.java | 3 +-- .../java/io/github/dfa1/vortex/protogen/TypeRegistry.java | 4 ++-- .../dfa1/vortex/reader/decode/PcoEncodingDecoderTest.java | 4 ++-- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/cli/src/main/java/io/github/dfa1/vortex/cli/FilterCommand.java b/cli/src/main/java/io/github/dfa1/vortex/cli/FilterCommand.java index 61df260b..cabb3351 100644 --- a/cli/src/main/java/io/github/dfa1/vortex/cli/FilterCommand.java +++ b/cli/src/main/java/io/github/dfa1/vortex/cli/FilterCommand.java @@ -131,11 +131,11 @@ private static IllegalArgumentException invalid(String expr) { private static Comparable parseValue(String raw) { try { return Long.parseLong(raw); - } catch (NumberFormatException _) { + } catch (NumberFormatException _) { // not this type; try the next } try { return Double.parseDouble(raw); - } catch (NumberFormatException _) { + } catch (NumberFormatException _) { // not this type; try the next } if ("true".equalsIgnoreCase(raw)) { return Boolean.TRUE; diff --git a/cli/src/main/java/io/github/dfa1/vortex/cli/tui/VortexInspectorTui.java b/cli/src/main/java/io/github/dfa1/vortex/cli/tui/VortexInspectorTui.java index e4f0374a..c0a1ae66 100644 --- a/cli/src/main/java/io/github/dfa1/vortex/cli/tui/VortexInspectorTui.java +++ b/cli/src/main/java/io/github/dfa1/vortex/cli/tui/VortexInspectorTui.java @@ -289,8 +289,7 @@ private void handleKey(Key key, List items) { case Key.PageUp _ -> selected = Math.max(selected - 10, 0); case Key.Home _ -> selected = 0; case Key.End _ -> selected = items.size() - 1; - default -> { - } + default -> { /* ignore unhandled keys */ } } } diff --git a/proto-gen/src/main/java/io/github/dfa1/vortex/protogen/TypeRegistry.java b/proto-gen/src/main/java/io/github/dfa1/vortex/protogen/TypeRegistry.java index 5cca538f..13c3e876 100644 --- a/proto-gen/src/main/java/io/github/dfa1/vortex/protogen/TypeRegistry.java +++ b/proto-gen/src/main/java/io/github/dfa1/vortex/protogen/TypeRegistry.java @@ -65,8 +65,8 @@ private void indexNested(Ast.MessageDecl parent, String parentFqn, String javaPa String fqn = parentFqn + "." + e.name(); byFqn.put(fqn, new ResolvedType.Enum(e, fqn, javaPackage)); } - case Ast.FieldDecl _ -> { } - case Ast.OneOfDecl _ -> { } + case Ast.FieldDecl _ -> { /* not a type declaration */ } + case Ast.OneOfDecl _ -> { /* not a type declaration */ } } } } diff --git a/reader/src/test/java/io/github/dfa1/vortex/reader/decode/PcoEncodingDecoderTest.java b/reader/src/test/java/io/github/dfa1/vortex/reader/decode/PcoEncodingDecoderTest.java index dbb939df..c6af3e7a 100644 --- a/reader/src/test/java/io/github/dfa1/vortex/reader/decode/PcoEncodingDecoderTest.java +++ b/reader/src/test/java/io/github/dfa1/vortex/reader/decode/PcoEncodingDecoderTest.java @@ -452,7 +452,7 @@ void randomChunkMetaBytes_neverThrowsJvmException(byte[] chunkMetaBytes) { assertThatCode(() -> { try { SUT.decode(ctx); - } catch (VortexException _) { + } catch (VortexException _) { // acceptable; only non-Vortex failures should escape } }).doesNotThrowAnyException(); } @@ -467,7 +467,7 @@ void randomPageBytes_classicMode_neverThrowsJvmException(byte[] pageBytes) { assertThatCode(() -> { try { SUT.decode(ctx); - } catch (VortexException _) { + } catch (VortexException _) { // acceptable; only non-Vortex failures should escape } }).doesNotThrowAnyException(); }