From d8984225c326a0c6a2fd07c917e0d1920f624145 Mon Sep 17 00:00:00 2001 From: Aman Sharma Date: Tue, 3 Sep 2024 18:23:36 +0200 Subject: [PATCH] style: please spotless --- ast/pom.xml | 15 ++ experiments/pom.xml | 136 +++++++++--------- .../src/main/java/org/example/Constants.java | 10 +- .../src/main/java/org/example/Dataset.java | 26 ++-- .../src/main/java/org/example/Diffoscope.java | 12 +- .../main/java/org/example/DiffoscopeDiff.java | 11 +- 6 files changed, 117 insertions(+), 93 deletions(-) diff --git a/ast/pom.xml b/ast/pom.xml index 5160d6e057..af6f6cabea 100644 --- a/ast/pom.xml +++ b/ast/pom.xml @@ -15,6 +15,21 @@ UTF-8 + + + com.github.gumtreediff + core + + + org.junit.jupiter + junit-jupiter-api + + + org.assertj + assertj-core + + + diff --git a/experiments/pom.xml b/experiments/pom.xml index d80ac74d7f..eafc2e78f9 100644 --- a/experiments/pom.xml +++ b/experiments/pom.xml @@ -1,75 +1,73 @@ - - 4.0.0 - - io.algomaster99 - by-the-pool - 1.0-SNAPSHOT - + + 4.0.0 + + io.algomaster99 + by-the-pool + 1.0-SNAPSHOT + - experiments + experiments - - 22 - 22 - UTF-8 - + + 22 + 22 + UTF-8 + - - - org.apache.commons - commons-csv - 1.11.0 - - + + + org.apache.commons + commons-csv + 1.11.0 + + - - - - org.apache.maven.plugins - maven-shade-plugin - - - main - package - - shade - - - dataset - false - - - - org.example.Dataset - - - - - - - diffoscope - package - - shade - - - diffoscope - false - - - - org.example.Diffoscope - - - - - - - - - + + + + org.apache.maven.plugins + maven-shade-plugin + + + main + + shade + + package + + dataset + false + + + + org.example.Dataset + + + + + + + diffoscope + + shade + + package + + diffoscope + false + + + + org.example.Diffoscope + + + + + + + + + - \ No newline at end of file + diff --git a/experiments/src/main/java/org/example/Constants.java b/experiments/src/main/java/org/example/Constants.java index 7269f65ffe..2fa321faed 100644 --- a/experiments/src/main/java/org/example/Constants.java +++ b/experiments/src/main/java/org/example/Constants.java @@ -12,17 +12,19 @@ public class Constants { public static final Properties PROPERTIES; + static { PROPERTIES = new Properties(); try { - //load a properties file from class path, inside static method + // load a properties file from class path, inside static method PROPERTIES.load(Constants.class.getClassLoader().getResourceAsStream("config.properties")); - } - catch (IOException ex) { + } catch (IOException ex) { ex.printStackTrace(); } } - public static final Path ROOT = Paths.get(PROPERTIES.getProperty("ROOT")).toAbsolutePath().normalize(); + + public static final Path ROOT = + Paths.get(PROPERTIES.getProperty("ROOT")).toAbsolutePath().normalize(); public static final Path DIFFOSCOPE_EXECUTABLE = Paths.get(PROPERTIES.getProperty("DIFFOSCOPE_EXECUTABLE")); public static Logger getLogger(Class clazz, String logFileName) { diff --git a/experiments/src/main/java/org/example/Dataset.java b/experiments/src/main/java/org/example/Dataset.java index d8e8d38768..50f0dd9311 100644 --- a/experiments/src/main/java/org/example/Dataset.java +++ b/experiments/src/main/java/org/example/Dataset.java @@ -1,7 +1,6 @@ package org.example; -import org.apache.commons.csv.CSVFormat; -import org.apache.commons.csv.CSVRecord; +import static org.example.Constants.ROOT; import java.io.FileReader; import java.io.FileWriter; @@ -10,12 +9,12 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.List; import java.util.jar.JarFile; import java.util.logging.Logger; import java.util.zip.ZipEntry; -import java.util.List; - -import static org.example.Constants.ROOT; +import org.apache.commons.csv.CSVFormat; +import org.apache.commons.csv.CSVRecord; public class Dataset { private static final Path DATASET = ROOT.resolve("dataset"); @@ -23,6 +22,7 @@ public class Dataset { private static final Path OUTPUT = ROOT.resolve("output"); private static final List RANDOM_NUMBERS; + static { try { RANDOM_NUMBERS = Files.readAllLines(ROOT.resolve("random_numbers.txt")); @@ -62,8 +62,12 @@ public static void main(String[] args) throws IOException { byte[] classfileBytes2 = getClassFileBytes(jar2, classfileInsideJar2); String classfileName1 = getClassNameFromFullyQualifiedClassName(classfileInsideJar1); String classfileName2 = getClassNameFromFullyQualifiedClassName(classfileInsideJar2); - Path outputClassfile1 = OUTPUT.resolve(String.valueOf(recordNumber)).resolve("first").resolve(classfileName1); - Path outputClassfile2 = OUTPUT.resolve(String.valueOf(recordNumber)).resolve("second").resolve(classfileName2); + Path outputClassfile1 = OUTPUT.resolve(String.valueOf(recordNumber)) + .resolve("first") + .resolve(classfileName1); + Path outputClassfile2 = OUTPUT.resolve(String.valueOf(recordNumber)) + .resolve("second") + .resolve(classfileName2); Files.createDirectories(outputClassfile1.getParent()); Files.write(outputClassfile1, classfileBytes1); @@ -71,9 +75,11 @@ public static void main(String[] args) throws IOException { Files.createDirectories(outputClassfile2.getParent()); Files.write(outputClassfile2, classfileBytes2); - f0.write(ROOT.relativize(outputClassfile1) + "," + ROOT.relativize(outputClassfile2) + System.lineSeparator()); + f0.write(ROOT.relativize(outputClassfile1) + "," + ROOT.relativize(outputClassfile2) + + System.lineSeparator()); - logger.info("Record Number: " + recordNumber + " " + ROOT.relativize(outputClassfile1) + " " + ROOT.relativize(outputClassfile1)); + logger.info("Record Number: " + recordNumber + " " + ROOT.relativize(outputClassfile1) + " " + + ROOT.relativize(outputClassfile1)); } f0.close(); } @@ -87,4 +93,4 @@ private static byte[] getClassFileBytes(JarFile jar, String classfile) throws IO private static String getClassNameFromFullyQualifiedClassName(String fullyQualifiedClassName) { return fullyQualifiedClassName.substring(fullyQualifiedClassName.lastIndexOf('/') + 1); } -} \ No newline at end of file +} diff --git a/experiments/src/main/java/org/example/Diffoscope.java b/experiments/src/main/java/org/example/Diffoscope.java index 1330e0e29f..17178a2c86 100644 --- a/experiments/src/main/java/org/example/Diffoscope.java +++ b/experiments/src/main/java/org/example/Diffoscope.java @@ -1,7 +1,6 @@ package org.example; -import org.apache.commons.csv.CSVFormat; -import org.apache.commons.csv.CSVRecord; +import static org.example.Constants.ROOT; import java.io.FileReader; import java.io.IOException; @@ -10,8 +9,8 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; - -import static org.example.Constants.ROOT; +import org.apache.commons.csv.CSVFormat; +import org.apache.commons.csv.CSVRecord; public class Diffoscope { @@ -20,8 +19,9 @@ public static void main(String[] args) throws IOException, InterruptedException Reader reader = new FileReader(paths.toFile()); Iterable records = CSVFormat.DEFAULT.parse(reader); - - int workers = args.length > 0 ? Integer.parseInt(args[0]) : Runtime.getRuntime().availableProcessors(); + int workers = args.length > 0 + ? Integer.parseInt(args[0]) + : Runtime.getRuntime().availableProcessors(); ExecutorService pool = Executors.newFixedThreadPool(workers); for (CSVRecord record : records) { diff --git a/experiments/src/main/java/org/example/DiffoscopeDiff.java b/experiments/src/main/java/org/example/DiffoscopeDiff.java index 12a582c1fb..ac37df7c96 100644 --- a/experiments/src/main/java/org/example/DiffoscopeDiff.java +++ b/experiments/src/main/java/org/example/DiffoscopeDiff.java @@ -1,11 +1,10 @@ package org.example; -import org.apache.commons.csv.CSVRecord; - import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; import java.util.logging.Logger; +import org.apache.commons.csv.CSVRecord; public class DiffoscopeDiff implements Runnable { private static final Path DIFFOSCOPE = Constants.DIFFOSCOPE_EXECUTABLE; @@ -24,7 +23,12 @@ public void run() { Path diffRootDirectory = class1.getParent().getParent(); - ProcessBuilder pb = new ProcessBuilder(DIFFOSCOPE.toString(), "--json", "diffoscope.json", diffRootDirectory.relativize(class1).toString(), diffRootDirectory.relativize(class2).toString()); + ProcessBuilder pb = new ProcessBuilder( + DIFFOSCOPE.toString(), + "--json", + "diffoscope.json", + diffRootDirectory.relativize(class1).toString(), + diffRootDirectory.relativize(class2).toString()); pb.directory(diffRootDirectory.toFile()); String recordNumber = class1.getParent().getParent().getFileName().toString(); @@ -35,6 +39,5 @@ public void run() { } catch (IOException | InterruptedException e) { throw new RuntimeException(e); } - } }