Просмотр исходного кода

Merge pull request #294 from dfuchss/feature/general-improvements

General improvements
Timur Sağlam 4 лет назад
Родитель
Сommit
38173b1747
80 измененных файлов с 663 добавлено и 827 удалено
  1. 2 2
      jplag.frontend-utils/src/main/java/de/jplag/ErrorConsumer.java
  2. 11 11
      jplag.frontend-utils/src/main/java/de/jplag/Language.java
  3. 2 2
      jplag.frontend-utils/src/main/java/de/jplag/TokenConstants.java
  4. 1 2
      jplag.frontend-utils/src/main/java/de/jplag/TokenList.java
  5. 2 2
      jplag.frontend.chars/src/main/java/de/jplag/chars/CharToken.java
  6. 2 4
      jplag.frontend.chars/src/main/java/de/jplag/chars/Language.java
  7. 2 2
      jplag.frontend.chars/src/main/java/de/jplag/chars/Parser.java
  8. 65 130
      jplag.frontend.cpp/src/main/java/de/jplag/cpp/CPPToken.java
  9. 62 62
      jplag.frontend.cpp/src/main/java/de/jplag/cpp/CPPTokenConstants.java
  10. 1 1
      jplag.frontend.cpp/src/main/java/de/jplag/cpp/Language.java
  11. 6 8
      jplag.frontend.cpp/src/main/java/de/jplag/cpp/NewlineStream.java
  12. 1 1
      jplag.frontend.cpp/src/main/java/de/jplag/cpp/Scanner.java
  13. 56 111
      jplag.frontend.csharp-1.2/src/main/java/de/jplag/csharp/CSharpToken.java
  14. 53 53
      jplag.frontend.csharp-1.2/src/main/java/de/jplag/csharp/CSharpTokenConstants.java
  15. 1 1
      jplag.frontend.csharp-1.2/src/main/java/de/jplag/csharp/Language.java
  16. 1 1
      jplag.frontend.csharp-1.2/src/main/java/de/jplag/csharp/Parser.java
  17. 8 9
      jplag.frontend.csharp-1.2/src/main/java/de/jplag/csharp/UnicodeReader.java
  18. 65 66
      jplag.frontend.java/src/main/java/de/jplag/java/JavaTokenConstants.java
  19. 1 1
      jplag.frontend.java/src/main/java/de/jplag/java/Language.java
  20. 2 2
      jplag.frontend.java/src/main/java/de/jplag/java/Parser.java
  21. 0 2
      jplag.frontend.java/src/main/java/de/jplag/java/TokenGeneratingTreeScanner.java
  22. 1 1
      jplag.frontend.python-3/src/main/java/de/jplag/python3/JplagPython3Listener.java
  23. 1 1
      jplag.frontend.python-3/src/main/java/de/jplag/python3/Language.java
  24. 1 1
      jplag.frontend.python-3/src/main/java/de/jplag/python3/Parser.java
  25. 31 31
      jplag.frontend.python-3/src/main/java/de/jplag/python3/Python3TokenConstants.java
  26. 1 1
      jplag.frontend.scheme/src/main/java/de/jplag/scheme/Language.java
  27. 1 1
      jplag.frontend.scheme/src/main/java/de/jplag/scheme/Parser.java
  28. 45 89
      jplag.frontend.scheme/src/main/java/de/jplag/scheme/SchemeToken.java
  29. 42 42
      jplag.frontend.scheme/src/main/java/de/jplag/scheme/SchemeTokenConstants.java
  30. 2 5
      jplag.frontend.text/src/main/java/de/jplag/text/Language.java
  31. 1 1
      jplag.frontend.text/src/main/java/de/jplag/text/Parser.java
  32. 5 2
      jplag.frontend.text/src/main/java/de/jplag/text/TextToken.java
  33. 1 1
      jplag/src/main/java/de/jplag/CLI.java
  34. 2 2
      jplag/src/main/java/de/jplag/CliGroupHelper.java
  35. 1 1
      jplag/src/main/java/de/jplag/ErrorCollector.java
  36. 2 2
      jplag/src/main/java/de/jplag/GreedyStringTiling.java
  37. 6 11
      jplag/src/main/java/de/jplag/JPlag.java
  38. 6 9
      jplag/src/main/java/de/jplag/JPlagComparison.java
  39. 1 1
      jplag/src/main/java/de/jplag/NumberOfArgumentValues.java
  40. 2 2
      jplag/src/main/java/de/jplag/Submission.java
  41. 2 2
      jplag/src/main/java/de/jplag/SubmissionSet.java
  42. 4 9
      jplag/src/main/java/de/jplag/SubmissionSetBuilder.java
  43. 4 4
      jplag/src/main/java/de/jplag/TimeUtil.java
  44. 3 2
      jplag/src/main/java/de/jplag/clustering/Cluster.java
  45. 6 6
      jplag/src/main/java/de/jplag/clustering/ClusteringAdapter.java
  46. 32 4
      jplag/src/main/java/de/jplag/clustering/ClusteringAlgorithm.java
  47. 1 8
      jplag/src/main/java/de/jplag/clustering/ClusteringFactory.java
  48. 3 3
      jplag/src/main/java/de/jplag/clustering/ClusteringResult.java
  49. 2 2
      jplag/src/main/java/de/jplag/clustering/IntegerMapping.java
  50. 1 1
      jplag/src/main/java/de/jplag/clustering/Preprocessing.java
  51. 8 7
      jplag/src/main/java/de/jplag/clustering/algorithm/AgglomerativeClustering.java
  52. 10 11
      jplag/src/main/java/de/jplag/clustering/algorithm/BFGS.java
  53. 10 8
      jplag/src/main/java/de/jplag/clustering/algorithm/BayesianOptimization.java
  54. 7 7
      jplag/src/main/java/de/jplag/clustering/algorithm/GaussianProcess.java
  55. 8 9
      jplag/src/main/java/de/jplag/clustering/algorithm/InterClusterSimilarity.java
  56. 5 6
      jplag/src/main/java/de/jplag/clustering/algorithm/SpectralClustering.java
  57. 1 1
      jplag/src/main/java/de/jplag/clustering/preprocessors/CumulativeDistributionFunctionPreprocessor.java
  58. 1 1
      jplag/src/main/java/de/jplag/clustering/preprocessors/PercentileThresholdProcessor.java
  59. 2 2
      jplag/src/main/java/de/jplag/clustering/preprocessors/ThresholdPreprocessor.java
  60. 3 0
      jplag/src/main/java/de/jplag/exceptions/BasecodeException.java
  61. 3 0
      jplag/src/main/java/de/jplag/exceptions/ExitException.java
  62. 3 0
      jplag/src/main/java/de/jplag/exceptions/ReportGenerationException.java
  63. 3 0
      jplag/src/main/java/de/jplag/exceptions/RootDirectoryException.java
  64. 3 0
      jplag/src/main/java/de/jplag/exceptions/SubmissionException.java
  65. 8 12
      jplag/src/main/java/de/jplag/options/JPlagOptions.java
  66. 4 4
      jplag/src/main/java/de/jplag/options/SimilarityMetric.java
  67. 4 8
      jplag/src/main/java/de/jplag/options/Verbosity.java
  68. 1 1
      jplag/src/main/java/de/jplag/reporting/Color.java
  69. 1 1
      jplag/src/main/java/de/jplag/reporting/HTMLFile.java
  70. 1 1
      jplag/src/main/java/de/jplag/reporting/MarkupText.java
  71. 1 1
      jplag/src/main/java/de/jplag/strategy/AbstractComparisonStrategy.java
  72. 2 2
      jplag/src/main/java/de/jplag/strategy/ComparisonMode.java
  73. 1 1
      jplag/src/main/java/de/jplag/strategy/NormalComparisonStrategy.java
  74. 1 1
      jplag/src/main/java/de/jplag/strategy/ParallelComparisonStrategy.java
  75. 1 1
      jplag/src/main/java/de/jplag/strategy/SubmissionTuple.java
  76. 1 8
      jplag/src/test/java/de/jplag/cli/MinTokenMatchTest.java
  77. 4 4
      jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/A/Token.java
  78. 4 4
      jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/B/Token.java
  79. 4 4
      jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/C/Token.java
  80. 4 4
      jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/D/Token.java

+ 2 - 2
jplag.frontend-utils/src/main/java/de/jplag/ErrorConsumer.java

@@ -9,12 +9,12 @@ public interface ErrorConsumer {
      * Adds an error to the error stack. The error is only printed directly when using the corresponding verbosity option.
      * @param errorMessage is the error message.
      */
-    public void addError(String errorMessage);
+    void addError(String errorMessage);
 
     /**
      * Prints a message depending on the verbosity.
      * @param message is the message for the normal mode.
      * @param longMessage is the message for verbose mode.
      */
-    public void print(String message, String longMessage);
+    void print(String message, String longMessage);
 }

+ 11 - 11
jplag.frontend-utils/src/main/java/de/jplag/Language.java

@@ -10,55 +10,55 @@ public interface Language {
     /**
      * Suffixes for the files containing code of the language.
      */
-    public String[] suffixes();
+    String[] suffixes();
 
     /**
      * Descriptive name of the language.
      */
-    public String getName();
+    String getName();
 
     /**
      * Short name of the language used for CLI options.
      */
-    public String getShortName();
+    String getShortName();
 
     /**
      * Minimum number of tokens required for a match.
      */
-    public int minimumTokenMatch();
+    int minimumTokenMatch();
 
     /**
      * Parses a set files in a directory.
      */
-    public TokenList parse(File dir, String[] files);
+    TokenList parse(File dir, String[] files);
 
     /**
      * Whether errors were found during the last {@link #parse}.
      */
-    public boolean hasErrors();
+    boolean hasErrors();
 
     /**
      * Number of errors found during the last {@link #parse}.
      */
-    public int errorCount();
+    int errorCount();
 
     /**
      * Determines whether the parser provide column information.
      */
-    public boolean supportsColumns();
+    boolean supportsColumns();
 
     /**
      * Determines whether JPlag should use a fixed-width font in its reports.
      */
-    public boolean isPreformatted();
+    boolean isPreformatted();
 
     /**
      * Determines whether tokens from the scanner are indexed.
      */
-    public boolean usesIndex();
+    boolean usesIndex();
 
     /**
      * Number of defined tokens in the scanner of the language.
      */
-    public int numberOfTokens();
+    int numberOfTokens();
 }

+ 2 - 2
jplag.frontend-utils/src/main/java/de/jplag/TokenConstants.java

@@ -7,10 +7,10 @@ public interface TokenConstants {
     /**
      * Marks the end of the file, has a special purpose in the comparison algorithm.
      */
-    final static int FILE_END = 0;
+    int FILE_END = 0;
 
     /**
      * Used to optionally separate methods from each other with an always marked token
      */
-    final static int SEPARATOR_TOKEN = 1;
+    int SEPARATOR_TOKEN = 1;
 }

+ 1 - 2
jplag.frontend-utils/src/main/java/de/jplag/TokenList.java

@@ -55,8 +55,7 @@ public class TokenList {
 
     @Override
     public final String toString() {
-        StringBuffer buffer = new StringBuffer();
-
+        StringBuilder buffer = new StringBuilder();
         try {
             for (int i = 0; i < tokens.size(); i++) {
                 buffer.append(i);

+ 2 - 2
jplag.frontend.chars/src/main/java/de/jplag/chars/CharToken.java

@@ -4,8 +4,8 @@ import de.jplag.Token;
 
 public class CharToken extends Token {
 
-    private int index;
-    private Character character;
+    private final int index;
+    private final Character character;
 
     public CharToken(int type, String file, int index, Character character, Parser parser) {
         super(type, file, -1);

+ 2 - 4
jplag.frontend.chars/src/main/java/de/jplag/chars/Language.java

@@ -9,13 +9,11 @@ import de.jplag.TokenList;
  * read in text files as characters
  */
 public class Language implements de.jplag.Language {
-    private ErrorConsumer program;
 
-    private de.jplag.chars.Parser parser = new Parser();
+    private final de.jplag.chars.Parser parser = new Parser();
 
     public Language(ErrorConsumer program) {
-        this.program = program;
-        this.parser.setProgram(this.program);
+        this.parser.setProgram(program);
     }
 
     @Override

+ 2 - 2
jplag.frontend.chars/src/main/java/de/jplag/chars/Parser.java

@@ -12,7 +12,7 @@ public class Parser extends AbstractParser {
 
     private TokenList tokens;
 
-    public TokenList parse(File directory, String files[]) {
+    public TokenList parse(File directory, String[] files) {
         tokens = new TokenList();
         errors = 0;
         for (String file : files) {
@@ -59,7 +59,7 @@ public class Parser extends AbstractParser {
         return true;
     }
 
-    private int[] mapping = {-1, // 0 (nul)
+    private final int[] mapping = {-1, // 0 (nul)
             -1, // 1 (soh)
             -1, // 2 (stx)
             -1, // 3 (etx)

+ 65 - 130
jplag.frontend.cpp/src/main/java/de/jplag/cpp/CPPToken.java

@@ -13,135 +13,70 @@ public class CPPToken extends Token implements CPPTokenConstants {
     }
 
     protected String type2string() {
-        switch (type) {
-            case CPPTokenConstants.FILE_END:
-                return "EOF";
-
-            case C_BLOCK_BEGIN:
-                return "BLOCK{";
-            case C_BLOCK_END:
-                return "}BLOCK";
-            case C_SCOPE:
-                return "SCOPE";
-            case C_QUESTIONMARK:
-                return "COND";
-            case C_ELLIPSIS:
-                return "...";
-            case C_ASSIGN:
-                return "ASSIGN";
-            case C_DOT:
-                return "DOT";
-            case C_ARROW:
-                return "ARROW";
-            case C_DOTSTAR:
-                return "DOTSTAR";
-            case C_ARROWSTAR:
-                return "ARROWSTAR";
-            case C_AUTO:
-                return "AUTO";
-            case C_BREAK:
-                return "BREAK";
-            case C_CASE:
-                return "CASE";
-            case C_CATCH:
-                return "CATCH";
-            case C_CHAR:
-                return "CHAR";
-            case C_CONST:
-                return "CONST";
-            case C_CONTINUE:
-                return "CONTINUE";
-            case C_DEFAULT:
-                return "DEFAULT";
-            case C_DELETE:
-                return "DELETE";
-            case C_DO:
-                return "DO";
-            case C_DOUBLE:
-                return "DOUBLE";
-            case C_ELSE:
-                return "ELSE";
-            case C_ENUM:
-                return "ENUM";
-            case C_EXTERN:
-                return "EXTERN";
-            case C_FLOAT:
-                return "FLOAT";
-            case C_FOR:
-                return "FOR";
-            case C_FRIEND:
-                return "FRIEND";
-            case C_GOTO:
-                return "GOTO";
-            case C_IF:
-                return "IF";
-            case C_INLINE:
-                return "INLINE";
-            case C_INT:
-                return "INT";
-            case C_LONG:
-                return "LONG";
-            case C_NEW:
-                return "NEW";
-            case C_PRIVATE:
-                return "PRIVATE";
-            case C_PROTECTED:
-                return "PROTECTED";
-            case C_PUBLIC:
-                return "PUBLIC";
-            case C_REDECLARED:
-                return "REDECLARED";
-            case C_REGISTER:
-                return "REGISTER";
-            case C_RETURN:
-                return "RETURN";
-            case C_SHORT:
-                return "SHORT";
-            case C_SIGNED:
-                return "SIGNED";
-            case C_SIZEOF:
-                return "SIZEOF";
-            case C_STATIC:
-                return "STATIC";
-            case C_STRUCT:
-                return "STRUCT";
-            case C_CLASS:
-                return "CLASS";
-            case C_SWITCH:
-                return "SWITCH";
-            case C_TEMPLATE:
-                return "TEMPLATE";
-            case C_THIS:
-                return "THIS";
-            case C_TRY:
-                return "TRY";
-            case C_TYPEDEF:
-                return "TYPEDEF";
-            case C_UNION:
-                return "UNION";
-            case C_UNSIGNED:
-                return "UNSIGNED";
-            case C_VIRTUAL:
-                return "VIRTUAL";
-            case C_VOID:
-                return "VOID";
-            case C_VOLANTILE:
-                return "VOLANTILE";
-            case C_WHILE:
-                return "WHILE";
-            case C_OPERATOR:
-                return "OPERATOR";
-            case C_THROW:
-                return "THROW";
-            case C_ID:
-                return "ID";
-            case C_FUN:
-                return "FUN";
-            case C_NULL:
-                return "NULL";
-
-            default:
-                return "<UNKNOWN" + type + ">";
-        }
+        return switch (type) {
+            case CPPTokenConstants.FILE_END -> "EOF";
+            case C_BLOCK_BEGIN -> "BLOCK{";
+            case C_BLOCK_END -> "}BLOCK";
+            case C_SCOPE -> "SCOPE";
+            case C_QUESTIONMARK -> "COND";
+            case C_ELLIPSIS -> "...";
+            case C_ASSIGN -> "ASSIGN";
+            case C_DOT -> "DOT";
+            case C_ARROW -> "ARROW";
+            case C_DOTSTAR -> "DOTSTAR";
+            case C_ARROWSTAR -> "ARROWSTAR";
+            case C_AUTO -> "AUTO";
+            case C_BREAK -> "BREAK";
+            case C_CASE -> "CASE";
+            case C_CATCH -> "CATCH";
+            case C_CHAR -> "CHAR";
+            case C_CONST -> "CONST";
+            case C_CONTINUE -> "CONTINUE";
+            case C_DEFAULT -> "DEFAULT";
+            case C_DELETE -> "DELETE";
+            case C_DO -> "DO";
+            case C_DOUBLE -> "DOUBLE";
+            case C_ELSE -> "ELSE";
+            case C_ENUM -> "ENUM";
+            case C_EXTERN -> "EXTERN";
+            case C_FLOAT -> "FLOAT";
+            case C_FOR -> "FOR";
+            case C_FRIEND -> "FRIEND";
+            case C_GOTO -> "GOTO";
+            case C_IF -> "IF";
+            case C_INLINE -> "INLINE";
+            case C_INT -> "INT";
+            case C_LONG -> "LONG";
+            case C_NEW -> "NEW";
+            case C_PRIVATE -> "PRIVATE";
+            case C_PROTECTED -> "PROTECTED";
+            case C_PUBLIC -> "PUBLIC";
+            case C_REDECLARED -> "REDECLARED";
+            case C_REGISTER -> "REGISTER";
+            case C_RETURN -> "RETURN";
+            case C_SHORT -> "SHORT";
+            case C_SIGNED -> "SIGNED";
+            case C_SIZEOF -> "SIZEOF";
+            case C_STATIC -> "STATIC";
+            case C_STRUCT -> "STRUCT";
+            case C_CLASS -> "CLASS";
+            case C_SWITCH -> "SWITCH";
+            case C_TEMPLATE -> "TEMPLATE";
+            case C_THIS -> "THIS";
+            case C_TRY -> "TRY";
+            case C_TYPEDEF -> "TYPEDEF";
+            case C_UNION -> "UNION";
+            case C_UNSIGNED -> "UNSIGNED";
+            case C_VIRTUAL -> "VIRTUAL";
+            case C_VOID -> "VOID";
+            case C_VOLANTILE -> "VOLANTILE";
+            case C_WHILE -> "WHILE";
+            case C_OPERATOR -> "OPERATOR";
+            case C_THROW -> "THROW";
+            case C_ID -> "ID";
+            case C_FUN -> "FUN";
+            case C_NULL -> "NULL";
+            default -> "<UNKNOWN" + type + ">";
+        };
     }
 }

+ 62 - 62
jplag.frontend.cpp/src/main/java/de/jplag/cpp/CPPTokenConstants.java

@@ -3,67 +3,67 @@ package de.jplag.cpp;
 import de.jplag.TokenConstants;
 
 public interface CPPTokenConstants extends TokenConstants {
-    final static int C_BLOCK_BEGIN = 2;
-    final static int C_BLOCK_END = 3;
-    final static int C_SCOPE = 4;
-    final static int C_QUESTIONMARK = 5;
-    final static int C_ELLIPSIS = 6;
-    final static int C_ASSIGN = 7;
-    final static int C_DOT = 8;
-    final static int C_ARROW = 9;
-    final static int C_ARROWSTAR = 10;
-    final static int C_AUTO = 11;
-    final static int C_BREAK = 12;
-    final static int C_CASE = 13;
-    final static int C_CATCH = 14;
-    final static int C_CHAR = 15;
-    final static int C_CONST = 16;
-    final static int C_CONTINUE = 17;
-    final static int C_DEFAULT = 18;
-    final static int C_DELETE = 19;
-    final static int C_DO = 20;
-    final static int C_DOUBLE = 21;
-    final static int C_ELSE = 22;
-    final static int C_ENUM = 23;
-    final static int C_EXTERN = 24;
-    final static int C_FLOAT = 25;
-    final static int C_FOR = 26;
-    final static int C_FRIEND = 27;
-    final static int C_GOTO = 28;
-    final static int C_IF = 29;
-    final static int C_INLINE = 30;
-    final static int C_INT = 31;
-    final static int C_LONG = 32;
-    final static int C_NEW = 33;
-    final static int C_PRIVATE = 34;
-    final static int C_PROTECTED = 35;
-    final static int C_PUBLIC = 36;
-    final static int C_REDECLARED = 37;
-    final static int C_REGISTER = 38;
-    final static int C_RETURN = 39;
-    final static int C_SHORT = 40;
-    final static int C_SIGNED = 41;
-    final static int C_SIZEOF = 42;
-    final static int C_STATIC = 43;
-    final static int C_STRUCT = 44;
-    final static int C_CLASS = 45;
-    final static int C_SWITCH = 46;
-    final static int C_TEMPLATE = 47;
-    final static int C_THIS = 48;
-    final static int C_TRY = 49;
-    final static int C_TYPEDEF = 50;
-    final static int C_UNION = 51;
-    final static int C_UNSIGNED = 52;
-    final static int C_VIRTUAL = 53;
-    final static int C_VOID = 54;
-    final static int C_VOLANTILE = 55;
-    final static int C_WHILE = 56;
-    final static int C_OPERATOR = 57;
-    final static int C_THROW = 58;
-    final static int C_ID = 59;
-    final static int C_FUN = 60;
-    final static int C_DOTSTAR = 61;
-    final static int C_NULL = 62;
+    int C_BLOCK_BEGIN = 2;
+    int C_BLOCK_END = 3;
+    int C_SCOPE = 4;
+    int C_QUESTIONMARK = 5;
+    int C_ELLIPSIS = 6;
+    int C_ASSIGN = 7;
+    int C_DOT = 8;
+    int C_ARROW = 9;
+    int C_ARROWSTAR = 10;
+    int C_AUTO = 11;
+    int C_BREAK = 12;
+    int C_CASE = 13;
+    int C_CATCH = 14;
+    int C_CHAR = 15;
+    int C_CONST = 16;
+    int C_CONTINUE = 17;
+    int C_DEFAULT = 18;
+    int C_DELETE = 19;
+    int C_DO = 20;
+    int C_DOUBLE = 21;
+    int C_ELSE = 22;
+    int C_ENUM = 23;
+    int C_EXTERN = 24;
+    int C_FLOAT = 25;
+    int C_FOR = 26;
+    int C_FRIEND = 27;
+    int C_GOTO = 28;
+    int C_IF = 29;
+    int C_INLINE = 30;
+    int C_INT = 31;
+    int C_LONG = 32;
+    int C_NEW = 33;
+    int C_PRIVATE = 34;
+    int C_PROTECTED = 35;
+    int C_PUBLIC = 36;
+    int C_REDECLARED = 37;
+    int C_REGISTER = 38;
+    int C_RETURN = 39;
+    int C_SHORT = 40;
+    int C_SIGNED = 41;
+    int C_SIZEOF = 42;
+    int C_STATIC = 43;
+    int C_STRUCT = 44;
+    int C_CLASS = 45;
+    int C_SWITCH = 46;
+    int C_TEMPLATE = 47;
+    int C_THIS = 48;
+    int C_TRY = 49;
+    int C_TYPEDEF = 50;
+    int C_UNION = 51;
+    int C_UNSIGNED = 52;
+    int C_VIRTUAL = 53;
+    int C_VOID = 54;
+    int C_VOLANTILE = 55;
+    int C_WHILE = 56;
+    int C_OPERATOR = 57;
+    int C_THROW = 58;
+    int C_ID = 59;
+    int C_FUN = 60;
+    int C_DOTSTAR = 61;
+    int C_NULL = 62;
 
-    final static int NUM_DIFF_TOKENS = 63;
+    int NUM_DIFF_TOKENS = 63;
 }

+ 1 - 1
jplag.frontend.cpp/src/main/java/de/jplag/cpp/Language.java

@@ -6,7 +6,7 @@ import de.jplag.ErrorConsumer;
 import de.jplag.TokenList;
 
 public class Language implements de.jplag.Language {
-    private Scanner scanner; // cpp code is scanned not parsed
+    private final Scanner scanner; // cpp code is scanned not parsed
 
     public Language(ErrorConsumer program) {
         this.scanner = new Scanner();

+ 6 - 8
jplag.frontend.cpp/src/main/java/de/jplag/cpp/NewlineStream.java

@@ -8,7 +8,7 @@ import java.io.InputStream;
  */
 public class NewlineStream extends InputStream {
     private int endOfFile = 0;
-    private InputStream stream;
+    private final InputStream stream;
 
     public NewlineStream(InputStream stream) {
         super();
@@ -19,20 +19,18 @@ public class NewlineStream extends InputStream {
     public int read() throws IOException {
         int result;
         switch (endOfFile) {
-            case 0:
+            case 0 -> {
                 result = stream.read();
                 if (result == -1) {
                     result = 13;
                     endOfFile = 1;
                 }
-                break;
-            case 1:
+            }
+            case 1 -> {
                 result = 10;
                 endOfFile = 2;
-                break;
-            default:
-                result = -1;
-                break;
+            }
+            default -> result = -1;
         }
         return result;
     }

+ 1 - 1
jplag.frontend.cpp/src/main/java/de/jplag/cpp/Scanner.java

@@ -10,7 +10,7 @@ public class Scanner extends AbstractParser {
 
     private TokenList tokens;
 
-    public TokenList scan(File directory, String files[]) {
+    public TokenList scan(File directory, String[] files) {
         tokens = new TokenList();
         errors = 0;
         CPPScanner scanner = null;// will be initialized in Method scanFile

+ 56 - 111
jplag.frontend.csharp-1.2/src/main/java/de/jplag/csharp/CSharpToken.java

@@ -9,116 +9,61 @@ public class CSharpToken extends Token implements CSharpTokenConstants {
     }
 
     protected String type2string() {
-        switch (type) {
-            case CSharpTokenConstants.FILE_END:
-                return "EOF";
-            case _INVOCATION:
-                return "INVOCATION";
-            case _OBJECT_CREATION:
-                return "OBJECT_CRE";
-            case _ARRAY_CREATION:
-                return "ARRAY_CREA";
-            case _ASSIGNMENT:
-                return "ASSIGNMENT";
-            case _L_BRACE:
-                return "L_BRACE { ";
-            case _R_BRACE:
-                return "R_BRACE } ";
-            case _DECLARE_VAR:
-                return "DECLAREVAR";
-            case _DECLARE_CONST:
-                return "DECLARE_CO";
-            case _IF:
-                return "IF {      ";
-            case _ELSE:
-                return "ELSE      ";
-            case _END_IF:
-                return "IF }      ";
-            case _SWITCH_BEGIN:
-                return "SWITCH {  ";
-            case _SWITCH_END:
-                return "SWITCH }  ";
-            case _CASE:
-                return "CASE      ";
-            case _DO:
-                return "DO        ";
-            case _WHILE:
-                return "WHILE     ";
-            case _FOR:
-                return "FOR       ";
-            case _FOREACH:
-                return "FOREACH   ";
-            case _BREAK:
-                return "BREAK     ";
-            case _CONTINUE:
-                return "CONTINUE  ";
-            case _GOTO:
-                return "GOTO      ";
-            case _RETURN:
-                return "RETURN    ";
-            case _THROW:
-                return "THROW     ";
-            case _CHECKED:
-                return "CHECKED   ";
-            case _UNCHECKED:
-                return "UNCHECKED ";
-            case _LOCK:
-                return "LOCK      ";
-            case _USING:
-                return "USING     ";
-            case _TRY:
-                return "TRY       ";
-            case _CATCH:
-                return "CATCH     ";
-            case _FINALLY:
-                return "FINALLY   ";
-            case _NAMESPACE_BEGIN:
-                return "NAMESPACE{";
-            case _NAMESPACE_END:
-                return "NAMESPACE}";
-            case _USING_DIRECTIVE:
-                return "USING_DIR ";
-            case _CLASS_BEGIN:
-                return "CLASS {   ";
-            case _CLASS_END:
-                return "CLASS }   ";
-            case _METHOD:
-                return "METHOD    ";
-            case _PROPERTY:
-                return "PROPERTY  ";
-            case _EVENT:
-                return "EVENT     ";
-            case _INDEXER:
-                return "INDEXER   ";
-            case _OPERATOR:
-                return "OPERATOR  ";
-            case _CONSTRUCTOR:
-                return "CONSTR    ";
-            case _STATIC_CONSTR:
-                return "ST_CONSTR ";
-            case _DESTRUCTOR:
-                return "DESTRUCTOR";
-            case _STRUCT_BEGIN:
-                return "STRUCT {  ";
-            case _STRUCT_END:
-                return "STRUCT }  ";
-            case _INTERFACE_BEGIN:
-                return "INTERFACE{";
-            case _INTERFACE_END:
-                return "INTERFACE}";
-            case _ENUM:
-                return "ENUM      ";
-            case _DELEGATE:
-                return "DELEGATE  ";
-            case _ATTRIBUTE:
-                return "ATTRIBUTE ";
-            case _UNSAFE:
-                return "UNSAFE    ";
-            case _FIXED:
-                return "FIXED     ";
-
-            default:
-                return "<UNKNOWN> ";
-        }
+        return switch (type) {
+            case CSharpTokenConstants.FILE_END -> "EOF";
+            case _INVOCATION -> "INVOCATION";
+            case _OBJECT_CREATION -> "OBJECT_CRE";
+            case _ARRAY_CREATION -> "ARRAY_CREA";
+            case _ASSIGNMENT -> "ASSIGNMENT";
+            case _L_BRACE -> "L_BRACE { ";
+            case _R_BRACE -> "R_BRACE } ";
+            case _DECLARE_VAR -> "DECLAREVAR";
+            case _DECLARE_CONST -> "DECLARE_CO";
+            case _IF -> "IF {      ";
+            case _ELSE -> "ELSE      ";
+            case _END_IF -> "IF }      ";
+            case _SWITCH_BEGIN -> "SWITCH {  ";
+            case _SWITCH_END -> "SWITCH }  ";
+            case _CASE -> "CASE      ";
+            case _DO -> "DO        ";
+            case _WHILE -> "WHILE     ";
+            case _FOR -> "FOR       ";
+            case _FOREACH -> "FOREACH   ";
+            case _BREAK -> "BREAK     ";
+            case _CONTINUE -> "CONTINUE  ";
+            case _GOTO -> "GOTO      ";
+            case _RETURN -> "RETURN    ";
+            case _THROW -> "THROW     ";
+            case _CHECKED -> "CHECKED   ";
+            case _UNCHECKED -> "UNCHECKED ";
+            case _LOCK -> "LOCK      ";
+            case _USING -> "USING     ";
+            case _TRY -> "TRY       ";
+            case _CATCH -> "CATCH     ";
+            case _FINALLY -> "FINALLY   ";
+            case _NAMESPACE_BEGIN -> "NAMESPACE{";
+            case _NAMESPACE_END -> "NAMESPACE}";
+            case _USING_DIRECTIVE -> "USING_DIR ";
+            case _CLASS_BEGIN -> "CLASS {   ";
+            case _CLASS_END -> "CLASS }   ";
+            case _METHOD -> "METHOD    ";
+            case _PROPERTY -> "PROPERTY  ";
+            case _EVENT -> "EVENT     ";
+            case _INDEXER -> "INDEXER   ";
+            case _OPERATOR -> "OPERATOR  ";
+            case _CONSTRUCTOR -> "CONSTR    ";
+            case _STATIC_CONSTR -> "ST_CONSTR ";
+            case _DESTRUCTOR -> "DESTRUCTOR";
+            case _STRUCT_BEGIN -> "STRUCT {  ";
+            case _STRUCT_END -> "STRUCT }  ";
+            case _INTERFACE_BEGIN -> "INTERFACE{";
+            case _INTERFACE_END -> "INTERFACE}";
+            case _ENUM -> "ENUM      ";
+            case _DELEGATE -> "DELEGATE  ";
+            case _ATTRIBUTE -> "ATTRIBUTE ";
+            case _UNSAFE -> "UNSAFE    ";
+            case _FIXED -> "FIXED     ";
+            default -> "<UNKNOWN> ";
+        };
     }
 }

+ 53 - 53
jplag.frontend.csharp-1.2/src/main/java/de/jplag/csharp/CSharpTokenConstants.java

@@ -3,58 +3,58 @@ package de.jplag.csharp;
 import de.jplag.TokenConstants;
 
 public interface CSharpTokenConstants extends TokenConstants {
-    final static int _INVOCATION = 2;
-    final static int _OBJECT_CREATION = 3;
-    final static int _ARRAY_CREATION = 4;
-    final static int _ASSIGNMENT = 5;
-    final static int _L_BRACE = 6;
-    final static int _R_BRACE = 7;
-    final static int _DECLARE_VAR = 8;
-    final static int _DECLARE_CONST = 9;
-    final static int _IF = 10;
-    final static int _ELSE = 11;
-    final static int _SWITCH_BEGIN = 12;
-    final static int _SWITCH_END = 13;
-    final static int _CASE = 14;
-    final static int _DO = 15;
-    final static int _WHILE = 16;
-    final static int _FOR = 17;
-    final static int _FOREACH = 18;
-    final static int _BREAK = 19;
-    final static int _CONTINUE = 20;
-    final static int _GOTO = 21;
-    final static int _RETURN = 22;
-    final static int _THROW = 23;
-    final static int _CHECKED = 24;
-    final static int _UNCHECKED = 25;
-    final static int _LOCK = 26;
-    final static int _USING = 27;
-    final static int _TRY = 28;
-    final static int _CATCH = 29;
-    final static int _FINALLY = 30;
-    final static int _NAMESPACE_BEGIN = 31;
-    final static int _NAMESPACE_END = 32;
-    final static int _USING_DIRECTIVE = 33;
-    final static int _CLASS_BEGIN = 34;
-    final static int _CLASS_END = 35;
-    final static int _METHOD = 36;
-    final static int _PROPERTY = 37;
-    final static int _EVENT = 38;
-    final static int _INDEXER = 39;
-    final static int _OPERATOR = 40;
-    final static int _CONSTRUCTOR = 41;
-    final static int _STATIC_CONSTR = 42;
-    final static int _DESTRUCTOR = 43;
-    final static int _STRUCT_BEGIN = 44;
-    final static int _STRUCT_END = 45;
-    final static int _INTERFACE_BEGIN = 46;
-    final static int _INTERFACE_END = 47;
-    final static int _ENUM = 48;
-    final static int _DELEGATE = 49;
-    final static int _ATTRIBUTE = 50;
-    final static int _END_IF = 51;
-    final static int _UNSAFE = 52;
-    final static int _FIXED = 53;
+    int _INVOCATION = 2;
+    int _OBJECT_CREATION = 3;
+    int _ARRAY_CREATION = 4;
+    int _ASSIGNMENT = 5;
+    int _L_BRACE = 6;
+    int _R_BRACE = 7;
+    int _DECLARE_VAR = 8;
+    int _DECLARE_CONST = 9;
+    int _IF = 10;
+    int _ELSE = 11;
+    int _SWITCH_BEGIN = 12;
+    int _SWITCH_END = 13;
+    int _CASE = 14;
+    int _DO = 15;
+    int _WHILE = 16;
+    int _FOR = 17;
+    int _FOREACH = 18;
+    int _BREAK = 19;
+    int _CONTINUE = 20;
+    int _GOTO = 21;
+    int _RETURN = 22;
+    int _THROW = 23;
+    int _CHECKED = 24;
+    int _UNCHECKED = 25;
+    int _LOCK = 26;
+    int _USING = 27;
+    int _TRY = 28;
+    int _CATCH = 29;
+    int _FINALLY = 30;
+    int _NAMESPACE_BEGIN = 31;
+    int _NAMESPACE_END = 32;
+    int _USING_DIRECTIVE = 33;
+    int _CLASS_BEGIN = 34;
+    int _CLASS_END = 35;
+    int _METHOD = 36;
+    int _PROPERTY = 37;
+    int _EVENT = 38;
+    int _INDEXER = 39;
+    int _OPERATOR = 40;
+    int _CONSTRUCTOR = 41;
+    int _STATIC_CONSTR = 42;
+    int _DESTRUCTOR = 43;
+    int _STRUCT_BEGIN = 44;
+    int _STRUCT_END = 45;
+    int _INTERFACE_BEGIN = 46;
+    int _INTERFACE_END = 47;
+    int _ENUM = 48;
+    int _DELEGATE = 49;
+    int _ATTRIBUTE = 50;
+    int _END_IF = 51;
+    int _UNSAFE = 52;
+    int _FIXED = 53;
 
-    final static int NUM_DIFF_TOKENS = 54;
+    int NUM_DIFF_TOKENS = 54;
 }

+ 1 - 1
jplag.frontend.csharp-1.2/src/main/java/de/jplag/csharp/Language.java

@@ -6,7 +6,7 @@ import de.jplag.ErrorConsumer;
 import de.jplag.TokenList;
 
 public class Language implements de.jplag.Language {
-    private Parser parser;
+    private final Parser parser;
 
     public Language(ErrorConsumer program) {
         this.parser = new Parser();

+ 1 - 1
jplag.frontend.csharp-1.2/src/main/java/de/jplag/csharp/Parser.java

@@ -15,7 +15,7 @@ public class Parser extends AbstractParser {
     private TokenList tokens;
     private String currentFile;
 
-    public TokenList parse(File directory, String files[]) {
+    public TokenList parse(File directory, String[] files) {
         tokens = new TokenList();
         errors = 0;
         for (int i = 0; i < files.length; i++) {

+ 8 - 9
jplag.frontend.csharp-1.2/src/main/java/de/jplag/csharp/UnicodeReader.java

@@ -7,6 +7,7 @@ import java.io.PushbackInputStream;
 import java.io.Reader;
 import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
+import java.util.Objects;
 
 /**
  * Generic unicode text reader, which will use BOM mark to identify the encoding to be used. If BOM is not found then
@@ -33,11 +34,11 @@ import java.nio.charset.StandardCharsets;
  * </pre>
  */
 public class UnicodeReader extends Reader {
-    private PushbackInputStream internalIn;
+    private final PushbackInputStream internalIn;
 
     private InputStreamReader internalIn2 = null;
 
-    private Charset defaultEnc;
+    private final Charset defaultEnc;
 
     private static final int BOM_SIZE = 4;
 
@@ -64,7 +65,7 @@ public class UnicodeReader extends Reader {
             return;
 
         Charset encoding;
-        byte bom[] = new byte[BOM_SIZE];
+        byte[] bom = new byte[BOM_SIZE];
         int n, unread;
         n = internalIn.read(bom, 0, bom.length);
 
@@ -80,7 +81,9 @@ public class UnicodeReader extends Reader {
         } else if ((bom[0] == (byte) 0x00) && (bom[1] == (byte) 0x00) && (bom[2] == (byte) 0xFE) && (bom[3] == (byte) 0xFF)) {
             encoding = Charset.forName("UTF-32BE");
             unread = n - 4;
-        } else if ((bom[0] == (byte) 0xFF) && (bom[1] == (byte) 0xFE) && (bom[2] == (byte) 0x00) && (bom[3] == (byte) 0x00)) {
+        }
+        // TODO WARNING: This line will evaluate always to false. Maybe that's an issue
+        else if ((bom[0] == (byte) 0xFF) && (bom[1] == (byte) 0xFE) && (bom[2] == (byte) 0x00) && (bom[3] == (byte) 0x00)) {
             encoding = Charset.forName("UTF-32LE");
             unread = n - 4;
         } else {
@@ -93,11 +96,7 @@ public class UnicodeReader extends Reader {
             internalIn.unread(bom, (n - unread), unread);
 
         // Use given encoding
-        if (encoding == null) {
-            internalIn2 = new InputStreamReader(internalIn, StandardCharsets.UTF_8);
-        } else {
-            internalIn2 = new InputStreamReader(internalIn, encoding);
-        }
+        internalIn2 = new InputStreamReader(internalIn, Objects.requireNonNullElse(encoding, StandardCharsets.UTF_8));
     }
 
     @Override

+ 65 - 66
jplag.frontend.java/src/main/java/de/jplag/java/JavaTokenConstants.java

@@ -4,78 +4,77 @@ import de.jplag.TokenConstants;
 
 public interface JavaTokenConstants extends TokenConstants {
 
-    // @formatter:off
-    final static int J_PACKAGE = 2;				// check
-    final static int J_IMPORT = 3;				// check
-    final static int J_CLASS_BEGIN = 4;			// check
-    final static int J_CLASS_END = 5;			// check
-    final static int J_METHOD_BEGIN = 6;		// check
-    final static int J_METHOD_END = 7;			// check
-    final static int J_VARDEF = 8;				// check
-    final static int J_SYNC_BEGIN = 9;			// check
-    final static int J_SYNC_END = 10;			// check
-    final static int J_DO_BEGIN = 11;			// check
-    final static int J_DO_END = 12;				// check
-    final static int J_WHILE_BEGIN = 13;		// check
-    final static int J_WHILE_END = 14;			// check
-    final static int J_FOR_BEGIN = 15;			// check
-    final static int J_FOR_END = 16;			// check
-    final static int J_SWITCH_BEGIN = 17;		// check
-    final static int J_SWITCH_END = 18;			// check
-    final static int J_CASE = 19;				// check
-    final static int J_TRY_BEGIN = 20;			// check
-    final static int J_CATCH_BEGIN = 21;    	// check
-    final static int J_CATCH_END = 22;      	// check
-    final static int J_FINALLY = 23;			// check
-    final static int J_IF_BEGIN = 24;			// check
-    final static int J_ELSE = 25;				// check
-    final static int J_IF_END = 26;				// check
-    final static int J_COND = 27;				// check
-    final static int J_BREAK = 28;				// check
-    final static int J_CONTINUE = 29;			// check
-    final static int J_RETURN = 30;				// check
-    final static int J_THROW = 31;				// check
-    final static int J_IN_CLASS_BEGIN = 32;		//
-    final static int J_IN_CLASS_END = 33;		//
-    final static int J_APPLY = 34;				// check
-    final static int J_NEWCLASS = 35;			// check
-    final static int J_NEWARRAY = 36;			// check
-    final static int J_ASSIGN = 37;				// check
-    final static int J_INTERFACE_BEGIN = 38;	// check
-    final static int J_INTERFACE_END = 39;		// check
-    final static int J_CONSTR_BEGIN = 40;		//
-    final static int J_CONSTR_END = 41;			//
-    final static int J_INIT_BEGIN = 42;			// check
-    final static int J_INIT_END = 43;			// check
-    final static int J_VOID = 44;				//
-    final static int J_ARRAY_INIT_BEGIN = 45;	// check
-    final static int J_ARRAY_INIT_END = 46; 	// check
+    int J_PACKAGE = 2;                // check
+    int J_IMPORT = 3;                // check
+    int J_CLASS_BEGIN = 4;            // check
+    int J_CLASS_END = 5;            // check
+    int J_METHOD_BEGIN = 6;        // check
+    int J_METHOD_END = 7;            // check
+    int J_VARDEF = 8;                // check
+    int J_SYNC_BEGIN = 9;            // check
+    int J_SYNC_END = 10;            // check
+    int J_DO_BEGIN = 11;            // check
+    int J_DO_END = 12;                // check
+    int J_WHILE_BEGIN = 13;        // check
+    int J_WHILE_END = 14;            // check
+    int J_FOR_BEGIN = 15;            // check
+    int J_FOR_END = 16;            // check
+    int J_SWITCH_BEGIN = 17;        // check
+    int J_SWITCH_END = 18;            // check
+    int J_CASE = 19;                // check
+    int J_TRY_BEGIN = 20;            // check
+    int J_CATCH_BEGIN = 21;        // check
+    int J_CATCH_END = 22;        // check
+    int J_FINALLY = 23;            // check
+    int J_IF_BEGIN = 24;            // check
+    int J_ELSE = 25;                // check
+    int J_IF_END = 26;                // check
+    int J_COND = 27;                // check
+    int J_BREAK = 28;                // check
+    int J_CONTINUE = 29;            // check
+    int J_RETURN = 30;                // check
+    int J_THROW = 31;                // check
+    int J_IN_CLASS_BEGIN = 32;        //
+    int J_IN_CLASS_END = 33;        //
+    int J_APPLY = 34;                // check
+    int J_NEWCLASS = 35;            // check
+    int J_NEWARRAY = 36;            // check
+    int J_ASSIGN = 37;                // check
+    int J_INTERFACE_BEGIN = 38;    // check
+    int J_INTERFACE_END = 39;        // check
+    int J_CONSTR_BEGIN = 40;        //
+    int J_CONSTR_END = 41;            //
+    int J_INIT_BEGIN = 42;            // check
+    int J_INIT_END = 43;            // check
+    int J_VOID = 44;                //
+    int J_ARRAY_INIT_BEGIN = 45;    // check
+    int J_ARRAY_INIT_END = 46;    // check
 
     // new in 1.5:
-    final static int J_ENUM_BEGIN = 47;			// check
-    final static int J_ENUM_CLASS_BEGIN = 48;	// ?? doesn't exist in JAVAC
-    final static int J_ENUM_END = 49;			// check
-    final static int J_GENERIC = 50;			// check
-    final static int J_ASSERT = 51;				// check
+    int J_ENUM_BEGIN = 47;            // check
+    int J_ENUM_CLASS_BEGIN = 48;    // ?? doesn't exist in JAVAC
+    int J_ENUM_END = 49;            // check
+    int J_GENERIC = 50;            // check
+    int J_ASSERT = 51;                // check
 
-    final static int J_ANNO = 52;				// check
-    final static int J_ANNO_MARKER = 53;		// ??
-    final static int J_ANNO_M_BEGIN = 54;		// ??
-    final static int J_ANNO_M_END = 55;			// ??
-    final static int J_ANNO_T_BEGIN = 56;		// check
-    final static int J_ANNO_T_END = 57;			// check
-    final static int J_ANNO_C_BEGIN = 58;		// ??
-    final static int J_ANNO_C_END = 59;			// ??
+    int J_ANNO = 52;                // check
+    int J_ANNO_MARKER = 53;        // ??
+    int J_ANNO_M_BEGIN = 54;        // ??
+    int J_ANNO_M_END = 55;            // ??
+    int J_ANNO_T_BEGIN = 56;        // check
+    int J_ANNO_T_END = 57;            // check
+    int J_ANNO_C_BEGIN = 58;        // ??
+    int J_ANNO_C_END = 59;            // ??
 
     // new in 1.7
-    final static int J_TRY_WITH_RESOURCE = 60; 	// check
+    int J_TRY_WITH_RESOURCE = 60;    // check
 
     // new in 1.9
-    final static int J_REQUIRES = 61; 	        // check
-    final static int J_PROVIDES = 62; 	        // check
-    final static int J_EXPORTS = 63; 	        // check
-    final static int J_MODULE_BEGIN = 64;       // check
-    final static int J_MODULE_END = 65; 	    // check
+    int J_REQUIRES = 61;            // check
+    int J_PROVIDES = 62;            // check
+    int J_EXPORTS = 63;            // check
+    int J_MODULE_BEGIN = 64;       // check
+    int J_MODULE_END = 65;        // check
 
-    final static int NUM_DIFF_TOKENS = 66;	    // @formatter:on
+    int NUM_DIFF_TOKENS = 66;
 }

+ 1 - 1
jplag.frontend.java/src/main/java/de/jplag/java/Language.java

@@ -9,7 +9,7 @@ import de.jplag.TokenList;
  * Language for Java 9 and newer.
  */
 public class Language implements de.jplag.Language {
-    private Parser parser;
+    private final Parser parser;
 
     public Language(ErrorConsumer program) {
         this.parser = new Parser();

+ 2 - 2
jplag.frontend.java/src/main/java/de/jplag/java/Parser.java

@@ -8,10 +8,10 @@ import de.jplag.TokenList;
 public class Parser extends AbstractParser {
     private TokenList tokens;
 
-    public TokenList parse(File directory, String files[]) {
+    public TokenList parse(File directory, String[] files) {
         tokens = new TokenList();
         errors = 0;
-        File pathedFiles[] = new File[files.length];
+        File[] pathedFiles = new File[files.length];
         for (int i = 0; i < files.length; i++) {
             pathedFiles[i] = new File(directory, files[i]);
         }

+ 0 - 2
jplag.frontend.java/src/main/java/de/jplag/java/TokenGeneratingTreeScanner.java

@@ -293,9 +293,7 @@ final class TokenGeneratingTreeScanner extends TreeScanner<Object, Object> {
         if (node.getInitializers() != null && !node.getInitializers().isEmpty()) {
             n = positions.getStartPosition(ast, node.getInitializers().get(0));
             parser.add(JavaTokenConstants.J_ARRAY_INIT_BEGIN, filename, map.getLineNumber(n), map.getColumnNumber(n), 1);
-            ;
             parser.add(JavaTokenConstants.J_ARRAY_INIT_END, filename, map.getLineNumber(m - 1), map.getColumnNumber(m - 1), 1);
-            ;
         }
         return super.visitNewArray(node, arg1);
     }

+ 1 - 1
jplag.frontend.python-3/src/main/java/de/jplag/python3/JplagPython3Listener.java

@@ -9,7 +9,7 @@ import de.jplag.python3.grammar.Python3Parser;
 
 public class JplagPython3Listener implements Python3Listener, Python3TokenConstants {
 
-    private Parser jplagParser;
+    private final Parser jplagParser;
 
     public JplagPython3Listener(de.jplag.python3.Parser jplag) {
         jplagParser = jplag;

+ 1 - 1
jplag.frontend.python-3/src/main/java/de/jplag/python3/Language.java

@@ -7,7 +7,7 @@ import de.jplag.TokenList;
 
 public class Language implements de.jplag.Language {
 
-    private Parser parser;
+    private final Parser parser;
 
     public Language(ErrorConsumer program) {
         this.parser = new Parser();

+ 1 - 1
jplag.frontend.python-3/src/main/java/de/jplag/python3/Parser.java

@@ -23,7 +23,7 @@ public class Parser extends AbstractParser {
     private TokenList tokens = new TokenList();
     private String currentFile;
 
-    public TokenList parse(File directory, String files[]) {
+    public TokenList parse(File directory, String[] files) {
         tokens = new TokenList();
         errors = 0;
         for (int i = 0; i < files.length; i++) {

+ 31 - 31
jplag.frontend.python-3/src/main/java/de/jplag/python3/Python3TokenConstants.java

@@ -3,36 +3,36 @@ package de.jplag.python3;
 import de.jplag.TokenConstants;
 
 public interface Python3TokenConstants extends TokenConstants {
-    final static int IMPORT = 2;
-    final static int CLASS_BEGIN = 3;
-    final static int CLASS_END = 4;
-    final static int METHOD_BEGIN = 5;
-    final static int METHOD_END = 6;
-    final static int ASSIGN = 7;
-    final static int WHILE_BEGIN = 8;
-    final static int WHILE_END = 9;
-    final static int FOR_BEGIN = 10;
-    final static int FOR_END = 11;
-    final static int TRY_BEGIN = 12;
-    final static int EXCEPT_BEGIN = 13;
-    final static int EXCEPT_END = 14;
-    final static int FINALLY = 15;
-    final static int IF_BEGIN = 16;
-    final static int IF_END = 18;
-    final static int APPLY = 19;
-    final static int BREAK = 20;
-    final static int CONTINUE = 21;
-    final static int RETURN = 22;
-    final static int RAISE = 23;
-    final static int DEC_BEGIN = 24;
-    final static int DEC_END = 25;
-    final static int LAMBDA = 26;
-    final static int ARRAY = 27;
-    final static int ASSERT = 28;
-    final static int YIELD = 29;
-    final static int DEL = 30;
-    final static int WITH_BEGIN = 31;
-    final static int WITH_END = 32;
+    int IMPORT = 2;
+    int CLASS_BEGIN = 3;
+    int CLASS_END = 4;
+    int METHOD_BEGIN = 5;
+    int METHOD_END = 6;
+    int ASSIGN = 7;
+    int WHILE_BEGIN = 8;
+    int WHILE_END = 9;
+    int FOR_BEGIN = 10;
+    int FOR_END = 11;
+    int TRY_BEGIN = 12;
+    int EXCEPT_BEGIN = 13;
+    int EXCEPT_END = 14;
+    int FINALLY = 15;
+    int IF_BEGIN = 16;
+    int IF_END = 18;
+    int APPLY = 19;
+    int BREAK = 20;
+    int CONTINUE = 21;
+    int RETURN = 22;
+    int RAISE = 23;
+    int DEC_BEGIN = 24;
+    int DEC_END = 25;
+    int LAMBDA = 26;
+    int ARRAY = 27;
+    int ASSERT = 28;
+    int YIELD = 29;
+    int DEL = 30;
+    int WITH_BEGIN = 31;
+    int WITH_END = 32;
 
-    final static int NUM_DIFF_TOKENS = 33;
+    int NUM_DIFF_TOKENS = 33;
 }

+ 1 - 1
jplag.frontend.scheme/src/main/java/de/jplag/scheme/Language.java

@@ -18,7 +18,7 @@ public class Language implements de.jplag.Language {
         return this.parser.errorsCount();
     }
 
-    private de.jplag.scheme.Parser parser; // Not yet instantiated? See constructor!
+    private final de.jplag.scheme.Parser parser; // Not yet instantiated? See constructor!
 
     @Override
     public String[] suffixes() {

+ 1 - 1
jplag.frontend.scheme/src/main/java/de/jplag/scheme/Parser.java

@@ -10,7 +10,7 @@ public class Parser extends AbstractParser {
 
     private TokenList tokens;
 
-    public TokenList parse(File directory, String files[]) {
+    public TokenList parse(File directory, String[] files) {
         tokens = new TokenList();
         errors = 0;
         for (int i = 0; i < files.length; i++) {

+ 45 - 89
jplag.frontend.scheme/src/main/java/de/jplag/scheme/SchemeToken.java

@@ -13,94 +13,50 @@ public class SchemeToken extends Token implements SchemeTokenConstants {
     }
 
     protected String type2string() {
-        switch (type) {
-            case SchemeTokenConstants.FILE_END:
-                return "EOF";
-            case S_BOOL:
-                return "BOOL    ";
-            case S_NUMBER:
-                return "NUMBER  ";
-            case S_CHAR:
-                return "CHAR    ";
-            case S_STRING:
-                return "STRING  ";
-            case S_ID:
-                return "ID      ";
-            case S_LIST_BEGIN:
-                return "(LIST   ";
-            case S_LIST_END:
-                return "LIST)   ";
-            case S_VECTOR_BEGIN:
-                return "(VECTOR ";
-            case S_VECTOR_END:
-                return "VECTOR) ";
-            case S_LITERAL:
-                return "LITERAL ";
-            case S_QUOT_BEGIN:
-                return "(QUOT   ";
-            case S_QUOT_END:
-                return "QUOT)   ";
-            case S_CALL:
-                return "CALL    ";
-            case S_LAMBDA_BEGIN:
-                return "(LAMBDA ";
-            case S_LAMBDA_END:
-                return "LAMBDA) ";
-            case S_FORMAL_BEGIN:
-                return "(FORMAL ";
-            case S_FORMAL_END:
-                return "FORMAL) ";
-            case S_BODY_BEGIN:
-                return "(BODY   ";
-            case S_BODY_END:
-                return "BODY)   ";
-            case S_IF_BEGIN:
-                return "(IF     ";
-            case S_IF_END:
-                return "IF)     ";
-            case S_ALTERN:
-                return "ALTERN  ";
-            case S_ASSIGN_BEGIN:
-                return "(ASSIGN ";
-            case S_ASSIGN_END:
-                return "ASSIGN) ";
-            case S_COND_BEGIN:
-                return "(COND   ";
-            case S_COND_END:
-                return "COND)   ";
-            case S_ELSE:
-                return "ELSE    ";
-            case S_CASE_BEGIN:
-                return "(CASE   ";
-            case S_CASE_END:
-                return "CASE)   ";
-            case S_DO_BEGIN:
-                return "(DO     ";
-            case S_DO_END:
-                return "DO)     ";
-            case S_COMMAND:
-                return "COMMAND ";
-            case S_DEF_BEGIN:
-                return "(DEF    ";
-            case S_DEF_END:
-                return "DEF)    ";
-            case S_BEGIN:
-                return "(       ";
-            case S_END:
-                return ")       ";
-            case S_AND:
-                return "AND     ";
-            case S_OR:
-                return "OR      ";
-            case S_LET:
-                return "LET     ";
-            case S_DELAY:
-                return "DELAY   ";
-            case S_VAR:
-                return "VAR     ";
-
-            default:
-                return "<?????> ";
-        }
+        return switch (type) {
+            case SchemeTokenConstants.FILE_END -> "EOF";
+            case S_BOOL -> "BOOL    ";
+            case S_NUMBER -> "NUMBER  ";
+            case S_CHAR -> "CHAR    ";
+            case S_STRING -> "STRING  ";
+            case S_ID -> "ID      ";
+            case S_LIST_BEGIN -> "(LIST   ";
+            case S_LIST_END -> "LIST)   ";
+            case S_VECTOR_BEGIN -> "(VECTOR ";
+            case S_VECTOR_END -> "VECTOR) ";
+            case S_LITERAL -> "LITERAL ";
+            case S_QUOT_BEGIN -> "(QUOT   ";
+            case S_QUOT_END -> "QUOT)   ";
+            case S_CALL -> "CALL    ";
+            case S_LAMBDA_BEGIN -> "(LAMBDA ";
+            case S_LAMBDA_END -> "LAMBDA) ";
+            case S_FORMAL_BEGIN -> "(FORMAL ";
+            case S_FORMAL_END -> "FORMAL) ";
+            case S_BODY_BEGIN -> "(BODY   ";
+            case S_BODY_END -> "BODY)   ";
+            case S_IF_BEGIN -> "(IF     ";
+            case S_IF_END -> "IF)     ";
+            case S_ALTERN -> "ALTERN  ";
+            case S_ASSIGN_BEGIN -> "(ASSIGN ";
+            case S_ASSIGN_END -> "ASSIGN) ";
+            case S_COND_BEGIN -> "(COND   ";
+            case S_COND_END -> "COND)   ";
+            case S_ELSE -> "ELSE    ";
+            case S_CASE_BEGIN -> "(CASE   ";
+            case S_CASE_END -> "CASE)   ";
+            case S_DO_BEGIN -> "(DO     ";
+            case S_DO_END -> "DO)     ";
+            case S_COMMAND -> "COMMAND ";
+            case S_DEF_BEGIN -> "(DEF    ";
+            case S_DEF_END -> "DEF)    ";
+            case S_BEGIN -> "(       ";
+            case S_END -> ")       ";
+            case S_AND -> "AND     ";
+            case S_OR -> "OR      ";
+            case S_LET -> "LET     ";
+            case S_DELAY -> "DELAY   ";
+            case S_VAR -> "VAR     ";
+            default -> "<?????> ";
+        };
     }
 }

+ 42 - 42
jplag.frontend.scheme/src/main/java/de/jplag/scheme/SchemeTokenConstants.java

@@ -4,47 +4,47 @@ import de.jplag.TokenConstants;
 
 public interface SchemeTokenConstants extends TokenConstants {
 
-    final static int S_BOOL = 2;
-    final static int S_NUMBER = 3;
-    final static int S_CHAR = 4;
-    final static int S_STRING = 5;
-    final static int S_ID = 6;
-    final static int S_LIST_BEGIN = 7;
-    final static int S_LIST_END = 8;
-    final static int S_VECTOR_BEGIN = 9;
-    final static int S_VECTOR_END = 10;
-    final static int S_LITERAL = 11;
-    final static int S_QUOT_BEGIN = 12;
-    final static int S_QUOT_END = 13;
-    final static int S_CALL = 14;
-    final static int S_LAMBDA_BEGIN = 15;
-    final static int S_LAMBDA_END = 16;
-    final static int S_FORMAL_BEGIN = 17;
-    final static int S_FORMAL_END = 18;
-    final static int S_BODY_BEGIN = 19;
-    final static int S_BODY_END = 20;
-    final static int S_IF_BEGIN = 21;
-    final static int S_IF_END = 22;
-    final static int S_ALTERN = 23;
-    final static int S_ASSIGN_BEGIN = 24;
-    final static int S_ASSIGN_END = 25;
-    final static int S_COND_BEGIN = 26;
-    final static int S_COND_END = 27;
-    final static int S_ELSE = 28;
-    final static int S_CASE_BEGIN = 29;
-    final static int S_CASE_END = 30;
-    final static int S_DO_BEGIN = 31;
-    final static int S_DO_END = 32;
-    final static int S_COMMAND = 33;
-    final static int S_DEF_BEGIN = 34;
-    final static int S_DEF_END = 35;
-    final static int S_BEGIN = 36;
-    final static int S_END = 37;
-    final static int S_AND = 38;
-    final static int S_OR = 39;
-    final static int S_LET = 40;
-    final static int S_DELAY = 41;
-    final static int S_VAR = 42;
+    int S_BOOL = 2;
+    int S_NUMBER = 3;
+    int S_CHAR = 4;
+    int S_STRING = 5;
+    int S_ID = 6;
+    int S_LIST_BEGIN = 7;
+    int S_LIST_END = 8;
+    int S_VECTOR_BEGIN = 9;
+    int S_VECTOR_END = 10;
+    int S_LITERAL = 11;
+    int S_QUOT_BEGIN = 12;
+    int S_QUOT_END = 13;
+    int S_CALL = 14;
+    int S_LAMBDA_BEGIN = 15;
+    int S_LAMBDA_END = 16;
+    int S_FORMAL_BEGIN = 17;
+    int S_FORMAL_END = 18;
+    int S_BODY_BEGIN = 19;
+    int S_BODY_END = 20;
+    int S_IF_BEGIN = 21;
+    int S_IF_END = 22;
+    int S_ALTERN = 23;
+    int S_ASSIGN_BEGIN = 24;
+    int S_ASSIGN_END = 25;
+    int S_COND_BEGIN = 26;
+    int S_COND_END = 27;
+    int S_ELSE = 28;
+    int S_CASE_BEGIN = 29;
+    int S_CASE_END = 30;
+    int S_DO_BEGIN = 31;
+    int S_DO_END = 32;
+    int S_COMMAND = 33;
+    int S_DEF_BEGIN = 34;
+    int S_DEF_END = 35;
+    int S_BEGIN = 36;
+    int S_END = 37;
+    int S_AND = 38;
+    int S_OR = 39;
+    int S_LET = 40;
+    int S_DELAY = 41;
+    int S_VAR = 42;
 
-    final static int NUM_DIFF_TOKENS = 43;
+    int NUM_DIFF_TOKENS = 43;
 }

+ 2 - 5
jplag.frontend.text/src/main/java/de/jplag/text/Language.java

@@ -8,13 +8,10 @@ import de.jplag.TokenList;
 
 public class Language implements de.jplag.Language {
 
-    private ErrorConsumer program;
-
-    private Parser parser = new Parser();
+    private final Parser parser = new Parser();
 
     public Language(ErrorConsumer program) {
-        this.program = program;
-        this.parser.setProgram(this.program);
+        this.parser.setProgram(program);
     }
 
     @Override

+ 1 - 1
jplag.frontend.text/src/main/java/de/jplag/text/Parser.java

@@ -21,7 +21,7 @@ public class Parser extends AbstractParser {
 
     private boolean runOut = false;
 
-    public TokenList parse(File directory, String files[]) {
+    public TokenList parse(File directory, String[] files) {
         tokens = new TokenList();
         errors = 0;
         for (String file : files) {

+ 5 - 2
jplag.frontend.text/src/main/java/de/jplag/text/TextToken.java

@@ -1,22 +1,25 @@
 package de.jplag.text;
 
+import java.io.Serial;
+
 import de.jplag.Token;
 
 public class TextToken extends Token {
+    @Serial
     private static final long serialVersionUID = 4301179216570538972L;
 
     private static int getSerial(String text, Parser parser) {
         text = text.toLowerCase();
         Integer serial = parser.table.get(text);
         if (serial == null) {
-            serial = Integer.valueOf(parser.serial);
+            serial = parser.serial;
             if (parser.serial == Integer.MAX_VALUE)
                 parser.outOfSerials();
             else
                 parser.serial++;
             parser.table.put(text, serial);
         }
-        return serial.intValue();
+        return serial;
     }
 
     private String text;

+ 1 - 1
jplag/src/main/java/de/jplag/CLI.java

@@ -109,7 +109,7 @@ public class CLI {
         options.setMinimumTokenMatch(MIN_TOKEN_MATCH.getFrom(namespace));
         options.setSimilarityThreshold(SIMILARITY_THRESHOLD.getFrom(namespace));
         options.setMaximumNumberOfComparisons(SHOWN_COMPARISONS.getFrom(namespace));
-        ComparisonMode.fromName(COMPARISON_MODE.getFrom(namespace)).ifPresentOrElse(it -> options.setComparisonMode(it),
+        ComparisonMode.fromName(COMPARISON_MODE.getFrom(namespace)).ifPresentOrElse(options::setComparisonMode,
                 () -> System.out.println("Unknown comparison mode, using default mode!"));
 
         ClusteringOptions.Builder clusteringBuilder = new ClusteringOptions.Builder();

+ 2 - 2
jplag/src/main/java/de/jplag/CliGroupHelper.java

@@ -15,8 +15,8 @@ import net.sourceforge.argparse4j.inf.MutuallyExclusiveGroup;
 public class CliGroupHelper {
 
     private final ArgumentParser parser;
-    private Map<String, MutuallyExclusiveGroup> mutuallyExclusiveGroups = new HashMap<>();
-    private Map<String, ArgumentGroup> argumentGroups = new HashMap<>();
+    private final Map<String, MutuallyExclusiveGroup> mutuallyExclusiveGroups = new HashMap<>();
+    private final Map<String, ArgumentGroup> argumentGroups = new HashMap<>();
 
     public CliGroupHelper(ArgumentParser parser) {
         this.parser = parser;

+ 1 - 1
jplag/src/main/java/de/jplag/ErrorCollector.java

@@ -55,7 +55,7 @@ public class ErrorCollector implements ErrorConsumer { // TODO TS should be even
             errorReport.append('\n');
         }
 
-        System.out.println(errorReport.toString());
+        System.out.println(errorReport);
     }
 
     /**

+ 2 - 2
jplag/src/main/java/de/jplag/GreedyStringTiling.java

@@ -97,7 +97,7 @@ public class GreedyStringTiling {
         return swapAndCompare(firstSubmission, secondSubmission, true);
     }
 
-    private final JPlagComparison swapAndCompare(Submission firstSubmission, Submission secondSubmission, boolean isBaseCodeComparison) {
+    private JPlagComparison swapAndCompare(Submission firstSubmission, Submission secondSubmission, boolean isBaseCodeComparison) {
         Submission smallerSubmission, largerSubmission;
         if (firstSubmission.getTokenList().size() > secondSubmission.getTokenList().size()) {
             smallerSubmission = secondSubmission;
@@ -122,7 +122,7 @@ public class GreedyStringTiling {
      * @param isBaseCodeComparison specifies whether one of the submissions is the base code.
      * @return the comparison results.
      */
-    private final JPlagComparison compare(Submission firstSubmission, Submission secondSubmission, boolean isBaseCodeComparison) {
+    private JPlagComparison compare(Submission firstSubmission, Submission secondSubmission, boolean isBaseCodeComparison) {
         // first and second refer to the list of tokens of the first and second submission:
         TokenList first = firstSubmission.getTokenList();
         TokenList second = secondSubmission.getTokenList();

+ 6 - 11
jplag/src/main/java/de/jplag/JPlag.java

@@ -37,9 +37,8 @@ public class JPlag {
     /**
      * Creates and initializes a JPlag instance, parameterized by a set of options.
      * @param options determines the parameterization.
-     * @throws ExitException if the initialization fails.
      */
-    public JPlag(JPlagOptions options) throws ExitException {
+    public JPlag(JPlagOptions options) {
         this.options = options;
         errorCollector = new ErrorCollector(options);
         coreAlgorithm = new GreedyStringTiling(options);
@@ -51,7 +50,7 @@ public class JPlag {
 
     /**
      * If an exclusion file is given, it is read in and all strings are saved in the set "excluded".
-     * @param exclusionFileName
+     * @param exclusionFileName the file name or path
      */
     Set<String> readExclusionFile(final String exclusionFileName) {
         try (BufferedReader reader = new BufferedReader(new FileReader(exclusionFileName, JPlagOptions.CHARSET))) {
@@ -98,14 +97,10 @@ public class JPlag {
     }
 
     private ComparisonStrategy initializeComparisonStrategy(final ComparisonMode comparisonMode) {
-        switch (comparisonMode) {
-            case NORMAL:
-                return new NormalComparisonStrategy(options, coreAlgorithm);
-            case PARALLEL:
-                return new ParallelComparisonStrategy(options, coreAlgorithm);
-            default:
-                throw new AssertionError("Unknown comparison strategy found.");
-        }
+        return switch (comparisonMode) {
+            case NORMAL -> new NormalComparisonStrategy(options, coreAlgorithm);
+            case PARALLEL -> new ParallelComparisonStrategy(options, coreAlgorithm);
+        };
     }
 
     private Language initializeLanguage() {

+ 6 - 9
jplag/src/main/java/de/jplag/JPlagComparison.java

@@ -2,7 +2,6 @@ package de.jplag;
 
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collections;
 import java.util.Comparator;
 import java.util.LinkedHashSet;
 import java.util.List;
@@ -44,7 +43,7 @@ public class JPlagComparison implements Comparator<JPlagComparison> { // FIXME T
      * The bigger a match (length) is relatively to the biggest match the redder is the color returned by this method.
      */
     public String color(int length) {
-        int longestMatch = matches.stream().mapToInt(it -> it.getLength()).max().orElse(0);
+        int longestMatch = matches.stream().mapToInt(Match::getLength).max().orElse(0);
         int color = 255 * length / longestMatch;
         String help = (color < 16 ? "0" : "") + Integer.toHexString(color);
         return "#" + help + "0000";
@@ -225,11 +224,9 @@ public class JPlagComparison implements Comparator<JPlagComparison> { // FIXME T
      */
     public final List<Integer> sort_permutation(boolean useFirst) {
         List<Integer> indices = new ArrayList<>(matches.size());
-        IntStream.range(0, matches.size()).forEach(index -> indices.add(index));
-        Comparator<Integer> comparator = (Integer i, Integer j) -> {
-            return Integer.compare(selectStartof(i, useFirst), selectStartof(j, useFirst));
-        };
-        Collections.sort(indices, comparator);
+        IntStream.range(0, matches.size()).forEach(indices::add);
+        Comparator<Integer> comparator = Comparator.comparingInt((Integer i) -> selectStartof(i, useFirst));
+        indices.sort(comparator);
         return indices;
     }
 
@@ -243,13 +240,13 @@ public class JPlagComparison implements Comparator<JPlagComparison> { // FIXME T
         return firstSubmission.getName() + " <-> " + secondSubmission.getName();
     }
 
-    private final float firstBasecodeSimilarity() {
+    private float firstBasecodeSimilarity() {
         float sa = firstSubmission.getSimilarityDivisor(false);
         JPlagComparison firstBaseCodeMatches = firstSubmission.getBaseCodeComparison();
         return firstBaseCodeMatches.getNumberOfMatchedTokens() * 100 / sa;
     }
 
-    private final float secondBasecodeSimilarity() {
+    private float secondBasecodeSimilarity() {
         float sb = secondSubmission.getSimilarityDivisor(false);
         JPlagComparison secondBaseCodeMatches = secondSubmission.getBaseCodeComparison();
         return secondBaseCodeMatches.getNumberOfMatchedTokens() * 100 / sb;

+ 1 - 1
jplag/src/main/java/de/jplag/NumberOfArgumentValues.java

@@ -9,7 +9,7 @@ public enum NumberOfArgumentValues {
 
     private final String representation;
 
-    private NumberOfArgumentValues(String representation) {
+    NumberOfArgumentValues(String representation) {
         this.representation = representation;
     }
 

+ 2 - 2
jplag/src/main/java/de/jplag/Submission.java

@@ -215,7 +215,7 @@ public class Submission implements Comparable<Submission> {
                 inputStreamReader.close();
                 fileInputStream.close();
             } catch (FileNotFoundException e) {
-                System.out.println("File not found: " + ((new File(submissionRootFile, files[i])).toString()));
+                System.out.println("File not found: " + new File(submissionRootFile, files[i]));
             } catch (IOException e) {
                 throw new ReportGenerationException("I/O exception!", e);
             }
@@ -304,7 +304,7 @@ public class Submission implements Comparable<Submission> {
             try {
                 Files.copy(file.toPath(), new File(submissionDirectory, file.getName()).toPath());
             } catch (IOException exception) {
-                errorCollector.print("Error copying file: " + exception.toString() + "\n", null);
+                errorCollector.print("Error copying file: " + exception + "\n", null);
             }
         }
     }

+ 2 - 2
jplag/src/main/java/de/jplag/SubmissionSet.java

@@ -52,7 +52,7 @@ public class SubmissionSet {
      * @return Whether a basecode is available for this collection.
      */
     public boolean hasBaseCode() {
-        return !baseCodeSubmission.isEmpty();
+        return baseCodeSubmission.isPresent();
     }
 
     /**
@@ -96,7 +96,7 @@ public class SubmissionSet {
     }
 
     private List<Submission> filterInvalidSubmissions() {
-        return allSubmissions.stream().filter(submission -> submission.hasErrors()).collect(toList());
+        return allSubmissions.stream().filter(Submission::hasErrors).collect(toList());
     }
 
     private void parseAllSubmissions() throws ExitException {

+ 4 - 9
jplag/src/main/java/de/jplag/SubmissionSetBuilder.java

@@ -36,7 +36,7 @@ public class SubmissionSetBuilder {
      * @param language is the language of the submissions.
      * @param options are the configured options.
      * @param errorCollector is the interface for error reporting.
-     * @param excludedFileNames
+     * @param excludedFileNames a list of file names to be excluded
      */
     public SubmissionSetBuilder(Language language, JPlagOptions options, ErrorCollector errorCollector, Set<String> excludedFileNames) {
         this.language = language;
@@ -108,14 +108,14 @@ public class SubmissionSetBuilder {
                 // Single root-directory, try the legacy way of specifying basecode.
                 baseCode = loadBaseCodeViaName(baseCodeName, rootDirectory, foundSubmissions);
             }
+            // TODO Optional.of() will cause a NPTR-Exception of baseCode is null. Is this a bug?
             baseCodeSubmission = Optional.of(baseCode);
-            System.out.println(String.format("Basecode directory \"%s\" will be used.", baseCode.getName()));
+            System.out.printf("Basecode directory \"%s\" will be used.%n", baseCode.getName());
 
             // Basecode may also be registered as a user submission. If so, remove the latter.
             Submission removed = foundSubmissions.remove(baseCode.getRoot());
             if (removed != null) {
-                System.out.println(
-                        String.format("Submission \"%s\" is the specified basecode, it will be skipped during comparison.", removed.getName()));
+                System.out.printf("Submission \"%s\" is the specified basecode, it will be skipped during comparison.%n", removed.getName());
             }
         }
         return baseCodeSubmission;
@@ -143,9 +143,6 @@ public class SubmissionSetBuilder {
             return processSubmission(basecodeSubmission.getName(), basecodeSubmission);
         } catch (SubmissionException exception) {
             throw new BasecodeException(exception.getMessage(), exception); // Change thrown exception to basecode exception.
-
-        } catch (ExitException exception) {
-            throw exception;
         }
     }
 
@@ -231,7 +228,6 @@ public class SubmissionSetBuilder {
     /**
      * Process the given directory entry as a submission, the path MUST not be excluded.
      * @param submissionFile the file for the submission.
-     * @param rootDirectoryPrefix Prefix for submission submissions to the root directory, may be empty.
      * @return The entry converted to a submission.
      * @throws ExitException when an error has been found with the entry.
      */
@@ -258,7 +254,6 @@ public class SubmissionSetBuilder {
     /**
      * Process entries in the root directory to check whether they qualify as submissions.
      * @param rootDirectory is the root directory being examined.
-     * @param addRootDirectoryPrefix specifies whether multiple root directories are in use.
      * @param foundSubmissions Submissions found so far, is updated in-place.
      */
     private void processRootDirectoryEntries(File rootDirectory, boolean multipleRoots, Map<File, Submission> foundSubmissions) throws ExitException {

+ 4 - 4
jplag/src/main/java/de/jplag/TimeUtil.java

@@ -7,12 +7,12 @@ public final class TimeUtil {
     }
 
     /**
-     * Convert a duration in milli-seconds to a human-readable representation.
-     * @param durationInMiliseconds Number of milli-seconds to convert.
+     * Convert a duration in milliseconds to a human-readable representation.
+     * @param durationInMilliseconds Number of milliseconds to convert.
      * @return Readable representation of the time interval.
      */
-    public static String formatDuration(long durationInMiliseconds) {
-        int timeInSeconds = (int) (durationInMiliseconds / 1000);
+    public static String formatDuration(long durationInMilliseconds) {
+        int timeInSeconds = (int) (durationInMilliseconds / 1000);
         String hours = (timeInSeconds / 3600 > 0) ? (timeInSeconds / 3600) + " h " : "";
         String minutes = (timeInSeconds / 60 > 0) ? ((timeInSeconds / 60) % 60) + " min " : "";
         String seconds = (timeInSeconds % 60) + " sec";

+ 3 - 2
jplag/src/main/java/de/jplag/clustering/Cluster.java

@@ -12,8 +12,8 @@ import java.util.stream.Collectors;
  */
 public class Cluster<T> {
 
-    private float communityStrength;
-    private Collection<T> members;
+    private final float communityStrength;
+    private final Collection<T> members;
     private ClusteringResult<T> clusteringResult = null;
 
     public Cluster(Collection<T> members, float communityStrength) {
@@ -22,6 +22,7 @@ public class Cluster<T> {
     }
 
     public Collection<T> getMembers() {
+        // TODO Check why access to local attribute.
         return members;
     }
 

+ 6 - 6
jplag/src/main/java/de/jplag/clustering/ClusteringAdapter.java

@@ -22,8 +22,8 @@ import de.jplag.clustering.algorithm.GenericClusteringAlgorithm;
  */
 public class ClusteringAdapter {
 
-    private RealMatrix similarityMatrix;
-    private IntegerMapping<Submission> mapping;
+    private final RealMatrix similarityMatrix;
+    private final IntegerMapping<Submission> mapping;
 
     /**
      * Creates the clustering adapter. Only submissions that appear in those similarities might also appear in
@@ -58,10 +58,10 @@ public class ClusteringAdapter {
     public ClusteringResult<Submission> doClustering(GenericClusteringAlgorithm algorithm) {
         Collection<Collection<Integer>> intResult = algorithm.cluster(similarityMatrix);
         ClusteringResult<Integer> modularityClusterResult = ClusteringResult.fromIntegerCollections(new ArrayList<>(intResult), similarityMatrix);
-        List<Cluster<Submission>> mappedClusters = modularityClusterResult.getClusters().stream().map(unmappedCluster -> {
-            return new Cluster<Submission>(unmappedCluster.getMembers().stream().map(mapping::unmap).collect(Collectors.toList()),
-                    unmappedCluster.getCommunityStrength());
-        }).collect(Collectors.toList());
+        List<Cluster<Submission>> mappedClusters = modularityClusterResult.getClusters().stream()
+                .map(unmappedCluster -> new Cluster<>(unmappedCluster.getMembers().stream().map(mapping::unmap).collect(Collectors.toList()),
+                        unmappedCluster.getCommunityStrength()))
+                .collect(Collectors.toList());
         return new ClusteringResult<>(mappedClusters, modularityClusterResult.getCommunityStrength());
     }
 

+ 32 - 4
jplag/src/main/java/de/jplag/clustering/ClusteringAlgorithm.java

@@ -1,14 +1,42 @@
 package de.jplag.clustering;
 
+import java.util.Objects;
+
 import de.jplag.clustering.algorithm.AgglomerativeClustering;
+import de.jplag.clustering.algorithm.GenericClusteringAlgorithm;
 import de.jplag.clustering.algorithm.SpectralClustering;
 
 /**
  * Choosable clustering algorithms
  */
 public enum ClusteringAlgorithm {
-    /** {@link AgglomerativeClustering} */
-    AGGLOMERATIVE,
-    /** {@link SpectralClustering} */
-    SPECTRAL
+    /**
+     * {@link AgglomerativeClustering}
+     */
+    AGGLOMERATIVE(AgglomerativeClustering::new),
+    /**
+     * {@link SpectralClustering}
+     */
+    SPECTRAL(SpectralClustering::new);
+
+    private final ClusteringAlgorithmSupplier constructor;
+
+    ClusteringAlgorithm(ClusteringAlgorithmSupplier constructor) {
+        this.constructor = constructor;
+    }
+
+    /**
+     * Create GenericClusteringAlgorithm by ClusteringOptions.
+     * @param options the options to use for creation
+     * @return a new instance of GenericClusteringAlgorithm
+     */
+    public GenericClusteringAlgorithm create(ClusteringOptions options) {
+        Objects.requireNonNull(options);
+        return this.constructor.create(options);
+    }
+
+    @FunctionalInterface
+    public interface ClusteringAlgorithmSupplier {
+        GenericClusteringAlgorithm create(ClusteringOptions options);
+    }
 }

+ 1 - 8
jplag/src/main/java/de/jplag/clustering/ClusteringFactory.java

@@ -8,9 +8,7 @@ import java.util.stream.Collectors;
 
 import de.jplag.JPlagComparison;
 import de.jplag.Submission;
-import de.jplag.clustering.algorithm.AgglomerativeClustering;
 import de.jplag.clustering.algorithm.GenericClusteringAlgorithm;
-import de.jplag.clustering.algorithm.SpectralClustering;
 
 /**
  * Runs the clustering according to an options object.
@@ -21,12 +19,7 @@ public class ClusteringFactory {
             return Collections.emptyList();
 
         // init algorithm
-        GenericClusteringAlgorithm clusteringAlgorithm = null;
-        if (options.getAlgorithm() == ClusteringAlgorithm.AGGLOMERATIVE) {
-            clusteringAlgorithm = new AgglomerativeClustering(options);
-        } else if (options.getAlgorithm() == ClusteringAlgorithm.SPECTRAL) {
-            clusteringAlgorithm = new SpectralClustering(options);
-        }
+        GenericClusteringAlgorithm clusteringAlgorithm = options.getAlgorithm().create(options);
 
         // init preprocessor
         Optional<ClusteringPreprocessor> preprocessor = options.getPreprocessor().constructPreprocessor(options);

+ 3 - 3
jplag/src/main/java/de/jplag/clustering/ClusteringResult.java

@@ -23,7 +23,7 @@ public class ClusteringResult<T> {
     private float communityStrength = 0;
 
     public ClusteringResult(Collection<Cluster<T>> clusters, float communityStrength) {
-        this.clusters = Collections.unmodifiableList(new ArrayList<>(clusters));
+        this.clusters = List.copyOf(clusters);
         this.communityStrength = communityStrength;
         for (Cluster<T> cluster : clusters) {
             cluster.setClusteringResult(this);
@@ -48,7 +48,7 @@ public class ClusteringResult<T> {
 
     /**
      * How much this clustering result is worth during optimization.
-     * @param similarity
+     * @param similarity TODO DF: JAVADOC
      * @return worth
      */
     public float getWorth(BiFunction<T, T, Float> similarity) {
@@ -92,7 +92,7 @@ public class ClusteringResult<T> {
             for (int i = 0; i < clustering.size(); i++) {
                 double outWeightSum = percentagesOfSimilaritySums.getRowVector(i).getL1Norm();
                 double clusterCommunityStrength = percentagesOfSimilaritySums.getEntry(i, i) - outWeightSum * outWeightSum;
-                clusters.add(new Cluster<Integer>(clustering.get(i), (float) clusterCommunityStrength));
+                clusters.add(new Cluster<>(clustering.get(i), (float) clusterCommunityStrength));
                 communityStrength += clusterCommunityStrength;
             }
         }

+ 2 - 2
jplag/src/main/java/de/jplag/clustering/IntegerMapping.java

@@ -9,8 +9,8 @@ import java.util.List;
  */
 public class IntegerMapping<T> {
 
-    private HashMap<T, Integer> mapping = new HashMap<>();
-    private List<T> backMapping = new ArrayList<>();
+    private HashMap<T, Integer> mapping;
+    private List<T> backMapping;
     private int size = 0;
 
     public IntegerMapping(int initialCapacity) {

+ 1 - 1
jplag/src/main/java/de/jplag/clustering/Preprocessing.java

@@ -21,7 +21,7 @@ public enum Preprocessing {
 
     private final Function<ClusteringOptions, ClusteringPreprocessor> constructor;
 
-    private Preprocessing(Function<ClusteringOptions, ClusteringPreprocessor> constructor) {
+    Preprocessing(Function<ClusteringOptions, ClusteringPreprocessor> constructor) {
         this.constructor = constructor;
     }
 

+ 8 - 7
jplag/src/main/java/de/jplag/clustering/algorithm/AgglomerativeClustering.java

@@ -17,7 +17,7 @@ import de.jplag.clustering.ClusteringOptions;
  */
 public class AgglomerativeClustering implements GenericClusteringAlgorithm {
 
-    private ClusteringOptions options;
+    private final ClusteringOptions options;
 
     public AgglomerativeClustering(ClusteringOptions options) {
         this.options = options;
@@ -60,6 +60,7 @@ public class AgglomerativeClustering implements GenericClusteringAlgorithm {
 
         while (clusters.size() > 1) {
             ClusterConnection nearest = similarities.poll();
+            // TODO Check that nearest is never null
             if (!(clusters.contains(nearest.left) && clusters.contains(nearest.right))) {
                 // One cluster already part of another cluster
                 continue;
@@ -82,11 +83,11 @@ public class AgglomerativeClustering implements GenericClusteringAlgorithm {
         return clusters.stream().map(Cluster::getSubmissions).collect(Collectors.toList());
     }
 
-    private class ClusterConnection implements Comparable<ClusterConnection> {
+    private static class ClusterConnection implements Comparable<ClusterConnection> {
 
-        private Cluster left;
-        private Cluster right;
-        private float similarity;
+        private final Cluster left;
+        private final Cluster right;
+        private final float similarity;
 
         public ClusterConnection(Cluster left, Cluster right, float similarity) {
             this.left = left;
@@ -105,8 +106,8 @@ public class AgglomerativeClustering implements GenericClusteringAlgorithm {
      * Encapsulate a list in a class because we do not want hashing based on the members but on identity only. Also a
      * cluster need a different identity than the list because the lists are reused.
      */
-    private class Cluster {
-        private List<Integer> submissions;
+    private static class Cluster {
+        private final List<Integer> submissions;
 
         public Cluster(List<Integer> submissions) {
             this.submissions = submissions;

+ 10 - 11
jplag/src/main/java/de/jplag/clustering/algorithm/BFGS.java

@@ -70,7 +70,7 @@ import org.apache.commons.math3.util.Pair;
 public class BFGS {
     // private static org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(BFGS.class);
     /** A number close to zero, between machine epsilon and its square root. */
-    private static final double EPSILON = Double.valueOf(System.getProperty("smile.bfgs.epsilon", "1E-10"));
+    private static final double EPSILON = Double.parseDouble(System.getProperty("smile.bfgs.epsilon", "1E-10"));
     /** The convergence criterion on function value. */
     private static final double TOLF = 4 * EPSILON;
     /** The scaled maximum step length allowed in line searches. */
@@ -670,14 +670,13 @@ public class BFGS {
      */
     private static class Matrix {
 
-        private RealMatrix d;
-        private int m;
-        private int n;
+        private final RealMatrix d;
+        private final int m;
+        private final int n;
 
         /**
-         * Constructor of zero matrix.
-         * @param m the number of rows.
-         * @param n the number of columns.
+         * Constructor of real matrix.
+         * @param delegate the matrix that shall be wrapped.
          */
         public Matrix(RealMatrix delegate) {
             d = delegate;
@@ -724,10 +723,10 @@ public class BFGS {
          * @return {@code A' * A}.
          */
         public Matrix ata() {
-            Matrix C = new Matrix(d.transpose().multiply(d));
-            // C.mm(TRANSPOSE, 1this, NO_TRANSPOSE, this);
-            // C.uplo(LOWER);
-            return C;
+            Matrix c = new Matrix(d.transpose().multiply(d));
+            // c.mm(TRANSPOSE, 1this, NO_TRANSPOSE, this);
+            // c.uplo(LOWER);
+            return c;
         }
 
         /**

+ 10 - 8
jplag/src/main/java/de/jplag/clustering/algorithm/BayesianOptimization.java

@@ -24,12 +24,12 @@ public class BayesianOptimization {
     private static final int MAX_NON_ZERO_ACQ_FN_EVALS_PER_ITERATION = 50;
     private static final int MAXIMUM_ACQ_FN_EVALS_PER_ITERATION = 1000;
 
-    private RealVector minima;
-    private RealVector maxima;
-    private int maxEvaluations;
-    private int initialPoints;
-    private double noise;
-    private RealVector lengthScale;
+    private final RealVector minima;
+    private final RealVector maxima;
+    private final int maxEvaluations;
+    private final int initialPoints;
+    private final double noise;
+    private final RealVector lengthScale;
     private boolean debug = false;
 
     /**
@@ -55,6 +55,7 @@ public class BayesianOptimization {
         this.lengthScale = lengthScale;
     }
 
+    // TODO This method is not used
     public void setDebugLogging(boolean debug) {
         this.debug = debug;
     }
@@ -157,6 +158,7 @@ public class BayesianOptimization {
                 if (debug) {
                     System.out.println(gpr.toString(minima, maxima, 100, 25, 0));
                 }
+                // TODO Check that best is not null here
                 coordinates = maxAcq(gpr, best.score, poiSampler, zeroAcquisitionsCounter);
                 testedCoordinates.add(coordinates);
             }
@@ -175,8 +177,8 @@ public class BayesianOptimization {
 
     public static final class OptimizationResult<T> {
 
-        private double score;
-        private T value;
+        private final double score;
+        private final T value;
         private RealVector params;
 
         public OptimizationResult(double score, T value) {

+ 7 - 7
jplag/src/main/java/de/jplag/clustering/algorithm/GaussianProcess.java

@@ -21,12 +21,12 @@ import org.apache.commons.math3.stat.StatUtils;
  */
 public class GaussianProcess {
 
-    private List<RealVector> listOfCoordinates;
-    private RealVector weight;
-    private double mean;
-    private double standardDeviation;
-    private CholeskyDecomposition cholesky;
-    private RealVector lengthScale;
+    private final List<RealVector> listOfCoordinates;
+    private final RealVector weight;
+    private final double mean;
+    private final double standardDeviation;
+    private final CholeskyDecomposition cholesky;
+    private final RealVector lengthScale;
 
     private GaussianProcess(List<RealVector> listOfCoordinates, RealVector weight, double mean, double standardDeviation,
             CholeskyDecomposition cholesky, RealVector lengthScale) {
@@ -65,7 +65,7 @@ public class GaussianProcess {
 
     /**
      * Fit Gaussian Process using a matern kernel.
-     * @param observedCoordinates
+     * @param observedCoordinates TODO DOCUMENTATION MISSING
      * @param observations expected to have zero mean, unit variance if normalize is false
      * @param noise variance of noise in Y
      * @param normalize if Y should be normalized

+ 8 - 9
jplag/src/main/java/de/jplag/clustering/algorithm/InterClusterSimilarity.java

@@ -1,19 +1,19 @@
 package de.jplag.clustering.algorithm;
 
 import java.util.List;
-import java.util.function.DoubleBinaryOperator;
+import java.util.function.BiFunction;
 
 import org.apache.commons.math3.linear.RealMatrix;
 
 public enum InterClusterSimilarity {
     MIN(Float.MAX_VALUE, Math::min),
     MAX(Float.MIN_VALUE, Math::max),
-    AVERAGE(0, (a, b) -> a + b);
+    AVERAGE(0, Float::sum);
 
     private final float neutralElement;
-    private final DoubleBinaryOperator accumulator;
+    private final BiFunction<Float, Float, Float> accumulator;
 
-    private InterClusterSimilarity(float neutralElement, DoubleBinaryOperator accumulator) {
+    InterClusterSimilarity(float neutralElement, BiFunction<Float, Float, Float> accumulator) {
         this.neutralElement = neutralElement;
         this.accumulator = accumulator;
     }
@@ -28,11 +28,10 @@ public enum InterClusterSimilarity {
     public float clusterSimilarity(List<Integer> leftCluster, List<Integer> rightCluster, RealMatrix similarityMatrix) {
         float similarity = this.neutralElement;
 
-        for (int leftIndex = 0; leftIndex < leftCluster.size(); leftIndex++) {
-            int leftSubmission = leftCluster.get(leftIndex);
-            for (int rightIndex = 0; rightIndex < rightCluster.size(); rightIndex++) {
-                float submissionSimilarity = (float) similarityMatrix.getEntry(leftSubmission, rightCluster.get(rightIndex));
-                similarity = (float) this.accumulator.applyAsDouble(similarity, submissionSimilarity);
+        for (int leftSubmission : leftCluster) {
+            for (int rightSubmission : rightCluster) {
+                float submissionSimilarity = (float) similarityMatrix.getEntry(leftSubmission, rightSubmission);
+                similarity = this.accumulator.apply(similarity, submissionSimilarity);
             }
         }
 

+ 5 - 6
jplag/src/main/java/de/jplag/clustering/algorithm/SpectralClustering.java

@@ -109,7 +109,7 @@ public class SpectralClustering implements GenericClusteringAlgorithm {
                 int eigenVectorId = eigenValueIds.get(column);
                 RealVector eigenVector = ed.getEigenvector(eigenVectorId);
                 return eigenVector.getEntry(row);
-            };
+            }
         });
 
         List<ClusterableEigenVector> normRows = IntStream.range(0, dimension).filter(i -> concatenatedEigenVectors.getRowVector(i).getNorm() > 0)
@@ -118,14 +118,13 @@ public class SpectralClustering implements GenericClusteringAlgorithm {
 
         Clusterer<ClusterableEigenVector> clusterer = new KMeansPlusPlusClusterer<>(numberOfClusters, options.getSpectralMaxKMeansIterationPerRun());
         List<? extends Cluster<ClusterableEigenVector>> clusters = clusterer.cluster(normRows);
-        return clusters.stream().map(cluster -> {
-            return cluster.getPoints().stream().map(eigenVector -> eigenVector.id).collect(Collectors.toList());
-        }).collect(Collectors.toList());
+        return clusters.stream().map(cluster -> cluster.getPoints().stream().map(eigenVector -> eigenVector.id).collect(Collectors.toList()))
+                .collect(Collectors.toList());
     }
 
     private static class ClusterableEigenVector implements Clusterable {
-        private int id;
-        private double[] eigenVector;
+        private final int id;
+        private final double[] eigenVector;
 
         public ClusterableEigenVector(int id, RealVector eigenVector) {
             this.id = id;

+ 1 - 1
jplag/src/main/java/de/jplag/clustering/preprocessors/CumulativeDistributionFunctionPreprocessor.java

@@ -15,7 +15,7 @@ import de.jplag.clustering.PreprocessorHelper;
  */
 public class CumulativeDistributionFunctionPreprocessor implements ClusteringPreprocessor {
 
-    private PreprocessorHelper helper = new PreprocessorHelper();
+    private final PreprocessorHelper helper = new PreprocessorHelper();
 
     @Override
     public double[][] preprocessSimilarities(double[][] similarityMatrix) {

+ 1 - 1
jplag/src/main/java/de/jplag/clustering/preprocessors/PercentileThresholdProcessor.java

@@ -12,7 +12,7 @@ import de.jplag.clustering.ClusteringPreprocessor;
  */
 public class PercentileThresholdProcessor implements ClusteringPreprocessor {
 
-    private float percentile;
+    private final float percentile;
     private ThresholdPreprocessor thresholdPreprocessor;
 
     public PercentileThresholdProcessor(float percentile) {

+ 2 - 2
jplag/src/main/java/de/jplag/clustering/preprocessors/ThresholdPreprocessor.java

@@ -12,8 +12,8 @@ import de.jplag.clustering.PreprocessorHelper;
  */
 public class ThresholdPreprocessor implements ClusteringPreprocessor {
 
-    private double threshold;
-    private PreprocessorHelper helper = new PreprocessorHelper();
+    private final double threshold;
+    private final PreprocessorHelper helper = new PreprocessorHelper();
 
     public ThresholdPreprocessor(double threshold) {
         this.threshold = threshold;

+ 3 - 0
jplag/src/main/java/de/jplag/exceptions/BasecodeException.java

@@ -1,10 +1,13 @@
 package de.jplag.exceptions;
 
+import java.io.Serial;
+
 /**
  * Exceptions for problems with the basecode submission that lead to an preemptive exit.
  */
 public class BasecodeException extends ExitException {
 
+    @Serial
     private static final long serialVersionUID = -3911476090624995247L; // generated
 
     public BasecodeException(String message) {

+ 3 - 0
jplag/src/main/java/de/jplag/exceptions/ExitException.java

@@ -1,10 +1,13 @@
 package de.jplag.exceptions;
 
+import java.io.Serial;
+
 /**
  * Exceptions for problems during the execution of JPlag that lead to an preemptive exit.
  */
 public abstract class ExitException extends Exception {
 
+    @Serial
     private static final long serialVersionUID = 7091658804288889231L; // generated
 
     public ExitException(String message) {

+ 3 - 0
jplag/src/main/java/de/jplag/exceptions/ReportGenerationException.java

@@ -1,10 +1,13 @@
 package de.jplag.exceptions;
 
+import java.io.Serial;
+
 /**
  * Exceptions for problems with the report generation that lead to an preemptive exit.
  */
 public class ReportGenerationException extends ExitException {
 
+    @Serial
     private static final long serialVersionUID = 628097693006117102L; // generated
 
     public ReportGenerationException(String message) {

+ 3 - 0
jplag/src/main/java/de/jplag/exceptions/RootDirectoryException.java

@@ -1,10 +1,13 @@
 package de.jplag.exceptions;
 
+import java.io.Serial;
+
 /**
  * Exceptions for problems with the root directory that lead to an preemptive exit.
  */
 public class RootDirectoryException extends ExitException {
 
+    @Serial
     private static final long serialVersionUID = 3134534079325843267L; // generated
 
     public RootDirectoryException(String message) {

+ 3 - 0
jplag/src/main/java/de/jplag/exceptions/SubmissionException.java

@@ -1,10 +1,13 @@
 package de.jplag.exceptions;
 
+import java.io.Serial;
+
 /**
  * Exceptions for problems with the regular submissions that lead to an preemptive exit.
  */
 public class SubmissionException extends ExitException {
 
+    @Serial
     private static final long serialVersionUID = 794916053362767596L; // generated
 
     public SubmissionException(String message) {

+ 8 - 12
jplag/src/main/java/de/jplag/options/JPlagOptions.java

@@ -46,7 +46,7 @@ public class JPlagOptions {
      * Percentage value (must be between 0 and 100). Comparisons (of submissions pairs) with a similarity below this
      * threshold will be ignored. The default value of 0 allows all matches to be stored. This affects which comparisons are
      * stored and thus make it into the result object.
-     * @see JPlagOptions.similarityMetric
+     * @see JPlagOptions#similarityMetric
      */
     private float similarityThreshold = DEFAULT_SIMILARITY_THRESHOLD;
 
@@ -59,7 +59,7 @@ public class JPlagOptions {
     /**
      * The similarity metric determines how the minimum similarity threshold required for a comparison (of two submissions)
      * is calculated. This affects which comparisons are stored and thus make it into the result object.
-     * @see JPlagOptions.similarityThreshold
+     * @see JPlagOptions#similarityThreshold
      */
     private SimilarityMetric similarityMetric = SimilarityMetric.AVG;
 
@@ -98,7 +98,7 @@ public class JPlagOptions {
      * of the compatibility fallback listed above.
      * </p>
      */
-    private Optional<String> baseCodeSubmissionName = Optional.empty();
+    private String baseCodeSubmissionName = null;
 
     /**
      * Example: If the subdirectoryName is 'src', only the code inside submissionDir/src of each submission will be used for
@@ -130,7 +130,7 @@ public class JPlagOptions {
     }
 
     public Optional<String> getBaseCodeSubmissionName() {
-        return baseCodeSubmissionName;
+        return Optional.ofNullable(baseCodeSubmissionName);
     }
 
     public ComparisonMode getComparisonMode() {
@@ -186,7 +186,7 @@ public class JPlagOptions {
     }
 
     public boolean hasBaseCode() {
-        return this.baseCodeSubmissionName.isPresent();
+        return this.baseCodeSubmissionName != null;
     }
 
     public boolean isDebugParser() {
@@ -199,9 +199,9 @@ public class JPlagOptions {
 
     public void setBaseCodeSubmissionName(String baseCodeSubmissionName) {
         if (baseCodeSubmissionName == null || baseCodeSubmissionName.isEmpty()) {
-            this.baseCodeSubmissionName = Optional.empty();
+            this.baseCodeSubmissionName = null;
         } else {
-            this.baseCodeSubmissionName = Optional.of(baseCodeSubmissionName);
+            this.baseCodeSubmissionName = baseCodeSubmissionName;
         }
     }
 
@@ -249,11 +249,7 @@ public class JPlagOptions {
     }
 
     public void setMaximumNumberOfComparisons(int maximumNumberOfComparisons) {
-        if (maximumNumberOfComparisons < -1) {
-            this.maximumNumberOfComparisons = -1;
-        } else {
-            this.maximumNumberOfComparisons = maximumNumberOfComparisons;
-        }
+        this.maximumNumberOfComparisons = Math.max(maximumNumberOfComparisons, -1);
     }
 
     public void setMinimumTokenMatch(Integer minimumTokenMatch) {

+ 4 - 4
jplag/src/main/java/de/jplag/options/SimilarityMetric.java

@@ -5,14 +5,14 @@ import java.util.function.Function;
 import de.jplag.JPlagComparison;
 
 public enum SimilarityMetric implements Function<JPlagComparison, Float> {
-    AVG(it -> it.similarity()),
-    MIN(it -> it.minimalSimilarity()),
-    MAX(it -> it.maximalSimilarity()),
+    AVG(JPlagComparison::similarity),
+    MIN(JPlagComparison::minimalSimilarity),
+    MAX(JPlagComparison::maximalSimilarity),
     INTERSECTION(it -> (float) it.getNumberOfMatchedTokens());
 
     private final Function<JPlagComparison, Float> similarityFunction;
 
-    private SimilarityMetric(Function<JPlagComparison, Float> determinePercentage) {
+    SimilarityMetric(Function<JPlagComparison, Float> determinePercentage) {
         this.similarityFunction = determinePercentage;
     }
 

+ 4 - 8
jplag/src/main/java/de/jplag/options/Verbosity.java

@@ -5,13 +5,9 @@ public enum Verbosity {
     LONG;
 
     public static Verbosity fromOption(String optionValue) {
-        switch (optionValue) {
-            case "quiet":
-                return QUIET;
-            case "long":
-                return LONG;
-            default:
-                return QUIET;
-        }
+        for (Verbosity verbosity : Verbosity.values())
+            if (verbosity.name().equalsIgnoreCase(optionValue))
+                return verbosity;
+        return QUIET;
     }
 }

+ 1 - 1
jplag/src/main/java/de/jplag/reporting/Color.java

@@ -61,7 +61,7 @@ public enum Color {
 
     private final String hexadecimalValue;
 
-    private Color(String hexadecimalValue) {
+    Color(String hexadecimalValue) {
         this.hexadecimalValue = hexadecimalValue;
     }
 

+ 1 - 1
jplag/src/main/java/de/jplag/reporting/HTMLFile.java

@@ -10,7 +10,7 @@ import de.jplag.options.JPlagOptions;
 
 public class HTMLFile extends PrintWriter {
 
-    private BufferedCounter counter;
+    private final BufferedCounter counter;
 
     /**
      * Static factory method to instantiate an HTMLFile objects.

+ 1 - 1
jplag/src/main/java/de/jplag/reporting/MarkupText.java

@@ -7,7 +7,7 @@ package de.jplag.reporting;
 public class MarkupText {
     public int fileIndex, lineIndex, column;
     public String text;
-    public boolean frontMarkup = false;
+    public boolean frontMarkup;
 
     public MarkupText(int fileIndex, int lineIndex, int column, String text, boolean frontMarkup) {
         this.fileIndex = fileIndex;

+ 1 - 1
jplag/src/main/java/de/jplag/strategy/AbstractComparisonStrategy.java

@@ -10,7 +10,7 @@ import de.jplag.options.JPlagOptions;
 
 public abstract class AbstractComparisonStrategy implements ComparisonStrategy {
 
-    private GreedyStringTiling greedyStringTiling;
+    private final GreedyStringTiling greedyStringTiling;
 
     protected JPlagOptions options;
 

+ 2 - 2
jplag/src/main/java/de/jplag/strategy/ComparisonMode.java

@@ -30,7 +30,7 @@ public enum ComparisonMode {
 
     /**
      * The textual description of the comparison mode.
-     * @return
+     * @return a description of the comparison mode
      */
     public String getDescription() {
         return description;
@@ -40,7 +40,7 @@ public enum ComparisonMode {
      * @return a collections of all mode names.
      */
     public static Collection<String> allNames() {
-        return Arrays.stream(values()).map(it -> it.getName()).collect(toList());
+        return Arrays.stream(values()).map(ComparisonMode::getName).collect(toList());
     }
 
     /**

+ 1 - 1
jplag/src/main/java/de/jplag/strategy/NormalComparisonStrategy.java

@@ -39,7 +39,7 @@ public class NormalComparisonStrategy extends AbstractComparisonStrategy {
                 if (second.getTokenList() == null) {
                     continue;
                 }
-                compareSubmissions(first, second, withBaseCode).ifPresent(it -> comparisons.add(it));
+                compareSubmissions(first, second, withBaseCode).ifPresent(comparisons::add);
             }
         }
 

+ 1 - 1
jplag/src/main/java/de/jplag/strategy/ParallelComparisonStrategy.java

@@ -106,7 +106,7 @@ public class ParallelComparisonStrategy extends AbstractComparisonStrategy {
                 boolean hasRight = hasLeft && rightLock.tryLock();
                 try {
                     if (hasLeft && hasRight) { // both locks acquired!
-                        compareSubmissions(tuple.getLeft(), tuple.getRight(), withBaseCode).ifPresent(it -> comparisons.add(it));
+                        compareSubmissions(tuple.getLeft(), tuple.getRight(), withBaseCode).ifPresent(comparisons::add);
                         synchronized (this) {
                             successfulComparisons++;
                         }

+ 1 - 1
jplag/src/main/java/de/jplag/strategy/SubmissionTuple.java

@@ -30,6 +30,6 @@ public class SubmissionTuple {
 
     @Override
     public String toString() {
-        return "(" + left.toString() + " | " + right.toString() + ")";
+        return "(" + left + " | " + right + ")";
     }
 }

+ 1 - 8
jplag/src/test/java/de/jplag/cli/MinTokenMatchTest.java

@@ -3,7 +3,6 @@ package de.jplag.cli;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
 
 import org.junit.Rule;
 import org.junit.Test;
@@ -11,7 +10,6 @@ import org.junit.contrib.java.lang.system.ExpectedSystemExit;
 
 import de.jplag.CommandLineArgument;
 import de.jplag.JPlag;
-import de.jplag.exceptions.ExitException;
 
 public class MinTokenMatchTest extends CommandLineInterfaceTest {
 
@@ -26,12 +24,7 @@ public class MinTokenMatchTest extends CommandLineInterfaceTest {
         assertNull(options.getLanguage());
 
         // Init JPlag:
-        try {
-            new JPlag(options);
-        } catch (ExitException e) {
-            e.printStackTrace();
-            fail("JPlag intialization failed!");
-        }
+        new JPlag(options);
 
         // Now the language is set:
         assertNotNull(options.getLanguage());

+ 4 - 4
jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/A/Token.java

@@ -1,6 +1,6 @@
 import java.io.Serializable;
 
-abstract public class Token implements TokenConstants, Serializable {
+public abstract class Token implements TokenConstants, Serializable {
 	private static final long serialVersionUID = 862935679966383302L;
 	public int type;
 	public String file;
@@ -22,9 +22,9 @@ abstract public class Token implements TokenConstants, Serializable {
 	}
 	
 	// abstract members
-	abstract public int getLine();
-	abstract public int getColumn();
-	abstract public int getLength();
+	public abstract int getLine();
+	public abstract int getColumn();
+	public abstract int getLength();
 	protected void setLine(int line) {}
 	protected void setColumn(int line) {}
 	protected void setLength(int line) {}

+ 4 - 4
jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/B/Token.java

@@ -1,6 +1,6 @@
 import java.io.Serializable;
 
-abstract public class Token implements TokenConstants, Serializable {
+public abstract class Token implements TokenConstants, Serializable {
 	private static final long serialVersionUID = 862935679966383302L;
 	public int type;
 	public String file;
@@ -22,9 +22,9 @@ abstract public class Token implements TokenConstants, Serializable {
 	}
 	
 	// abstract members
-	abstract public int getLine();
-	abstract public int getColumn();
-	abstract public int getLength();
+	public abstract int getLine();
+	public abstract int getColumn();
+	public abstract int getLength();
 	protected void setLine(int line) {}
 	protected void setColumn(int line) {}
 	protected void setLength(int line) {}

+ 4 - 4
jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/C/Token.java

@@ -1,6 +1,6 @@
 import java.io.Serializable;
 
-abstract public class Token implements TokenConstants, Serializable {
+public abstract class Token implements TokenConstants, Serializable {
 	private static final long serialVersionUID = 862935679966383302L;
 	public int type;
 	public String file;
@@ -22,9 +22,9 @@ abstract public class Token implements TokenConstants, Serializable {
 	}
 	
 	// abstract members
-	abstract public int getLine();
-	abstract public int getColumn();
-	abstract public int getLength();
+	public abstract int getLine();
+	public abstract int getColumn();
+	public abstract int getLength();
 	protected void setLine(int line) {}
 	protected void setColumn(int line) {}
 	protected void setLength(int line) {}

+ 4 - 4
jplag/src/test/resources/de/jplag/samples/PartialPlagiarism/D/Token.java

@@ -2,7 +2,7 @@ package samples.PartialPlagiarism.D;
 
 import java.io.Serializable;
 
-abstract public class Token implements TokenConstants, Serializable {
+public abstract class Token implements TokenConstants, Serializable {
 	private static final long serialVersionUID = 862335679966383302L;
 	public int type;
 	public String file;
@@ -20,9 +20,9 @@ abstract public class Token implements TokenConstants, Serializable {
 	}
 	
 	// abstract members
-	abstract public int getLine();
-	abstract public int getColumn();
-	abstract public int getLength();
+	public abstract int getLine();
+	public abstract int getColumn();
+	public abstract int getLength();
 	protected void setLine(int line) {}
 	protected void setColumn(int line) {}
 	protected void setLength(int line) {}