Skip to content

Commit 927b70f

Browse files
committed
Merge remote-tracking branch 'origin/update-from-template' into develop
2 parents fcb785e + b353001 commit 927b70f

11 files changed

Lines changed: 116 additions & 20 deletions

File tree

.config/checkstyle/checkstyle.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@
7979
<property name="format" value="^(?!(.*(Map|List|Set))$).+$"/>
8080
<property name="tokens" value="PARAMETER_DEF, VARIABLE_DEF, PATTERN_VARIABLE_DEF, RECORD_COMPONENT_DEF, LAMBDA"/>
8181
</module>
82+
<!-- Name classes correctly and don't use generic name for everything -->
83+
<module name="IllegalIdentifierName">
84+
<property name="format" value="^(?!(.*(Helper|Util))$).+$"/>
85+
<property name="tokens" value=" CLASS_DEF"/>
86+
</module>
8287
<module name="IllegalImport"/>
8388
<module name="InterfaceIsType"/>
8489
<module name="JavadocStyle">

.config/pmd/java/ruleset.xml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@
146146
<rule ref="category/java/errorprone.xml/CollectionTypeMismatch"/>
147147
<rule ref="category/java/errorprone.xml/ComparisonWithNaN"/>
148148
<rule ref="category/java/errorprone.xml/DoNotCallGarbageCollectionExplicitly"/>
149-
<rule ref="category/java/errorprone.xml/DontImportSun"/>
150149
<rule ref="category/java/errorprone.xml/DontUseFloatTypeForLoopIndices"/>
151150
<rule ref="category/java/errorprone.xml/EqualsNull"/>
152151
<rule ref="category/java/errorprone.xml/IdempotentOperations"/>
@@ -164,6 +163,7 @@
164163
<rule ref="category/java/errorprone.xml/SingletonClassReturningNewInstance"/>
165164
<rule ref="category/java/errorprone.xml/UnconditionalIfStatement"/>
166165
<rule ref="category/java/errorprone.xml/UnnecessaryCaseChange"/>
166+
<rule ref="category/java/errorprone.xml/UnsupportedJdkApiUsage"/>
167167
<rule ref="category/java/errorprone.xml/UselessPureMethodCall"/>
168168

169169

@@ -208,6 +208,36 @@
208208
<rule ref="category/java/security.xml"/>
209209

210210

211+
<rule name="AvoidOptionalGet"
212+
language="java"
213+
message="Avoid using Optional#get"
214+
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule"
215+
externalInfoUrl="https://stackoverflow.com/a/49159955">
216+
<description>
217+
`Optional#get` can be interpreted as a getter by developers, however this is not the case as it throws an exception when empty.
218+
219+
It should be replaced by
220+
* doing a mapping directly using `.map` or `.ifPresent`
221+
* using the preferred `.orElseThrow`, `.orElse` or `.or` methods
222+
223+
Java Developer Brian Goetz also writes regarding this topic:
224+
225+
> Java 8 was a huge improvement to the platform, but one of the few mistakes we made was the naming of `Optional.get()`, because the name just invites people to call it without calling `isPresent()`, undermining the whole point of using `Optional` in the first place.
226+
>
227+
> During the Java 9 time frame, we proposed to deprecate `Optional.get()`, but the public response to that was ... let's say cold. As a smaller step, we introduced `orElseThrow()` in 10 (see [JDK-8140281](https://bugs.openjdk.java.net/browse/JDK-8140281)) as a more transparently named synonym for the current pernicious behavior of `get()`. IDEs warn on unconditional use of `get()`, but not on `orElseThrow()`, which is a step forward in teaching people to code better. The question is, in a sense, a "glass half empty" view of the current situation; `get()` is still problematic.
228+
</description>
229+
<priority>3</priority>
230+
<properties>
231+
<property name="xpath">
232+
<value>
233+
<![CDATA[
234+
//MethodCall[pmd-java:matchesSig('java.util.Optional#get()')]
235+
]]>
236+
</value>
237+
</property>
238+
</properties>
239+
</rule>
240+
211241
<rule name="AvoidStringBuilderOrBuffer"
212242
language="java"
213243
message="StringBuilder/StringBuffer should not be used"

.github/workflows/broken-links.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919

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

.github/workflows/check-build.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ jobs:
4242
path: |
4343
~/.gradle/caches
4444
~/.gradle/wrapper
45-
key: ${{ runner.os }}-gradle-build-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
45+
key: ${{ runner.os }}-gradle-build-${{ hashFiles('**/*.gradle*', '**/gradle.properties', '**/gradle-wrapper.properties') }}
4646
restore-keys: |
4747
${{ runner.os }}-gradle-build-
4848
4949
- name: Build
5050
run: ./gradlew build buildPlugin --info --stacktrace
5151

5252
- name: Try upload test reports when failure occurs
53-
uses: actions/upload-artifact@v6
53+
uses: actions/upload-artifact@v7
5454
if: failure()
5555
with:
5656
name: test-reports-${{ matrix.java }}
@@ -75,7 +75,7 @@ jobs:
7575
fi
7676
7777
- name: Upload plugin files
78-
uses: actions/upload-artifact@v6
78+
uses: actions/upload-artifact@v7
7979
with:
8080
name: plugin-files-java-${{ matrix.java }}
8181
path: build/distributions/*.zip
@@ -104,7 +104,7 @@ jobs:
104104
path: |
105105
~/.gradle/caches
106106
~/.gradle/wrapper
107-
key: ${{ runner.os }}-gradle-checkstyle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
107+
key: ${{ runner.os }}-gradle-checkstyle-${{ hashFiles('**/*.gradle*', '**/gradle.properties', '**/gradle-wrapper.properties') }}
108108
restore-keys: |
109109
${{ runner.os }}-gradle-checkstyle-
110110
@@ -137,13 +137,13 @@ jobs:
137137
path: |
138138
~/.gradle/caches
139139
~/.gradle/wrapper
140-
key: ${{ runner.os }}-gradle-pmd-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
140+
key: ${{ runner.os }}-gradle-pmd-${{ hashFiles('**/*.gradle*', '**/gradle.properties', '**/gradle-wrapper.properties') }}
141141
restore-keys: |
142142
${{ runner.os }}-gradle-pmd-
143143
144144
- name: Upload report
145145
if: always()
146-
uses: actions/upload-artifact@v6
146+
uses: actions/upload-artifact@v7
147147
with:
148148
name: pmd-report
149149
if-no-files-found: ignore

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
path: |
5656
~/.gradle/caches
5757
~/.gradle/wrapper
58-
key: ${{ runner.os }}-gradle-ide-compatibility-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
58+
key: ${{ runner.os }}-gradle-ide-compatibility-${{ hashFiles('**/*.gradle*', '**/gradle.properties', '**/gradle-wrapper.properties') }}
5959
restore-keys: |
6060
${{ runner.os }}-gradle-ide-compatibility-
6161
@@ -64,7 +64,7 @@ jobs:
6464
run: ./gradlew verifyPlugin --info --stacktrace
6565

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

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
path: |
2828
~/.gradle/caches
2929
~/.gradle/wrapper
30-
key: ${{ runner.os }}-gradle-build-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
30+
key: ${{ runner.os }}-gradle-build-${{ hashFiles('**/*.gradle*', '**/gradle.properties', '**/gradle-wrapper.properties') }}
3131
restore-keys: |
3232
${{ runner.os }}-gradle-build-
3333
@@ -91,7 +91,7 @@ jobs:
9191
9292
- name: Create Release
9393
id: create_release
94-
uses: shogo82148/actions-create-release@559c27ce7eb834825e2b55927c64f6d1bd1db716 # v1
94+
uses: shogo82148/actions-create-release@6a396031bc74c57403da1018fec74d24c6aa03cd # v1
9595
with:
9696
tag_name: v${{ steps.version.outputs.release }}
9797
release_name: v${{ steps.version.outputs.release }}
@@ -135,7 +135,7 @@ jobs:
135135
run: ./gradlew publishPlugin --info --stacktrace
136136

137137
- name: Upload plugin files
138-
uses: actions/upload-artifact@v6
138+
uses: actions/upload-artifact@v7
139139
with:
140140
name: plugin-files
141141
path: build/distributions/*
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Report workflow security problems
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [ develop ]
7+
paths:
8+
- '.github/workflows/**'
9+
10+
permissions:
11+
issues: write
12+
13+
jobs:
14+
prt:
15+
runs-on: ubuntu-latest
16+
timeout-minutes: 15
17+
# Only run this in our repos (Prevent notification spam by forks)
18+
if: ${{ github.repository_owner == 'xdev-software' }}
19+
steps:
20+
- uses: actions/checkout@v6
21+
22+
- name: Check
23+
id: check
24+
run: |
25+
grep -l 'pull_request_target:' --exclude report-gha-workflow-security-problems.yml *.yml > reported.txt && exit 1 || exit 0
26+
working-directory: .github/workflows
27+
28+
- name: Find already existing issue
29+
id: find-issue
30+
if: ${{ !cancelled() }}
31+
run: |
32+
echo "number=$(gh issue list -l 'bug' -l 'automated' -L 1 -S 'in:title "Incorrectly configure GHA workflow (prt)"' -s 'open' --json 'number' --jq '.[].number')" >> $GITHUB_OUTPUT
33+
env:
34+
GH_TOKEN: ${{ github.token }}
35+
36+
- name: Close issue if everything is fine
37+
if: ${{ success() && steps.find-issue.outputs.number != '' }}
38+
run: gh issue close -r 'not planned' ${{ steps.find-issue.outputs.number }}
39+
env:
40+
GH_TOKEN: ${{ github.token }}
41+
42+
- name: Create report
43+
if: ${{ failure() && steps.check.conclusion == 'failure' }}
44+
run: |
45+
echo 'Detected usage of `pull_request_target`. This event is dangerous and MUST NOT BE USED AT ALL COST!' > reported.md
46+
echo '' >> reported.md
47+
echo '/cc @xdev-software/gha-workflow-security' >> reported.md
48+
echo '' >> reported.md
49+
echo '```' >> reported.md
50+
cat .github/workflows/reported.txt >> reported.md
51+
echo '```' >> reported.md
52+
cat reported.md
53+
54+
- name: Create Issue From File
55+
if: ${{ failure() && steps.check.conclusion == 'failure' }}
56+
uses: peter-evans/create-issue-from-file@fca9117c27cdc29c6c4db3b86c48e4115a786710 # v6
57+
with:
58+
issue-number: ${{ steps.find-issue.outputs.number }}
59+
title: 'Incorrectly configure GHA workflow (prt)'
60+
content-filepath: ./reported.md
61+
labels: bug, automated

.github/workflows/test-deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
run: ./gradlew publishPlugin --info --stacktrace
3636

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

.idea/externalDependencies.xml

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

build.gradle

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ plugins {
33
id 'idea'
44
id 'checkstyle'
55
id 'pmd'
6-
id 'org.jetbrains.intellij.platform' version '2.11.0'
6+
id 'org.jetbrains.intellij.platform' version '2.13.1'
77
}
88

99
ext {
10-
checkstyleVersion = '13.0.0'
10+
checkstyleVersion = '13.3.0'
1111

12-
pmdVersion = '7.20.0'
12+
pmdVersion = '7.22.0'
1313
}
1414

1515
def properties(String key) {
@@ -55,13 +55,12 @@ dependencies {
5555
plugins(properties("platformPlugins").map { it.split(",").collect { it.trim() }.findAll { !it.empty } })
5656
pluginVerifier()
5757
zipSigner()
58-
instrumentationTools()
5958
testFramework TestFrameworkType.Platform.INSTANCE
6059
}
6160
checkstyle "com.puppycrawl.tools:checkstyle:${checkstyleVersion}"
6261
pmd "net.sourceforge.pmd:pmd-ant:${pmdVersion}",
6362
"net.sourceforge.pmd:pmd-java:${pmdVersion}"
64-
testImplementation platform('org.junit:junit-bom:6.0.2'),
63+
testImplementation platform('org.junit:junit-bom:6.0.3'),
6564
'org.junit.jupiter:junit-jupiter',
6665
'org.junit.jupiter:junit-jupiter-engine',
6766
'org.assertj:assertj-core:3.27.7'

0 commit comments

Comments
 (0)