From 2a2912f5196f024d41b376e650cee7c2a8d6793c Mon Sep 17 00:00:00 2001 From: gtoison Date: Tue, 11 Nov 2025 18:05:59 +0100 Subject: [PATCH 1/2] deps: Upgrade errorprone to 2.42.0 Last version before errorprone requires JDK 21 --- pom.xml | 2 +- .../erroraway/rules/ErrorAwayRulesMapping.java | 2 +- .../bugpattern/EqualsIncompatibleType.md | 6 +++--- .../errorprone/bugpattern/SelfAssertion.md | 14 +++++++++----- .../errorprone/bugpattern/SystemConsoleNull.md | 16 ++++++++++++++-- 5 files changed, 28 insertions(+), 12 deletions(-) diff --git a/pom.xml b/pom.xml index 357cc1c..60b3309 100644 --- a/pom.xml +++ b/pom.xml @@ -41,7 +41,7 @@ 8.2.0.36672 5.6.0.2578 - 2.39.0 + 2.42.0 0.12.7 0.1.29 0.23.0 diff --git a/sonar-erroraway-lib/src/main/java/com/github/erroraway/rules/ErrorAwayRulesMapping.java b/sonar-erroraway-lib/src/main/java/com/github/erroraway/rules/ErrorAwayRulesMapping.java index ffac2e1..cd372f7 100644 --- a/sonar-erroraway-lib/src/main/java/com/github/erroraway/rules/ErrorAwayRulesMapping.java +++ b/sonar-erroraway-lib/src/main/java/com/github/erroraway/rules/ErrorAwayRulesMapping.java @@ -34,7 +34,7 @@ public final class ErrorAwayRulesMapping { public static final String ERRORPRONE_SLF4J_REPOSITORY = "errorprone-slf4j"; public static final String PICNIC_REPOSITORY = "picnic-errorprone"; - public static final int ERRORPRONE_REPOSITORY_RULES_COUNT = 471; + public static final int ERRORPRONE_REPOSITORY_RULES_COUNT = 475; public static final int NULLAWAY_REPOSITORY_RULES_COUNT = 1; public static final int ERRORPRONE_SLF4J_REPOSITORY_RULES_COUNT = 8; public static final int PICNIC_REPOSITORY_RULES_COUNT = 45; diff --git a/sonar-erroraway-maven-plugin/src/main/resources/errorprone/bugpattern/EqualsIncompatibleType.md b/sonar-erroraway-maven-plugin/src/main/resources/errorprone/bugpattern/EqualsIncompatibleType.md index 6ff71b9..bc38438 100644 --- a/sonar-erroraway-maven-plugin/src/main/resources/errorprone/bugpattern/EqualsIncompatibleType.md +++ b/sonar-erroraway-maven-plugin/src/main/resources/errorprone/bugpattern/EqualsIncompatibleType.md @@ -146,6 +146,6 @@ if (set.contains(hi)) { } ``` -[equalstester]: https://static.javadoc.io/com.google.guava/guava-testlib/19.0/com/google/common/testing/EqualsTester.html -[objeq]: https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html#equals(java.lang.Object) -[av]: https://github.com/google/auto/blob/master/value/userguide/index.md +[equalstester]: https://www.javadoc.io/doc/com.google.guava/guava-testlib/latest/com/google/common/testing/EqualsTester.html +[objeq]: https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals(java.lang.Object) +[av]: https://github.com/google/auto/blob/main/value/userguide/index.md diff --git a/sonar-erroraway-maven-plugin/src/main/resources/errorprone/bugpattern/SelfAssertion.md b/sonar-erroraway-maven-plugin/src/main/resources/errorprone/bugpattern/SelfAssertion.md index 2e805c1..c5a2e9a 100644 --- a/sonar-erroraway-maven-plugin/src/main/resources/errorprone/bugpattern/SelfAssertion.md +++ b/sonar-erroraway-maven-plugin/src/main/resources/errorprone/bugpattern/SelfAssertion.md @@ -1,8 +1,8 @@ -If a test subject and the argument to `isEqualTo` are the same instance (e.g. -`assertThat(x).isEqualTo(x)`), then the assertion will always pass. Truth -implements `isEqualTo` using [`Objects#equal`] , which tests its arguments for -reference equality and returns true without calling `equals()` if both arguments -are the same instance. +When using Truth, if a test subject and the argument to `isEqualTo` are the same +instance (for example `assertThat(x).isEqualTo(x)`), then the assertion will +always pass. Truth implements `isEqualTo` using [`Objects#equal`] , which tests +its arguments for reference equality and returns true without calling `equals()` +if both arguments are the same instance. JUnit's `assertEquals` (and similar) methods are implemented in terms of `Object#equals`. However, this is not explicitly documented, so isn't a @@ -14,4 +14,8 @@ To test the implementation of an `equals` method, use [Guava's EqualsTester][javadoc], or explicitly call `equals` as part of the test. +In our experience, `assertThat(x).isEqualTo(x)` and similar are *more likely to +be typos* than assertions about an `equals` method. This alone is sufficient +motivation to choose a dedicated approach for testing `equals` implementations. + [javadoc]: https://static.javadoc.io/com.google.guava/guava-testlib/21.0/com/google/common/testing/EqualsTester.html diff --git a/sonar-erroraway-maven-plugin/src/main/resources/errorprone/bugpattern/SystemConsoleNull.md b/sonar-erroraway-maven-plugin/src/main/resources/errorprone/bugpattern/SystemConsoleNull.md index 079e649..7e939e4 100644 --- a/sonar-erroraway-maven-plugin/src/main/resources/errorprone/bugpattern/SystemConsoleNull.md +++ b/sonar-erroraway-maven-plugin/src/main/resources/errorprone/bugpattern/SystemConsoleNull.md @@ -1,7 +1,7 @@ Null-checking `System.console()` is not a reliable way to detect if the console is connected to a terminal. -See +See JDK 22 [Release Note: JLine As The Default Console Provider](https://bugs.openjdk.org/browse/JDK-8309155): > `System.console()` now returns a `Console` object when the standard streams @@ -15,6 +15,18 @@ See > A new method `Console.isTerminal()` has been added to test if console is > connected to a terminal. +and JDK 25 release note +[Release Note: Default Console Implementation No Longer Based On JLine](https://bugs.openjdk.org/browse/JDK-8351576): + +> The default Console obtained via `System.console()` is no longer based on +> JLine. Since JDK 20, the JDK has included a JLine-based Console +> implementation, offering a richer user experience and better support for +> virtual terminal environments, such as IDEs. This implementation was initially +> opt-in via a system property in JDK 20 and JDK 21 and became the default in +> JDK 22. However, maintaining the JLine-based Console proved challenging. As a +> result, in JDK 25, it has reverted to being opt-in, as it was in JDK 20 and +> JDK 21. + To prepare for this change while remaining compatible with JDK versions prior to JDK 22, consider using reflection to call `Console#isTerminal` on JDK versions that support it: @@ -23,7 +35,7 @@ that support it: @SuppressWarnings("SystemConsoleNull") // https://errorprone.info/bugpattern/SystemConsoleNull private static boolean systemConsoleIsTerminal() { Console systemConsole = System.console(); - if (Runtime.version().feature() < 22) { + if (Runtime.version().feature() < 22 || systemConsole == null) { return systemConsole != null; } try { From ddf2685fcaee990c9c71c2cf6a346979d94cc05e Mon Sep 17 00:00:00 2001 From: gtoison Date: Tue, 11 Nov 2025 18:17:41 +0100 Subject: [PATCH 2/2] deps: upgrade errorprone picnic to 0.25.0 StringJoin was taken over by core errorprone --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 60b3309..e20a367 100644 --- a/pom.xml +++ b/pom.xml @@ -44,7 +44,7 @@ 2.42.0 0.12.7 0.1.29 - 0.23.0 + 0.25.0 4.30.1