From bdee0696526b7ed47d55354c724ec126bedcf6bb Mon Sep 17 00:00:00 2001 From: Shitikanth Kashyap Date: Sat, 21 Feb 2026 12:03:44 +0530 Subject: [PATCH 1/2] Configure spotless plugin for Java and POM formatting --- pom.xml | 644 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 342 insertions(+), 302 deletions(-) diff --git a/pom.xml b/pom.xml index 960709d..95775ff 100644 --- a/pom.xml +++ b/pom.xml @@ -1,314 +1,354 @@ - - 4.0.0 + + 4.0.0 - io.github.shitikanth - enforcer-rules - 1.0.5-SNAPSHOT + io.github.shitikanth + enforcer-rules + 1.0.5-SNAPSHOT - Enforcer Rules - Maven Enforcer Rule to ban empty java source files - https://github.com/shitikanth/enforcer-rules + Enforcer Rules + Maven Enforcer Rule to ban empty java source files + https://github.com/shitikanth/enforcer-rules - - - The Apache Software License, Version 2.0 - https://www.apache.org/licenses/LICENSE-2.0.txt - repo - - + + + The Apache Software License, Version 2.0 + https://www.apache.org/licenses/LICENSE-2.0.txt + repo + + - - - Shitikanth Kashyap - shitikanth1@gmail.com - - + + + Shitikanth Kashyap + shitikanth1@gmail.com + + - - scm:git:https://github.com/shitikanth/enforcer-rules.git - scm:git:https://github.com/shitikanth/enforcer-rules.git - HEAD - https://github.com/shitikanth/enforcer-rules/tree/main - + + scm:git:https://github.com/shitikanth/enforcer-rules.git + scm:git:https://github.com/shitikanth/enforcer-rules.git + HEAD + https://github.com/shitikanth/enforcer-rules/tree/main + - - 11 - 11 - UTF-8 - 3.8.1 - - 3.4.0 - 3.13.0 - 3.1.3 - 3.5.0 - 3.2.6 - 3.1.3 - 3.8.0 - 3.4.2 - 3.8.0 - 3.3.1 - 3.20.0 - 2.4 - 3.2.2 - 0.9.0.M3 - 0.6.0 + - - 4.13.0 - 3.25.3 - 5.11.0 - 1.5.12 - + + 4.13.0 + 0.6.0 + 3.25.3 + 5.11.0 + 1.5.12 + + 3.4.0 + 3.13.0 + 3.1.3 + 3.5.0 + 3.2.6 + 3.1.3 + 3.8.0 + 3.4.2 + 3.8.0 + 3.3.1 + 3.20.0 + 2.4 + 3.2.2 + 11 + 11 + 3.8.1 + UTF-8 + 0.9.0.M3 + 2.44.4 + + origin/main + - - - org.apache.maven.enforcer - enforcer-api - ${maven-enforcer-plugin.version} - provided - - - org.apache.maven - maven-core - ${mavenVersion} - provided - - - org.antlr - antlr4-runtime - ${antlr4.version} - - - com.github.javaparser - javaparser-core - ${javaparser-core.version} - true - - - org.junit.jupiter - junit-jupiter - ${junit-jupiter.version} - test - - - ch.qos.logback - logback-classic - ${logback-classic.version} - test - - + + + com.github.javaparser + javaparser-core + ${javaparser-core.version} + true + + + org.antlr + antlr4-runtime + ${antlr4.version} + + + org.apache.maven + maven-core + ${mavenVersion} + provided + + + org.apache.maven.enforcer + enforcer-api + ${maven-enforcer-plugin.version} + provided + + + ch.qos.logback + logback-classic + ${logback-classic.version} + test + + + org.junit.jupiter + junit-jupiter + ${junit-jupiter.version} + test + + - - - - - org.apache.maven.plugins - maven-source-plugin - ${maven-source-plugin.version} - - - org.apache.maven.plugins - maven-javadoc-plugin - ${maven-javadoc-plugin.version} - - - org.apache.maven.plugins - maven-enforcer-plugin - ${maven-enforcer-plugin.version} - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven-compiler-plugin.version} - - - org.apache.maven.plugins - maven-clean-plugin - ${maven-clean-plugin.version} - - - org.apache.maven.plugins - maven-deploy-plugin - ${maven-deploy-plugin.version} - - - org.apache.maven.plugins - maven-gpg-plugin - ${maven-gpg-plugin.version} - - - org.apache.maven.plugins - maven-install-plugin - ${maven-install-plugin.version} - - - org.apache.maven.plugins - maven-jar-plugin - ${maven-jar-plugin.version} - - - org.apache.maven.plugins - maven-resources-plugin - ${maven-resources-plugin.version} - - - org.apache.maven.plugins - maven-site-plugin - ${maven-site-plugin.version} - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - org.sonatype.central - central-publishing-maven-plugin - ${central-publishing-maven-plugin.version} - - - - - - org.apache.maven.plugins - maven-enforcer-plugin - - - enforce-maven-version - validate - - ${mavenVersion} - You need at least Maven ${mavenVersion} to build this project. - - - - - - org.antlr - antlr4-maven-plugin - ${antlr4.version} - - - - antlr4 - - - - - - org.eclipse.sisu - sisu-maven-plugin - ${sisu-maven-plugin.version} - - - generate-index - - main-index - - - - - - + + + + + org.apache.maven.plugins + maven-source-plugin + ${maven-source-plugin.version} + + + org.apache.maven.plugins + maven-javadoc-plugin + ${maven-javadoc-plugin.version} + + + org.apache.maven.plugins + maven-enforcer-plugin + ${maven-enforcer-plugin.version} + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + + org.apache.maven.plugins + maven-clean-plugin + ${maven-clean-plugin.version} + + + org.apache.maven.plugins + maven-deploy-plugin + ${maven-deploy-plugin.version} + + + org.apache.maven.plugins + maven-gpg-plugin + ${maven-gpg-plugin.version} + + + org.apache.maven.plugins + maven-install-plugin + ${maven-install-plugin.version} + + + org.apache.maven.plugins + maven-jar-plugin + ${maven-jar-plugin.version} + + + org.apache.maven.plugins + maven-resources-plugin + ${maven-resources-plugin.version} + + + org.apache.maven.plugins + maven-site-plugin + ${maven-site-plugin.version} + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + org.sonatype.central + central-publishing-maven-plugin + ${central-publishing-maven-plugin.version} + + + com.diffplug.spotless + spotless-maven-plugin + ${spotless-maven-plugin.version} + + ${spotless.ratchetFrom} + + + + java,javax,,io.github.shitikanth,\# + + + + + false + schemaLocation + -1 + scope,groupId,artifactId + true + + + + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + + + enforce-maven-version + validate + + ${mavenVersion} + You need at least Maven ${mavenVersion} to build this project. + + + + + + org.antlr + antlr4-maven-plugin + ${antlr4.version} + + + + antlr4 + + + + + + org.eclipse.sisu + sisu-maven-plugin + ${sisu-maven-plugin.version} + + + generate-index + + main-index + + + + + + com.diffplug.spotless + spotless-maven-plugin + + + spotless-check + + check + + verify + + + + + - - - run-its - - true - - - - - org.apache.maven.plugins - maven-invoker-plugin - ${maven-invoker-plugin.version} - - true - ${project.build.directory}/it - true - src/it/settings.xml - setup - verify - true - ${project.build.directory}/local-repo - -Djava.io.tmpdir=${project.build.directory} - - enforcer:enforce - - - ${maven.compiler.source} - ${maven.compiler.target} - - - - - integration-test - - install - run - - - - - - - - - release - - - - org.sonatype.central - central-publishing-maven-plugin - true - - central - - - - org.apache.maven.plugins - maven-source-plugin - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - - - attach-javadocs - - jar - - - - - - org.apache.maven.plugins - maven-gpg-plugin - - - sign-artifacts - verify - - sign - - - bc - - - - - - - - + + + run-its + + true + + + + + org.apache.maven.plugins + maven-invoker-plugin + ${maven-invoker-plugin.version} + + true + ${project.build.directory}/it + true + src/it/settings.xml + setup + verify + true + ${project.build.directory}/local-repo + -Djava.io.tmpdir=${project.build.directory} + + enforcer:enforce + + + ${maven.compiler.source} + ${maven.compiler.target} + + + + + integration-test + + install + run + + + + + + + + + release + + + + org.sonatype.central + central-publishing-maven-plugin + true + + central + + + + org.apache.maven.plugins + maven-source-plugin + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + + attach-javadocs + + jar + + + + + + org.apache.maven.plugins + maven-gpg-plugin + + + sign-artifacts + + sign + + verify + + bc + + + + + + + + From 18a2b0ae146e4d40b707c87853fb50e465876894 Mon Sep 17 00:00:00 2001 From: Shitikanth Kashyap Date: Sat, 21 Feb 2026 12:06:46 +0530 Subject: [PATCH 2/2] Format files --- pom.xml | 2 +- .../enforcerrules/BanEmptyJavaFiles.java | 91 ++++++++++--------- .../enforcerrules/impl/AntlrTLDParser.java | 7 +- .../impl/JavaParserTLDParser.java | 3 +- .../impl/RecursiveDescentTLDParser.java | 51 ++++------- .../impl/RegexBasedTLDParser.java | 10 +- .../impl/TLDParserFactories.java | 16 ++-- .../impl/AntlrTLDParserTest.java | 5 +- .../impl/RecursiveDescentTLDParserTest.java | 1 + .../impl/RegexBasedTLDParserTest.java | 4 +- 10 files changed, 97 insertions(+), 93 deletions(-) diff --git a/pom.xml b/pom.xml index 95775ff..2d7934c 100644 --- a/pom.xml +++ b/pom.xml @@ -60,8 +60,8 @@ 3.8.1 UTF-8 0.9.0.M3 - 2.44.4 + 3.2.1 origin/main diff --git a/src/main/java/io/github/shitikanth/enforcerrules/BanEmptyJavaFiles.java b/src/main/java/io/github/shitikanth/enforcerrules/BanEmptyJavaFiles.java index b63655b..ec87b18 100644 --- a/src/main/java/io/github/shitikanth/enforcerrules/BanEmptyJavaFiles.java +++ b/src/main/java/io/github/shitikanth/enforcerrules/BanEmptyJavaFiles.java @@ -19,7 +19,6 @@ import javax.inject.Inject; import javax.inject.Named; -import io.github.shitikanth.enforcerrules.impl.TLDParserFactories; import org.apache.maven.enforcer.rule.api.AbstractEnforcerRule; import org.apache.maven.enforcer.rule.api.EnforcerRuleException; import org.apache.maven.execution.MavenSession; @@ -27,11 +26,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import io.github.shitikanth.enforcerrules.impl.TLDParserFactories; + @Named("banEmptyJavaFiles") -class BanEmptyJavaFiles extends AbstractEnforcerRule { +class BanEmptyJavaFiles extends AbstractEnforcerRule { private static final Logger LOGGER = LoggerFactory.getLogger(BanEmptyJavaFiles.class); - private final MavenSession session; private ExecutorService executor; @@ -87,38 +87,44 @@ private void analyzeSourceRoots(List sourceRoots) throws EnforcerRuleExcep continue; } try { - var sourceFiles = Files.find(sourceRoot, Integer.MAX_VALUE, (path, attr) -> attr.isRegularFile() && path.toFile().getName().endsWith(".java")) - .collect(Collectors.toList()); + var sourceFiles = Files.find( + sourceRoot, + Integer.MAX_VALUE, + (path, attr) -> attr.isRegularFile() + && path.toFile().getName().endsWith(".java")) + .collect(Collectors.toList()); long startTime = System.currentTimeMillis(); LOGGER.info("Analyzing {} files", sourceFiles.size()); executor = Executors.newFixedThreadPool(4); executor.invokeAll(sourceFiles.stream() - .filter(path -> { - String fileName = null; - if (path.getFileName() != null) { - fileName = path.getFileName().toString(); - } - return fileName != null && !fileName.equals("package-info.java") && !fileName.equals("module-info.java"); - }) - .map( - path -> (Callable) () -> { - boolean isEmpty = analyzer.isEmptyJavaFile(path); - return new AnalysisResult(path, isEmpty); - }).collect(Collectors.toList())) - .forEach(result -> { - if (result.isDone()) { - try { - var analysisResult = result.get(); - if (analysisResult.isEmpty()) { - emptyJavaSourceFiles.add(analysisResult.path()); + .filter(path -> { + String fileName = null; + if (path.getFileName() != null) { + fileName = path.getFileName().toString(); + } + return fileName != null + && !fileName.equals("package-info.java") + && !fileName.equals("module-info.java"); + }) + .map(path -> (Callable) () -> { + boolean isEmpty = analyzer.isEmptyJavaFile(path); + return new AnalysisResult(path, isEmpty); + }) + .collect(Collectors.toList())) + .forEach(result -> { + if (result.isDone()) { + try { + var analysisResult = result.get(); + if (analysisResult.isEmpty()) { + emptyJavaSourceFiles.add(analysisResult.path()); + } + } catch (ExecutionException e) { + LOGGER.error("Task encountered exception: ", e.getCause()); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); } - } catch (ExecutionException e) { - LOGGER.error("Task encountered exception: ", e.getCause()); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); } - } - }); + }); long endTime = System.currentTimeMillis(); LOGGER.info("Finished in {}ms", endTime - startTime); } catch (IOException e) { @@ -132,7 +138,12 @@ private void analyzeSourceRoots(List sourceRoots) throws EnforcerRuleExcep if (!emptyJavaSourceFiles.isEmpty()) { StringBuilder sb = new StringBuilder("Empty Java source files found:\n"); for (Path path : emptyJavaSourceFiles) { - sb.append("\t- ").append(session.getTopLevelProject().getBasedir().toPath().relativize(path)).append("\n"); + sb.append("\t- ") + .append(session.getTopLevelProject() + .getBasedir() + .toPath() + .relativize(path)) + .append("\n"); } throw new EnforcerRuleException(sb.toString()); } @@ -142,25 +153,25 @@ static final class AnalysisResult { private final Path path; private final boolean isEmpty; - AnalysisResult( - Path path, - boolean isEmpty - ) { + AnalysisResult(Path path, boolean isEmpty) { this.path = path; this.isEmpty = isEmpty; } - public Path path() {return path;} + public Path path() { + return path; + } - public boolean isEmpty() {return isEmpty;} + public boolean isEmpty() { + return isEmpty; + } @Override public boolean equals(Object obj) { if (obj == this) return true; if (obj == null || obj.getClass() != this.getClass()) return false; var that = (AnalysisResult) obj; - return Objects.equals(this.path, that.path) && - this.isEmpty == that.isEmpty; + return Objects.equals(this.path, that.path) && this.isEmpty == that.isEmpty; } @Override @@ -170,9 +181,7 @@ public int hashCode() { @Override public String toString() { - return "AnalysisResult[" + - "path=" + path + ", " + - "isEmpty=" + isEmpty + ']'; + return "AnalysisResult[" + "path=" + path + ", " + "isEmpty=" + isEmpty + ']'; } } } diff --git a/src/main/java/io/github/shitikanth/enforcerrules/impl/AntlrTLDParser.java b/src/main/java/io/github/shitikanth/enforcerrules/impl/AntlrTLDParser.java index bbd0c1f..e2ce9a0 100644 --- a/src/main/java/io/github/shitikanth/enforcerrules/impl/AntlrTLDParser.java +++ b/src/main/java/io/github/shitikanth/enforcerrules/impl/AntlrTLDParser.java @@ -7,13 +7,14 @@ import java.util.List; import java.util.stream.Collectors; -import io.github.shitikanth.enforcerrules.AbstractTLDParser; -import io.github.shitikanth.enforcerrules.JavaTLDLexer; -import io.github.shitikanth.enforcerrules.JavaTLDParser; import com.google.common.annotations.VisibleForTesting; import org.antlr.v4.runtime.CharStreams; import org.antlr.v4.runtime.CommonTokenStream; +import io.github.shitikanth.enforcerrules.AbstractTLDParser; +import io.github.shitikanth.enforcerrules.JavaTLDLexer; +import io.github.shitikanth.enforcerrules.JavaTLDParser; + class AntlrTLDParser extends AbstractTLDParser { public AntlrTLDParser(Path path) { super(path); diff --git a/src/main/java/io/github/shitikanth/enforcerrules/impl/JavaParserTLDParser.java b/src/main/java/io/github/shitikanth/enforcerrules/impl/JavaParserTLDParser.java index ee0ecb3..b1ed36c 100644 --- a/src/main/java/io/github/shitikanth/enforcerrules/impl/JavaParserTLDParser.java +++ b/src/main/java/io/github/shitikanth/enforcerrules/impl/JavaParserTLDParser.java @@ -11,6 +11,7 @@ import com.github.javaparser.JavaParserAdapter; import com.github.javaparser.ast.CompilationUnit; import com.github.javaparser.ast.body.TypeDeclaration; + import io.github.shitikanth.enforcerrules.AbstractTLDParser; class JavaParserTLDParser extends AbstractTLDParser { @@ -22,7 +23,7 @@ public JavaParserTLDParser(JavaParser javaParser, Path path) { } @Override - public List parse() { + public List parse() { CompilationUnit compilationUnit = null; try (BufferedReader reader = this.getReader()) { compilationUnit = parser.parse(reader); diff --git a/src/main/java/io/github/shitikanth/enforcerrules/impl/RecursiveDescentTLDParser.java b/src/main/java/io/github/shitikanth/enforcerrules/impl/RecursiveDescentTLDParser.java index 65d4d1e..e9e246a 100644 --- a/src/main/java/io/github/shitikanth/enforcerrules/impl/RecursiveDescentTLDParser.java +++ b/src/main/java/io/github/shitikanth/enforcerrules/impl/RecursiveDescentTLDParser.java @@ -11,18 +11,18 @@ import javax.annotation.Nullable; -import io.github.shitikanth.enforcerrules.AbstractTLDParser; import org.apache.commons.io.IOUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import io.github.shitikanth.enforcerrules.AbstractTLDParser; class RecursiveDescentTLDParser extends AbstractTLDParser { static final Logger LOGGER = LoggerFactory.getLogger(RecursiveDescentTLDParser.class); private String input; private State state; - private int start=0; - private int pos=0; + private int start = 0; + private int pos = 0; private final List collector = new ArrayList<>(); public RecursiveDescentTLDParser(Path path) { @@ -60,7 +60,7 @@ private void next() { } private char cur() { - return input.charAt(pos-1); + return input.charAt(pos - 1); } private char peek() { @@ -97,7 +97,7 @@ private boolean lookingAt(Pattern pattern) { } private void skipWs() { - while(!eof() && Character.isWhitespace(peek())) { + while (!eof() && Character.isWhitespace(peek())) { next(); } skip(); @@ -143,30 +143,23 @@ class InitialState implements State { @Override public State runState() { Pattern classKeyword = Pattern.compile("(class|record|@?interface|enum)\\b"); - while(!eof()) { + while (!eof()) { skipWs(); if (lookingAt("\"\"\"")) { return new InsideTextState(this); - } - else if (lookingAt("\"")) { + } else if (lookingAt("\"")) { return new InsideStringState(this); - } - else if (lookingAt("(")) { + } else if (lookingAt("(")) { return new SkipParentheticalBlockState(this, '(', ')'); - } - else if (lookingAt("//")) { + } else if (lookingAt("//")) { return new LineCommentState(this); - } - else if (lookingAt("/*")) { + } else if (lookingAt("/*")) { return new BlockCommentState(this); - } - else if (lookingAt("package") || lookingAt("import")) { + } else if (lookingAt("package") || lookingAt("import")) { return new PackageOrImportState(); - } - else if (lookingAt(classKeyword)) { + } else if (lookingAt(classKeyword)) { return new TypeDeclarationState(); - } - else { + } else { skipWord(); } } @@ -212,7 +205,7 @@ public InsideStringState(State parent) { public State runState() { LOGGER.debug("{}\tinside string: {}", pos, input.substring(pos, Math.min(pos + 10, input.length()))); boolean escaped = false; - while(!eof()) { + while (!eof()) { char c = peek(); next(); if (c == '\"' && !escaped) { @@ -226,10 +219,8 @@ public State runState() { } return parent; } - } - class InsideCharacterLiteralState implements State { private final State parent; @@ -240,9 +231,10 @@ public InsideCharacterLiteralState(State parent) { @Nullable @Override public State runState() { - LOGGER.debug("{}\tinside character literal: {}", pos, input.substring(pos, Math.min(pos + 10, input.length()))); + LOGGER.debug( + "{}\tinside character literal: {}", pos, input.substring(pos, Math.min(pos + 10, input.length()))); boolean escaped = false; - while(!eof()) { + while (!eof()) { char c = peek(); next(); if (c == '\'' && !escaped) { @@ -324,18 +316,16 @@ public SkipParentheticalBlockState(State nextState, char startMarker, char endMa @Override public State runState() { char c; - while(!eof()) { + while (!eof()) { skipWs(); if (lookingAt("\"\"\"")) { return new InsideTextState(this); - } - else if (lookingAt("\"")) { + } else if (lookingAt("\"")) { return new InsideStringState(this); } if (lookingAt("//")) { return new LineCommentState(this); - } - else if (lookingAt("/*")) { + } else if (lookingAt("/*")) { return new BlockCommentState(this); } else if (lookingAt("'")) { return new InsideCharacterLiteralState(this); @@ -356,5 +346,4 @@ else if (lookingAt("/*")) { throw new RuntimeException("Failed to parse: " + getPath()); } } - } diff --git a/src/main/java/io/github/shitikanth/enforcerrules/impl/RegexBasedTLDParser.java b/src/main/java/io/github/shitikanth/enforcerrules/impl/RegexBasedTLDParser.java index 4914d96..f6c9531 100644 --- a/src/main/java/io/github/shitikanth/enforcerrules/impl/RegexBasedTLDParser.java +++ b/src/main/java/io/github/shitikanth/enforcerrules/impl/RegexBasedTLDParser.java @@ -9,11 +9,13 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import io.github.shitikanth.enforcerrules.AbstractTLDParser; import com.google.common.annotations.VisibleForTesting; +import io.github.shitikanth.enforcerrules.AbstractTLDParser; + class RegexBasedTLDParser extends AbstractTLDParser { - private Pattern pattern = Pattern.compile("^((public|protected|private|static|abstract|final|sealed|non_sealed)\\s+)*(class|interface|@interface|enum|record)\\s+(\\w+)"); + private Pattern pattern = Pattern.compile( + "^((public|protected|private|static|abstract|final|sealed|non_sealed)\\s+)*(class|interface|@interface|enum|record)\\s+(\\w+)"); public RegexBasedTLDParser(Path path) { super(path); @@ -25,7 +27,7 @@ public RegexBasedTLDParser(BufferedReader reader) { @Override public List parse() { - try(var bufferedReader = getReader()) { + try (var bufferedReader = getReader()) { return parse(bufferedReader); } catch (IOException e) { throw new UncheckedIOException(e); @@ -44,6 +46,4 @@ public List parse(BufferedReader bufferedReader) { }); return types; } - - } diff --git a/src/main/java/io/github/shitikanth/enforcerrules/impl/TLDParserFactories.java b/src/main/java/io/github/shitikanth/enforcerrules/impl/TLDParserFactories.java index b48ce14..4556eb2 100644 --- a/src/main/java/io/github/shitikanth/enforcerrules/impl/TLDParserFactories.java +++ b/src/main/java/io/github/shitikanth/enforcerrules/impl/TLDParserFactories.java @@ -5,19 +5,21 @@ import com.github.javaparser.JavaParser; import com.github.javaparser.ParserConfiguration; + import io.github.shitikanth.enforcerrules.TLDParser; import io.github.shitikanth.enforcerrules.TLDParserFactory; public class TLDParserFactories { static String DEFAULT = "default"; static Map factories = Map.of( - DEFAULT, TLDParserFactories::recursiveDescentParser, - "java-parser", TLDParserFactories::javaParser, - "regex", TLDParserFactories::regexBasedParser - ); - - private TLDParserFactories() { - } + DEFAULT, + TLDParserFactories::recursiveDescentParser, + "java-parser", + TLDParserFactories::javaParser, + "regex", + TLDParserFactories::regexBasedParser); + + private TLDParserFactories() {} public static TLDParserFactory getParserFactory(String parserId) { if (parserId == null) { diff --git a/src/test/java/io/github/shitikanth/enforcerrules/impl/AntlrTLDParserTest.java b/src/test/java/io/github/shitikanth/enforcerrules/impl/AntlrTLDParserTest.java index 742d256..6f3b8e1 100644 --- a/src/test/java/io/github/shitikanth/enforcerrules/impl/AntlrTLDParserTest.java +++ b/src/test/java/io/github/shitikanth/enforcerrules/impl/AntlrTLDParserTest.java @@ -5,8 +5,10 @@ import java.io.InputStream; import java.io.InputStreamReader; -import io.github.shitikanth.enforcerrules.TLDParser; import org.junit.jupiter.api.Test; + +import io.github.shitikanth.enforcerrules.TLDParser; + import static org.junit.jupiter.api.Assertions.fail; class AntlrTLDParserTest { @@ -20,6 +22,5 @@ void example1() throws IOException { TLDParser parser = new AntlrTLDParser(new BufferedReader(new InputStreamReader(inputStream))); var types = parser.parse(); System.out.println(types); - } } diff --git a/src/test/java/io/github/shitikanth/enforcerrules/impl/RecursiveDescentTLDParserTest.java b/src/test/java/io/github/shitikanth/enforcerrules/impl/RecursiveDescentTLDParserTest.java index faae40c..23e86c2 100644 --- a/src/test/java/io/github/shitikanth/enforcerrules/impl/RecursiveDescentTLDParserTest.java +++ b/src/test/java/io/github/shitikanth/enforcerrules/impl/RecursiveDescentTLDParserTest.java @@ -8,6 +8,7 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; + import static org.junit.jupiter.api.Assertions.*; class RecursiveDescentTLDParserTest { diff --git a/src/test/java/io/github/shitikanth/enforcerrules/impl/RegexBasedTLDParserTest.java b/src/test/java/io/github/shitikanth/enforcerrules/impl/RegexBasedTLDParserTest.java index 31bf54d..eb7c3e9 100644 --- a/src/test/java/io/github/shitikanth/enforcerrules/impl/RegexBasedTLDParserTest.java +++ b/src/test/java/io/github/shitikanth/enforcerrules/impl/RegexBasedTLDParserTest.java @@ -6,13 +6,13 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import static org.junit.jupiter.api.Assertions.*; class RegexBasedTLDParserTest { @BeforeEach - void setUp() { - } + void setUp() {} @Test void example() {