Skip to content

Commit 6a78616

Browse files
author
Vincent Potucek
committed
Add error-prone.picnic.tech
1 parent 805adad commit 6a78616

File tree

5 files changed

+276
-35
lines changed

5 files changed

+276
-35
lines changed

gradle/libs.versions.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ bndlib = { module = "biz.aQute.bnd:biz.aQute.bndlib", version.ref = "bnd" }
3131
checkstyle = { module = "com.puppycrawl.tools:checkstyle", version.ref = "checkstyle" }
3232
classgraph = { module = "io.github.classgraph:classgraph", version = "4.8.181" }
3333
commons-io = { module = "commons-io:commons-io", version = "2.20.0" }
34-
errorProne-core = { module = "com.google.errorprone:error_prone_core", version = "2.42.0" }
34+
error-prone-core = { module = "com.google.errorprone:error_prone_core", version = "2.42.0" }
35+
error-prone-contrib = { module = "tech.picnic.error-prone-support:error-prone-contrib", version = "0.25.0" }
36+
refaster-runner = { module = "tech.picnic.error-prone-support:refaster-runner", version = "0.25.0" }
3537
fastcsv = { module = "de.siegmar:fastcsv", version = "4.0.0" }
3638
groovy = { module = "org.apache.groovy:groovy", version = "5.0.1" }
3739
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: 263 additions & 19 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,8 +10,10 @@ 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"))
16+
errorprone(dependencyFromLibs("refaster-runner"))
1417
constraints {
1518
errorprone("com.google.guava:guava") {
1619
version {
@@ -27,29 +30,270 @@ nullaway {
2730

2831
tasks.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 {

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
}

junit-platform-console/src/main/java/org/junit/platform/console/options/TestDiscoveryOptionsMixin.java

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -155,22 +155,18 @@ public static class FilterOptions {
155155
+ "When this option is repeated, all patterns will be combined using OR semantics.")
156156
private final List<String> excludeClassNamePatterns = new ArrayList<>();
157157

158-
@Option(names = {
159-
"--include-package" }, paramLabel = "PKG", arity = "1", description = "Provide a package to be included in the test run. This option can be repeated.")
158+
@Option(names = "--include-package", paramLabel = "PKG", arity = "1", description = "Provide a package to be included in the test run. This option can be repeated.")
160159
private final List<String> includePackages = new ArrayList<>();
161160

162-
@Option(names = {
163-
"--exclude-package" }, paramLabel = "PKG", arity = "1", description = "Provide a package to be excluded from the test run. This option can be repeated.")
161+
@Option(names = "--exclude-package", paramLabel = "PKG", arity = "1", description = "Provide a package to be excluded from the test run. This option can be repeated.")
164162
private final List<String> excludePackages = new ArrayList<>();
165163

166-
@Option(names = {
167-
"--include-methodname" }, paramLabel = "PATTERN", arity = "1", description = "Provide a regular expression to include only methods whose fully qualified names without parameters match. " //
168-
+ "When this option is repeated, all patterns will be combined using OR semantics.")
164+
@Option(names = "--include-methodname", paramLabel = "PATTERN", arity = "1", description = "Provide a regular expression to include only methods whose fully qualified names without parameters match. " //
165+
+ "When this option is repeated, all patterns will be combined using OR semantics.")
169166
private final List<String> includeMethodNamePatterns = new ArrayList<>();
170167

171-
@Option(names = {
172-
"--exclude-methodname" }, paramLabel = "PATTERN", arity = "1", description = "Provide a regular expression to exclude those methods whose fully qualified names without parameters match. " //
173-
+ "When this option is repeated, all patterns will be combined using OR semantics.")
168+
@Option(names = "--exclude-methodname", paramLabel = "PATTERN", arity = "1", description = "Provide a regular expression to exclude those methods whose fully qualified names without parameters match. " //
169+
+ "When this option is repeated, all patterns will be combined using OR semantics.")
174170
private final List<String> excludeMethodNamePatterns = new ArrayList<>();
175171

176172
@Option(names = { "-t",
@@ -217,8 +213,7 @@ public static class RuntimeConfigurationOptions {
217213
// Implementation note: the @Option annotation is on a setter method to allow validation.
218214
private final Map<String, String> configurationParameters = new LinkedHashMap<>();
219215

220-
@Option(names = {
221-
"--config-resource" }, paramLabel = "PATH", arity = "1", description = "Set configuration parameters for test discovery and execution via a classpath resource. This option can be repeated.")
216+
@Option(names = "--config-resource", paramLabel = "PATH", arity = "1", description = "Set configuration parameters for test discovery and execution via a classpath resource. This option can be repeated.")
222217
private List<String> configurationParametersResources = new ArrayList<>();
223218

224219
@CommandLine.Spec

junit-platform-launcher/src/main/java/org/junit/platform/launcher/core/EngineExecutionOrchestrator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ void execute(InternalTestPlan internalTestPlan, NamespacedHierarchicalStore<Name
7474
* {@linkplain TestExecutionListener testExecutionListener} of execution
7575
* events.
7676
*/
77-
@API(status = INTERNAL, since = "1.9", consumers = { "org.junit.platform.suite.engine" })
77+
@API(status = INTERNAL, since = "1.9", consumers = "org.junit.platform.suite.engine")
7878
public void execute(LauncherDiscoveryResult discoveryResult, EngineExecutionListener engineExecutionListener,
7979
TestExecutionListener testExecutionListener, NamespacedHierarchicalStore<Namespace> requestLevelStore,
8080
CancellationToken cancellationToken) {
@@ -166,7 +166,7 @@ private void withInterceptedStreams(ConfigurationParameters configurationParamet
166166
* discovery results} and notifies the supplied {@linkplain
167167
* EngineExecutionListener listener} of execution events.
168168
*/
169-
@API(status = INTERNAL, since = "1.7", consumers = { "org.junit.platform.testkit" })
169+
@API(status = INTERNAL, since = "1.7", consumers = "org.junit.platform.testkit")
170170
public void execute(LauncherDiscoveryResult discoveryResult, EngineExecutionListener engineExecutionListener,
171171
NamespacedHierarchicalStore<Namespace> requestLevelStore, CancellationToken cancellationToken) {
172172
Preconditions.notNull(discoveryResult, "discoveryResult must not be null");

0 commit comments

Comments
 (0)