11import junitbuild.extensions.dependencyFromLibs
22import net.ltgt.gradle.errorprone.errorprone
33import net.ltgt.gradle.nullaway.nullaway
4+ import java.lang.System.getenv
45
56plugins {
67 `java- library`
@@ -9,8 +10,10 @@ plugins {
910}
1011
1112dependencies {
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 {
@@ -27,29 +30,270 @@ nullaway {
2730
2831tasks.withType<JavaCompile >().configureEach {
2932 options.errorprone {
33+ disableWarningsInGeneratedCode = true
34+ errorproneArgs.add(" -XepOpt:Refaster:NamePattern=^(?!.*Rules\\ $).*" ) // might consider.
35+ if (getenv(" IN_PLACE" ).toBoolean()) {
36+ errorproneArgs.addAll(
37+ " -XepPatchLocation:IN_PLACE" , // why only certain picnic rules apply?
38+ " -XepPatchChecks:" +
39+ " AddNullMarkedToPackageInfo," +
40+ " AlwaysThrows," +
41+ " AmbiguousJsonCreator," +
42+ " AndroidInjectionBeforeSuper," +
43+ " ArrayEquals," +
44+ " ArrayFillIncompatibleType," +
45+ " ArrayHashCode," +
46+ " ArrayToString," +
47+ " ArraysAsListPrimitiveArray," +
48+ " AssertJNullnessAssertion," +
49+ " AsyncCallableReturnsNull," +
50+ " AsyncFunctionReturnsNull," +
51+ " AutoValueBuilderDefaultsInConstructor," +
52+ " AutoValueConstructorOrderChecker," +
53+ " AutowiredConstructor," +
54+ " BadAnnotationImplementation," +
55+ " BadShiftAmount," +
56+ " BanJNDI," +
57+ " BoxedPrimitiveEquality," +
58+ " BundleDeserializationCast," +
59+ " CanonicalAnnotationSyntax," +
60+ " CanonicalClassNameUsage," +
61+ " ChainingConstructorIgnoresParameter," +
62+ " CheckNotNullMultipleTimes," +
63+ " CheckReturnValue," +
64+ " ClassCastLambdaUsage," +
65+ " CollectionIncompatibleType," +
66+ " CollectionToArraySafeParameter," +
67+ " CollectorMutability," +
68+ " ComparableType," +
69+ " ComparingThisWithNull," +
70+ " ComparisonOutOfRange," +
71+ " CompatibleWithAnnotationMisuse," +
72+ " CompileTimeConstant," +
73+ " ComputeIfAbsentAmbiguousReference," +
74+ " ConditionalExpressionNumericPromotion," +
75+ " ConstantNaming," +
76+ " ConstantOverflow," +
77+ " DaggerProvidesNull," +
78+ " DangerousLiteralNull," +
79+ " DeadException," +
80+ " DeadThread," +
81+ " DefaultCharset," +
82+ " DereferenceWithNullBranch," +
83+ " DiscardedPostfixExpression," +
84+ " DoNotCall," +
85+ " DoNotMock," +
86+ " DoubleBraceInitialization," +
87+ " DuplicateMapKeys," +
88+ " DurationFrom," +
89+ " DurationGetTemporalUnit," +
90+ " DurationTemporalUnit," +
91+ " DurationToLongTimeUnit," +
92+ " EagerStringFormatting," +
93+ " EmptyMethod," +
94+ " EmptyMonoZip," +
95+ " EqualsHashCode," +
96+ " EqualsNaN," +
97+ " EqualsNull," +
98+ " EqualsReference," +
99+ " EqualsWrongThing," +
100+ " ExplicitArgumentEnumeration," +
101+ " ExplicitEnumOrdering," +
102+ " FloggerFormatString," +
103+ " FloggerLogString," +
104+ " FloggerLogVarargs," +
105+ " FloggerSplitLogStatement," +
106+ " FluxFlatMapUsage," +
107+ " FluxImplicitBlock," +
108+ " ForOverride," +
109+ " FormatString," +
110+ " FormatStringAnnotation," +
111+ " FormatStringConcatenation," +
112+ " FromTemporalAccessor," +
113+ " FunctionalInterfaceMethodChanged," +
114+ " FuturesGetCheckedIllegalExceptionType," +
115+ " FuzzyEqualsShouldNotBeUsedInEqualsMethod," +
116+ " GetClassOnAnnotation," +
117+ " GetClassOnClass," +
118+ " GuardedBy," +
119+ " GuiceAssistedInjectScoping," +
120+ " GuiceAssistedParameters," +
121+ " GuiceInjectOnFinalField," +
122+ " HashtableContains," +
123+ " IdentityBinaryExpression," +
124+ " IdentityConversion," +
125+ " IdentityHashMapBoxing," +
126+ " Immutable," +
127+ " ImmutableEnumChecker," +
128+ " ImmutablesSortedSetComparator," +
129+ " ImpossibleNullComparison," +
130+ " Incomparable," +
131+ " IncompatibleArgumentType," +
132+ " IncompatibleModifiers," +
133+ " IndexOfChar," +
134+ " InexactVarargsConditional," +
135+ " InfiniteRecursion," +
136+ " InjectMoreThanOneScopeAnnotationOnClass," +
137+ " InjectOnMemberAndConstructor," +
138+ " InlineMeValidator," +
139+ " InstantTemporalUnit," +
140+ " InvalidJavaTimeConstant," +
141+ " InvalidPatternSyntax," +
142+ " InvalidTimeZoneID," +
143+ " InvalidZoneId," +
144+ " IsInstanceIncompatibleType," +
145+ " IsInstanceLambdaUsage," +
146+ " IsInstanceOfClass," +
147+ " IsLoggableTagLength," +
148+ " JUnit3TestNotRun," +
149+ " JUnit4ClassAnnotationNonStatic," +
150+ " JUnit4SetUpNotRun," +
151+ " JUnit4TearDownNotRun," +
152+ " JUnit4TestNotRun," +
153+ " JUnit4TestsNotRunWithinEnclosed," +
154+ " JUnitAssertSameCheck," +
155+ " JUnitClassModifiers," +
156+ " JUnitMethodDeclaration," +
157+ " JUnitNullaryParameterizedTestDeclaration," +
158+ " JUnitParameterMethodNotFound," +
159+ " JUnitValueSource," +
160+ " JavaxInjectOnAbstractMethod," +
161+ " JodaToSelf," +
162+ " LenientFormatStringValidation," +
163+ " LexicographicalAnnotationAttributeListing," +
164+ " LexicographicalAnnotationListing," +
165+ " LiteByteStringUtf8," +
166+ " LocalDateTemporalAmount," +
167+ " LockOnBoxedPrimitive," +
168+ " LoopConditionChecker," +
169+ " LossyPrimitiveCompare," +
170+ " MathRoundIntLong," +
171+ " MislabeledAndroidString," +
172+ " MisleadingEmptyVarargs," +
173+ " MisleadingEscapedSpace," +
174+ " MisplacedScopeAnnotations," +
175+ " MissingOverride," +
176+ " MissingSuperCall," +
177+ " MissingTestCall," +
178+ " MisusedDayOfYear," +
179+ " MisusedWeekYear," +
180+ " MixedDescriptors," +
181+ " MockitoMockClassReference," +
182+ " MockitoStubbing," +
183+ " MockitoUsage," +
184+ " ModifyingCollectionWithItself," +
185+ " MongoDBTextFilterUsage," +
186+ " MoreThanOneInjectableConstructor," +
187+ " MustBeClosedChecker," +
188+ " NCopiesOfChar," +
189+ " NestedOptionals," +
190+ " NestedPublishers," +
191+ " NoCanIgnoreReturnValueOnClasses," +
192+ " NonCanonicalStaticImport," +
193+ " NonEmptyMono," +
194+ " NonFinalCompileTimeConstant," +
195+ " NonRuntimeAnnotation," +
196+ " NonStaticImport," +
197+ " NullArgumentForNonNullParameter," +
198+ " NullTernary," +
199+ " NullableOnContainingClass," +
200+ " OptionalEquality," +
201+ " OptionalMapUnusedValue," +
202+ " OptionalOfRedundantMethod," +
203+ " OptionalOrElseGet," +
204+ " OverlappingQualifierAndScopeAnnotation," +
205+ " OverridesJavaxInjectableMethod," +
206+ " PackageInfo," +
207+ " ParametersButNotParameterized," +
208+ " ParcelableCreator," +
209+ " PeriodFrom," +
210+ " PeriodGetTemporalUnit," +
211+ " PeriodTimeMath," +
212+ " PreconditionsInvalidPlaceholder," +
213+ " PrimitiveComparison," +
214+ " PrivateSecurityContractProtoAccess," +
215+ " ProtoBuilderReturnValueIgnored," +
216+ " ProtoStringFieldReferenceEquality," +
217+ " ProtoTruthMixedDescriptors," +
218+ " ProtocolBufferOrdinal," +
219+ " ProvidesMethodOutsideOfModule," +
220+ " RandomCast," +
221+ " RandomModInteger," +
222+ " RectIntersectReturnValueIgnored," +
223+ " RedundantSetterCall," +
224+ " RedundantStringConversion," +
225+ " RedundantStringEscape," +
226+ " RefasterAnyOfUsage," +
227+ " RequestMappingAnnotation," +
228+ " RequestParamType," +
229+ " RequiredModifiers," +
230+ " RestrictedApi," +
231+ " ReturnValueIgnored," +
232+ " SelfAssertion," +
233+ " SelfAssignment," +
234+ " SelfComparison," +
235+ " SelfEquals," +
236+ " SetUnrecognized," +
237+ " ShouldHaveEvenArgs," +
238+ " SizeGreaterThanOrEqualsZero," +
239+ " Slf4jLogStatement," +
240+ " Slf4jLoggerDeclaration," +
241+ " SpringMvcAnnotation," +
242+ " StaticImport," +
243+ " StreamToString," +
244+ " StringBuilderInitWithChar," +
245+ " StringJoin," +
246+ " StringJoin," +
247+ " SubstringOfZero," +
248+ " SuppressWarningsDeprecated," +
249+ " TemporalAccessorGetChronoField," +
250+ " TestParametersNotInitialized," +
251+ " TheoryButNoTheories," +
252+ " ThreadBuilderNameWithPlaceholder," +
253+ " ThrowIfUncheckedKnownChecked," +
254+ " ThrowNull," +
255+ " TimeZoneUsage," +
256+ " TreeToString," +
257+ " TryFailThrowable," +
258+ " TypeParameterQualifier," +
259+ " UnicodeDirectionalityCharacters," +
260+ " UnicodeInCode," +
261+ " UnnecessaryCheckNotNull," +
262+ " UnnecessaryTypeArgument," +
263+ " UnsafeWildcard," +
264+ " UnusedAnonymousClass," +
265+ " UnusedCollectionModifiedInPlace," +
266+ " VarTypeName," +
267+ " WrongOneof," +
268+ " XorPower," +
269+ " ZoneIdOfZ,"
270+ )
271+ }
30272 val shouldDisableErrorProne = java.toolchain.implementation.orNull == JvmImplementation .J9
31273 if (name == " compileJava" && ! shouldDisableErrorProne) {
32274 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" ,
275+ // error-prone (https://errorprone.info/bugpatterns)
276+ " AnnotateFormatMethod" , // We don't want to use ErrorProne's annotations.
277+ " 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.
278+ " DirectReturn" , // https://github.com/junit-team/junit-framework/pull/5006#discussion_r2403984446
43279 " DoNotCallSuggester" ,
44- " InlineMeSuggester" ,
45280 " 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" ,
281+ " InlineMeSuggester" ,
282+ " MissingSummary" , // Produces a lot of findings that we consider to be false positives, for example for package-private classes and methods.
283+ " StringSplitter" , // We don't want to use Guava.
284+ " UnnecessaryLambda" , // The findings of this check are subjective because a named constant can be more readable in many cases.
285+ // error-prone.picnic (https://error-prone.picnic.tech)
286+ " ConstantNaming" ,
287+ " FormatStringConcatenation" ,
288+ " IdentityConversion" ,
289+ " LexicographicalAnnotationAttributeListing" ,
290+ " LexicographicalAnnotationListing" ,
291+ " NestedOptionals" ,
292+ " NonStaticImport" ,
293+ " OptionalOrElseGet" ,
294+ " PrimitiveComparison" ,
295+ " StaticImport" ,
296+ " TimeZoneUsage" ,
53297 )
54298 error(" PackageLocation" )
55299 } else {
0 commit comments