From de71440bb2c8bc407921c862e1d9a4698853c4e4 Mon Sep 17 00:00:00 2001 From: Rick Ossendrijver Date: Mon, 7 Nov 2022 14:55:01 +0100 Subject: [PATCH] Suggestions --- .../bugpatterns/util/MoreJUnitMatchers.java | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/util/MoreJUnitMatchers.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/util/MoreJUnitMatchers.java index be780a49..e3365df8 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/util/MoreJUnitMatchers.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/util/MoreJUnitMatchers.java @@ -34,25 +34,25 @@ import org.jspecify.annotations.Nullable; public final class MoreJUnitMatchers { /** Matches JUnit Jupiter test methods. */ public static final MultiMatcher TEST_METHOD = - annotations( - AT_LEAST_ONE, - anyOf( - isType("org.junit.jupiter.api.Test"), - hasMetaAnnotation("org.junit.jupiter.api.TestTemplate"))); + annotations( + AT_LEAST_ONE, + anyOf( + isType("org.junit.jupiter.api.Test"), + hasMetaAnnotation("org.junit.jupiter.api.TestTemplate"))); /** Matches JUnit Jupiter setup and teardown methods. */ public static final MultiMatcher SETUP_OR_TEARDOWN_METHOD = - annotations( - AT_LEAST_ONE, - anyOf( - isType("org.junit.jupiter.api.AfterAll"), - isType("org.junit.jupiter.api.AfterEach"), - isType("org.junit.jupiter.api.BeforeAll"), - isType("org.junit.jupiter.api.BeforeEach"))); + annotations( + AT_LEAST_ONE, + anyOf( + isType("org.junit.jupiter.api.AfterAll"), + isType("org.junit.jupiter.api.AfterEach"), + isType("org.junit.jupiter.api.BeforeAll"), + isType("org.junit.jupiter.api.BeforeEach"))); /** * Matches methods that have a {@link org.junit.jupiter.params.provider.MethodSource} annotation. */ public static final MultiMatcher HAS_METHOD_SOURCE = - annotations(AT_LEAST_ONE, isType("org.junit.jupiter.params.provider.MethodSource")); + annotations(AT_LEAST_ONE, isType("org.junit.jupiter.params.provider.MethodSource")); private MoreJUnitMatchers() {} @@ -64,7 +64,7 @@ public final class MoreJUnitMatchers { * @return One or more value factory names. */ static ImmutableSet getMethodSourceFactoryNames( - AnnotationTree methodSourceAnnotation, MethodTree method) { + AnnotationTree methodSourceAnnotation, MethodTree method) { String methodName = method.getName().toString(); ExpressionTree value = AnnotationMatcherUtils.getArgument(methodSourceAnnotation, "value"); @@ -73,15 +73,15 @@ public final class MoreJUnitMatchers { } return ((NewArrayTree) value) - .getInitializers().stream() + .getInitializers().stream() .map(name -> toMethodSourceFactoryName(name, methodName)) .collect(toImmutableSet()); } private static String toMethodSourceFactoryName( - @Nullable ExpressionTree tree, String annotatedMethodName) { + @Nullable ExpressionTree tree, String annotatedMethodName) { return requireNonNullElse( - Strings.emptyToNull(ASTHelpers.constValue(tree, String.class)), annotatedMethodName); + Strings.emptyToNull(ASTHelpers.constValue(tree, String.class)), annotatedMethodName); } /** @@ -94,13 +94,13 @@ public final class MoreJUnitMatchers { * {@link Optional#empty()} if there is more than one. */ public static Optional extractSingleFactoryMethodName( - AnnotationTree methodSourceAnnotation) { + AnnotationTree methodSourceAnnotation) { ExpressionTree attributeExpression = - ((AssignmentTree) Iterables.getOnlyElement(methodSourceAnnotation.getArguments())) - .getExpression(); + ((AssignmentTree) Iterables.getOnlyElement(methodSourceAnnotation.getArguments())) + .getExpression(); Type attributeType = ASTHelpers.getType(attributeExpression); return attributeType.getKind() == TypeKind.ARRAY - ? Optional.empty() - : Optional.of(attributeType.stringValue()); + ? Optional.empty() + : Optional.of(attributeType.stringValue()); } }