Skip to content

Commit afcad28

Browse files
author
Vincent Potucek
committed
Add LexicographicalAnnotationAttributeListing
1 parent 38ab1ee commit afcad28

File tree

22 files changed

+56
-50
lines changed

22 files changed

+56
-50
lines changed

gradle/libs.versions.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ bndlib = { module = "biz.aQute.bnd:biz.aQute.bndlib", version.ref = "bnd" }
3232
checkstyle = { module = "com.puppycrawl.tools:checkstyle", version.ref = "checkstyle" }
3333
classgraph = { module = "io.github.classgraph:classgraph", version = "4.8.184" }
3434
commons-io = { module = "commons-io:commons-io", version = "2.20.0" }
35-
errorProne-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+
error-prone-core = { module = "com.google.errorprone:error_prone_core", version = "2.42.0" }
3637
fastcsv = { module = "de.siegmar:fastcsv", version = "4.1.0" }
3738
groovy = { module = "org.apache.groovy:groovy", version = "5.0.1" }
3839
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: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,49 +9,53 @@ plugins {
99
}
1010

1111
dependencies {
12-
errorprone(dependencyFromLibs("errorProne-core"))
12+
errorprone(dependencyFromLibs("error-prone-contrib"))
13+
errorprone(dependencyFromLibs("error-prone-core"))
1314
errorprone(dependencyFromLibs("nullaway"))
1415
constraints {
1516
errorprone("com.google.guava:guava") {
1617
version {
1718
require("33.4.8-jre")
1819
}
1920
because("Older versions use deprecated methods in sun.misc.Unsafe")
21+
// https://github.com/junit-team/junit-framework/pull/5039#discussion_r2414490581
2022
}
2123
}
2224
}
2325

24-
nullaway {
25-
onlyNullMarked = true
26-
}
27-
2826
tasks.withType<JavaCompile>().configureEach {
2927
options.errorprone {
3028
val shouldDisableErrorProne = java.toolchain.implementation.orNull == JvmImplementation.J9
3129
if (name == "compileJava" && !shouldDisableErrorProne) {
3230
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",
43-
"DoNotCallSuggester",
44-
"InlineMeSuggester",
45-
"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",
31+
"AnnotateFormatMethod", // We don`t want to use ErrorProne's annotations.
32+
"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.
33+
"DoNotCallSuggester", // We don`t want to use ErrorProne's annotations.
34+
"ImmutableEnumChecker", // We don`t want to use ErrorProne's annotations.
35+
"InlineMeSuggester", // We don`t want to use ErrorProne's annotations.
36+
"MissingSummary", // Produces a lot of findings that we consider to be false positives, for example for package-private classes and methods.
37+
"StringSplitter", // We don`t want to use Guava.
38+
"UnnecessaryLambda", // The findings of this check are subjective because a named constant can be more readable in many cases.
39+
// picnic (https://error-prone.picnic.tech)
40+
"ConstantNaming",
41+
"DirectReturn", // https://github.com/junit-team/junit-framework/pull/5006#discussion_r2403984446
42+
"FormatStringConcatenation",
43+
"IdentityConversion",
44+
"LexicographicalAnnotationListing",
45+
"MissingTestCall",
46+
"NestedOptionals",
47+
"NonStaticImport",
48+
"OptionalOrElseGet",
49+
"PrimitiveComparison",
50+
"StaticImport",
51+
"TimeZoneUsage",
52+
)
53+
error(
54+
"LexicographicalAnnotationAttributeListing",
55+
"PackageLocation",
56+
"RedundantStringConversion",
57+
"RedundantStringEscape",
5358
)
54-
error("PackageLocation")
5559
} else {
5660
disableAllChecks = true
5761
}
@@ -61,6 +65,7 @@ tasks.withType<JavaCompile>().configureEach {
6165
} else {
6266
enable()
6367
}
68+
onlyNullMarked = true
6469
isJSpecifyMode = true
6570
customContractAnnotations.add("org.junit.platform.commons.annotation.Contract")
6671
checkContracts = true

junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/execution/InterceptingExecutableInvoker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public void invokeVoid(Method method, @Nullable Object target, ExtensionContext
8989
ExtensionContext extensionContext, ExtensionRegistry extensionRegistry,
9090
ReflectiveInterceptorCall<Method, T> interceptorCall) {
9191

92-
@SuppressWarnings({ "unchecked", "rawtypes" })
92+
@SuppressWarnings({ "rawtypes", "unchecked" })
9393
Optional<Object> optionalTarget = (target instanceof Optional optional ? optional
9494
: Optional.ofNullable(target));
9595
@Nullable

junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/execution/MethodInvocation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public List<Object> getArguments() {
5555
}
5656

5757
@Override
58-
@SuppressWarnings({ "unchecked", "NullAway" })
58+
@SuppressWarnings({ "NullAway", "unchecked" })
5959
public T proceed() {
6060
var actualTarget = this.target.orElse(null);
6161
return (T) MethodReflectionUtils.invoke(this.method, actualTarget, this.arguments);

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-jupiter-engine/src/main/java/org/junit/jupiter/engine/extension/TestInfoParameterResolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public String toString() {
9090
// @formatter:on
9191
}
9292

93-
@SuppressWarnings({ "OptionalAssignedToNull", "NullableOptional" })
93+
@SuppressWarnings({ "NullableOptional", "OptionalAssignedToNull" })
9494
private static @Nullable Object nullSafeGet(@Nullable Optional<?> optional) {
9595
return optional != null ? optional.orElse(null) : null;
9696
}

junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/extension/TimeoutInvocationFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public void close() throws Exception {
7878
@SuppressWarnings("try")
7979
static class SingleThreadExecutorResource extends ExecutorResource {
8080

81-
@SuppressWarnings({ "unused", "ThreadPriorityCheck" })
81+
@SuppressWarnings({ "ThreadPriorityCheck", "unused" })
8282
SingleThreadExecutorResource() {
8383
super(Executors.newSingleThreadScheduledExecutor(runnable -> {
8484
Thread thread = new Thread(runnable, "junit-jupiter-timeout-watcher");

junit-jupiter-params/src/main/java/org/junit/jupiter/params/provider/EnumArgumentsProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ private <E extends Enum<E>> Set<? extends E> getEnumConstants(ParameterDeclarati
6161
return EnumSet.range(from, to);
6262
}
6363

64-
@SuppressWarnings({ "unchecked", "rawtypes" })
64+
@SuppressWarnings({ "rawtypes", "unchecked" })
6565
private <E extends Enum<E>> Class<E> determineEnumClass(ParameterDeclarations parameters, EnumSource enumSource) {
6666
Class enumClass = enumSource.value();
6767
if (enumClass.equals(NullEnum.class)) {

junit-jupiter-params/src/main/java/org/junit/jupiter/params/support/AnnotationConsumerInitializer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ private AnnotationConsumerInitializer() {
4848
/* no-op */
4949
}
5050

51-
@SuppressWarnings({ "unchecked", "rawtypes" })
51+
@SuppressWarnings({ "rawtypes", "unchecked" })
5252
public static <T> T initialize(AnnotatedElement annotatedElement, T annotationConsumerInstance) {
5353
if (annotationConsumerInstance instanceof AnnotationConsumer consumer) {
5454
Class<? extends Annotation> annotationType = findConsumedAnnotationType(annotationConsumerInstance);

junit-platform-commons/src/main/java/org/junit/platform/commons/support/conversion/StringToEnumConverter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public boolean canConvertTo(Class<?> targetType) {
1818
}
1919

2020
@Override
21-
@SuppressWarnings({ "unchecked", "rawtypes" })
21+
@SuppressWarnings({ "rawtypes", "unchecked" })
2222
public Object convert(String source, Class targetType) throws Exception {
2323
return Enum.valueOf(targetType, source);
2424
}

0 commit comments

Comments
 (0)