Skip to content

Commit

Permalink
chore(deps): Update dependency net.sourceforge.pmd:pmd-java to v7 (#497)
Browse files Browse the repository at this point in the history
* chore(deps): Update dependency net.sourceforge.pmd:pmd-java to v7

* hm

* chore: resolve pmd lint errors and renamed rules

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: zml <[email protected]>
  • Loading branch information
renovate[bot] and zml2008 authored Feb 16, 2025
1 parent 561aa31 commit 3df76e2
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 11 deletions.
14 changes: 7 additions & 7 deletions .pmd/rules.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
<exclude name="ArrayIsStoredDirectly"/> <!-- triggers on package-private constructors -->
<exclude name="AvoidReassigningLoopVariables"/>
<exclude name="AvoidReassigningParameters"/>
<exclude name="ExhaustiveSwitchHasDefault"/> <!-- does not make sense when targeting JDK8, since we can't use switch expressions -->
<exclude name="ForLoopCanBeForeach"/> <!-- has false positives when catching exceptions thrown by Iterator.next -->
<exclude name="JUnitAssertionsShouldIncludeMessage"/>
<exclude name="JUnitTestContainsTooManyAsserts"/>
<exclude name="JUnitTestsShouldIncludeAssert"/>
<exclude name="GuardLogStatement"/> <!-- we use parameter substitution instead -->
<exclude name="UnitTestAssertionsShouldIncludeMessage"/>
<exclude name="UnitTestContainsTooManyAsserts"/>
<exclude name="UnitTestShouldIncludeAssert"/>
<exclude name="LiteralsFirstInComparisons"/>
<exclude name="PreserveStackTrace"/> <!-- for a lot of parse errors, the stacktrace is not important -->
<exclude name="UseAssertTrueInsteadOfAssertEquals"/> <!-- false positives on comparisons to Object-returning methods -->
<exclude name="UseVarargs"/>

<!-- We don't want to depend on a logging framework -->
Expand All @@ -38,7 +39,6 @@
<rule ref="category/java/codestyle.xml/UnnecessaryAnnotationValueElement"/>
<rule ref="category/java/codestyle.xml/UnnecessaryImport"/>
<rule ref="category/java/codestyle.xml/UnnecessarySemicolon"/>
<rule ref="category/java/codestyle.xml/UseDiamondOperator"/>

<!-- https://pmd.github.io/latest/pmd_rules_java_design.html -->
<rule ref="category/java/design.xml/AvoidThrowingNullPointerException"/>
Expand Down Expand Up @@ -92,7 +92,7 @@
<rule ref="category/java/errorprone.xml/MissingSerialVersionUID"/>
<rule ref="category/java/errorprone.xml/MissingStaticMethodInNonInstantiatableClass"/>
<rule ref="category/java/errorprone.xml/MoreThanOneLogger"/>
<rule ref="category/java/errorprone.xml/NonCaseLabelInSwitchStatement"/>
<rule ref="category/java/errorprone.xml/NonCaseLabelInSwitch"/>
<rule ref="category/java/errorprone.xml/NonStaticInitializer"/>
<rule ref="category/java/errorprone.xml/OverrideBothEqualsAndHashcode"/>
<rule ref="category/java/errorprone.xml/ProperCloneImplementation"/>
Expand Down Expand Up @@ -135,7 +135,7 @@
<rule ref="category/java/performance.xml/RedundantFieldInitializer"/>
<rule ref="category/java/performance.xml/StringInstantiation"/>
<rule ref="category/java/performance.xml/StringToString"/>
<rule ref="category/java/performance.xml/TooFewBranchesForASwitchStatement"/>
<rule ref="category/java/performance.xml/TooFewBranchesForSwitch"/>
<rule ref="category/java/performance.xml/UseArrayListInsteadOfVector"/>
<rule ref="category/java/performance.xml/UseArraysAsList"/>
<rule ref="category/java/performance.xml/UseIndexOfChar"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ protected AbstractConfigurationNode(final @Nullable Object key, final @Nullable
}
}

@SuppressWarnings("PMD.ConstructorCallsOverridableMethod")
protected AbstractConfigurationNode(final @Nullable A parent, final A copyOf) {
this.options = copyOf.options();
this.attached = true; // copies are always attached
Expand Down Expand Up @@ -734,7 +735,7 @@ public final <S, T> T visit(final ConfigurationVisitor.Safe<S, T> visitor, final
}
}

@SuppressWarnings({"JdkObsolete", "unchecked"})
@SuppressWarnings({"JdkObsolete", "unchecked", "PMD.LooseCoupling"})
private <S, T, E extends Exception> T visitInternal(final ConfigurationVisitor<S, T, E> visitor, final S state) throws E {
visitor.beginVisit(this.self(), state);
if (!(this.value instanceof NullConfigValue)) { // only visit if we have an actual value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.nio.file.WatchKey;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.locks.Lock;
Expand All @@ -41,7 +42,7 @@ class DirectoryListenerRegistration implements Subscriber<WatchEvent<?>> {
private final Lock lock = new ReentrantLock();
private final AtomicBoolean acceptingRegistrations = new AtomicBoolean(true);
private final WatchKey key;
private final ConcurrentHashMap<Path, Processor<WatchEvent<?>, WatchEvent<?>>> fileListeners
private final ConcurrentMap<Path, Processor<WatchEvent<?>, WatchEvent<?>>> fileListeners
= new ConcurrentHashMap<>();
private final Executor executor;
private final Processor<WatchEvent<?>, WatchEvent<?>> dirListeners;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public final class WatchServiceListener implements AutoCloseable {
private volatile boolean open = true;
private final Thread executor;
final Executor taskExecutor;
@SuppressWarnings("PMD.LooseCoupling") // we use implementation-specific API
private final ConcurrentHashMap<Path, DirectoryListenerRegistration> activeListeners = new ConcurrentHashMap<>();
private static final ThreadLocal<IOException> exceptionHolder = new ThreadLocal<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@
import java.util.UUID;
import java.util.regex.Pattern;

@SuppressWarnings("checkstyle:IllegalType") // for Optional
@SuppressWarnings({
"checkstyle:IllegalType", // for Optional
"PMD.LooseCoupling" // testing specific type implementations
})
class TypeSerializersTest {

private <T> TypeSerializer<T> serializer(final TypeToken<T> type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import java.util.AbstractCollection;
import java.util.Collection;

@SuppressWarnings("PMD.LooseCoupling") // specific types matter
class TypesTest {

@Test
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ indra = "3.1.3"
junit="5.11.4"
ktlint="0.49.1"
ktfmt="0.54"
pmd = "6.55.0"
pmd = "7.10.0"
spotless = "7.0.2"

[libraries]
Expand Down

0 comments on commit 3df76e2

Please sign in to comment.