Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ bndlib = { module = "biz.aQute.bnd:biz.aQute.bndlib", version.ref = "bnd" }
checkstyle = { module = "com.puppycrawl.tools:checkstyle", version.ref = "checkstyle" }
classgraph = { module = "io.github.classgraph:classgraph", version = "4.8.181" }
commons-io = { module = "commons-io:commons-io", version = "2.20.0" }
errorProne-core = { module = "com.google.errorprone:error_prone_core", version = "2.42.0" }
error-prone-core = { module = "com.google.errorprone:error_prone_core", version = "2.42.0" }
error-prone-contrib = { module = "tech.picnic.error-prone-support:error-prone-contrib", version = "0.25.0" }
refaster-runner = { module = "tech.picnic.error-prone-support:refaster-runner", version = "0.25.0" }
fastcsv = { module = "de.siegmar:fastcsv", version = "4.0.0" }
groovy = { module = "org.apache.groovy:groovy", version = "5.0.1" }
groovy2-bom = { module = "org.codehaus.groovy:groovy-bom", version = "2.5.23" }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import junitbuild.extensions.dependencyFromLibs
import net.ltgt.gradle.errorprone.errorprone
import net.ltgt.gradle.nullaway.nullaway
import org.gradle.jvm.toolchain.JvmImplementation.J9

plugins {
`java-library`
Expand All @@ -9,61 +10,80 @@ plugins {
}

dependencies {
errorprone(dependencyFromLibs("errorProne-core"))
errorprone(dependencyFromLibs("error-prone-contrib"))
errorprone(dependencyFromLibs("error-prone-core"))
errorprone(dependencyFromLibs("nullaway"))
errorprone(dependencyFromLibs("refaster-runner"))
constraints {
errorprone("com.google.guava:guava") {
version {
require("33.4.8-jre")
}
because("Older versions use deprecated methods in sun.misc.Unsafe")
// https://github.com/junit-team/junit-framework/pull/5039#discussion_r2414490581
}
}
}

nullaway {
onlyNullMarked = true
}

tasks.withType<JavaCompile>().configureEach {
options.errorprone {
val shouldDisableErrorProne = java.toolchain.implementation.orNull == JvmImplementation.J9
if (name == "compileJava" && !shouldDisableErrorProne) {
// allErrorsAsWarnings = true
// disableAllWarnings = true
disableAllChecks = !(J9 != java.toolchain.implementation.orNull && "compileJava" == name)
if (!disableAllChecks.get()) {
// errorproneArgs.add("-XepOpt:Refaster:NamePattern=^(?!.*Rules\\$).*") // currently failing Refaster; might consider whitelist.
disable(

// This check is opinionated wrt. which method names it considers unsuitable for import which includes
// a few of our own methods in `ReflectionUtils` etc.
"BadImport",

// The findings of this check are subjective because a named constant can be more readable in many cases
"UnnecessaryLambda",

// Resolving findings for these checks requires ErrorProne's annotations which we don't want to use
"AnnotateFormatMethod",
"AnnotateFormatMethod", // We don`t want to use ErrorProne`s annotations.
"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.
"DoNotCallSuggester",
"InlineMeSuggester",
"ImmutableEnumChecker",
"InlineMeSuggester",
"MissingSummary", // Produces a lot of findings that we consider to be false positives, for example for package-private classes and methods.
"StringSplitter", // We don`t want to use Guava.
"UnnecessaryLambda", // The findings of this check are subjective because a named constant can be more readable in many cases.
// picnic (https://error-prone.picnic.tech)
"ConstantNaming",
"DirectReturn", // https://github.com/junit-team/junit-framework/pull/5006#discussion_r2403984446
"FormatStringConcatenation",
"IdentityConversion",
"LexicographicalAnnotationAttributeListing",
"LexicographicalAnnotationListing",
"UnnecessarilyFullyQualified",
"MissingTestCall",
"NestedOptionals",
"StaticImport",
"NonStaticImport",
"CanIgnoreReturnValueSuggester",
"OptionalOrElseGet",
"ThrowsUncheckedException",
"TimeZoneUsage",
)
error(
"PackageLocation",
"RedundantStringConversion",
"RedundantStringEscape",
)
// introduce new check by activating once:
// CompositeFilter.java:75: Note: [Refaster Rule] OptionalRules.OptionalOrElseThrow: Refactoring opportunity

// Resolving findings for this check requires using Guava which we don't want to use
"StringSplitter",

// Produces a lot of findings that we consider to be false positives, for example for package-private
// classes and methods
"MissingSummary",
errorproneArgs.addAll(
"-Xep:Refaster:ERROR", // TODO why failing not on warning error prone stuff? https://errorprone.info/bugpattern/AvoidObjectArrays
"-XepOpt:Refaster:NamePattern=OptionalRules", // without this it's going cray-cray, having to disable all failing checks.
// "-XepPatchChecks:OptionalRules",
"-XepPatchLocation:IN_PLACE",
"-XepOpt:Refaster:NamePattern=OptionalRules.OptionalOrElseThrow"
)
error("PackageLocation")
} else {
disableAllChecks = true
}
nullaway {
if (shouldDisableErrorProne) {
disable()
} else {
if (J9 == java.toolchain.implementation.orNull) {
enable()
} else {
disable()
}
isJSpecifyMode = true
customContractAnnotations.add("org.junit.platform.commons.annotation.Contract")
checkContracts = true
customContractAnnotations.add("org.junit.platform.commons.annotation.Contract")
isJSpecifyMode = true
onlyNullMarked = true
suppressionNameAliases.add("DataFlowIssue")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void beforeThreadInterrupt(PreInterruptContext preInterruptContext, Exten
sb.append(NL);
// Use the same prefix as java.lang.Throwable.printStackTrace(PrintStreamOrWriter)
sb.append("\tat ");
sb.append(stackTraceElement.toString());
sb.append(stackTraceElement);
}
sb.append(NL);
}
Expand Down
Loading