Repository: deepjavalibrary/djl
Pull request #2764 (2023-08-23 19:51:29)

[ci] Fixes PMD warnings
## Description ##

Brief description of what this PR is about

- If this change is a backward incompatible change, why must this change be made?
- Interesting edge cases to note here



Patch:
diff --git a/api/src/main/java/ai/djl/training/Trainer.java b/api/src/main/java/ai/djl/training/Trainer.java
index 8358c0238..eab6ba07f 100644
--- a/api/src/main/java/ai/djl/training/Trainer.java
+++ b/api/src/main/java/ai/djl/training/Trainer.java
@@ -281,7 +281,7 @@ public class Trainer implements AutoCloseable {
      *
      * @param listenerConsumer a consumer that executes the method
      */
-    public void notifyListeners(Consumer<TrainingListener> listenerConsumer) {
+    public final void notifyListeners(Consumer<TrainingListener> listenerConsumer) {
         listeners.forEach(listenerConsumer);
     }
 
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 9fdf29027..5c0274801 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
diff --git a/tools/conf/pmd.xml b/tools/conf/pmd.xml
index 16642b659..fa3370942 100644
--- a/tools/conf/pmd.xml
+++ b/tools/conf/pmd.xml
@@ -407,7 +407,6 @@
         <exclude name="AvoidFieldNameMatchingTypeName"/>
         <exclude name="AvoidInstanceofChecksInCatchClause"/>
         <exclude name="AvoidLiteralsInIfCondition"/>
-        <exclude name="BeanMembersShouldSerialize"/>
         <exclude name="CloneMethodMustImplementCloneable"/>
         <exclude name="CloseResource"/>
         <exclude name="CompareObjectsWithEquals"/>


Test patch:
diff --git a/api/src/test/java/ai/djl/nn/BlockFactoryTest.java b/api/src/test/java/ai/djl/nn/BlockFactoryTest.java
index e67fe7457..230631486 100644
--- a/api/src/test/java/ai/djl/nn/BlockFactoryTest.java
+++ b/api/src/test/java/ai/djl/nn/BlockFactoryTest.java
@@ -20,6 +20,7 @@ import org.testng.annotations.Test;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 
+@SuppressWarnings("PMD.TestClassWithoutTestCases")
 public class BlockFactoryTest {
 
     @Test
diff --git a/integration/src/main/java/ai/djl/integration/IntegrationTest.java b/integration/src/main/java/ai/djl/integration/IntegrationTest.java
index 41a7cafaf..a55cec9a2 100644
--- a/integration/src/main/java/ai/djl/integration/IntegrationTest.java
+++ b/integration/src/main/java/ai/djl/integration/IntegrationTest.java
@@ -51,6 +51,7 @@ import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
 import java.util.stream.Collectors;
 
+@SuppressWarnings("PMD.TestClassWithoutTestCases")
 public class IntegrationTest {
 
     private static final Logger logger = LoggerFactory.getLogger(IntegrationTest.class);
diff --git a/integration/src/main/java/ai/djl/integration/tests/inference/StreamingTest.java b/integration/src/main/java/ai/djl/integration/tests/inference/StreamingTest.java
index c6561852a..8ca827f90 100644
--- a/integration/src/main/java/ai/djl/integration/tests/inference/StreamingTest.java
+++ b/integration/src/main/java/ai/djl/integration/tests/inference/StreamingTest.java
@@ -35,6 +35,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.stream.Stream;
 
+@SuppressWarnings("PMD.TestClassWithoutTestCases")
 public class StreamingTest {
 
     @Test
diff --git a/integration/src/main/java/ai/djl/integration/tests/nn/BlockFactoryTest.java b/integration/src/main/java/ai/djl/integration/tests/nn/BlockFactoryTest.java
index d7ce5b163..9c356e08c 100644
--- a/integration/src/main/java/ai/djl/integration/tests/nn/BlockFactoryTest.java
+++ b/integration/src/main/java/ai/djl/integration/tests/nn/BlockFactoryTest.java
@@ -99,6 +99,7 @@ public class BlockFactoryTest {
         return zipPath;
     }
 
+    @SuppressWarnings("PMD.TestClassWithoutTestCases")
     public static class TestBlockFactory implements BlockFactory {
 
         private static final long serialVersionUID = 1234567L;
diff --git a/integration/src/main/java/ai/djl/integration/tests/nn/ScaledDotProductAttentionBlockTest.java b/integration/src/main/java/ai/djl/integration/tests/nn/ScaledDotProductAttentionBlockTest.java
index 71c731519..122a2029f 100644
--- a/integration/src/main/java/ai/djl/integration/tests/nn/ScaledDotProductAttentionBlockTest.java
+++ b/integration/src/main/java/ai/djl/integration/tests/nn/ScaledDotProductAttentionBlockTest.java
@@ -30,6 +30,7 @@ import ai.djl.training.initializer.NormalInitializer;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 
+@SuppressWarnings("PMD.TestClassWithoutTestCases")
 public class ScaledDotProductAttentionBlockTest {
 
     private double[] keySequenceInitialization = {
diff --git a/integration/src/main/java/ai/djl/integration/util/TestUtils.java b/integration/src/main/java/ai/djl/integration/util/TestUtils.java
index 4331cdc0e..7af2fe991 100644
--- a/integration/src/main/java/ai/djl/integration/util/TestUtils.java
+++ b/integration/src/main/java/ai/djl/integration/util/TestUtils.java
@@ -20,6 +20,7 @@ import org.testng.SkipException;
 
 import java.util.Arrays;
 
+@SuppressWarnings("PMD.TestClassWithoutTestCases")
 public final class TestUtils {
 
     private static String engineName = Engine.getDefaultEngineName();
diff --git a/testing/src/main/java/ai/djl/testing/CoverageUtils.java b/testing/src/main/java/ai/djl/testing/CoverageUtils.java
index 07213638b..42cdecb5f 100644
--- a/testing/src/main/java/ai/djl/testing/CoverageUtils.java
+++ b/testing/src/main/java/ai/djl/testing/CoverageUtils.java
@@ -39,7 +39,7 @@ import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
 import java.util.stream.Collectors;
 
-@SuppressWarnings("PMD.AvoidAccessibilityAlteration")
+@SuppressWarnings({"PMD.AvoidAccessibilityAlteration", "PMD.TestClassWithoutTestCases"})
 public final class CoverageUtils {
 
     private CoverageUtils() {}
diff --git a/testing/src/main/java/ai/djl/testing/TestRequirements.java b/testing/src/main/java/ai/djl/testing/TestRequirements.java
index 1d4da5f76..bf57d64bd 100644
--- a/testing/src/main/java/ai/djl/testing/TestRequirements.java
+++ b/testing/src/main/java/ai/djl/testing/TestRequirements.java
@@ -24,6 +24,7 @@ import java.util.Calendar;
  * <p>When the test requirements are not fulfilled, the test is skipped with a {@link
  * SkipException}.
  */
+@SuppressWarnings("PMD.TestClassWithoutTestCases")
 public final class TestRequirements {
 
     private TestRequirements() {}