-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add error-prone.picnic.tech
#5006
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Pankraz76
wants to merge
1
commit into
junit-team:main
Choose a base branch
from
Pankraz76:extend-errorprone
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+114
−21
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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` | ||
|
@@ -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 { | ||
|
@@ -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 | ||
"AnnotateFormatMethod", | ||
"AnnotateFormatMethod", // We don't want to use ErrorProne's annotations. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. assuming |
||
sb.append(stackTraceElement); | ||
} | ||
sb.append(NL); | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
.