Skip to content

Commit aa4fe3a

Browse files
authored
Merge pull request #497 from xdev-software/develop
Release
2 parents 6734f3d + 475f930 commit aa4fe3a

File tree

11 files changed

+126
-80
lines changed

11 files changed

+126
-80
lines changed

.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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ jobs:
6969
fi
7070
7171
- name: Upload demo files
72-
uses: actions/upload-artifact@v6
72+
uses: actions/upload-artifact@v7
7373
with:
7474
name: demo-files-java-${{ matrix.java }}
7575
path: ${{ env.DEMO_MAVEN_MODULE }}/target/${{ env.DEMO_MAVEN_MODULE }}.jar
7676
if-no-files-found: error
7777

7878
- name: Upload screenshots of test failures
7979
if: failure()
80-
uses: actions/upload-artifact@v6
80+
uses: actions/upload-artifact@v7
8181
with:
8282
name: test-fail-screenshots-${{ matrix.java }}
8383
path: ${{ env.PRIMARY_MAVEN_MODULE }}/target/screenshots
@@ -160,7 +160,7 @@ jobs:
160160

161161
- name: Upload report
162162
if: always()
163-
uses: actions/upload-artifact@v6
163+
uses: actions/upload-artifact@v7
164164
with:
165165
name: pmd-report
166166
if-no-files-found: ignore
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

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 3.0.1
2+
* Updated dependencies
3+
14
# 3.0.0
25
_Java 17 is now required_
36
* Updated dependencies

chartjs-java-model-demo/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
<plugin>
4545
<groupId>org.apache.maven.plugins</groupId>
4646
<artifactId>maven-compiler-plugin</artifactId>
47-
<version>3.14.1</version>
47+
<version>3.15.0</version>
4848
<configuration>
4949
<release>${maven.compiler.release}</release>
5050
<compilerArgs>

chartjs-java-model/pom.xml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
<dependency>
6060
<groupId>tools.jackson.core</groupId>
6161
<artifactId>jackson-databind</artifactId>
62-
<version>3.0.3</version>
62+
<version>3.1.0</version>
6363
</dependency>
6464

6565
<!-- Tests -->
@@ -93,7 +93,7 @@
9393
<dependency>
9494
<groupId>org.junit.jupiter</groupId>
9595
<artifactId>junit-jupiter</artifactId>
96-
<version>6.0.2</version>
96+
<version>6.0.3</version>
9797
<scope>test</scope>
9898
</dependency>
9999

@@ -107,15 +107,15 @@
107107
<dependency>
108108
<groupId>software.xdev</groupId>
109109
<artifactId>testcontainers-selenium</artifactId>
110-
<version>1.5.1</version>
110+
<version>1.5.3</version>
111111
<scope>test</scope>
112112
</dependency>
113113

114114
<!-- Selenium -->
115115
<dependency>
116116
<groupId>org.seleniumhq.selenium</groupId>
117117
<artifactId>selenium-chrome-driver</artifactId>
118-
<version>4.40.0</version>
118+
<version>4.41.0</version>
119119
<scope>test</scope>
120120
<exclusions>
121121
<!-- Tracing is not needed -->
@@ -175,7 +175,7 @@
175175
<plugin>
176176
<groupId>org.apache.maven.plugins</groupId>
177177
<artifactId>maven-compiler-plugin</artifactId>
178-
<version>3.14.1</version>
178+
<version>3.15.0</version>
179179
<configuration>
180180
<release>${maven.compiler.release}</release>
181181
<compilerArgs>
@@ -219,7 +219,7 @@
219219
<plugin>
220220
<groupId>org.apache.maven.plugins</groupId>
221221
<artifactId>maven-surefire-plugin</artifactId>
222-
<version>3.5.4</version>
222+
<version>3.5.5</version>
223223
<configuration>
224224
<skipTests>${skipTests}</skipTests>
225225
</configuration>
@@ -308,7 +308,7 @@
308308
<dependency>
309309
<groupId>com.puppycrawl.tools</groupId>
310310
<artifactId>checkstyle</artifactId>
311-
<version>13.0.0</version>
311+
<version>13.3.0</version>
312312
</dependency>
313313
</dependencies>
314314
<configuration>
@@ -346,12 +346,12 @@
346346
<dependency>
347347
<groupId>net.sourceforge.pmd</groupId>
348348
<artifactId>pmd-core</artifactId>
349-
<version>7.20.0</version>
349+
<version>7.22.0</version>
350350
</dependency>
351351
<dependency>
352352
<groupId>net.sourceforge.pmd</groupId>
353353
<artifactId>pmd-java</artifactId>
354-
<version>7.20.0</version>
354+
<version>7.22.0</version>
355355
</dependency>
356356
</dependencies>
357357
</plugin>

chartjs-java-model/src/test/java/software/xdev/chartjs/model/BasicChartTest.java

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -185,35 +185,11 @@ private static <D extends HomogeneousData<D, S>, S extends Dataset<S, O>, O> Sup
185185
};
186186
}
187187

188-
public static class ArgumentDTO<O extends Options<?, ?>, D extends AbstractData<?, ?>>
188+
public record ArgumentDTO<O extends Options<?, ?>, D extends AbstractData<?, ?>>(
189+
Supplier<Chart<?, O, D>> chartSupplier,
190+
Supplier<O> optionsSupplier,
191+
Supplier<D> dataSupplier
192+
)
189193
{
190-
private final Supplier<Chart<?, O, D>> chartSupplier;
191-
private final Supplier<O> optionsSupplier;
192-
private final Supplier<D> dataSupplier;
193-
194-
public ArgumentDTO(
195-
final Supplier<Chart<?, O, D>> chartSupplier,
196-
final Supplier<O> optionsSupplier,
197-
final Supplier<D> dataSupplier)
198-
{
199-
this.chartSupplier = chartSupplier;
200-
this.optionsSupplier = optionsSupplier;
201-
this.dataSupplier = dataSupplier;
202-
}
203-
204-
public Supplier<Chart<?, O, D>> chartSupplier()
205-
{
206-
return this.chartSupplier;
207-
}
208-
209-
public Supplier<O> optionsSupplier()
210-
{
211-
return this.optionsSupplier;
212-
}
213-
214-
public Supplier<D> dataSupplier()
215-
{
216-
return this.dataSupplier;
217-
}
218194
}
219195
}

chartjs-java-model/src/test/java/software/xdev/chartjs/model/ChartAxisFormatTest.java

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -51,40 +51,11 @@ void format()
5151
"Format");
5252
}
5353

54-
public static class CurrencyFormatOptions
54+
public record CurrencyFormatOptions(
55+
String style,
56+
String currency
57+
)
5558
{
56-
private String style;
57-
private String currency;
58-
59-
public CurrencyFormatOptions()
60-
{
61-
}
62-
63-
public CurrencyFormatOptions(final String style, final String currency)
64-
{
65-
this.style = style;
66-
this.currency = currency;
67-
}
68-
69-
public String getStyle()
70-
{
71-
return this.style;
72-
}
73-
74-
public void setStyle(final String style)
75-
{
76-
this.style = style;
77-
}
78-
79-
public String getCurrency()
80-
{
81-
return this.currency;
82-
}
83-
84-
public void setCurrency(final String currency)
85-
{
86-
this.currency = currency;
87-
}
8859
}
8960

9061
static BarData data()

0 commit comments

Comments
 (0)