Clean up inspection warnings

This commit is contained in:
Johan Maasing 2025-03-29 15:13:35 +01:00
parent ea99135dab
commit 66434a6bc1
6 changed files with 79 additions and 78 deletions

View file

@ -10,7 +10,6 @@
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</parent> </parent>
<groupId>nu.zoom.dsl</groupId>
<artifactId>assembly</artifactId> <artifactId>assembly</artifactId>
<dependencies> <dependencies>

View file

@ -10,8 +10,8 @@
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</parent> </parent>
<groupId>nu.zoom.dsl</groupId>
<artifactId>parser</artifactId> <artifactId>parser</artifactId>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.antlr</groupId> <groupId>org.antlr</groupId>

View file

@ -1,7 +1,5 @@
package nu.zoom.dsl.ast; package nu.zoom.dsl.ast;
import java.util.Optional;
public record EndpointNode( public record EndpointNode(
PathsNode paths, PathsNode paths,
String inputType) { String inputType) {

View file

@ -8,9 +8,10 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public class EndpointsVisitorTransformer extends EndpointsBaseVisitor<EndpointsParser.DocumentContext> { public class EndpointsVisitorTransformer extends EndpointsBaseVisitor<EndpointsParser.DocumentContext> {
private ArrayList<EndpointNode> endpoints = new ArrayList<>(); private final ArrayList<EndpointNode> endpoints = new ArrayList<>();
private ArrayList<ConfigItemNode> config = new ArrayList<>(); private final ArrayList<ConfigItemNode> config = new ArrayList<>();
private ArrayList<CompoundTypeNode> dataTypes = new ArrayList<>(); private final ArrayList<CompoundTypeNode> dataTypes = new ArrayList<>();
public EndpointsVisitorTransformer() { public EndpointsVisitorTransformer() {
} }
@ -81,7 +82,7 @@ public class EndpointsVisitorTransformer extends EndpointsBaseVisitor<EndpointsP
// and you just want the text from whichever is not null. // and you just want the text from whichever is not null.
private String getText(TerminalNode identifier, TerminalNode value) { private String getText(TerminalNode identifier, TerminalNode value) {
return return
identifier != null ? identifier.getText() : "" ((identifier != null) ? identifier.getText() : "") +
+ value != null ? value.getText() : "" ; ((value != null) ? value.getText() : "");
} }
} }

View file

@ -7,7 +7,6 @@ import org.antlr.v4.runtime.CommonTokenStream;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
public class ParserWrapper { public class ParserWrapper {

View file

@ -19,15 +19,19 @@ import java.util.concurrent.Callable;
description = "Generate source code from an endpoints specification file." description = "Generate source code from an endpoints specification file."
) )
public class EndpointsCLI implements Callable<Integer> { public class EndpointsCLI implements Callable<Integer> {
@SuppressWarnings("unused")
@Parameters(index = "0", description = "The source endpoints DSL file.") @Parameters(index = "0", description = "The source endpoints DSL file.")
private Path file; private Path file;
@SuppressWarnings("CanBeFinal")
@Option(names = {"-t", "--template"}, description = "The template directory. Default is ~/endpoints-templates") @Option(names = {"-t", "--template"}, description = "The template directory. Default is ~/endpoints-templates")
private Path templateDir = Paths.get(System.getProperty("user.dir"), "endpoints-templates"); private Path templateDir = Paths.get(System.getProperty("user.dir"), "endpoints-templates");
@SuppressWarnings("CanBeFinal")
@Option(names = {"-o", "--output"}, description = "The directory to write the generated code to. Default is ~/endpoints-output") @Option(names = {"-o", "--output"}, description = "The directory to write the generated code to. Default is ~/endpoints-output")
private Path outputDir = Paths.get(System.getProperty("user.dir"), "endpoints-output"); private Path outputDir = Paths.get(System.getProperty("user.dir"), "endpoints-output");
@SuppressWarnings("unused")
@Option(names = {"-v", "--verbose"}, description = "Print verbose debug messages.") @Option(names = {"-v", "--verbose"}, description = "Print verbose debug messages.")
private Boolean verbose = false; private Boolean verbose = false;
@ -60,13 +64,13 @@ public class EndpointsCLI implements Callable<Integer> {
} }
} }
private void validateTemplateDirectory() throws IOException { private void validateTemplateDirectory() {
if (!Files.isDirectory(this.templateDir)) { if (!Files.isDirectory(this.templateDir)) {
throw new IllegalArgumentException("Template directory '" + this.templateDir + "' is not a directory."); throw new IllegalArgumentException("Template directory '" + this.templateDir + "' is not a directory.");
} }
} }
private void validateInputFile() throws IOException { private void validateInputFile() {
if (Files.notExists(this.file)) { if (Files.notExists(this.file)) {
throw new IllegalArgumentException("Input file '" + this.file + "' does not exist."); throw new IllegalArgumentException("Input file '" + this.file + "' does not exist.");
} }