From 9456adfd1b4546c1494fa859a594f337eb631b5f Mon Sep 17 00:00:00 2001
From: Ulli Hafner <ullrich.hafner@gmail.com>
Date: Tue, 5 Mar 2024 11:47:06 +0100
Subject: [PATCH] Fix styling with OpenRewrite.

---
 .gitignore                                    |  2 ++
 doc/Continuous-Integration.md                 |  2 +-
 pom.xml                                       | 32 +++++++++++++++++++
 .../java/edu/hm/hafner/util/LineRange.java    |  1 -
 .../java/edu/hm/hafner/util/package-info.java |  2 +-
 .../edu/hm/hafner/util/ArchitectureRules.java |  2 +-
 6 files changed, 37 insertions(+), 4 deletions(-)

diff --git a/.gitignore b/.gitignore
index 9f04e894..e651159e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,7 @@ node
 node_modules
 target
 *.iml
+*.bak
 .classpath
 .project
 .settings
@@ -11,4 +12,5 @@ release.properties
 metrics.env
 maven.log
 .DS_Store
+.idea
 /package-lock.json
diff --git a/doc/Continuous-Integration.md b/doc/Continuous-Integration.md
index 01de3162..15bbd877 100644
--- a/doc/Continuous-Integration.md
+++ b/doc/Continuous-Integration.md
@@ -52,7 +52,7 @@ Eine solche Visualisierung ist unter GitHub Actions nicht verfügbar.
 Da es für Jenkins keinen öffentlichen Service wie bei GitHub Actions gibt, um eigene Projekte zu bauen, muss die Jenkins 
 Integration lokal durchgeführt werden. Zur Vereinfachung des Jenkins Setup ist in diesem Coding Style eine
 lauffähige Jenkins Installation enthalten (im Sinne von *Infrastructure as Code*). 
-Diese kann über `jenkins.sh` im Hauptverzeichnis gestartet werden. Anschließend wird die
+Diese kann über `bin/jenkins.sh` gestartet werden. Anschließend wird die
 aktuelle Jenkins LTS Version mit allen benötigten Plugins in einem Docker Container gebaut und gestartet (das dauert
 beim ersten Aufruf etwas). Dazu wird ebenso ein als Docker Container initialisierter Java Agent (**Achtung**: Java 8) 
 verbunden, der die Builds ausführt. 
diff --git a/pom.xml b/pom.xml
index 5855f4ac..6361ade5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -106,9 +106,15 @@
     <maven-enforcer-plugin.version>3.4.1</maven-enforcer-plugin.version>
     <maven-dependency-plugin.version>3.1.2</maven-dependency-plugin.version>
     <depgraph-maven-plugin.version>4.0.3</depgraph-maven-plugin.version>
+    <sortpom-maven-plugin.version>3.4.0</sortpom-maven-plugin.version>
+
+    <!-- OpenRewrite versions   -->
     <rewrite-maven-plugin.version>5.23.3</rewrite-maven-plugin.version>
     <rewrite-testing-frameworks.version>2.4.1</rewrite-testing-frameworks.version>
     <sortpom-maven-plugin.version>3.4.0</sortpom-maven-plugin.version>
+    <rewrite-static-analysis.version>1.3.1</rewrite-static-analysis.version>
+    <rewrite-migrate-java.version>2.9.0</rewrite-migrate-java.version>
+    <rewrite-recommendations.version>1.2.2</rewrite-recommendations.version>
 
     <!-- Maven Surefire ArgLine -->
     <argLine>-Djava.util.logging.config.file=logging.properties</argLine>
@@ -297,6 +303,7 @@
         </configuration>
       </plugin>
       <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-compiler-plugin</artifactId>
         <version>${maven-compiler-plugin.version}</version>
         <configuration>
@@ -396,6 +403,7 @@
         </configuration>
       </plugin>
       <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-javadoc-plugin</artifactId>
         <version>${maven-javadoc-plugin.version}</version>
         <configuration>
@@ -760,6 +768,15 @@
         <configuration>
           <activeRecipes>
             <recipe>org.openrewrite.java.testing.assertj.SimplifyChainedAssertJAssertions</recipe>
+            <recipe>org.openrewrite.maven.BestPractices</recipe>
+            <recipe>org.openrewrite.staticanalysis.MissingOverrideAnnotation</recipe>
+            <recipe>org.openrewrite.staticanalysis.CommonStaticAnalysis</recipe>
+            <recipe>org.openrewrite.staticanalysis.RemoveExtraSemicolons</recipe>
+            <recipe>org.openrewrite.java.migrate.Java8toJava11</recipe>
+            <recipe>org.openrewrite.java.migrate.util.SequencedCollection</recipe>
+            <recipe>org.openrewrite.java.format.RemoveTrailingWhitespace</recipe>
+            <recipe>org.openrewrite.java.format.BlankLines</recipe>
+            <recipe>org.openrewrite.java.format.EmptyNewlineAtEndOfFile</recipe>
           </activeRecipes>
         </configuration>
         <dependencies>
@@ -768,6 +785,21 @@
             <artifactId>rewrite-testing-frameworks</artifactId>
             <version>${rewrite-testing-frameworks.version}</version>
           </dependency>
+          <dependency>
+            <groupId>org.openrewrite.recipe</groupId>
+            <artifactId>rewrite-static-analysis</artifactId>
+            <version>${rewrite-static-analysis.version}</version>
+          </dependency>
+          <dependency>
+            <groupId>org.openrewrite.recipe</groupId>
+            <artifactId>rewrite-migrate-java</artifactId>
+            <version>${rewrite-migrate-java.version}</version>
+          </dependency>
+          <dependency>
+            <groupId>org.openrewrite.recipe</groupId>
+            <artifactId>rewrite-recommendations</artifactId>
+            <version>${rewrite-recommendations.version}</version>
+          </dependency>
         </dependencies>
       </plugin>
       <plugin>
diff --git a/src/main/java/edu/hm/hafner/util/LineRange.java b/src/main/java/edu/hm/hafner/util/LineRange.java
index de5d72c0..16fea08b 100644
--- a/src/main/java/edu/hm/hafner/util/LineRange.java
+++ b/src/main/java/edu/hm/hafner/util/LineRange.java
@@ -129,4 +129,3 @@ public String toString() {
         return String.format("[%d-%d]", start, end);
     }
 }
-
diff --git a/src/main/java/edu/hm/hafner/util/package-info.java b/src/main/java/edu/hm/hafner/util/package-info.java
index bfdc9ab5..f609b325 100644
--- a/src/main/java/edu/hm/hafner/util/package-info.java
+++ b/src/main/java/edu/hm/hafner/util/package-info.java
@@ -8,4 +8,4 @@
 package edu.hm.hafner.util;
 
 import edu.umd.cs.findbugs.annotations.DefaultAnnotation;
-import edu.umd.cs.findbugs.annotations.NonNull;
\ No newline at end of file
+import edu.umd.cs.findbugs.annotations.NonNull;
diff --git a/src/test/java/edu/hm/hafner/util/ArchitectureRules.java b/src/test/java/edu/hm/hafner/util/ArchitectureRules.java
index 3ea127df..6791e901 100644
--- a/src/test/java/edu/hm/hafner/util/ArchitectureRules.java
+++ b/src/test/java/edu/hm/hafner/util/ArchitectureRules.java
@@ -189,7 +189,7 @@ private static class ExceptionHasNoContext extends DescribedPredicate<JavaConstr
         @Override
         public boolean test(final JavaConstructorCall javaConstructorCall) {
             ConstructorCallTarget target = javaConstructorCall.getTarget();
-            if (target.getRawParameterTypes().size() > 0) {
+            if (!target.getRawParameterTypes().isEmpty()) {
                 return false;
             }
             return target.getOwner().isAssignableTo(Throwable.class)