Skip to content

Commit 6128d80

Browse files
committed
Merge remote-tracking branch 'origin/update-from-template' into develop
2 parents a334a09 + fada224 commit 6128d80

16 files changed

Lines changed: 105 additions & 43 deletions

.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: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
java: [21]
2929
distribution: [temurin]
3030
steps:
31-
- uses: actions/checkout@v5
31+
- uses: actions/checkout@v6
3232

3333
- name: Set up JDK
3434
uses: actions/setup-java@v5
@@ -37,7 +37,7 @@ jobs:
3737
java-version: ${{ matrix.java }}
3838

3939
- name: Cache Gradle
40-
uses: actions/cache@v4
40+
uses: actions/cache@v5
4141
with:
4242
path: |
4343
~/.gradle/caches
@@ -50,7 +50,7 @@ jobs:
5050
run: ./gradlew build buildPlugin --info --stacktrace
5151

5252
- name: Try upload test reports when failure occurs
53-
uses: actions/upload-artifact@v5
53+
uses: actions/upload-artifact@v6
5454
if: failure()
5555
with:
5656
name: test-reports-${{ matrix.java }}
@@ -75,10 +75,10 @@ jobs:
7575
fi
7676
7777
- name: Upload plugin files
78-
uses: actions/upload-artifact@v5
78+
uses: actions/upload-artifact@v6
7979
with:
8080
name: plugin-files-java-${{ matrix.java }}
81-
path: build/libs/intellij-plugin-openrewriter-*.jar
81+
path: build/distributions/*.zip
8282
if-no-files-found: error
8383

8484
checkstyle:
@@ -90,7 +90,7 @@ jobs:
9090
java: [21]
9191
distribution: [temurin]
9292
steps:
93-
- uses: actions/checkout@v5
93+
- uses: actions/checkout@v6
9494

9595
- name: Set up JDK
9696
uses: actions/setup-java@v5
@@ -99,7 +99,7 @@ jobs:
9999
java-version: ${{ matrix.java }}
100100

101101
- name: Cache Gradle
102-
uses: actions/cache@v4
102+
uses: actions/cache@v5
103103
with:
104104
path: |
105105
~/.gradle/caches
@@ -120,7 +120,7 @@ jobs:
120120
java: [21]
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
@@ -132,7 +132,7 @@ jobs:
132132
run: ./gradlew pmdMain pmdTest -PpmdEnabled --stacktrace -x test
133133

134134
- name: Cache Gradle
135-
uses: actions/cache@v4
135+
uses: actions/cache@v5
136136
with:
137137
path: |
138138
~/.gradle/caches
@@ -143,7 +143,7 @@ jobs:
143143
144144
- name: Upload report
145145
if: always()
146-
uses: actions/upload-artifact@v5
146+
uses: actions/upload-artifact@v6
147147
with:
148148
name: pmd-report
149149
if-no-files-found: ignore

.github/workflows/check-ide-compatibility.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
done
4242
sudo df -h
4343
44-
- uses: actions/checkout@v5
44+
- uses: actions/checkout@v6
4545

4646
- name: Set up JDK
4747
uses: actions/setup-java@v5
@@ -50,7 +50,7 @@ jobs:
5050
java-version: 21
5151

5252
- name: Cache Gradle
53-
uses: actions/cache@v4
53+
uses: actions/cache@v5
5454
with:
5555
path: |
5656
~/.gradle/caches
@@ -64,7 +64,7 @@ jobs:
6464
run: ./gradlew verifyPlugin --info --stacktrace
6565

6666
- name: Upload report
67-
uses: actions/upload-artifact@v5
67+
uses: actions/upload-artifact@v6
6868
if: ${{ always() }}
6969
with:
7070
name: plugin-verifier-reports

.github/workflows/release.yml

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

1818
- name: Set up JDK
1919
uses: actions/setup-java@v5
@@ -22,7 +22,7 @@ jobs:
2222
distribution: 'temurin'
2323

2424
- name: Try restore Gradle Cache
25-
uses: actions/cache/restore@v4
25+
uses: actions/cache/restore@v5
2626
with:
2727
path: |
2828
~/.gradle/caches
@@ -59,7 +59,7 @@ jobs:
5959
outputs:
6060
upload_url: ${{ steps.create_release.outputs.upload_url }}
6161
steps:
62-
- uses: actions/checkout@v5
62+
- uses: actions/checkout@v6
6363

6464
- name: Configure Git
6565
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 }}
@@ -112,7 +112,7 @@ jobs:
112112
needs: [prepare_release]
113113
timeout-minutes: 60
114114
steps:
115-
- uses: actions/checkout@v5
115+
- uses: actions/checkout@v6
116116

117117
- name: Set up JDK
118118
uses: actions/setup-java@v5
@@ -135,7 +135,7 @@ jobs:
135135
run: ./gradlew publishPlugin --info --stacktrace
136136

137137
- name: Upload plugin files
138-
uses: actions/upload-artifact@v5
138+
uses: actions/upload-artifact@v6
139139
with:
140140
name: plugin-files
141141
path: build/distributions/*
@@ -145,7 +145,7 @@ jobs:
145145
needs: [publish]
146146
timeout-minutes: 10
147147
steps:
148-
- uses: actions/checkout@v5
148+
- uses: actions/checkout@v6
149149

150150
- name: Init Git and pull
151151
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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: ubuntu-latest
99
timeout-minutes: 60
1010
steps:
11-
- uses: actions/checkout@v5
11+
- uses: actions/checkout@v6
1212

1313
- name: Set up JDK
1414
uses: actions/setup-java@v5
@@ -35,7 +35,7 @@ jobs:
3535
run: ./gradlew publishPlugin --info --stacktrace
3636

3737
- name: Upload plugin files
38-
uses: actions/upload-artifact@v5
38+
uses: actions/upload-artifact@v6
3939
with:
4040
name: plugin-files-java-${{ matrix.java }}
4141
path: build/distributions/*

.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
@@ -26,6 +26,7 @@ build/
2626
!.idea/saveactions_settings.xml
2727
!.idea/checkstyle-idea.xml
2828
!.idea/externalDependencies.xml
29+
!.idea/pmd-x.xml
2930
!.idea/PMDPlugin.xml
3031

3132
!.idea/inspectionProfiles/

0 commit comments

Comments
 (0)