Skip to content

Commit d288d0c

Browse files
committed
fix pmd
1 parent 72ddd5e commit d288d0c

20 files changed

Lines changed: 54 additions & 39 deletions

File tree

‎config/pmd/pmd-ruleset.xml‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
<!-- Best Practices -->
1010
<rule ref="category/java/bestpractices.xml">
11-
<exclude name="JUnitTestContainsTooManyAsserts"/>
12-
<exclude name="JUnitAssertionsShouldIncludeMessage"/>
1311
<exclude name="GuardLogStatement"/>
1412
</rule>
1513

@@ -18,7 +16,6 @@
1816
<exclude name="OnlyOneReturn"/>
1917
<exclude name="AtLeastOneConstructor"/>
2018
<exclude name="CommentDefaultAccessModifier"/>
21-
<exclude name="DefaultPackage"/>
2219
<exclude name="LongVariable"/>
2320
<exclude name="ShortVariable"/>
2421
<exclude name="ShortMethodName"/>
@@ -27,6 +24,7 @@
2724
<exclude name="CallSuperInConstructor"/>
2825
<exclude name="LocalVariableCouldBeFinal"/>
2926
<exclude name="MethodArgumentCouldBeFinal"/>
27+
<exclude name="FieldDeclarationsShouldBeAtStartOfClass"/>
3028
</rule>
3129

3230
<!-- Design -->
@@ -42,8 +40,6 @@
4240

4341
<!-- Error Prone -->
4442
<rule ref="category/java/errorprone.xml">
45-
<exclude name="BeanMembersShouldSerialize"/>
46-
<exclude name="DataflowAnomalyAnalysis"/>
4743
<exclude name="AvoidLiteralsInIfCondition"/>
4844
<exclude name="AvoidFieldNameMatchingMethodName"/>
4945
</rule>

‎pom.xml‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
<checkstyle.version>3.6.0</checkstyle.version>
113113
<checkstyle-tool.version>10.21.4</checkstyle-tool.version>
114114
<pmd-plugin.version>3.26.0</pmd-plugin.version>
115-
<pmd-tool.version>7.9.0</pmd-tool.version>
115+
<pmd-tool.version>7.11.0</pmd-tool.version>
116116
<spotbugs.version>4.9.3.0</spotbugs.version>
117117
<jacoco.version>0.8.15</jacoco.version>
118118
</properties>
@@ -442,8 +442,19 @@
442442
<artifactId>pmd-java</artifactId>
443443
<version>${pmd-tool.version}</version>
444444
</dependency>
445+
<dependency>
446+
<groupId>net.sourceforge.pmd</groupId>
447+
<artifactId>pmd-core</artifactId>
448+
<version>${pmd-tool.version}</version>
449+
</dependency>
450+
<dependency>
451+
<groupId>org.ow2.asm</groupId>
452+
<artifactId>asm</artifactId>
453+
<version>9.7.1</version>
454+
</dependency>
445455
</dependencies>
446456
<configuration>
457+
<targetJdk>21</targetJdk>
447458
<rulesets>
448459
<ruleset>${maven.multiModuleProjectDirectory}/config/pmd/pmd-ruleset.xml</ruleset>
449460
</rulesets>

‎zthread-benchmark/pom.xml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
<name>zThread Benchmark</name>
1515
<description>JMH benchmarks for the zThread event runtime comparing against BlockingQueue, ExecutorService, and Netty.</description>
1616

17+
<properties>
18+
<pmd.skip>true</pmd.skip>
19+
</properties>
20+
1721
<dependencies>
1822
<dependency>
1923
<groupId>io.github.namanoncode</groupId>

‎zthread-core/src/main/java/io/github/namanoncode/zthread/DefaultEventDispatcher.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public final class DefaultEventDispatcher implements EventDispatcher {
4848

4949
private static final Logger LOG = LoggerFactory.getLogger(DefaultEventDispatcher.class);
5050

51+
@SuppressWarnings("PMD.LooseCoupling")
5152
private final Map<Class<? extends ZEvent>, List<HandlerEntry<?>>> handlers =
5253
new ConcurrentHashMap<>();
5354
private final RuntimeMetrics metrics;
@@ -78,7 +79,7 @@ public <T extends ZEvent> HandlerRegistration register(
7879
}
7980

8081
@Override
81-
@SuppressWarnings({"unchecked", "rawtypes"})
82+
@SuppressWarnings({"unchecked", "rawtypes", "PMD.AvoidCatchingGenericException"})
8283
public void dispatch(ZEvent event) {
8384
List<HandlerEntry<?>> entries = handlers.get(event.getClass());
8485
if (entries == null || entries.isEmpty()) {
@@ -93,8 +94,7 @@ public void dispatch(ZEvent event) {
9394
try {
9495
entry.handler().handle(event);
9596
} catch (Exception e) {
96-
LOG.error("Handler threw exception for {}: {}", event.getClass().getSimpleName(),
97-
e.getMessage(), e);
97+
LOG.error("Handler threw exception for {}: {}", event.getClass().getSimpleName(), e);
9898
dispatchError(e, "Handler exception for " + event.getClass().getSimpleName());
9999
} finally {
100100
metrics.recordHandlerTime(System.nanoTime() - start);

‎zthread-core/src/main/java/io/github/namanoncode/zthread/ZRuntimeBuilder.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public final class ZRuntimeBuilder {
4949
private int bufferSize = 4096;
5050
private int maxEventsPerPoll = 64;
5151
private boolean metricsEnabled = true;
52-
private boolean debugEnabled = false;
52+
private boolean debugEnabled;
5353

5454
/** Creates a new builder with default settings. */
5555
ZRuntimeBuilder() {}

‎zthread-core/src/main/java/io/github/namanoncode/zthread/event/ErrorEvent.java‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ public final class ErrorEvent implements ZEvent {
3030
private String message;
3131
private long timestampNanos;
3232

33-
/** Creates an uninitialized error event. */
34-
public ErrorEvent() {}
3533

3634
/**
3735
* Resets this event with new values.

‎zthread-core/src/main/java/io/github/namanoncode/zthread/event/FileEvent.java‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ public final class FileEvent implements ZEvent {
6868
private String name;
6969
private long timestampNanos;
7070

71-
/** Creates an uninitialized file event. */
72-
public FileEvent() {}
7371

7472
/**
7573
* Resets this event with new values.

‎zthread-core/src/main/java/io/github/namanoncode/zthread/event/ShutdownEvent.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
*/
3131
public final class ShutdownEvent implements ZEvent {
3232

33-
private long timestampNanos;
33+
private final long timestampNanos;
3434

3535
/** Creates a new shutdown event. */
3636
public ShutdownEvent() {

‎zthread-core/src/main/java/io/github/namanoncode/zthread/event/SignalEvent.java‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ public final class SignalEvent implements ZEvent {
3434
private int senderUid;
3535
private long timestampNanos;
3636

37-
/** Creates an uninitialized signal event. */
38-
public SignalEvent() {}
3937

4038
/**
4139
* Resets this event with new values.

‎zthread-core/src/main/java/io/github/namanoncode/zthread/event/SocketEvent.java‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ public final class SocketEvent implements ZEvent {
5151
private int eventMask;
5252
private long timestampNanos;
5353

54-
/** Creates an uninitialized socket event. Used by the object pool. */
55-
public SocketEvent() {}
5654

5755
/**
5856
* Resets this event with new values. Called by the event loop before dispatch.

0 commit comments

Comments
 (0)