Skip to content

Commit 829d540

Browse files
Merge pull request #98 from xdev-software/update-from-template-fix
Update from template [manual]
2 parents 0e794a0 + 170d934 commit 829d540

File tree

29 files changed

+654
-608
lines changed

29 files changed

+654
-608
lines changed

.config/pmd/ruleset.xml

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
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+
<!-- This was fixed in Java 10 -->
139+
<exclude name="AvoidFileStream"/>
140+
141+
<!-- Used everywhere and has neglectable performance impact -->
142+
<exclude name="AvoidInstantiatingObjectsInLoops"/>
143+
144+
<!-- Handled by checkstyle -->
145+
<exclude name="RedundantFieldInitializer"/>
146+
147+
<!-- Nowadays optimized by compiler; No code bloating needed -->
148+
<exclude name="UseStringBufferForStringAppends"/>
149+
</rule>
150+
151+
<rule ref="category/java/security.xml"/>
152+
</ruleset>

.github/workflows/check-build.yml

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ jobs:
7070
path: ${{ env.DEMO_MAVEN_MODULE }}/target/${{ env.DEMO_MAVEN_MODULE }}.jar
7171
if-no-files-found: error
7272

73-
code-style:
73+
checkstyle:
7474
runs-on: ubuntu-latest
7575
if: ${{ github.event_name != 'pull_request' || !startsWith(github.head_ref, 'renovate/') }}
7676

@@ -92,6 +92,43 @@ jobs:
9292
- name: Run Checkstyle
9393
run: ./mvnw -B checkstyle:check -P checkstyle -T2C
9494

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

@@ -107,4 +144,4 @@ jobs:
107144
run: npm i antora @antora/lunr-extension
108145

109146
- name: Generate Site
110-
run: npx antora docs/antora-playbook.yml
147+
run: npx antora docs/antora-playbook.yml

.gitignore

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@ buildNumber.properties
3939
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
4040
hs_err_pid*
4141

42-
43-
# bin / compiled stuff
44-
target/
45-
46-
4742
# JRebel
4843
**/resources/rebel.xml
4944
**/resources/rebel-remote.xml

pom.xml

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
<properties>
1818
<javaVersion>17</javaVersion>
1919
<maven.compiler.release>${javaVersion}</maven.compiler.release>
20+
21+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
22+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
2023
</properties>
2124

2225
<modules>
@@ -36,20 +39,81 @@
3639

3740
<profiles>
3841
<profile>
39-
<!-- Disable checkstyle in root module as there is nothing to check -->
4042
<id>checkstyle</id>
4143
<build>
4244
<plugins>
4345
<plugin>
4446
<groupId>org.apache.maven.plugins</groupId>
4547
<artifactId>maven-checkstyle-plugin</artifactId>
4648
<version>3.4.0</version>
49+
<dependencies>
50+
<dependency>
51+
<groupId>com.puppycrawl.tools</groupId>
52+
<artifactId>checkstyle</artifactId>
53+
<version>10.17.0</version>
54+
</dependency>
55+
</dependencies>
56+
<configuration>
57+
<configLocation>.config/checkstyle/checkstyle.xml</configLocation>
58+
<includeTestSourceDirectory>true</includeTestSourceDirectory>
59+
</configuration>
60+
<executions>
61+
<execution>
62+
<goals>
63+
<goal>check</goal>
64+
</goals>
65+
</execution>
66+
</executions>
67+
</plugin>
68+
</plugins>
69+
</build>
70+
</profile>
71+
<profile>
72+
<id>pmd</id>
73+
<build>
74+
<plugins>
75+
<plugin>
76+
<groupId>org.apache.maven.plugins</groupId>
77+
<artifactId>maven-pmd-plugin</artifactId>
78+
<version>3.23.0</version>
4779
<configuration>
48-
<skip>true</skip>
80+
<includeTests>true</includeTests>
81+
<printFailingErrors>true</printFailingErrors>
82+
<rulesets>
83+
<ruleset>.config/pmd/ruleset.xml</ruleset>
84+
</rulesets>
85+
<excludes>
86+
<exclude>**/benchmark/**/jmh_generated/**</exclude>
87+
<!-- Dynamic types for tests -->
88+
<exclude>**/shared/**/Customer*</exclude>
89+
<exclude>**/shared/**/Child*</exclude>
90+
</excludes>
4991
</configuration>
92+
<dependencies>
93+
<dependency>
94+
<groupId>net.sourceforge.pmd</groupId>
95+
<artifactId>pmd-core</artifactId>
96+
<version>7.2.0</version>
97+
</dependency>
98+
<dependency>
99+
<groupId>net.sourceforge.pmd</groupId>
100+
<artifactId>pmd-java</artifactId>
101+
<version>7.2.0</version>
102+
</dependency>
103+
</dependencies>
50104
</plugin>
51105
</plugins>
52106
</build>
107+
<reporting>
108+
<plugins>
109+
<!-- Required for reporting -->
110+
<plugin>
111+
<groupId>org.apache.maven.plugins</groupId>
112+
<artifactId>maven-jxr-plugin</artifactId>
113+
<version>3.4.0</version>
114+
</plugin>
115+
</plugins>
116+
</reporting>
53117
</profile>
54118
</profiles>
55119
</project>

renovate.json5

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
{
22
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3-
"rebaseWhen": "behind-base-branch"
3+
"rebaseWhen": "behind-base-branch",
4+
"packageRules": [
5+
{
6+
"description": "Ignore project internal dependencies",
7+
"packagePattern": "^software.xdev:spring-data-eclipse-store",
8+
"datasources": [
9+
"maven"
10+
],
11+
"enabled": false
12+
}
13+
]
414
}

0 commit comments

Comments
 (0)