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
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import junitbuild.extensions.dependencyFromLibs
import net.ltgt.gradle.errorprone.errorprone
import net.ltgt.gradle.nullaway.nullaway
import org.gradle.jvm.toolchain.JvmImplementation.J9
import java.lang.System.getenv

plugins {
`java-library`
Expand All @@ -16,27 +18,19 @@ dependencies {

tasks.withType<JavaCompile>().configureEach {
options.errorprone {
val shouldDisableErrorProne = java.toolchain.implementation.orNull == JvmImplementation.J9
if (name == "compileJava" && !shouldDisableErrorProne) {
disable(
"AnnotateFormatMethod", // We don`t want to use ErrorProne's annotations.
"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.
"DoNotCallSuggester", // We don`t want to use ErrorProne's annotations.
"ImmutableEnumChecker", // We don`t want to use ErrorProne's annotations.
"InlineMeSuggester", // We don`t want to use ErrorProne's annotations.
"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.
val enableErrorProne = java.toolchain.implementation.orNull != J9
if (enableErrorProne && name == "compileJava") {
disableAllWarnings = true // considering this immense spam burden, remove this once to fix dedicated flaw. https://github.com/diffplug/spotless/pull/2766
disable( // We don`t want to use ErrorProne's annotations.
// picnic (https://error-prone.picnic.tech)
"ConstantNaming",
"DirectReturn", // We don`t want to use this: https://github.com/junit-team/junit-framework/pull/5006#discussion_r2403984446
"DirectReturn", // We don`t want to use this. https://github.com/junit-team/junit-framework/pull/5006#discussion_r2403984446
"FormatStringConcatenation",
"IdentityConversion",
"LexicographicalAnnotationAttributeListing", // We don`t want to use this: https://github.com/junit-team/junit-framework/pull/5043#pullrequestreview-3330615838
"LexicographicalAnnotationAttributeListing", // We don`t want to use this. https://github.com/junit-team/junit-framework/pull/5043#pullrequestreview-3330615838
"LexicographicalAnnotationListing",
"MissingTestCall",
"NestedOptionals",
"NonStaticImport",
"OptionalOrElseGet",
"PrimitiveComparison",
"StaticImport",
Expand All @@ -45,22 +39,34 @@ tasks.withType<JavaCompile>().configureEach {
error(
"CanonicalAnnotationSyntax",
"IsInstanceLambdaUsage",
"MissingOverride",
"NonStaticImport",
"PackageLocation",
"RedundantStringConversion",
"RedundantStringEscape",
"SelfAssignment",
"StringCharset",
"StringJoin",
)
if (!getenv().containsKey("CI") && getenv("IN_PLACE").toBoolean()) {
errorproneArgs.addAll(
"-XepPatchLocation:IN_PLACE",
"-XepPatchChecks:" +
"NonStaticImport,"
)
}
} else {
disableAllChecks = true
}
nullaway {
if (shouldDisableErrorProne) {
disable()
} else {
if (enableErrorProne) {
enable()
} else {
disable()
}
onlyNullMarked = true
isJSpecifyMode = true
checkContracts = true
isJSpecifyMode = true
onlyNullMarked = true
suppressionNameAliases.add("DataFlowIssue")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
package org.junit.jupiter.params.provider;

import static org.junit.jupiter.params.provider.Arguments.arguments;
import static org.junit.platform.commons.util.ReflectionUtils.newInstance;

import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
Expand All @@ -32,6 +31,7 @@
import org.junit.jupiter.params.support.ParameterDeclarations;
import org.junit.platform.commons.PreconditionViolationException;
import org.junit.platform.commons.util.Preconditions;
import org.junit.platform.commons.util.ReflectionUtils;

/**
* @since 5.4
Expand Down Expand Up @@ -80,7 +80,7 @@ public Stream<? extends Arguments> provideArguments(ParameterDeclarations parame
if (Collection.class.isAssignableFrom(parameterType) || Map.class.isAssignableFrom(parameterType)) {
Optional<Constructor<?>> defaultConstructor = getDefaultConstructor(parameterType);
if (defaultConstructor.isPresent()) {
return Stream.of(arguments(newInstance(defaultConstructor.get())));
return Stream.of(arguments(ReflectionUtils.newInstance(defaultConstructor.get())));
}
}
if (parameterType.isArray()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import static org.junit.platform.commons.support.ReflectionSupport.findMethods;
import static org.junit.platform.commons.support.ReflectionSupport.invokeMethod;
import static org.junit.platform.commons.util.ReflectionUtils.findConstructors;
import static org.junit.platform.commons.util.ReflectionUtils.newInstance;

import java.lang.reflect.Constructor;
import java.lang.reflect.Executable;
Expand All @@ -28,6 +27,7 @@

import org.jspecify.annotations.Nullable;
import org.junit.platform.commons.util.Preconditions;
import org.junit.platform.commons.util.ReflectionUtils;

/**
* {@code FallbackStringToObjectConverter} is a {@link StringToObjectConverter}
Expand Down Expand Up @@ -115,7 +115,7 @@ public boolean canConvertTo(Class<?> targetType) {
}
Constructor<?> constructor = findFactoryConstructor(targetType, parameterType);
if (constructor != null) {
return source -> newInstance(constructor, source);
return source -> ReflectionUtils.newInstance(constructor, source);
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

package org.junit.platform.launcher.tagexpression;

import static java.lang.Integer.MIN_VALUE;
import static java.util.Objects.requireNonNull;
import static org.junit.platform.launcher.tagexpression.Operator.nullaryOperator;
import static org.junit.platform.launcher.tagexpression.ParseStatus.emptyTagExpression;
Expand All @@ -34,7 +33,7 @@ class ShuntingYard {

private static final Operator RightParenthesis = nullaryOperator(")", -1);
private static final Operator LeftParenthesis = nullaryOperator("(", -2);
private static final Operator Sentinel = nullaryOperator("sentinel", MIN_VALUE);
private static final Operator Sentinel = nullaryOperator("sentinel", Integer.MIN_VALUE);
private static final Token SentinelToken = new Token(-1, "");

private final Operators validOperators = new Operators();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

package org.junit.platform.testkit.engine;

import static java.util.Collections.sort;
import static java.util.function.Predicate.isEqual;
import static org.apiguardian.api.API.Status.MAINTAINED;
import static org.junit.platform.commons.util.FunctionUtils.where;
Expand All @@ -22,6 +21,7 @@
import java.io.Writer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
Expand Down Expand Up @@ -457,7 +457,7 @@ private static void assertEventsMatchLooselyInOrder(List<Event> events, Conditio

private static boolean isNotInIncreasingOrder(List<Integer> indices) {
List<Integer> copy = new ArrayList<>(indices);
sort(copy);
Collections.sort(copy);

return !indices.equals(copy);
}
Expand Down