Skip to content

Commit 6ff9a3b

Browse files
committed
Merge remote-tracking branch 'origin/update-from-template' into develop
2 parents 59a7fbc + a22d20d commit 6ff9a3b

File tree

5 files changed

+294
-36
lines changed

5 files changed

+294
-36
lines changed

.config/pmd/ruleset.xml

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ruleset name="Default"
3+
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
6+
7+
<description>
8+
This ruleset checks the code for discouraged programming constructs.
9+
</description>
10+
11+
<!-- Only rules that don't overlap with CheckStyle! -->
12+
13+
<rule ref="category/java/bestpractices.xml/AvoidUsingHardCodedIP"/>
14+
<rule ref="category/java/bestpractices.xml/PreserveStackTrace"/>
15+
<rule ref="category/java/bestpractices.xml/UseCollectionIsEmpty"/>
16+
<rule ref="category/java/bestpractices.xml/UseStandardCharsets"/>
17+
18+
<!-- Native code is platform dependent; Loading external native libs might pose a security threat -->
19+
<rule ref="category/java/codestyle.xml/AvoidUsingNativeCode"/>
20+
<rule ref="category/java/codestyle.xml/IdenticalCatchBranches"/>
21+
<rule ref="category/java/codestyle.xml/NoPackage"/>
22+
<rule ref="category/java/codestyle.xml/PrematureDeclaration"/>
23+
24+
<rule ref="category/java/design.xml">
25+
<!-- Sometimes abstract classes have just fields -->
26+
<exclude name="AbstractClassWithoutAnyMethod"/>
27+
28+
<!-- Using RuntimeExceptions is ok -->
29+
<exclude name="AvoidCatchingGenericException"/>
30+
<exclude name="AvoidThrowingRawExceptionTypes"/>
31+
32+
<!-- Limit too low -->
33+
<exclude name="AvoidDeeplyNestedIfStmts"/>
34+
35+
<!-- Limit too low -->
36+
<exclude name="CouplingBetweenObjects"/>
37+
38+
<!-- Limit too low -->
39+
<exclude name="CyclomaticComplexity"/>
40+
41+
<!-- Makes entity classes impossible -->
42+
<exclude name="DataClass"/>
43+
44+
<!-- Used commonly particular in bigger methods with upstream throws -->
45+
<exclude name="ExceptionAsFlowControl"/>
46+
47+
<!-- Limit too low -->
48+
<exclude name="ExcessiveImports"/>
49+
50+
<!-- Handled by TooManyFields/TooManyMethods -->
51+
<exclude name="ExcessivePublicCount"/>
52+
53+
<!-- Prohibits accessing members using multiple depths -->
54+
<exclude name="LawOfDemeter"/>
55+
56+
<!-- No effect -->
57+
<exclude name="LoosePackageCoupling"/>
58+
59+
<!-- Prohibits singleton pattern -->
60+
<exclude name="MutableStaticState"/>
61+
62+
<!-- Some override methods or Junit require this -->
63+
<exclude name="SignatureDeclareThrowsException"/>
64+
65+
<!-- Reports FP for equals methods -->
66+
<exclude name="SimplifyBooleanReturns"/>
67+
68+
<!-- Limit too low -->
69+
<exclude name="TooManyFields"/>
70+
71+
<!-- Limit too low -->
72+
<exclude name="TooManyMethods"/>
73+
74+
<!-- Limit too low -->
75+
<exclude name="UseObjectForClearerAPI"/>
76+
77+
<!-- Handled by checkstyle -->
78+
<exclude name="UseUtilityClass"/>
79+
</rule>
80+
81+
<rule ref="category/java/design.xml/AvoidDeeplyNestedIfStmts">
82+
<properties>
83+
<property name="problemDepth" value="4"/>
84+
</properties>
85+
</rule>
86+
<rule ref="category/java/design.xml/CouplingBetweenObjects">
87+
<properties>
88+
<property name="threshold" value="100"/>
89+
</properties>
90+
</rule>
91+
<rule ref="category/java/design.xml/CyclomaticComplexity">
92+
<properties>
93+
<property name="classReportLevel" value="150"/>
94+
<property name="methodReportLevel" value="25"/>
95+
<property name="cycloOptions" value=""/>
96+
</properties>
97+
</rule>
98+
<rule ref="category/java/design.xml/ExcessiveImports">
99+
<properties>
100+
<property name="minimum" value="200"/>
101+
</properties>
102+
</rule>
103+
<rule ref="category/java/design.xml/TooManyFields">
104+
<properties>
105+
<property name="maxfields" value="50"/>
106+
</properties>
107+
</rule>
108+
<rule ref="category/java/design.xml/TooManyMethods">
109+
<properties>
110+
<property name="maxmethods" value="100"/>
111+
</properties>
112+
</rule>
113+
114+
<rule ref="category/java/errorprone.xml/AvoidUsingOctalValues"/>
115+
<rule ref="category/java/errorprone.xml/BrokenNullCheck"/>
116+
<rule ref="category/java/errorprone.xml/ComparisonWithNaN"/>
117+
<rule ref="category/java/errorprone.xml/DoNotCallGarbageCollectionExplicitly"/>
118+
<rule ref="category/java/errorprone.xml/DontImportSun"/>
119+
<rule ref="category/java/errorprone.xml/MisplacedNullCheck"/>
120+
<rule ref="category/java/errorprone.xml/UnnecessaryCaseChange"/>
121+
122+
123+
<rule ref="category/java/multithreading.xml">
124+
<!-- Just bloats code -->
125+
<exclude name="AvoidSynchronizedAtMethodLevel"/>
126+
127+
<!-- NOPE -->
128+
<exclude name="DoNotUseThreads"/>
129+
130+
<!-- Doesn't detect nested thread safe singleton pattern -->
131+
<exclude name="NonThreadSafeSingleton"/>
132+
133+
<!-- Should relevant for fields that use multithreading which is rare -->
134+
<exclude name="UseConcurrentHashMap"/>
135+
</rule>
136+
137+
<rule ref="category/java/performance.xml">
138+
<!-- Used everywhere and has neglectable performance impact -->
139+
<exclude name="AvoidInstantiatingObjectsInLoops"/>
140+
141+
<!-- Handled by checkstyle -->
142+
<exclude name="RedundantFieldInitializer"/>
143+
144+
<!-- Nowadays optimized by compiler; No code bloating needed -->
145+
<exclude name="UseStringBufferForStringAppends"/>
146+
</rule>
147+
148+
<rule ref="category/java/security.xml"/>
149+
</ruleset>

.github/workflows/check-build.yml

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ jobs:
7979
path: ${{ env.PRIMARY_MAVEN_MODULE }}/target/screenshots
8080
if-no-files-found: ignore
8181

82-
code-style:
82+
checkstyle:
8383
runs-on: ubuntu-latest
8484
if: ${{ github.event_name != 'pull_request' || !startsWith(github.head_ref, 'renovate/') }}
8585

@@ -100,3 +100,40 @@ jobs:
100100

101101
- name: Run Checkstyle
102102
run: ./mvnw -B checkstyle:check -P checkstyle -T2C
103+
104+
pmd:
105+
runs-on: ubuntu-latest
106+
if: ${{ github.event_name != 'pull_request' || !startsWith(github.head_ref, 'renovate/') }}
107+
108+
strategy:
109+
matrix:
110+
java: [17]
111+
distribution: [temurin]
112+
113+
steps:
114+
- uses: actions/checkout@v4
115+
116+
- name: Set up JDK
117+
uses: actions/setup-java@v4
118+
with:
119+
distribution: ${{ matrix.distribution }}
120+
java-version: ${{ matrix.java }}
121+
cache: 'maven'
122+
123+
- name: Run PMD
124+
run: ./mvnw -B test pmd:aggregate-pmd-no-fork pmd:check -P pmd -DskipTests -T2C
125+
126+
- name: Run CPD (Copy Paste Detector)
127+
run: ./mvnw -B pmd:aggregate-cpd pmd:cpd-check -P pmd -DskipTests -T2C
128+
129+
- name: Upload report
130+
if: always()
131+
uses: actions/upload-artifact@v4
132+
with:
133+
name: pmd-report
134+
if-no-files-found: ignore
135+
path: |
136+
target/site/*.html
137+
target/site/css/**
138+
target/site/images/logos/maven-feather.png
139+
target/site/images/external.png

chartjs-java-model-demo/pom.xml

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<modelVersion>4.0.0</modelVersion>
66

7-
<groupId>software.xdev</groupId>
7+
<parent>
8+
<groupId>software.xdev</groupId>
9+
<artifactId>chartjs-java-model-root</artifactId>
10+
<version>2.0.2-SNAPSHOT</version>
11+
</parent>
12+
813
<artifactId>chartjs-java-model-demo</artifactId>
914
<version>2.0.2-SNAPSHOT</version>
1015
<packaging>jar</packaging>
@@ -77,36 +82,4 @@
7782
</plugin>
7883
</plugins>
7984
</build>
80-
<profiles>
81-
<profile>
82-
<id>checkstyle</id>
83-
<build>
84-
<plugins>
85-
<plugin>
86-
<groupId>org.apache.maven.plugins</groupId>
87-
<artifactId>maven-checkstyle-plugin</artifactId>
88-
<version>3.4.0</version>
89-
<dependencies>
90-
<dependency>
91-
<groupId>com.puppycrawl.tools</groupId>
92-
<artifactId>checkstyle</artifactId>
93-
<version>10.17.0</version>
94-
</dependency>
95-
</dependencies>
96-
<configuration>
97-
<configLocation>../.config/checkstyle/checkstyle.xml</configLocation>
98-
<includeTestSourceDirectory>true</includeTestSourceDirectory>
99-
</configuration>
100-
<executions>
101-
<execution>
102-
<goals>
103-
<goal>check</goal>
104-
</goals>
105-
</execution>
106-
</executions>
107-
</plugin>
108-
</plugins>
109-
</build>
110-
</profile>
111-
</profiles>
11285
</project>

chartjs-java-model/pom.xml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,5 +378,45 @@
378378
</plugins>
379379
</build>
380380
</profile>
381+
<profile>
382+
<id>pmd</id>
383+
<build>
384+
<plugins>
385+
<plugin>
386+
<groupId>org.apache.maven.plugins</groupId>
387+
<artifactId>maven-pmd-plugin</artifactId>
388+
<version>3.23.0</version>
389+
<configuration>
390+
<includeTests>true</includeTests>
391+
<rulesets>
392+
<ruleset>../.config/pmd/ruleset.xml</ruleset>
393+
</rulesets>
394+
</configuration>
395+
<dependencies>
396+
<dependency>
397+
<groupId>net.sourceforge.pmd</groupId>
398+
<artifactId>pmd-core</artifactId>
399+
<version>7.2.0</version>
400+
</dependency>
401+
<dependency>
402+
<groupId>net.sourceforge.pmd</groupId>
403+
<artifactId>pmd-java</artifactId>
404+
<version>7.2.0</version>
405+
</dependency>
406+
</dependencies>
407+
</plugin>
408+
</plugins>
409+
</build>
410+
<reporting>
411+
<plugins>
412+
<!-- Required for reporting -->
413+
<plugin>
414+
<groupId>org.apache.maven.plugins</groupId>
415+
<artifactId>maven-jxr-plugin</artifactId>
416+
<version>3.4.0</version>
417+
</plugin>
418+
</plugins>
419+
</reporting>
420+
</profile>
381421
</profiles>
382422
</project>

pom.xml

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
<module>chartjs-java-model-demo</module>
2020
</modules>
2121

22+
<properties>
23+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
24+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
25+
</properties>
26+
2227
<licenses>
2328
<license>
2429
<name>Apache License, Version 2.0</name>
@@ -29,20 +34,74 @@
2934

3035
<profiles>
3136
<profile>
32-
<!-- Disable checkstyle in root module as there is nothing to check -->
3337
<id>checkstyle</id>
3438
<build>
3539
<plugins>
3640
<plugin>
3741
<groupId>org.apache.maven.plugins</groupId>
3842
<artifactId>maven-checkstyle-plugin</artifactId>
3943
<version>3.4.0</version>
44+
<dependencies>
45+
<dependency>
46+
<groupId>com.puppycrawl.tools</groupId>
47+
<artifactId>checkstyle</artifactId>
48+
<version>10.17.0</version>
49+
</dependency>
50+
</dependencies>
51+
<configuration>
52+
<configLocation>.config/checkstyle/checkstyle.xml</configLocation>
53+
<includeTestSourceDirectory>true</includeTestSourceDirectory>
54+
</configuration>
55+
<executions>
56+
<execution>
57+
<goals>
58+
<goal>check</goal>
59+
</goals>
60+
</execution>
61+
</executions>
62+
</plugin>
63+
</plugins>
64+
</build>
65+
</profile>
66+
<profile>
67+
<id>pmd</id>
68+
<build>
69+
<plugins>
70+
<plugin>
71+
<groupId>org.apache.maven.plugins</groupId>
72+
<artifactId>maven-pmd-plugin</artifactId>
73+
<version>3.23.0</version>
4074
<configuration>
41-
<skip>true</skip>
75+
<includeTests>true</includeTests>
76+
<rulesets>
77+
<ruleset>.config/pmd/ruleset.xml</ruleset>
78+
</rulesets>
4279
</configuration>
80+
<dependencies>
81+
<dependency>
82+
<groupId>net.sourceforge.pmd</groupId>
83+
<artifactId>pmd-core</artifactId>
84+
<version>7.2.0</version>
85+
</dependency>
86+
<dependency>
87+
<groupId>net.sourceforge.pmd</groupId>
88+
<artifactId>pmd-java</artifactId>
89+
<version>7.2.0</version>
90+
</dependency>
91+
</dependencies>
4392
</plugin>
4493
</plugins>
4594
</build>
95+
<reporting>
96+
<plugins>
97+
<!-- Required for reporting -->
98+
<plugin>
99+
<groupId>org.apache.maven.plugins</groupId>
100+
<artifactId>maven-jxr-plugin</artifactId>
101+
<version>3.4.0</version>
102+
</plugin>
103+
</plugins>
104+
</reporting>
46105
</profile>
47106
</profiles>
48107
</project>

0 commit comments

Comments
 (0)