From efd3a9a002f945c2627dabae43f23c14312820da Mon Sep 17 00:00:00 2001 From: Vincent Koeman Date: Fri, 6 Oct 2023 17:45:28 +0200 Subject: [PATCH] suppress warning and fix an occurence --- .../picnic/errorprone/refasterrules/JUnitRules.java | 1 + .../bugpatterns/JUnitSingleArgumentsTest.java | 4 ++-- .../bugpatterns/util/MethodMatcherFactoryTest.java | 12 +++++------- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/JUnitRules.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/JUnitRules.java index 218213ab9a..e64e3adeb6 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/JUnitRules.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/JUnitRules.java @@ -23,6 +23,7 @@ Arguments before(@Repeated T objects) { } @AfterTemplate + @SuppressWarnings("JUnitSingleArguments" /* The bugpattern does not understand Repeated. */) @UseImportPolicy(STATIC_IMPORT_ALWAYS) Arguments after(@Repeated T objects) { return arguments(objects); diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/JUnitSingleArgumentsTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/JUnitSingleArgumentsTest.java index 88535276e2..46ac2678b8 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/JUnitSingleArgumentsTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/JUnitSingleArgumentsTest.java @@ -9,8 +9,8 @@ void identification() { CompilationTestHelper.newInstance(JUnitSingleArguments.class, getClass()) .addSourceLines( "A.java", - "import static java.util.function.Function.identity;", "import static java.util.Objects.requireNonNull;", + "import static java.util.function.Function.identity;", "import static org.junit.jupiter.params.provider.Arguments.arguments;", "", "class A {", @@ -20,7 +20,7 @@ void identification() { " // BUG: Diagnostic contains:", " arguments(1);", " arguments(1,2);", - " ", + "", " identity();", " requireNonNull(null);", " }", diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/util/MethodMatcherFactoryTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/util/MethodMatcherFactoryTest.java index 2e06f291aa..bd762f6c4c 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/util/MethodMatcherFactoryTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/util/MethodMatcherFactoryTest.java @@ -2,7 +2,6 @@ import static com.google.errorprone.BugPattern.SeverityLevel.SUGGESTION; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.jupiter.params.provider.Arguments.arguments; import com.google.common.collect.ImmutableList; import com.google.errorprone.BugPattern; @@ -17,7 +16,6 @@ import java.util.stream.Stream; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; final class MethodMatcherFactoryTest { @@ -29,13 +27,13 @@ final class MethodMatcherFactoryTest { "com.example.A#m2(java.lang.String)", "com.example.sub.B#m3(int,int)")); - private static Stream createWithMalformedSignaturesTestCases() { + private static Stream> createWithMalformedSignaturesTestCases() { /* { signatures } */ return Stream.of( - arguments(ImmutableList.of("foo.bar")), - arguments(ImmutableList.of("foo.bar#baz")), - arguments(ImmutableList.of("a", "foo.bar#baz()")), - arguments(ImmutableList.of("foo.bar#baz()", "a"))); + ImmutableList.of("foo.bar"), + ImmutableList.of("foo.bar#baz"), + ImmutableList.of("a", "foo.bar#baz()"), + ImmutableList.of("foo.bar#baz()", "a")); } @MethodSource("createWithMalformedSignaturesTestCases")