Преглед изворни кода

Clean-up minor code quality issues.

Timur Sağlam пре 4 година
родитељ
комит
d7830ed0cc

+ 8 - 12
cli/src/main/java/de/jplag/CLI.java

@@ -58,7 +58,7 @@ import de.jplag.reporting.reportobject.ReportObjectFactory;
  */
  */
 public final class CLI {
 public final class CLI {
 
 
-    private static final Logger logger = LoggerFactory.getLogger(CLI.class);
+    private static final Logger logger = LoggerFactory.getLogger("JPlag");
 
 
     private static final Random RANDOM = new SecureRandom();
     private static final Random RANDOM = new SecureRandom();
 
 
@@ -83,9 +83,9 @@ public final class CLI {
             CLI cli = new CLI();
             CLI cli = new CLI();
             Namespace arguments = cli.parseArguments(args);
             Namespace arguments = cli.parseArguments(args);
             JPlagOptions options = cli.buildOptionsFromArguments(arguments);
             JPlagOptions options = cli.buildOptionsFromArguments(arguments);
-            JPlag program = new JPlag(options);
-            logger.info("JPlag initialized");
-            JPlagResult result = program.run();
+            JPlag jplag = new JPlag(options);
+            logger.debug("JPlag initialized");
+            JPlagResult result = jplag.run();
             ReportObjectFactory reportObjectFactory = new ReportObjectFactory();
             ReportObjectFactory reportObjectFactory = new ReportObjectFactory();
             reportObjectFactory.createAndSaveReport(result, arguments.getString(RESULT_FOLDER.flagWithoutDash()));
             reportObjectFactory.createAndSaveReport(result, arguments.getString(RESULT_FOLDER.flagWithoutDash()));
 
 
@@ -202,15 +202,11 @@ public final class CLI {
             clusteringOptions = clusteringOptions
             clusteringOptions = clusteringOptions
                     .withAgglomerativeInterClusterSimilarity(CLUSTER_AGGLOMERATIVE_INTER_CLUSTER_SIMILARITY.getFrom(namespace));
                     .withAgglomerativeInterClusterSimilarity(CLUSTER_AGGLOMERATIVE_INTER_CLUSTER_SIMILARITY.getFrom(namespace));
         }
         }
-        if (CLUSTER_PREPROCESSING_NONE.isSet(namespace)) {
-            if (CLUSTER_PREPROCESSING_NONE.<Boolean>getFrom(namespace)) {
-                clusteringOptions = clusteringOptions.withPreprocessor(Preprocessing.NONE);
-            }
+        if (CLUSTER_PREPROCESSING_NONE.isSet(namespace) && Boolean.TRUE.equals(CLUSTER_PREPROCESSING_NONE.getFrom(namespace))) {
+            clusteringOptions = clusteringOptions.withPreprocessor(Preprocessing.NONE);
         }
         }
-        if (CLUSTER_PREPROCESSING_CDF.isSet(namespace)) {
-            if (CLUSTER_PREPROCESSING_CDF.<Boolean>getFrom(namespace)) {
-                clusteringOptions = clusteringOptions.withPreprocessor(Preprocessing.CUMULATIVE_DISTRIBUTION_FUNCTION);
-            }
+        if (CLUSTER_PREPROCESSING_CDF.isSet(namespace) && Boolean.TRUE.equals(CLUSTER_PREPROCESSING_CDF.getFrom(namespace))) {
+            clusteringOptions = clusteringOptions.withPreprocessor(Preprocessing.CUMULATIVE_DISTRIBUTION_FUNCTION);
         }
         }
         if (CLUSTER_PREPROCESSING_PERCENTILE.isSet(namespace)) {
         if (CLUSTER_PREPROCESSING_PERCENTILE.isSet(namespace)) {
             clusteringOptions = clusteringOptions.withPreprocessor(Preprocessing.PERCENTILE)
             clusteringOptions = clusteringOptions.withPreprocessor(Preprocessing.PERCENTILE)

+ 3 - 1
core/src/main/java/de/jplag/options/JPlagOptions.java

@@ -186,7 +186,9 @@ public record JPlagOptions(Language language, Integer minimumTokenMatch, Set<Fil
     private Set<String> readExclusionFile(final String exclusionFileName) {
     private Set<String> readExclusionFile(final String exclusionFileName) {
         try (BufferedReader reader = new BufferedReader(new FileReader(exclusionFileName, JPlagOptions.CHARSET))) {
         try (BufferedReader reader = new BufferedReader(new FileReader(exclusionFileName, JPlagOptions.CHARSET))) {
             final var excludedFileNames = reader.lines().collect(Collectors.toSet());
             final var excludedFileNames = reader.lines().collect(Collectors.toSet());
-            logger.debug("Excluded files:\n{}", String.join("\n", excludedFileNames));
+            if (logger.isDebugEnabled()) {
+                logger.debug("Excluded files:{}{}", System.lineSeparator(), String.join(System.lineSeparator(), excludedFileNames));
+            }
             return excludedFileNames;
             return excludedFileNames;
         } catch (IOException e) {
         } catch (IOException e) {
             logger.error("Could not read exclusion file: " + e.getMessage(), e);
             logger.error("Could not read exclusion file: " + e.getMessage(), e);

+ 2 - 2
core/src/main/java/de/jplag/strategy/SubmissionTuple.java

@@ -3,11 +3,11 @@ package de.jplag.strategy;
 import de.jplag.Submission;
 import de.jplag.Submission;
 
 
 /**
 /**
- * Tupel of source code submissions.
+ * Tuple of source code submissions.
  */
  */
 public record SubmissionTuple(Submission left, Submission right) {
 public record SubmissionTuple(Submission left, Submission right) {
     /**
     /**
-     * Creates a tupel from two submissions.
+     * Creates a tuple from two submissions.
      */
      */
     public SubmissionTuple {
     public SubmissionTuple {
         if (left == null || right == null) {
         if (left == null || right == null) {