Skip to content

Commit 7d31112

Browse files
committed
Merge remote-tracking branch 'origin/update-from-template' into develop
2 parents 5612e69 + 1ff105e commit 7d31112

5 files changed

Lines changed: 44 additions & 9 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"

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
<dependency>
4747
<groupId>com.puppycrawl.tools</groupId>
4848
<artifactId>checkstyle</artifactId>
49-
<version>13.0.0</version>
49+
<version>13.2.0</version>
5050
</dependency>
5151
</dependencies>
5252
<configuration>
@@ -84,12 +84,12 @@
8484
<dependency>
8585
<groupId>net.sourceforge.pmd</groupId>
8686
<artifactId>pmd-core</artifactId>
87-
<version>7.20.0</version>
87+
<version>7.21.0</version>
8888
</dependency>
8989
<dependency>
9090
<groupId>net.sourceforge.pmd</groupId>
9191
<artifactId>pmd-java</artifactId>
92-
<version>7.20.0</version>
92+
<version>7.21.0</version>
9393
</dependency>
9494
</dependencies>
9595
</plugin>

testcontainers-advanced-imagebuilder-demo/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
<plugin>
5151
<groupId>org.apache.maven.plugins</groupId>
5252
<artifactId>maven-compiler-plugin</artifactId>
53-
<version>3.14.1</version>
53+
<version>3.15.0</version>
5454
<configuration>
5555
<release>${maven.compiler.release}</release>
5656
<compilerArgs>

testcontainers-advanced-imagebuilder/pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
<plugin>
137137
<groupId>org.apache.maven.plugins</groupId>
138138
<artifactId>maven-compiler-plugin</artifactId>
139-
<version>3.14.1</version>
139+
<version>3.15.0</version>
140140
<executions>
141141
<execution>
142142
<id>compile-java-17</id>
@@ -291,7 +291,7 @@
291291
<dependency>
292292
<groupId>com.puppycrawl.tools</groupId>
293293
<artifactId>checkstyle</artifactId>
294-
<version>13.0.0</version>
294+
<version>13.2.0</version>
295295
</dependency>
296296
</dependencies>
297297
<configuration>
@@ -329,12 +329,12 @@
329329
<dependency>
330330
<groupId>net.sourceforge.pmd</groupId>
331331
<artifactId>pmd-core</artifactId>
332-
<version>7.20.0</version>
332+
<version>7.21.0</version>
333333
</dependency>
334334
<dependency>
335335
<groupId>net.sourceforge.pmd</groupId>
336336
<artifactId>pmd-java</artifactId>
337-
<version>7.20.0</version>
337+
<version>7.21.0</version>
338338
</dependency>
339339
</dependencies>
340340
</plugin>

0 commit comments

Comments
 (0)