Skip to content

Commit

Permalink
Prepare for PMD 7.x.
Browse files Browse the repository at this point in the history
  • Loading branch information
uhafner committed Mar 12, 2024
1 parent 1e02054 commit 679838e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
14 changes: 13 additions & 1 deletion etc/pmd-configuration.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<ruleset xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
name="pmd-eclipse"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
<description>Ullrich Hafner's PMD rules</description>

<rule ref="category/java/bestpractices.xml">
Expand All @@ -16,6 +16,12 @@
<exclude name="JUnit5TestShouldBePackagePrivate"/>
<exclude name="JUnit4TestShouldUseTestAnnotation"/>
<exclude name="UnusedPrivateMethod"/>
<exclude name="LooseCoupling"/>
</rule>
<rule ref="category/java/bestpractices.xml/LooseCoupling">
<properties>
<property name="allowedTypes" value="com.tngtech.archunit.core.domain.JavaClasses"/>
</properties>
</rule>
<rule ref="category/java/codestyle.xml">
<exclude name="EmptyControlStatement"/>
Expand Down Expand Up @@ -67,6 +73,12 @@
<exclude name="FinalFieldCouldBeStatic"/>
<exclude name="AvoidUncheckedExceptionsInSignatures"/>
<exclude name="ExcessiveImports"/>
<exclude name="SimplifyBooleanReturns"/>
</rule>
<rule ref="category/java/design.xml/SimplifyBooleanReturns">
<properties>
<property name="violationSuppressXPath" value="./ancestor::*[@Name = 'equals']"/>
</properties>
</rule>
<rule ref="category/java/errorprone.xml">
<exclude name="AvoidDuplicateLiterals"/>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/edu/hm/hafner/util/TreeString.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public final class TreeString implements Serializable {
}

String getLabel() {
return new String(label);
return String.valueOf(label);
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/test/java/edu/hm/hafner/util/ArchitectureRules.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
*
* @author Ullrich Hafner
*/
@SuppressWarnings("PMD.DataClass")
public final class ArchitectureRules {
/** Tests should not use fields. Recommendation is to use factory methods for stubs and mocks. */
public static final ArchRule NO_FIELDS_IN_TESTS =
Expand Down
10 changes: 6 additions & 4 deletions src/test/java/edu/hm/hafner/util/LineRangeListTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package edu.hm.hafner.util;

import java.util.List;

import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.*;
Expand Down Expand Up @@ -75,15 +77,15 @@ void shouldResizeCorrectly() {

@Test
void shouldProvideContains() {
LineRangeList last = createThreeElements();
var last = createThreeElements();
last.remove(new LineRange(4, 5));
assertThat(last).containsExactly(new LineRange(0, 1), new LineRange(2, 3));

LineRangeList middle = createThreeElements();
var middle = createThreeElements();
middle.remove(new LineRange(2, 3));
assertThat(middle).containsExactly(new LineRange(0, 1), new LineRange(4, 5));

LineRangeList first = createThreeElements();
var first = createThreeElements();
assertThat(first.contains(new LineRange(0, 1))).isTrue();
assertThat(first.contains(new LineRange(2, 3))).isTrue();
assertThat(first.contains(new LineRange(4, 5))).isTrue();
Expand All @@ -95,7 +97,7 @@ void shouldProvideContains() {
assertThat(first.contains(new LineRange(0, 1))).isFalse();
}

private LineRangeList createThreeElements() {
private List<LineRange> createThreeElements() {
var range = new LineRangeList();
range.add(new LineRange(0, 1));
range.add(new LineRange(2, 3));
Expand Down

0 comments on commit 679838e

Please sign in to comment.