Repository: iluwatar/java-design-patterns
Issue: feature: Run sonar analysis on pull requests
Labels: type: feature
epic: code quality

⭐ This feature will help us review pull requests easier by helping us reviewing the modified or newly added code 👨🏻‍💻  by SonarCloud and comment out the report in the pull request.

✔️ This is going to help the contributor to increase their code quality and the coverage while removing static code errors.
✔️ Overall this is going to increase the code quality and make the process more smooth and fast.

As we cannot run sonar analysis on pull requests from forked repositories using ❌ GitHub Actions; which we currently use due to its limitations to pass secrets, we will be moving with a solution from Circle CI for the time being to make our jobs easier.

Issue comments:

Pull request review comments:

Patch that resolved the issue:
diff --git a/.circleci/config.yml b/.circleci/config.yml
new file mode 100644
index 000000000000..3e35aee712dd
--- /dev/null
+++ b/.circleci/config.yml
@@ -0,0 +1,52 @@
+#
+# The MIT License
+# Copyright © 2014-2021 Ilkka Seppälä
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+
+version: 2
+
+jobs:
+  sonar-pr:
+    docker:
+      - image: circleci/openjdk:11-node
+    steps:
+    - checkout
+    - restore_cache:
+        key: jdp-sonar-pr-{{ checksum "pom.xml" }}
+    - run: |
+        if [ -n "${CIRCLE_PR_NUMBER}" ]; then
+          MAVEN_OPTS="-Xmx3000m" xvfb-run ./mvnw -B clean verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \
+             -Dsonar.pullrequest.key=${CIRCLE_PR_NUMBER} \
+             -Dsonar.pullrequest.branch=${CIRCLE_BRANCH} \
+             -Dsonar.pullrequest.base=master
+        else
+          echo "No Sonar PR analysis as this is not a pull request"
+        fi
+    - save_cache:
+        key: jdp-sonar-pr-{{ checksum "pom.xml" }}
+        paths:
+        - ~/.m2
+
+workflows:
+  version: 2
+  all:
+    jobs:
+    - sonar-pr
diff --git a/.mvn/wrapper/MavenWrapperDownloader.java b/.mvn/wrapper/MavenWrapperDownloader.java
index b901097f2db6..cfc696f0122a 100644
--- a/.mvn/wrapper/MavenWrapperDownloader.java
+++ b/.mvn/wrapper/MavenWrapperDownloader.java
@@ -1,18 +1,26 @@
 /*
- * Copyright 2007-present the original author or authors.
+ * The MIT License
+ * Copyright © 2014-2021 Ilkka Seppälä
  *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
  *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
  */
+
 import java.net.*;
 import java.io.*;
 import java.nio.channels.*;
diff --git a/mvnw.cmd b/mvnw.cmd
index 86115719e538..ed1dd59b0539 100644
--- a/mvnw.cmd
+++ b/mvnw.cmd
@@ -1,21 +1,25 @@
-@REM ----------------------------------------------------------------------------
-@REM Licensed to the Apache Software Foundation (ASF) under one
-@REM or more contributor license agreements.  See the NOTICE file
-@REM distributed with this work for additional information
-@REM regarding copyright ownership.  The ASF licenses this file
-@REM to you under the Apache License, Version 2.0 (the
-@REM "License"); you may not use this file except in compliance
-@REM with the License.  You may obtain a copy of the License at
 @REM
-@REM    http://www.apache.org/licenses/LICENSE-2.0
+@REM The MIT License
+@REM Copyright © 2014-2021 Ilkka Seppälä
+@REM
+@REM Permission is hereby granted, free of charge, to any person obtaining a copy
+@REM of this software and associated documentation files (the "Software"), to deal
+@REM in the Software without restriction, including without limitation the rights
+@REM to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+@REM copies of the Software, and to permit persons to whom the Software is
+@REM furnished to do so, subject to the following conditions:
+@REM
+@REM The above copyright notice and this permission notice shall be included in
+@REM all copies or substantial portions of the Software.
+@REM
+@REM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+@REM IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+@REM FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+@REM AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+@REM LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+@REM OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+@REM THE SOFTWARE.
 @REM
-@REM Unless required by applicable law or agreed to in writing,
-@REM software distributed under the License is distributed on an
-@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-@REM KIND, either express or implied.  See the License for the
-@REM specific language governing permissions and limitations
-@REM under the License.
-@REM ----------------------------------------------------------------------------
 
 @REM ----------------------------------------------------------------------------
 @REM Maven Start Up Batch script
diff --git a/parameter-object/pom.xml b/parameter-object/pom.xml
index be64d62df81a..5fbf060662c2 100644
--- a/parameter-object/pom.xml
+++ b/parameter-object/pom.xml
@@ -2,7 +2,7 @@
 <!--
 
     The MIT License
-    Copyright © 2014-2019 Ilkka Seppälä
+    Copyright © 2014-2021 Ilkka Seppälä
 
     Permission is hereby granted, free of charge, to any person obtaining a copy
     of this software and associated documentation files (the "Software"), to deal
diff --git a/parameter-object/src/main/java/com/iluwatar/parameter/object/App.java b/parameter-object/src/main/java/com/iluwatar/parameter/object/App.java
index 7d4f600e21fa..e0f2008d9b0e 100644
--- a/parameter-object/src/main/java/com/iluwatar/parameter/object/App.java
+++ b/parameter-object/src/main/java/com/iluwatar/parameter/object/App.java
@@ -1,6 +1,6 @@
 /*
  * The MIT License
- * Copyright © 2014-2019 Ilkka Seppälä
+ * Copyright © 2014-2021 Ilkka Seppälä
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
diff --git a/parameter-object/src/main/java/com/iluwatar/parameter/object/ParameterObject.java b/parameter-object/src/main/java/com/iluwatar/parameter/object/ParameterObject.java
index 65f636191b5a..d90344930a54 100644
--- a/parameter-object/src/main/java/com/iluwatar/parameter/object/ParameterObject.java
+++ b/parameter-object/src/main/java/com/iluwatar/parameter/object/ParameterObject.java
@@ -1,6 +1,6 @@
 /*
  * The MIT License
- * Copyright © 2014-2019 Ilkka Seppälä
+ * Copyright © 2014-2021 Ilkka Seppälä
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
diff --git a/parameter-object/src/main/java/com/iluwatar/parameter/object/SearchService.java b/parameter-object/src/main/java/com/iluwatar/parameter/object/SearchService.java
index 62acc840df92..7f038bbce13e 100644
--- a/parameter-object/src/main/java/com/iluwatar/parameter/object/SearchService.java
+++ b/parameter-object/src/main/java/com/iluwatar/parameter/object/SearchService.java
@@ -1,6 +1,6 @@
 /*
  * The MIT License
- * Copyright © 2014-2019 Ilkka Seppälä
+ * Copyright © 2014-2021 Ilkka Seppälä
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
diff --git a/parameter-object/src/main/java/com/iluwatar/parameter/object/SortOrder.java b/parameter-object/src/main/java/com/iluwatar/parameter/object/SortOrder.java
index 6420ca9e134f..3f7240f6a4ba 100644
--- a/parameter-object/src/main/java/com/iluwatar/parameter/object/SortOrder.java
+++ b/parameter-object/src/main/java/com/iluwatar/parameter/object/SortOrder.java
@@ -1,6 +1,6 @@
 /*
  * The MIT License
- * Copyright © 2014-2019 Ilkka Seppälä
+ * Copyright © 2014-2021 Ilkka Seppälä
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal


Test patch:
diff --git a/parameter-object/src/test/java/com/iluwatar/parameter/object/AppTest.java b/parameter-object/src/test/java/com/iluwatar/parameter/object/AppTest.java
index 809e41f3677c..16baef96fba6 100644
--- a/parameter-object/src/test/java/com/iluwatar/parameter/object/AppTest.java
+++ b/parameter-object/src/test/java/com/iluwatar/parameter/object/AppTest.java
@@ -1,6 +1,6 @@
 /*
  * The MIT License
- * Copyright © 2014-2019 Ilkka Seppälä
+ * Copyright © 2014-2021 Ilkka Seppälä
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
diff --git a/parameter-object/src/test/java/com/iluwatar/parameter/object/ParameterObjectTest.java b/parameter-object/src/test/java/com/iluwatar/parameter/object/ParameterObjectTest.java
index 05907b9c677a..999cd19e0b2e 100644
--- a/parameter-object/src/test/java/com/iluwatar/parameter/object/ParameterObjectTest.java
+++ b/parameter-object/src/test/java/com/iluwatar/parameter/object/ParameterObjectTest.java
@@ -1,6 +1,6 @@
 /*
  * The MIT License
- * Copyright © 2014-2019 Ilkka Seppälä
+ * Copyright © 2014-2021 Ilkka Seppälä
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
diff --git a/parameter-object/src/test/java/com/iluwatar/parameter/object/SearchServiceTest.java b/parameter-object/src/test/java/com/iluwatar/parameter/object/SearchServiceTest.java
index d7633f0e3bf9..76f56121335c 100644
--- a/parameter-object/src/test/java/com/iluwatar/parameter/object/SearchServiceTest.java
+++ b/parameter-object/src/test/java/com/iluwatar/parameter/object/SearchServiceTest.java
@@ -1,6 +1,6 @@
 /*
  * The MIT License
- * Copyright © 2014-2019 Ilkka Seppälä
+ * Copyright © 2014-2021 Ilkka Seppälä
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal