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 @@ -31,7 +31,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 java.lang.System.getenv

plugins {
`java-library`
Expand All @@ -9,8 +10,10 @@ 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 {
Expand All @@ -27,29 +30,117 @@ nullaway {

tasks.withType<JavaCompile>().configureEach {
options.errorprone {
allErrorsAsWarnings = true
disableWarningsInGeneratedCode = true
errorproneArgs.add("-XepOpt:Refaster:NamePattern=^(?!.*Rules\\$).*") // might consider.
if (getenv("IN_PLACE").toBoolean()) {
errorproneArgs.addAll(
"-XepPatchLocation:IN_PLACE", // why only certain picnic rules apply?
"-XepPatchChecks:" +
"AddNullMarkedToPackageInfo," +
"AmbiguousJsonCreator," +
"AssertJNullnessAssertion," +
"AutowiredConstructor," +
"CanonicalAnnotationSyntax," +
"CanonicalClassNameUsage," +
"ClassCastLambdaUsage," +
"CollectorMutability," +
"ConstantNaming," +
"DeadException," +
"DefaultCharset," +
"EagerStringFormatting," +
"EmptyMethod," +
"EmptyMonoZip," +
"ExplicitArgumentEnumeration," +
"ExplicitEnumOrdering," +
"FluxFlatMapUsage," +
"FluxImplicitBlock," +
"FormatStringConcatenation," +
"IdentityConversion," +
"ImmutablesSortedSetComparator," +
"IsInstanceLambdaUsage," +
"JUnitClassModifiers," +
"JUnitMethodDeclaration," +
"JUnitNullaryParameterizedTestDeclaration," +
"JUnitValueSource," +
"LexicographicalAnnotationAttributeListing," +
"LexicographicalAnnotationListing," +
"MissingOverride," +
"MockitoMockClassReference," +
"MockitoStubbing," +
"MongoDBTextFilterUsage," +
"NestedOptionals," +
"NestedPublishers," +
"NonEmptyMono," +
"NonStaticImport," +
"OptionalOrElseGet," +
"PrimitiveComparison," +
"RedundantStringConversion," +
"RedundantStringEscape," +
"RefasterAnyOfUsage," +
"ImmutableEnumChecker," +
"RequestMappingAnnotation," +
"RequestParamType," +
"Slf4jLogStatement," +
"Slf4jLoggerDeclaration," +
"SpringMvcAnnotation," +
"StaticImport," +
"StringJoin," +
"TimeZoneUsage"
)
}
val shouldDisableErrorProne = java.toolchain.implementation.orNull == JvmImplementation.J9
if (name == "compileJava" && !shouldDisableErrorProne) {
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
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assumed this is for the whole block as the block is some kind of pattern here but its a nice trap, assuming the comment only regards to AnnotateFormatMethod.

"AnnotateFormatMethod",
"AnnotateFormatMethod", // We don't want to use ErrorProne's annotations.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inline this is an clear intent and not an obsolete question.

"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.
"DirectReturn", // https://github.com/junit-team/junit-framework/pull/5006#discussion_r2403984446
"DoNotCallSuggester",
"InlineMeSuggester",
"ImmutableEnumChecker",

// 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",
"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.
// might consider: https://error-prone.picnic.tech
"AddNullMarkedToPackageInfo",
"AmbiguousJsonCreator",
"AssertJNullnessAssertion",
"AutowiredConstructor",
"CanonicalAnnotationSyntax",
"CanonicalClassNameUsage",
"ClassCastLambdaUsage",
"CollectorMutability",
"ConstantNaming",
"DeadException",
"EagerStringFormatting",
"EmptyMonoZip",
"ExplicitArgumentEnumeration",
"ExplicitEnumOrdering",
"FluxFlatMapUsage",
"FluxImplicitBlock",
"FormatStringConcatenation",
"IdentityConversion",
"ImmutablesSortedSetComparator",
"IsInstanceLambdaUsage",
"JUnitClassModifiers",
"JUnitMethodDeclaration",
"JUnitNullaryParameterizedTestDeclaration",
"JUnitValueSource",
"LexicographicalAnnotationAttributeListing",
"LexicographicalAnnotationListing",
"MockitoMockClassReference",
"MockitoStubbing",
"NestedOptionals",
"NestedPublishers",
"NonEmptyMono",
"NonStaticImport",
"OptionalOrElseGet",
"PrimitiveComparison",
"RequestMappingAnnotation",
"Slf4jLogStatement",
"Slf4jLoggerDeclaration",
"StaticImport",
"TimeZoneUsage",
)
error("PackageLocation")
} else {
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());
Copy link
Author

@Pankraz76 Pankraz76 Oct 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assuming RedundantStringEscape is the fix.

sb.append(stackTraceElement);
}
sb.append(NL);
}
Expand Down