Skip to content

Commit 632aa90

Browse files
author
Vincent Potucek
committed
Add error-prone.picnic.tech featuring RedundantStringConversion
1 parent 343017b commit 632aa90

File tree

3 files changed

+46
-41
lines changed

3 files changed

+46
-41
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: 42 additions & 39 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 java.lang.System.getenv
45

56
plugins {
67
`java-library`
@@ -9,61 +10,63 @@ 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"))
14-
constraints {
15-
errorprone("com.google.guava:guava") {
16-
version {
17-
require("33.4.8-jre")
18-
}
19-
because("Older versions use deprecated methods in sun.misc.Unsafe")
20-
}
21-
}
22-
}
23-
24-
nullaway {
25-
onlyNullMarked = true
16+
errorprone(dependencyFromLibs("refaster-runner"))
2617
}
2718

2819
tasks.withType<JavaCompile>().configureEach {
2920
options.errorprone {
30-
val shouldDisableErrorProne = java.toolchain.implementation.orNull == JvmImplementation.J9
31-
if (name == "compileJava" && !shouldDisableErrorProne) {
21+
disableWarningsInGeneratedCode = true
22+
allErrorsAsWarnings = true
23+
disableAllChecks = !(name == "compileJava" && java.toolchain.implementation.orNull != JvmImplementation.J9)
24+
if (!disableAllChecks.get()) {
25+
errorproneArgs.add("-XepOpt:Refaster:NamePattern=^(?!.*Rules\\$).*") // currently failing Refaster; might consider whitelist.
3226
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",
27+
"AnnotateFormatMethod", // We don`t want to use ErrorProne`s annotations.
28+
"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.
29+
"DirectReturn", // https://github.com/junit-team/junit-framework/pull/5006#discussion_r2403984446
4330
"DoNotCallSuggester",
44-
"InlineMeSuggester",
4531
"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",
32+
"InlineMeSuggester",
33+
"MissingSummary", // Produces a lot of findings that we consider to be false positives, for example for package-private classes and methods.
34+
"StringSplitter", // We don`t want to use Guava.
35+
"UnnecessaryLambda", // The findings of this check are subjective because a named constant can be more readable in many cases.
36+
// picnic
37+
"ConstantNaming",
38+
"FormatStringConcatenation",
39+
"IdentityConversion",
40+
"LexicographicalAnnotationAttributeListing",
41+
"LexicographicalAnnotationListing",
42+
"MissingTestCall",
43+
"NestedOptionals",
44+
"StaticImport",
45+
"NonStaticImport",
46+
"OptionalOrElseGet",
47+
"PrimitiveComparison",
48+
"TimeZoneUsage",
49+
)
50+
error(
51+
"PackageLocation",
52+
"PrimitiveComparison",
53+
"RedundantStringConversion",
54+
"RedundantStringEscape",
55+
"RequestMappingAnnotation",
5356
)
54-
error("PackageLocation")
55-
} else {
56-
disableAllChecks = true
57+
// introduce new checks with:
58+
// errorproneArgs.addAll("-XepPatchLocation:IN_PLACE","-XepPatchChecks:ConstantNaming")
5759
}
5860
nullaway {
59-
if (shouldDisableErrorProne) {
61+
if (disableAllChecks.get()) {
6062
disable()
6163
} else {
6264
enable()
6365
}
64-
isJSpecifyMode = true
65-
customContractAnnotations.add("org.junit.platform.commons.annotation.Contract")
6666
checkContracts = true
67+
customContractAnnotations.add("org.junit.platform.commons.annotation.Contract")
68+
isJSpecifyMode = true
69+
onlyNullMarked = true
6770
suppressionNameAliases.add("DataFlowIssue")
6871
}
6972
}

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)