Skip to content

Commit 2b1d4ae

Browse files
author
Vincent Potucek
committed
Add error-prone.picnic.tech featuring RedundantStringConversion
1 parent 40c3b0a commit 2b1d4ae

File tree

3 files changed

+42
-35
lines changed

3 files changed

+42
-35
lines changed

gradle/libs.versions.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ bndlib = { module = "biz.aQute.bnd:biz.aQute.bndlib", version.ref = "bnd" }
3232
checkstyle = { module = "com.puppycrawl.tools:checkstyle", version.ref = "checkstyle" }
3333
classgraph = { module = "io.github.classgraph:classgraph", version = "4.8.181" }
3434
commons-io = { module = "commons-io:commons-io", version = "2.20.0" }
35-
errorProne-core = { module = "com.google.errorprone:error_prone_core", version = "2.42.0" }
35+
error-prone-core = { module = "com.google.errorprone:error_prone_core", version = "2.42.0" }
36+
error-prone-contrib = { module = "tech.picnic.error-prone-support:error-prone-contrib", version = "0.25.0" }
37+
refaster-runner = { module = "tech.picnic.error-prone-support:refaster-runner", version = "0.25.0" }
3638
fastcsv = { module = "de.siegmar:fastcsv", version = "4.0.0" }
3739
groovy = { module = "org.apache.groovy:groovy", version = "5.0.1" }
3840
groovy2-bom = { module = "org.codehaus.groovy:groovy-bom", version = "2.5.23" }

gradle/plugins/common/src/main/kotlin/junitbuild.java-nullability-conventions.gradle.kts

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import junitbuild.extensions.dependencyFromLibs
22
import net.ltgt.gradle.errorprone.errorprone
33
import net.ltgt.gradle.nullaway.nullaway
4+
import org.gradle.jvm.toolchain.JvmImplementation.J9
45

56
plugins {
67
`java-library`
@@ -9,61 +10,65 @@ plugins {
910
}
1011

1112
dependencies {
12-
errorprone(dependencyFromLibs("errorProne-core"))
13+
errorprone(dependencyFromLibs("error-prone-contrib"))
14+
errorprone(dependencyFromLibs("error-prone-core"))
1315
errorprone(dependencyFromLibs("nullaway"))
16+
errorprone(dependencyFromLibs("refaster-runner"))
1417
constraints {
1518
errorprone("com.google.guava:guava") {
1619
version {
1720
require("33.4.8-jre")
1821
}
1922
because("Older versions use deprecated methods in sun.misc.Unsafe")
23+
// https://github.com/junit-team/junit-framework/pull/5039#discussion_r2414490581
2024
}
2125
}
2226
}
2327

24-
nullaway {
25-
onlyNullMarked = true
26-
}
27-
2828
tasks.withType<JavaCompile>().configureEach {
2929
options.errorprone {
30-
val shouldDisableErrorProne = java.toolchain.implementation.orNull == JvmImplementation.J9
31-
if (name == "compileJava" && !shouldDisableErrorProne) {
30+
disableAllChecks = !(J9 != java.toolchain.implementation.orNull && "compileJava" == name)
31+
if (!disableAllChecks.get()) {
32+
errorproneArgs.add("-XepOpt:Refaster:NamePattern=^(?!.*Rules\\$).*") // currently failing Refaster; might consider whitelist.
3233
disable(
33-
34-
// This check is opinionated wrt. which method names it considers unsuitable for import which includes
35-
// a few of our own methods in `ReflectionUtils` etc.
36-
"BadImport",
37-
38-
// The findings of this check are subjective because a named constant can be more readable in many cases
39-
"UnnecessaryLambda",
40-
41-
// Resolving findings for these checks requires ErrorProne's annotations which we don't want to use
42-
"AnnotateFormatMethod",
34+
"AnnotateFormatMethod", // We don`t want to use ErrorProne`s annotations.
35+
"BadImport", // This check is opinionated wrt. which method names it considers unsuitable for import which includes a few of our own methods in `ReflectionUtils` etc.
4336
"DoNotCallSuggester",
44-
"InlineMeSuggester",
4537
"ImmutableEnumChecker",
46-
47-
// Resolving findings for this check requires using Guava which we don't want to use
48-
"StringSplitter",
49-
50-
// Produces a lot of findings that we consider to be false positives, for example for package-private
51-
// classes and methods
52-
"MissingSummary",
38+
"InlineMeSuggester",
39+
"MissingSummary", // Produces a lot of findings that we consider to be false positives, for example for package-private classes and methods.
40+
"StringSplitter", // We don`t want to use Guava.
41+
"UnnecessaryLambda", // The findings of this check are subjective because a named constant can be more readable in many cases.
42+
// picnic (https://error-prone.picnic.tech)
43+
"ConstantNaming",
44+
"DirectReturn", // https://github.com/junit-team/junit-framework/pull/5006#discussion_r2403984446
45+
"FormatStringConcatenation",
46+
"IdentityConversion",
47+
"LexicographicalAnnotationAttributeListing",
48+
"LexicographicalAnnotationListing",
49+
"MissingTestCall",
50+
"NestedOptionals",
51+
"StaticImport",
52+
"NonStaticImport",
53+
"OptionalOrElseGet",
54+
"TimeZoneUsage",
55+
)
56+
error(
57+
"PackageLocation",
58+
"RedundantStringConversion",
59+
"RedundantStringEscape",
5360
)
54-
error("PackageLocation")
55-
} else {
56-
disableAllChecks = true
5761
}
5862
nullaway {
59-
if (shouldDisableErrorProne) {
60-
disable()
61-
} else {
63+
if (J9 == java.toolchain.implementation.orNull) {
6264
enable()
65+
} else {
66+
disable()
6367
}
64-
isJSpecifyMode = true
65-
customContractAnnotations.add("org.junit.platform.commons.annotation.Contract")
6668
checkContracts = true
69+
customContractAnnotations.add("org.junit.platform.commons.annotation.Contract")
70+
isJSpecifyMode = true
71+
onlyNullMarked = true
6772
suppressionNameAliases.add("DataFlowIssue")
6873
}
6974
}

junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/extension/PreInterruptThreadDumpPrinter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public void beforeThreadInterrupt(PreInterruptContext preInterruptContext, Exten
4949
sb.append(NL);
5050
// Use the same prefix as java.lang.Throwable.printStackTrace(PrintStreamOrWriter)
5151
sb.append("\tat ");
52-
sb.append(stackTraceElement.toString());
52+
sb.append(stackTraceElement);
5353
}
5454
sb.append(NL);
5555
}

0 commit comments

Comments
 (0)