diff --git a/.config/checkstyle/checkstyle.xml b/.config/checkstyle/checkstyle.xml index 463a629..262c9f9 100644 --- a/.config/checkstyle/checkstyle.xml +++ b/.config/checkstyle/checkstyle.xml @@ -79,6 +79,11 @@ + + + + + diff --git a/.config/pmd/java/ruleset.xml b/.config/pmd/java/ruleset.xml index e96576b..9dc7a0f 100644 --- a/.config/pmd/java/ruleset.xml +++ b/.config/pmd/java/ruleset.xml @@ -146,7 +146,6 @@ - @@ -164,6 +163,7 @@ + @@ -208,6 +208,36 @@ + + +`Optional#get` can be interpreted as a getter by developers, however this is not the case as it throws an exception when empty. + +It should be replaced by +* doing a mapping directly using `.map` or `.ifPresent` +* using the preferred `.orElseThrow`, `.orElse` or `.or` methods + +Java Developer Brian Goetz also writes regarding this topic: + +> 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. +> +> 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. + + 3 + + + + + + + + + com.puppycrawl.tools checkstyle - 13.0.0 + 13.2.0 @@ -83,12 +83,12 @@ net.sourceforge.pmd pmd-core - 7.20.0 + 7.21.0 net.sourceforge.pmd pmd-java - 7.20.0 + 7.21.0 diff --git a/sessionize-java-client-demo/pom.xml b/sessionize-java-client-demo/pom.xml index 16e965f..d044393 100644 --- a/sessionize-java-client-demo/pom.xml +++ b/sessionize-java-client-demo/pom.xml @@ -59,7 +59,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.14.1 + 3.15.0 ${maven.compiler.release} diff --git a/sessionize-java-client/pom.xml b/sessionize-java-client/pom.xml index c1c86c2..8c46a1a 100644 --- a/sessionize-java-client/pom.xml +++ b/sessionize-java-client/pom.xml @@ -149,7 +149,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.14.1 + 3.15.0 ${maven.compiler.release} @@ -444,7 +444,7 @@ com.puppycrawl.tools checkstyle - 13.0.0 + 13.2.0 @@ -486,12 +486,12 @@ net.sourceforge.pmd pmd-core - 7.20.0 + 7.21.0 net.sourceforge.pmd pmd-java - 7.20.0 + 7.21.0