Skip to content

Commit 8816e15

Browse files
committed
Merge remote-tracking branch 'origin/update-from-template' into develop
2 parents 9034c9c + ff00b21 commit 8816e15

File tree

15 files changed

+109
-52
lines changed

15 files changed

+109
-52
lines changed

.config/checkstyle/checkstyle.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@
7474
<!-- https://docs.pmd-code.org/pmd-doc-7.11.0/pmd_rules_java_errorprone.html#avoidcatchingthrowable -->
7575
<property name="illegalClassNames" value="Error,Throwable,NullPointerException,java.lang.Error,java.lang.Throwable,java.lang.NullPointerException"/>
7676
</module>
77+
<!-- Do not allow params and vars to end with collection type names -->
78+
<module name="IllegalIdentifierName">
79+
<property name="format" value="^(?!(.*(Map|List|Set))$).+$"/>
80+
<property name="tokens" value="PARAMETER_DEF, VARIABLE_DEF, PATTERN_VARIABLE_DEF, RECORD_COMPONENT_DEF, LAMBDA"/>
81+
</module>
7782
<module name="IllegalImport"/>
7883
<module name="InterfaceIsType"/>
7984
<module name="JavadocStyle">
@@ -91,7 +96,7 @@
9196
<property name="ignoreFieldDeclaration" value="true"/>
9297
<property name="ignoreHashCodeMethod" value="true"/>
9398
<!-- Defaults + other common constant values (e.g. time) -->
94-
<property name="ignoreNumbers" value="-1, 0, 1, 2, 3, 4, 5, 10, 12, 24, 31, 60, 100, 1000"/>
99+
<property name="ignoreNumbers" value="-1, 0, 1, 2, 3, 4, 5, 8, 10, 12, 16, 24, 25, 31, 32, 50, 60, 64, 100, 128, 200, 256, 500, 512, 1000, 1024, 2000, 2048, 4000, 4096, 8000, 8192"/>
95100
</module>
96101
<module name="MemberName"/>
97102
<module name="MethodLength"/>
@@ -123,7 +128,8 @@
123128
<module name="StringLiteralEquality"/>
124129
<module name="SuppressWarningsHolder"/>
125130
<module name="TodoComment">
126-
<property name="severity" value="info"/>
131+
<!-- Default is "TODO:" -->
132+
<property name="format" value="(?i)(TODO)"/>
127133
</module>
128134
<module name="TypecastParenPad"/>
129135
<module name="TypeName"/>

.config/pmd/java/ruleset.xml

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<rule ref="category/java/bestpractices.xml/AvoidUsingHardCodedIP"/>
1818
<rule ref="category/java/bestpractices.xml/ConstantsInInterface"/>
1919
<rule ref="category/java/bestpractices.xml/ExhaustiveSwitchHasDefault"/>
20+
<rule ref="category/java/bestpractices.xml/LabeledStatement"/>
2021
<rule ref="category/java/bestpractices.xml/LiteralsFirstInComparisons"/>
2122
<!-- CheckStyle can't handle this switch behavior -> delegated to PMD -->
2223
<rule ref="category/java/bestpractices.xml/NonExhaustiveSwitch"/>
@@ -149,6 +150,7 @@
149150
<rule ref="category/java/errorprone.xml/DontUseFloatTypeForLoopIndices"/>
150151
<rule ref="category/java/errorprone.xml/EqualsNull"/>
151152
<rule ref="category/java/errorprone.xml/IdempotentOperations"/>
153+
<rule ref="category/java/errorprone.xml/IdenticalConditionalBranches"/>
152154
<rule ref="category/java/errorprone.xml/ImplicitSwitchFallThrough"/>
153155
<rule ref="category/java/errorprone.xml/InstantiationToGetClass"/>
154156
<rule ref="category/java/errorprone.xml/InvalidLogMessageFormat"/>
@@ -211,11 +213,11 @@
211213
message="StringBuilder/StringBuffer should not be used"
212214
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule">
213215
<description>
214-
Usually all cases where `StringBuilder` (or the outdated `StringBuffer`) is used are either due to confusing (legacy) logic or may be replaced by a simpler string concatenation.
216+
Usually all cases where `StringBuilder` (or the outdated `StringBuffer`) is used are either due to confusing (legacy) logic or in situations where it may be easily replaced by a simpler string concatenation.
215217

216218
Solution:
217219
* Do not use `StringBuffer` because it's thread-safe and usually this is not needed
218-
* If `StringBuilder` is only used in a simple method (like `toString`) and is effectively inlined: Use a simpler string concatenation (`"a" + x + "b"`). This will be optimized by the Java compiler internally.
220+
* If `StringBuilder` is only used in a simple method (like `toString`) and is effectively inlined: Use a simpler string concatenation (`"a" + x + "b"`). This will be [optimized by the Java compiler internally](https://docs.oracle.com/javase/specs/jls/se25/html/jls-15.html#jls-15.18.1).
219221
* In all other cases:
220222
* Check what is happening and if it makes ANY sense! If for example a CSV file is built here consider using a proper library instead!
221223
* Abstract the Strings into a DTO, join them together using a collection (or `StringJoiner`) or use Java's Streaming API instead
@@ -237,8 +239,8 @@ Solution:
237239
message="Setters of java.lang.System should not be called unless really needed"
238240
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule">
239241
<description>
240-
Calling setters of java.lang.System usually indicates bad design and likely causes unexpected behavior.
241-
For example, it may break when multiple Threads are setting the value.
242+
Calling setters of `java.lang.System` usually indicates bad design and likely causes unexpected behavior.
243+
For example, it may break when multiple Threads are working with the same value.
242244
It may also overwrite user defined options or properties.
243245

244246
Try to pass the value only to the place where it's really needed and use it there accordingly.
@@ -350,7 +352,8 @@ You can suppress this warning when you properly sanitized the name.
350352
Nearly every known usage of (Java) Object Deserialization has resulted in [a security vulnerability](https://cloud.google.com/blog/topics/threat-intelligence/hunting-deserialization-exploits?hl=en).
351353
Vulnerabilities are so common that there are [dedicated projects for exploit payload generation](https://github.com/frohoff/ysoserial).
352354

353-
Java Object Serialization may also fail to deserialize when the underlying classes are changed.
355+
Java Object Serialization may also fail to deserialize properly when the underlying classes are changed.
356+
This can result in unexpected crashes when outdated data is deserialized.
354357

355358
Use proven data interchange formats like JSON instead.
356359
</description>
@@ -372,7 +375,8 @@ Use proven data interchange formats like JSON instead.
372375
<rule name="VaadinNativeHTMLIsUnsafe"
373376
language="java"
374377
message="Unescaped native HTML is unsafe and will result in XSS vulnerabilities"
375-
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" >
378+
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule"
379+
externalInfoUrl="https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML">
376380
<description>
377381
Do not use native HTML! Use Vaadin layouts and components to create required structure.
378382
If you are 100% sure that you escaped the value properly and you have no better options you can suppress this.
@@ -390,6 +394,30 @@ If you are 100% sure that you escaped the value properly and you have no better
390394
</properties>
391395
</rule>
392396

397+
<!-- Jakarta Persistence -->
398+
<rule name="AvoidListAsEntityRelation"
399+
language="java"
400+
message="Use a Set instead of a List in entity relations"
401+
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule"
402+
externalInfoUrl="https://www.baeldung.com/spring-jpa-onetomany-list-vs-set#bd-pros-and-cons">
403+
<description>
404+
`List` allows duplicates while a `Set` does not.
405+
A `Set` also prevents duplicates when the ORM reads multiple identical rows from the database (e.g. when using JOIN).
406+
</description>
407+
<priority>2</priority>
408+
<properties>
409+
<property name="xpath">
410+
<value>
411+
<![CDATA[
412+
//ClassDeclaration[pmd-java:hasAnnotation('jakarta.persistence.Entity')]
413+
//FieldDeclaration[pmd-java:hasAnnotation('jakarta.persistence.ManyToMany') or pmd-java:hasAnnotation('jakarta.persistence.OneToMany')]
414+
/ClassType[pmd-java:typeIs('java.util.List')]
415+
]]>
416+
</value>
417+
</property>
418+
</properties>
419+
</rule>
420+
393421

394422
<!-- Rules from JPinPoint with slight modifications -->
395423
<!-- https://github.com/jborgers/PMD-jPinpoint-rules -->

.github/workflows/broken-links.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ jobs:
1313
runs-on: ubuntu-latest
1414
timeout-minutes: 15
1515
steps:
16-
- uses: actions/checkout@v5
16+
- uses: actions/checkout@v6
1717

1818
- run: mv .github/.lycheeignore .lycheeignore
1919

2020
- name: Link Checker
2121
id: lychee
22-
uses: lycheeverse/lychee-action@885c65f3dc543b57c898c8099f4e08c8afd178a2 # v2
22+
uses: lycheeverse/lychee-action@a8c4c7cb88f0c7386610c35eb25108e448569cb0 # v2
2323
with:
2424
fail: false # Don't fail on broken links, create an issue instead
2525

.github/workflows/check-build.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
java: [17, 21, 25]
3232
distribution: [temurin]
3333
steps:
34-
- uses: actions/checkout@v5
34+
- uses: actions/checkout@v6
3535

3636
- name: Set up JDK
3737
uses: actions/setup-java@v5
@@ -40,7 +40,7 @@ jobs:
4040
java-version: ${{ matrix.java }}
4141

4242
- name: Cache Maven
43-
uses: actions/cache@v4
43+
uses: actions/cache@v5
4444
with:
4545
path: ~/.m2/repository
4646
key: ${{ runner.os }}-mvn-build-${{ hashFiles('**/pom.xml') }}
@@ -69,7 +69,7 @@ jobs:
6969
fi
7070
7171
- name: Upload demo files
72-
uses: actions/upload-artifact@v5
72+
uses: actions/upload-artifact@v6
7373
with:
7474
name: demo-files-java-${{ matrix.java }}
7575
path: ${{ env.DEMO_MAVEN_MODULE }}/target/${{ env.DEMO_MAVEN_MODULE }}.jar
@@ -81,10 +81,10 @@ jobs:
8181
timeout-minutes: 15
8282
strategy:
8383
matrix:
84-
java: [17]
84+
java: [21]
8585
distribution: [temurin]
8686
steps:
87-
- uses: actions/checkout@v5
87+
- uses: actions/checkout@v6
8888

8989
- name: Set up JDK
9090
uses: actions/setup-java@v5
@@ -93,15 +93,15 @@ jobs:
9393
java-version: ${{ matrix.java }}
9494

9595
- name: Cache Maven
96-
uses: actions/cache@v4
96+
uses: actions/cache@v5
9797
with:
9898
path: ~/.m2/repository
9999
key: ${{ runner.os }}-mvn-checkstyle-${{ hashFiles('**/pom.xml') }}
100100
restore-keys: |
101101
${{ runner.os }}-mvn-checkstyle-
102102
103103
- name: CheckStyle Cache
104-
uses: actions/cache@v4
104+
uses: actions/cache@v5
105105
with:
106106
path: '**/target/checkstyle-cachefile'
107107
key: ${{ runner.os }}-checkstyle-${{ hashFiles('**/pom.xml') }}
@@ -120,7 +120,7 @@ jobs:
120120
java: [17]
121121
distribution: [temurin]
122122
steps:
123-
- uses: actions/checkout@v5
123+
- uses: actions/checkout@v6
124124

125125
- name: Set up JDK
126126
uses: actions/setup-java@v5
@@ -129,15 +129,15 @@ jobs:
129129
java-version: ${{ matrix.java }}
130130

131131
- name: Cache Maven
132-
uses: actions/cache@v4
132+
uses: actions/cache@v5
133133
with:
134134
path: ~/.m2/repository
135135
key: ${{ runner.os }}-mvn-pmd-${{ hashFiles('**/pom.xml') }}
136136
restore-keys: |
137137
${{ runner.os }}-mvn-pmd-
138138
139139
- name: PMD Cache
140-
uses: actions/cache@v4
140+
uses: actions/cache@v5
141141
with:
142142
path: '**/target/pmd/pmd.cache'
143143
key: ${{ runner.os }}-pmd-${{ hashFiles('**/pom.xml') }}
@@ -152,7 +152,7 @@ jobs:
152152

153153
- name: Upload report
154154
if: always()
155-
uses: actions/upload-artifact@v5
155+
uses: actions/upload-artifact@v6
156156
with:
157157
name: pmd-report
158158
if-no-files-found: ignore

.github/workflows/release.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
runs-on: ubuntu-latest
1919
timeout-minutes: 30
2020
steps:
21-
- uses: actions/checkout@v5
21+
- uses: actions/checkout@v6
2222

2323
- name: Set up JDK
2424
uses: actions/setup-java@v5
@@ -28,7 +28,7 @@ jobs:
2828

2929
# Try to reuse existing cache from check-build
3030
- name: Try restore Maven Cache
31-
uses: actions/cache/restore@v4
31+
uses: actions/cache/restore@v5
3232
with:
3333
path: ~/.m2/repository
3434
key: ${{ runner.os }}-mvn-build-${{ hashFiles('**/pom.xml') }}
@@ -63,7 +63,7 @@ jobs:
6363
outputs:
6464
upload_url: ${{ steps.create-release.outputs.upload_url }}
6565
steps:
66-
- uses: actions/checkout@v5
66+
- uses: actions/checkout@v6
6767

6868
- name: Configure Git
6969
run: |
@@ -91,7 +91,7 @@ jobs:
9191
9292
- name: Create Release
9393
id: create-release
94-
uses: shogo82148/actions-create-release@28d99e2a5b407558d17c15d0384fc0d7fb625b4c # v1
94+
uses: shogo82148/actions-create-release@559c27ce7eb834825e2b55927c64f6d1bd1db716 # v1
9595
with:
9696
tag_name: v${{ steps.version.outputs.release }}
9797
release_name: v${{ steps.version.outputs.release }}
@@ -115,7 +115,7 @@ jobs:
115115
needs: [prepare-release]
116116
timeout-minutes: 60
117117
steps:
118-
- uses: actions/checkout@v5
118+
- uses: actions/checkout@v6
119119

120120
- name: Init Git and pull
121121
run: |
@@ -163,7 +163,7 @@ jobs:
163163
needs: [prepare-release]
164164
timeout-minutes: 15
165165
steps:
166-
- uses: actions/checkout@v5
166+
- uses: actions/checkout@v6
167167

168168
- name: Init Git and pull
169169
run: |
@@ -179,7 +179,7 @@ jobs:
179179

180180
# Try to reuse existing cache from check-build
181181
- name: Try restore Maven Cache
182-
uses: actions/cache/restore@v4
182+
uses: actions/cache/restore@v5
183183
with:
184184
path: ~/.m2/repository
185185
key: ${{ runner.os }}-mvn-build-${{ hashFiles('**/pom.xml') }}
@@ -202,7 +202,7 @@ jobs:
202202
needs: [publish-maven]
203203
timeout-minutes: 10
204204
steps:
205-
- uses: actions/checkout@v5
205+
- uses: actions/checkout@v6
206206

207207
- name: Init Git and pull
208208
run: |

.github/workflows/sync-labels.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
runs-on: ubuntu-latest
1717
timeout-minutes: 10
1818
steps:
19-
- uses: actions/checkout@v5
19+
- uses: actions/checkout@v6
2020
with:
2121
sparse-checkout: .github/labels.yml
2222

.github/workflows/test-deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
timeout-minutes: 60
1313
steps:
14-
- uses: actions/checkout@v5
14+
- uses: actions/checkout@v6
1515

1616
- name: Set up JDK
1717
uses: actions/setup-java@v5

.github/workflows/update-from-template.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
update_branch_merged_commit: ${{ steps.manage-branches.outputs.update_branch_merged_commit }}
3737
create_update_branch_merged_pr: ${{ steps.manage-branches.outputs.create_update_branch_merged_pr }}
3838
steps:
39-
- uses: actions/checkout@v5
39+
- uses: actions/checkout@v6
4040
with:
4141
# Required because otherwise there are always changes detected when executing diff/rev-list
4242
fetch-depth: 0
@@ -183,7 +183,7 @@ jobs:
183183
runs-on: ubuntu-latest
184184
timeout-minutes: 60
185185
steps:
186-
- uses: actions/checkout@v5
186+
- uses: actions/checkout@v6
187187
with:
188188
# Required because otherwise there are always changes detected when executing diff/rev-list
189189
fetch-depth: 0

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ hs_err_pid*
4444
!.idea/saveactions_settings.xml
4545
!.idea/checkstyle-idea.xml
4646
!.idea/externalDependencies.xml
47+
!.idea/pmd-x.xml
4748
!.idea/PMDPlugin.xml
4849

4950
!.idea/inspectionProfiles/

.idea/checkstyle-idea.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)