Skip to content

Commit 5acbb23

Browse files
authored
Upgrade errorprone to 2.42.0 (#73)
Last version before errorprone requires JDK 21 deps: upgrade errorprone picnic to 0.25.0 because StringJoin was taken over by core errorprone
1 parent 5d021ea commit 5acbb23

File tree

5 files changed

+29
-13
lines changed

5 files changed

+29
-13
lines changed

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@
4141
<sonar-java-frontend.version>8.2.0.36672</sonar-java-frontend.version>
4242
<sonar-orchestrator.version>5.6.0.2578</sonar-orchestrator.version>
4343

44-
<errorprone.version>2.39.0</errorprone.version>
44+
<errorprone.version>2.42.0</errorprone.version>
4545
<nullaway.version>0.12.7</nullaway.version>
4646
<errorprone.slf4j.version>0.1.29</errorprone.slf4j.version>
47-
<picnic.errorprone.support.version>0.23.0</picnic.errorprone.support.version>
47+
<picnic.errorprone.support.version>0.25.0</picnic.errorprone.support.version>
4848

4949
<protobuf.version>4.30.1</protobuf.version>
5050

sonar-erroraway-lib/src/main/java/com/github/erroraway/rules/ErrorAwayRulesMapping.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public final class ErrorAwayRulesMapping {
3434
public static final String ERRORPRONE_SLF4J_REPOSITORY = "errorprone-slf4j";
3535
public static final String PICNIC_REPOSITORY = "picnic-errorprone";
3636

37-
public static final int ERRORPRONE_REPOSITORY_RULES_COUNT = 471;
37+
public static final int ERRORPRONE_REPOSITORY_RULES_COUNT = 475;
3838
public static final int NULLAWAY_REPOSITORY_RULES_COUNT = 1;
3939
public static final int ERRORPRONE_SLF4J_REPOSITORY_RULES_COUNT = 8;
4040
public static final int PICNIC_REPOSITORY_RULES_COUNT = 45;

sonar-erroraway-maven-plugin/src/main/resources/errorprone/bugpattern/EqualsIncompatibleType.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,6 @@ if (set.contains(hi)) {
146146
}
147147
```
148148

149-
[equalstester]: https://static.javadoc.io/com.google.guava/guava-testlib/19.0/com/google/common/testing/EqualsTester.html
150-
[objeq]: https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html#equals(java.lang.Object)
151-
[av]: https://github.com/google/auto/blob/master/value/userguide/index.md
149+
[equalstester]: https://www.javadoc.io/doc/com.google.guava/guava-testlib/latest/com/google/common/testing/EqualsTester.html
150+
[objeq]: https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals(java.lang.Object)
151+
[av]: https://github.com/google/auto/blob/main/value/userguide/index.md
Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
If a test subject and the argument to `isEqualTo` are the same instance (e.g.
2-
`assertThat(x).isEqualTo(x)`), then the assertion will always pass. Truth
3-
implements `isEqualTo` using [`Objects#equal`] , which tests its arguments for
4-
reference equality and returns true without calling `equals()` if both arguments
5-
are the same instance.
1+
When using Truth, if a test subject and the argument to `isEqualTo` are the same
2+
instance (for example `assertThat(x).isEqualTo(x)`), then the assertion will
3+
always pass. Truth implements `isEqualTo` using [`Objects#equal`] , which tests
4+
its arguments for reference equality and returns true without calling `equals()`
5+
if both arguments are the same instance.
66

77
JUnit's `assertEquals` (and similar) methods are implemented in terms of
88
`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
1414
[Guava's EqualsTester][javadoc], or explicitly call `equals` as part of the
1515
test.
1616

17+
In our experience, `assertThat(x).isEqualTo(x)` and similar are *more likely to
18+
be typos* than assertions about an `equals` method. This alone is sufficient
19+
motivation to choose a dedicated approach for testing `equals` implementations.
20+
1721
[javadoc]: https://static.javadoc.io/com.google.guava/guava-testlib/21.0/com/google/common/testing/EqualsTester.html

sonar-erroraway-maven-plugin/src/main/resources/errorprone/bugpattern/SystemConsoleNull.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Null-checking `System.console()` is not a reliable way to detect if the console
22
is connected to a terminal.
33

4-
See
4+
See JDK 22
55
[Release Note: JLine As The Default Console Provider](https://bugs.openjdk.org/browse/JDK-8309155):
66

77
> `System.console()` now returns a `Console` object when the standard streams
@@ -15,6 +15,18 @@ See
1515
> A new method `Console.isTerminal()` has been added to test if console is
1616
> connected to a terminal.
1717
18+
and JDK 25 release note
19+
[Release Note: Default Console Implementation No Longer Based On JLine](https://bugs.openjdk.org/browse/JDK-8351576):
20+
21+
> The default Console obtained via `System.console()` is no longer based on
22+
> JLine. Since JDK 20, the JDK has included a JLine-based Console
23+
> implementation, offering a richer user experience and better support for
24+
> virtual terminal environments, such as IDEs. This implementation was initially
25+
> opt-in via a system property in JDK 20 and JDK 21 and became the default in
26+
> JDK 22. However, maintaining the JLine-based Console proved challenging. As a
27+
> result, in JDK 25, it has reverted to being opt-in, as it was in JDK 20 and
28+
> JDK 21.
29+
1830
To prepare for this change while remaining compatible with JDK versions prior to
1931
JDK 22, consider using reflection to call `Console#isTerminal` on JDK versions
2032
that support it:
@@ -23,7 +35,7 @@ that support it:
2335
@SuppressWarnings("SystemConsoleNull") // https://errorprone.info/bugpattern/SystemConsoleNull
2436
private static boolean systemConsoleIsTerminal() {
2537
Console systemConsole = System.console();
26-
if (Runtime.version().feature() < 22) {
38+
if (Runtime.version().feature() < 22 || systemConsole == null) {
2739
return systemConsole != null;
2840
}
2941
try {

0 commit comments

Comments
 (0)