From 5830d3a1f9d0c82d40c9e83b7ec62acbcb226ea2 Mon Sep 17 00:00:00 2001 From: Pieter Dirk Soels Date: Tue, 15 Mar 2022 12:05:07 +0100 Subject: [PATCH 1/6] Add `ImportPolicy` static import --- .../errorprone/bugpatterns/StaticImportCheck.java | 1 + .../errorprone/bugpatterns/StaticImportCheckTest.java | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/StaticImportCheck.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/StaticImportCheck.java index 6799ae3470..ebedbf1cd6 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/StaticImportCheck.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/StaticImportCheck.java @@ -67,6 +67,7 @@ public final class StaticImportCheck extends BugChecker implements MemberSelectT "com.google.errorprone.BugPattern.LinkType", "com.google.errorprone.BugPattern.SeverityLevel", "com.google.errorprone.BugPattern.StandardTags", + "com.google.errorprone.refaster.ImportPolicy", "com.mongodb.client.model.Accumulators", "com.mongodb.client.model.Aggregates", "com.mongodb.client.model.Filters", diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/StaticImportCheckTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/StaticImportCheckTest.java index 8cae9098fb..95ec6875c0 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/StaticImportCheckTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/StaticImportCheckTest.java @@ -46,6 +46,8 @@ void identification() { "import com.google.common.collect.ImmutableMap;", "import com.google.common.collect.ImmutableMultiset;", "import com.google.common.collect.ImmutableSet;", + "import com.google.errorprone.refaster.ImportPolicy;", + "import com.google.errorprone.refaster.annotation.UseImportPolicy;", "import java.nio.charset.StandardCharsets;", "import java.util.Optional;", "import java.util.function.Predicate;", @@ -97,6 +99,8 @@ void identification() { " Optional.empty();", " }", "", + " // BUG: Diagnostic contains:", + " @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS)", " void toImmutableMultiset() {}", "}") .doTest(); @@ -114,6 +118,8 @@ void replacement() { "import com.google.common.collect.ImmutableSet;", "import com.google.errorprone.BugPattern;", "import com.google.errorprone.BugPattern.SeverityLevel;", + "import com.google.errorprone.refaster.ImportPolicy;", + "import com.google.errorprone.refaster.annotation.UseImportPolicy;", "import java.nio.charset.StandardCharsets;", "import java.util.Objects;", "import java.util.regex.Pattern;", @@ -125,6 +131,7 @@ void replacement() { "import org.springframework.http.MediaType;", "", "class A {", + " @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS)", " void m1() {", " ImmutableMap.toImmutableMap(v -> v, v -> v);", " ImmutableMap.toImmutableMap(v -> v, v -> v);", @@ -195,6 +202,8 @@ void replacement() { "import com.google.common.collect.ImmutableSet;", "import com.google.errorprone.BugPattern;", "import com.google.errorprone.BugPattern.SeverityLevel;", + "import com.google.errorprone.refaster.ImportPolicy;", + "import com.google.errorprone.refaster.annotation.UseImportPolicy;", "import java.nio.charset.StandardCharsets;", "import java.util.Objects;", "import java.util.regex.Pattern;", @@ -206,6 +215,7 @@ void replacement() { "import org.springframework.http.MediaType;", "", "class A {", + " @UseImportPolicy(STATIC_IMPORT_ALWAYS)", " void m1() {", " toImmutableMap(v -> v, v -> v);", " ImmutableMap.toImmutableMap(v -> v, v -> v);", From 816af072d605cf0fe58d09b9a9682e9403c83262 Mon Sep 17 00:00:00 2001 From: Pieter Dirk Soels Date: Tue, 15 Mar 2022 16:41:39 +0100 Subject: [PATCH 2/6] Self apply static import of `ImportPolicy.STATIC_IMPORT_ALWAYS` --- .../AssertJBooleanTemplates.java | 6 +- .../AssertJCharSequenceTemplates.java | 8 +- .../AssertJObjectTemplates.java | 12 +- .../AssertJOptionalTemplates.java | 10 +- .../AssertJStringTemplates.java | 6 +- .../refastertemplates/AssertJTemplates.java | 104 +++++++++--------- .../refastertemplates/AssortedTemplates.java | 4 +- .../ComparatorTemplates.java | 12 +- .../ImmutableListMultimapTemplates.java | 4 +- .../ImmutableListTemplates.java | 6 +- .../ImmutableMapTemplates.java | 4 +- .../ImmutableMultisetTemplates.java | 4 +- .../ImmutableSetMultimapTemplates.java | 4 +- .../ImmutableSetTemplates.java | 4 +- .../ImmutableSortedMultisetTemplates.java | 4 +- .../ImmutableSortedSetTemplates.java | 4 +- .../refastertemplates/JUnitTemplates.java | 4 +- .../refastertemplates/MapEntryTemplates.java | 10 +- .../refastertemplates/MockitoTemplates.java | 6 +- .../refastertemplates/NullTemplates.java | 4 +- .../refastertemplates/OptionalTemplates.java | 5 +- .../refastertemplates/ReactorTemplates.java | 4 +- .../refastertemplates/StreamTemplates.java | 6 +- .../TestNGToAssertJTemplates.java | 78 ++++++------- 24 files changed, 157 insertions(+), 156 deletions(-) diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJBooleanTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJBooleanTemplates.java index 2edea92c63..6f56835c3f 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJBooleanTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJBooleanTemplates.java @@ -1,8 +1,8 @@ package tech.picnic.errorprone.refastertemplates; +import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; import static org.assertj.core.api.Assertions.assertThat; -import com.google.errorprone.refaster.ImportPolicy; import com.google.errorprone.refaster.Refaster; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; @@ -59,7 +59,7 @@ AbstractBooleanAssert before(boolean b) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractBooleanAssert after(boolean b) { return assertThat(b).isTrue(); } @@ -88,7 +88,7 @@ AbstractBooleanAssert before(boolean b) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractBooleanAssert after(boolean b) { return assertThat(b).isFalse(); } diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJCharSequenceTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJCharSequenceTemplates.java index 2d861de2f2..f528b7d285 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJCharSequenceTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJCharSequenceTemplates.java @@ -1,8 +1,8 @@ package tech.picnic.errorprone.refastertemplates; +import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; import static org.assertj.core.api.Assertions.assertThat; -import com.google.errorprone.refaster.ImportPolicy; import com.google.errorprone.refaster.Refaster; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; @@ -21,7 +21,7 @@ void before(CharSequence charSequence) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(CharSequence charSequence) { assertThat(charSequence).isEmpty(); } @@ -36,7 +36,7 @@ static final class AssertThatCharSequenceIsNotEmpty { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractAssert after(CharSequence charSequence) { return assertThat(charSequence).isNotEmpty(); } @@ -49,7 +49,7 @@ static final class AssertThatCharSequenceHasSize { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractAssert after(CharSequence charSequence, int length) { return assertThat(charSequence).hasSize(length); } diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJObjectTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJObjectTemplates.java index e0c1651f33..458a4c2c66 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJObjectTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJObjectTemplates.java @@ -1,8 +1,8 @@ package tech.picnic.errorprone.refastertemplates; +import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; import static org.assertj.core.api.Assertions.assertThat; -import com.google.errorprone.refaster.ImportPolicy; import com.google.errorprone.refaster.Refaster; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; @@ -21,7 +21,7 @@ AbstractBooleanAssert before(S object) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) ObjectAssert after(S object) { return assertThat(object).isInstanceOf(Refaster.clazz()); } @@ -34,7 +34,7 @@ AbstractBooleanAssert before(S object) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) ObjectAssert after(S object) { return assertThat(object).isNotInstanceOf(Refaster.clazz()); } @@ -47,7 +47,7 @@ AbstractBooleanAssert before(S object1, T object2) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) ObjectAssert after(S object1, T object2) { return assertThat(object1).isEqualTo(object2); } @@ -60,7 +60,7 @@ AbstractBooleanAssert before(S object1, T object2) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) ObjectAssert after(S object1, T object2) { return assertThat(object1).isNotEqualTo(object2); } @@ -73,7 +73,7 @@ AbstractStringAssert before(T object, String str) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) ObjectAssert after(T object, String str) { return assertThat(object).hasToString(str); } diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJOptionalTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJOptionalTemplates.java index e9532dacf4..6769749cf5 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJOptionalTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJOptionalTemplates.java @@ -1,8 +1,8 @@ package tech.picnic.errorprone.refastertemplates; +import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; import static org.assertj.core.api.Assertions.assertThat; -import com.google.errorprone.refaster.ImportPolicy; import com.google.errorprone.refaster.Refaster; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; @@ -26,7 +26,7 @@ ObjectAssert before(Optional optional) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractObjectAssert after(Optional optional) { return assertThat(optional).get(); } @@ -53,7 +53,7 @@ static final class AssertThatOptionalIsPresent { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) OptionalAssert after(Optional optional) { return assertThat(optional).isPresent(); } @@ -80,7 +80,7 @@ static final class AssertThatOptionalIsEmpty { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) OptionalAssert after(Optional optional) { return assertThat(optional).isEmpty(); } @@ -122,7 +122,7 @@ AbstractOptionalAssert before(Optional optional, Predicate p } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractObjectAssert after(Optional optional, Predicate predicate) { return assertThat(optional).get().matches(predicate); } diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJStringTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJStringTemplates.java index 30679581e6..221af1b8e9 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJStringTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJStringTemplates.java @@ -1,8 +1,8 @@ package tech.picnic.errorprone.refastertemplates; +import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; import static org.assertj.core.api.Assertions.assertThat; -import com.google.errorprone.refaster.ImportPolicy; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; import com.google.errorprone.refaster.annotation.UseImportPolicy; @@ -31,7 +31,7 @@ void before(String string) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(String string) { assertThat(string).isEmpty(); } @@ -56,7 +56,7 @@ static final class AssertThatStringIsNotEmpty { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractAssert after(String string) { return assertThat(string).isNotEmpty(); } diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJTemplates.java index 82913fc248..831fbc1e02 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssertJTemplates.java @@ -1,5 +1,6 @@ package tech.picnic.errorprone.refastertemplates; +import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; import static org.assertj.core.api.Assertions.assertThat; import com.google.common.collect.ImmutableBiMap; @@ -12,7 +13,6 @@ import com.google.common.collect.ImmutableSortedSet; import com.google.common.collect.Iterables; import com.google.common.collect.Multiset; -import com.google.errorprone.refaster.ImportPolicy; import com.google.errorprone.refaster.Refaster; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; @@ -137,7 +137,7 @@ AbstractDoubleAssert before(OptionalDouble optional, double expected) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) OptionalDoubleAssert after(OptionalDouble optional, double expected) { return assertThat(optional).hasValue(expected); } @@ -156,7 +156,7 @@ AbstractIntegerAssert before(OptionalInt optional, int expected) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) OptionalIntAssert after(OptionalInt optional, int expected) { return assertThat(optional).hasValue(expected); } @@ -175,7 +175,7 @@ AbstractLongAssert before(OptionalLong optional, long expected) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) OptionalLongAssert after(OptionalLong optional, long expected) { return assertThat(optional).hasValue(expected); } @@ -365,7 +365,7 @@ ObjectEnumerableAssert before(Set set, T element) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) ObjectEnumerableAssert after(Set set, T element) { return assertThat(set).containsExactly(element); } @@ -430,7 +430,7 @@ void before(Collection iterable) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(Collection iterable) { assertThat(iterable).isEmpty(); } @@ -454,7 +454,7 @@ static final class AssertThatIterableIsNotEmpty { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) IterableAssert after(Iterable iterable) { return assertThat(iterable).isNotEmpty(); } @@ -472,7 +472,7 @@ AbstractIntegerAssert before(Collection iterable, int length) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) IterableAssert after(Iterable iterable, int length) { return assertThat(iterable).hasSize(length); } @@ -485,7 +485,7 @@ ObjectAssert before(Iterable iterable, T element) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) IterableAssert after(Iterable iterable, T element) { return assertThat(iterable).containsExactly(element); } @@ -502,7 +502,7 @@ AbstractComparableAssert before(Iterable iterable, T element) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) IterableAssert after(Iterable iterable, T element) { return assertThat(iterable).containsExactly(element); } @@ -519,7 +519,7 @@ ListAssert before(List list1, List list2) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) ListAssert after(List list1, List list2) { return assertThat(list1).containsExactlyElementsOf(list2); } @@ -538,7 +538,7 @@ static final class AssertThatSetsAreEqual { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractCollectionAssert after(Set set1, Set set2) { return assertThat(set1).hasSameElementsAs(set2); } @@ -555,7 +555,7 @@ static final class AssertThatMultisetsAreEqual { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) AbstractCollectionAssert after(Multiset multiset1, Multiset multiset2) { return assertThat(multiset1).containsExactlyInAnyOrderElementsOf(multiset2); } @@ -633,7 +633,7 @@ void before2(Map map) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(Map map) { assertThat(map).isEmpty(); } @@ -670,7 +670,7 @@ static final class AssertThatMapIsNotEmpty2 { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) MapAssert after(Map map) { return assertThat(map).isNotEmpty(); } @@ -685,7 +685,7 @@ static final class AssertThatMapHasSize { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) MapAssert after(Map map, int length) { return assertThat(map).hasSize(length); } @@ -699,7 +699,7 @@ static final class AssertThatMapsHaveSameSize { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) MapAssert after(Map map1, Map map2) { return assertThat(map1).hasSameSizeAs(map2); } @@ -713,7 +713,7 @@ AbstractBooleanAssert before(Map map, K key) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) MapAssert after(Map map, K key) { return assertThat(map).containsKey(key); } @@ -726,7 +726,7 @@ AbstractBooleanAssert before(Map map, K key) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) MapAssert after(Map map, K key) { return assertThat(map).doesNotContainKey(key); } @@ -739,7 +739,7 @@ ObjectAssert before(Map map, K key, V value) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) MapAssert after(Map map, K key, V value) { return assertThat(map).containsEntry(key, value); } @@ -764,7 +764,7 @@ ListAssert before2( } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) ListAssert after(Stream stream, Iterable iterable) { return assertThat(stream).containsAnyElementsOf(iterable); } @@ -785,7 +785,7 @@ ListAssert before2( } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) ListAssert after(Stream stream, U[] array) { return assertThat(stream).containsAnyOf(array); } @@ -809,7 +809,7 @@ ListAssert before2( @AfterTemplate @SuppressWarnings("ObjectEnumerableContainsOneElement" /* Not a true singleton. */) - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) ListAssert after(Stream stream, @Repeated U elements) { return assertThat(stream).containsAnyOf(elements); } @@ -830,7 +830,7 @@ ListAssert before2( } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) ListAssert after(Stream stream, Iterable iterable) { return assertThat(stream).containsAll(iterable); } @@ -851,7 +851,7 @@ ListAssert before2( } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) ListAssert after(Stream stream, U[] array) { return assertThat(stream).contains(array); } @@ -874,7 +874,7 @@ ListAssert before2( } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) ListAssert after(Stream stream, @Repeated U elements) { return assertThat(stream).contains(elements); } @@ -889,7 +889,7 @@ ListAssert before( } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) ListAssert after(Stream stream, Iterable iterable) { return assertThat(stream).containsExactlyElementsOf(iterable); } @@ -904,7 +904,7 @@ ListAssert before( } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) ListAssert after(Stream stream, U[] array) { return assertThat(stream).containsExactly(array); } @@ -920,7 +920,7 @@ ListAssert before( } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) ListAssert after(Stream stream, @Repeated U elements) { return assertThat(stream).containsExactly(elements); } @@ -942,7 +942,7 @@ ListAssert before( } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) ListAssert after(Stream stream, Iterable iterable) { return assertThat(stream).containsExactlyInAnyOrderElementsOf(iterable); } @@ -963,7 +963,7 @@ ListAssert before( } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) ListAssert after(Stream stream, U[] array) { return assertThat(stream).containsExactlyInAnyOrder(array); } @@ -989,7 +989,7 @@ ListAssert before( @AfterTemplate @SuppressWarnings("ObjectEnumerableContainsExactlyOneElement" /* Not a true singleton. */) - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) ListAssert after(Stream stream, @Repeated U elements) { return assertThat(stream).containsExactlyInAnyOrder(elements); } @@ -1010,7 +1010,7 @@ ListAssert before( } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) ListAssert after(Stream stream, Iterable iterable) { return assertThat(stream).containsSequence(iterable); } @@ -1027,7 +1027,7 @@ ListAssert before( @AfterTemplate @SuppressWarnings("ObjectEnumerableContainsOneElement" /* Not a true singleton. */) - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) ListAssert after(Stream stream, @Repeated U elements) { return assertThat(stream).containsSequence(elements); } @@ -1048,7 +1048,7 @@ ListAssert before( } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) ListAssert after(Stream stream, Iterable iterable) { return assertThat(stream).containsSubsequence(iterable); } @@ -1066,7 +1066,7 @@ ListAssert before( @AfterTemplate @SuppressWarnings("ObjectEnumerableContainsOneElement" /* Not a true singleton. */) - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) ListAssert after(Stream stream, @Repeated U elements) { return assertThat(stream).containsSubsequence(elements); } @@ -1087,7 +1087,7 @@ ListAssert before2( } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) ListAssert after(Stream stream, Iterable iterable) { return assertThat(stream).doesNotContainAnyElementsOf(iterable); } @@ -1108,7 +1108,7 @@ ListAssert before2( } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) ListAssert after(Stream stream, U[] array) { return assertThat(stream).doesNotContain(array); } @@ -1131,7 +1131,7 @@ ListAssert before2( } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) ListAssert after(Stream stream, @Repeated U elements) { return assertThat(stream).doesNotContain(elements); } @@ -1152,7 +1152,7 @@ ListAssert before( } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) ListAssert after(Stream stream, Iterable iterable) { return assertThat(stream).doesNotContainSequence(iterable); } @@ -1170,7 +1170,7 @@ ListAssert before( @AfterTemplate @SuppressWarnings("ObjectEnumerableDoesNotContainOneElement" /* Not a true singleton. */) - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) ListAssert after(Stream stream, @Repeated U elements) { return assertThat(stream).doesNotContainSequence(elements); } @@ -1191,7 +1191,7 @@ ListAssert before2( } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) ListAssert after(Stream stream, Iterable iterable) { return assertThat(stream).hasSameElementsAs(iterable); } @@ -1212,7 +1212,7 @@ ListAssert before2( } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) ListAssert after(Stream stream, U[] array) { return assertThat(stream).containsOnly(array); } @@ -1235,7 +1235,7 @@ ListAssert before2( } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) ListAssert after(Stream stream, @Repeated U elements) { return assertThat(stream).containsOnly(elements); } @@ -1268,7 +1268,7 @@ ListAssert before2( } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) ListAssert after(Stream stream, U[] iterable) { return assertThat(stream).isSubsetOf(iterable); } @@ -1291,7 +1291,7 @@ ListAssert before2( } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) ListAssert after(Stream stream, @Repeated U elements) { return assertThat(stream).isSubsetOf(elements); } @@ -1310,7 +1310,7 @@ void before2(Stream stream, Collector> collector) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(Stream stream) { assertThat(stream).isEmpty(); } @@ -1329,7 +1329,7 @@ void before2(Stream stream, Collector> collector) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(Stream stream) { assertThat(stream).isNotEmpty(); } @@ -1342,7 +1342,7 @@ void before(Stream stream, int size) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(Stream stream, int size) { assertThat(stream).hasSize(size); } @@ -1359,7 +1359,7 @@ void before(Predicate predicate, T object) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(Predicate predicate, T object) { assertThat(predicate).accepts(object); } @@ -1372,7 +1372,7 @@ void before(Predicate predicate, T object) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(Predicate predicate, T object) { assertThat(predicate).rejects(object); } @@ -2213,7 +2213,7 @@ ObjectEnumerableAssert after( // } // // @AfterTemplate - // @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + // @UseImportPolicy(STATIC_IMPORT_ALWAYS) // IterableAssert after(Iterable iterable, E expected) { // return assertThat(iterable).containsExactly(expected); // } diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssortedTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssortedTemplates.java index fefca9707b..ffd4ad3237 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssortedTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/AssortedTemplates.java @@ -3,6 +3,7 @@ import static com.google.common.base.Preconditions.checkElementIndex; import static com.google.common.collect.ImmutableSet.toImmutableSet; import static com.google.common.collect.Sets.toImmutableEnumSet; +import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; import static java.util.Objects.checkIndex; import com.google.common.base.Splitter; @@ -11,7 +12,6 @@ import com.google.common.collect.Iterators; import com.google.common.collect.Sets; import com.google.common.collect.Streams; -import com.google.errorprone.refaster.ImportPolicy; import com.google.errorprone.refaster.Refaster; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; @@ -92,7 +92,7 @@ ImmutableSet before(Stream stream) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) ImmutableSet after(Stream stream) { return stream.collect(toImmutableEnumSet()); } diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ComparatorTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ComparatorTemplates.java index 3a3d837c01..61183071a2 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ComparatorTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ComparatorTemplates.java @@ -1,5 +1,6 @@ package tech.picnic.errorprone.refastertemplates; +import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; import static java.util.Comparator.comparing; import static java.util.Comparator.comparingDouble; import static java.util.Comparator.comparingInt; @@ -11,7 +12,6 @@ import com.google.common.collect.Comparators; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; -import com.google.errorprone.refaster.ImportPolicy; import com.google.errorprone.refaster.Refaster; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; @@ -38,7 +38,7 @@ Comparator before() { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) Comparator after() { return naturalOrder(); } @@ -52,7 +52,7 @@ Comparator before() { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) Comparator after() { return reverseOrder(); } @@ -66,7 +66,7 @@ Comparator before(Comparator cmp) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) Comparator after(Comparator cmp) { return cmp; } @@ -93,7 +93,7 @@ Comparator before(Comparator cmp, Function functio } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) Comparator after(Comparator cmp, Function function) { return cmp.thenComparing(function, reverseOrder()); } @@ -180,7 +180,7 @@ Comparator before(Comparator cmp) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) Comparator after(Comparator cmp) { return cmp.thenComparing(naturalOrder()); } diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableListMultimapTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableListMultimapTemplates.java index 61b39db642..78c5960871 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableListMultimapTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableListMultimapTemplates.java @@ -2,6 +2,7 @@ import static com.google.common.collect.ImmutableListMultimap.flatteningToImmutableListMultimap; import static com.google.common.collect.ImmutableListMultimap.toImmutableListMultimap; +import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; import static java.util.function.Function.identity; import com.google.common.collect.ImmutableListMultimap; @@ -12,7 +13,6 @@ import com.google.common.collect.SetMultimap; import com.google.common.collect.SortedSetMultimap; import com.google.common.collect.Streams; -import com.google.errorprone.refaster.ImportPolicy; import com.google.errorprone.refaster.Refaster; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; @@ -161,7 +161,7 @@ ImmutableListMultimap before(Stream stream) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) ImmutableListMultimap after(Stream stream) { return stream.collect(toImmutableListMultimap(e -> keyFunction(e), e -> valueFunction(e))); } diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableListTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableListTemplates.java index c6f6c3bbc1..a7aaf0c316 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableListTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableListTemplates.java @@ -2,6 +2,7 @@ import static com.google.common.collect.ImmutableList.toImmutableList; import static com.google.common.collect.ImmutableSet.toImmutableSet; +import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; import static java.util.Comparator.naturalOrder; import static java.util.stream.Collectors.collectingAndThen; import static java.util.stream.Collectors.toList; @@ -9,7 +10,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Streams; -import com.google.errorprone.refaster.ImportPolicy; import com.google.errorprone.refaster.Refaster; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; @@ -122,7 +122,7 @@ ImmutableList before(Stream stream) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) ImmutableList after(Stream stream) { return stream.collect(toImmutableList()); } @@ -181,7 +181,7 @@ ImmutableList before(Stream stream) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) ImmutableList after(Stream stream) { return stream.collect(toImmutableSet()).asList(); } diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableMapTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableMapTemplates.java index 9c307a8e3a..2fd5b5390c 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableMapTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableMapTemplates.java @@ -1,12 +1,12 @@ package tech.picnic.errorprone.refastertemplates; import static com.google.common.collect.ImmutableMap.toImmutableMap; +import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; import static java.util.function.Function.identity; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import com.google.common.collect.Streams; -import com.google.errorprone.refaster.ImportPolicy; import com.google.errorprone.refaster.Refaster; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; @@ -178,7 +178,7 @@ ImmutableMap before(Stream stream) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) ImmutableMap after(Stream stream) { return stream.collect(toImmutableMap(e -> keyFunction(e), e -> valueFunction(e))); } diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableMultisetTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableMultisetTemplates.java index adb6a0f5e3..65883602c0 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableMultisetTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableMultisetTemplates.java @@ -1,12 +1,12 @@ package tech.picnic.errorprone.refastertemplates; import static com.google.common.collect.ImmutableMultiset.toImmutableMultiset; +import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; import static java.util.stream.Collectors.collectingAndThen; import static java.util.stream.Collectors.toList; import com.google.common.collect.ImmutableMultiset; import com.google.common.collect.Streams; -import com.google.errorprone.refaster.ImportPolicy; import com.google.errorprone.refaster.Refaster; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; @@ -96,7 +96,7 @@ ImmutableMultiset before(Stream stream) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) ImmutableMultiset after(Stream stream) { return stream.collect(toImmutableMultiset()); } diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableSetMultimapTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableSetMultimapTemplates.java index 01f4b5488f..fa4251e82a 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableSetMultimapTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableSetMultimapTemplates.java @@ -2,6 +2,7 @@ import static com.google.common.collect.ImmutableSetMultimap.flatteningToImmutableSetMultimap; import static com.google.common.collect.ImmutableSetMultimap.toImmutableSetMultimap; +import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; import com.google.common.collect.ImmutableSetMultimap; import com.google.common.collect.ListMultimap; @@ -10,7 +11,6 @@ import com.google.common.collect.SetMultimap; import com.google.common.collect.SortedSetMultimap; import com.google.common.collect.Streams; -import com.google.errorprone.refaster.ImportPolicy; import com.google.errorprone.refaster.Refaster; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; @@ -138,7 +138,7 @@ ImmutableSetMultimap before(Stream stream) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) ImmutableSetMultimap after(Stream stream) { return stream.collect(toImmutableSetMultimap(e -> keyFunction(e), e -> valueFunction(e))); } diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableSetTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableSetTemplates.java index f2391b9cd5..7e19377eaa 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableSetTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableSetTemplates.java @@ -1,6 +1,7 @@ package tech.picnic.errorprone.refastertemplates; import static com.google.common.collect.ImmutableSet.toImmutableSet; +import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; import static java.util.stream.Collectors.collectingAndThen; import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toSet; @@ -8,7 +9,6 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets.SetView; import com.google.common.collect.Streams; -import com.google.errorprone.refaster.ImportPolicy; import com.google.errorprone.refaster.Refaster; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; @@ -120,7 +120,7 @@ ImmutableSet before(Stream stream) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) ImmutableSet after(Stream stream) { return stream.collect(toImmutableSet()); } diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableSortedMultisetTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableSortedMultisetTemplates.java index bee7a13f89..f3006b5d90 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableSortedMultisetTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableSortedMultisetTemplates.java @@ -1,6 +1,7 @@ package tech.picnic.errorprone.refastertemplates; import static com.google.common.collect.ImmutableSortedMultiset.toImmutableSortedMultiset; +import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; import static java.util.Comparator.naturalOrder; import static java.util.stream.Collectors.collectingAndThen; import static java.util.stream.Collectors.toList; @@ -8,7 +9,6 @@ import com.google.common.collect.ImmutableMultiset; import com.google.common.collect.ImmutableSortedMultiset; import com.google.common.collect.Streams; -import com.google.errorprone.refaster.ImportPolicy; import com.google.errorprone.refaster.Refaster; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; @@ -140,7 +140,7 @@ ImmutableSortedMultiset before(Stream stream) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) ImmutableSortedMultiset after(Stream stream) { return stream.collect(toImmutableSortedMultiset(naturalOrder())); } diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableSortedSetTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableSortedSetTemplates.java index 574710233b..6a888984b8 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableSortedSetTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ImmutableSortedSetTemplates.java @@ -1,6 +1,7 @@ package tech.picnic.errorprone.refastertemplates; import static com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet; +import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; import static java.util.Comparator.naturalOrder; import static java.util.stream.Collectors.collectingAndThen; import static java.util.stream.Collectors.toList; @@ -8,7 +9,6 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSortedSet; import com.google.common.collect.Streams; -import com.google.errorprone.refaster.ImportPolicy; import com.google.errorprone.refaster.Refaster; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; @@ -140,7 +140,7 @@ ImmutableSortedSet before(Stream stream) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) ImmutableSortedSet after(Stream stream) { return stream.collect(toImmutableSortedSet(naturalOrder())); } diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/JUnitTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/JUnitTemplates.java index 393b5843c7..3386787e95 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/JUnitTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/JUnitTemplates.java @@ -1,8 +1,8 @@ package tech.picnic.errorprone.refastertemplates; +import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; import static org.junit.jupiter.params.provider.Arguments.arguments; -import com.google.errorprone.refaster.ImportPolicy; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; import com.google.errorprone.refaster.annotation.Repeated; @@ -21,7 +21,7 @@ Arguments before(@Repeated T objects) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) Arguments after(@Repeated T objects) { return arguments(objects); } diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/MapEntryTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/MapEntryTemplates.java index 3c29b0f303..d01d621563 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/MapEntryTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/MapEntryTemplates.java @@ -1,12 +1,12 @@ package tech.picnic.errorprone.refastertemplates; +import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; import static java.util.Comparator.comparing; import static java.util.Comparator.naturalOrder; import static java.util.Map.Entry.comparingByKey; import static java.util.Map.Entry.comparingByValue; import com.google.common.collect.Maps; -import com.google.errorprone.refaster.ImportPolicy; import com.google.errorprone.refaster.Refaster; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; @@ -51,7 +51,7 @@ Comparator> before() { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) Comparator> after() { return comparingByKey(); } @@ -65,7 +65,7 @@ Comparator> before(Comparator cmp) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) Comparator> after(Comparator cmp) { return comparingByKey(cmp); } @@ -80,7 +80,7 @@ Comparator> before() { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) Comparator> after() { return comparingByValue(); } @@ -94,7 +94,7 @@ Comparator> before(Comparator cmp) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) Comparator> after(Comparator cmp) { return comparingByValue(cmp); } diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/MockitoTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/MockitoTemplates.java index de1852e98e..3b67c27046 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/MockitoTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/MockitoTemplates.java @@ -1,10 +1,10 @@ package tech.picnic.errorprone.refastertemplates; +import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; import static org.mockito.Mockito.never; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -import com.google.errorprone.refaster.ImportPolicy; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; import com.google.errorprone.refaster.annotation.UseImportPolicy; @@ -26,7 +26,7 @@ VerificationMode before() { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) VerificationMode after() { return never(); } @@ -43,7 +43,7 @@ T before(T mock) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) T after(T mock) { return verify(mock); } diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/NullTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/NullTemplates.java index a4aee0b232..c719a4592c 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/NullTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/NullTemplates.java @@ -1,9 +1,9 @@ package tech.picnic.errorprone.refastertemplates; +import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; import static java.util.Objects.requireNonNullElse; import com.google.common.base.MoreObjects; -import com.google.errorprone.refaster.ImportPolicy; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; import com.google.errorprone.refaster.annotation.UseImportPolicy; @@ -24,7 +24,7 @@ T before(T first, T second) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) T after(T first, T second) { return requireNonNullElse(first, second); } diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/OptionalTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/OptionalTemplates.java index 1dc598171a..1945e9cd4d 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/OptionalTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/OptionalTemplates.java @@ -1,7 +1,8 @@ package tech.picnic.errorprone.refastertemplates; +import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; + import com.google.common.collect.Streams; -import com.google.errorprone.refaster.ImportPolicy; import com.google.errorprone.refaster.Refaster; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; @@ -103,7 +104,7 @@ Optional before(Iterator it) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) Optional after(Iterator it) { return Streams.stream(it).findFirst(); } diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ReactorTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ReactorTemplates.java index 74143680cb..9f329d1935 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ReactorTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/ReactorTemplates.java @@ -1,9 +1,9 @@ package tech.picnic.errorprone.refastertemplates; import static com.google.common.collect.MoreCollectors.toOptional; +import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; import com.google.common.collect.MoreCollectors; -import com.google.errorprone.refaster.ImportPolicy; import com.google.errorprone.refaster.Refaster; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; @@ -217,7 +217,7 @@ Mono> before(Mono mono) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) Mono> after(Mono mono) { return mono.flux().collect(toOptional()); } diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/StreamTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/StreamTemplates.java index ba0003eee9..bbe281770a 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/StreamTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/StreamTemplates.java @@ -1,11 +1,11 @@ package tech.picnic.errorprone.refastertemplates; +import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; import static java.util.Comparator.naturalOrder; import static java.util.Comparator.reverseOrder; import static java.util.function.Predicate.not; import com.google.common.collect.Streams; -import com.google.errorprone.refaster.ImportPolicy; import com.google.errorprone.refaster.Refaster; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; @@ -216,7 +216,7 @@ Optional before(Stream stream) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) Optional after(Stream stream) { return stream.min(naturalOrder()); } @@ -242,7 +242,7 @@ Optional before(Stream stream) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) Optional after(Stream stream) { return stream.max(naturalOrder()); } diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/TestNGToAssertJTemplates.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/TestNGToAssertJTemplates.java index d14296b117..4c9e79dd77 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/TestNGToAssertJTemplates.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/TestNGToAssertJTemplates.java @@ -1,5 +1,6 @@ package tech.picnic.errorprone.refastertemplates; +import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.fail; @@ -17,7 +18,6 @@ import com.google.common.collect.ImmutableList; import com.google.errorprone.annotations.DoNotCall; -import com.google.errorprone.refaster.ImportPolicy; import com.google.errorprone.refaster.annotation.AfterTemplate; import com.google.errorprone.refaster.annotation.BeforeTemplate; import com.google.errorprone.refaster.annotation.UseImportPolicy; @@ -96,7 +96,7 @@ void before(String message) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(String message) { fail(message); } @@ -110,7 +110,7 @@ void before(String message, Throwable throwable) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(String message, Throwable throwable) { fail(message, throwable); } @@ -123,7 +123,7 @@ void before(boolean condition) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(boolean condition) { assertThat(condition).isTrue(); } @@ -136,7 +136,7 @@ void before(boolean condition, String message) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(boolean condition, String message) { assertThat(condition).withFailMessage(message).isTrue(); } @@ -149,7 +149,7 @@ void before(boolean condition) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(boolean condition) { assertThat(condition).isFalse(); } @@ -162,7 +162,7 @@ void before(boolean condition, String message) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(boolean condition, String message) { assertThat(condition).withFailMessage(message).isFalse(); } @@ -175,7 +175,7 @@ void before(Object object) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(Object object) { assertThat(object).isNull(); } @@ -188,7 +188,7 @@ void before(Object object, String message) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(Object object, String message) { assertThat(object).withFailMessage(message).isNull(); } @@ -201,7 +201,7 @@ void before(Object object) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(Object object) { assertThat(object).isNotNull(); } @@ -214,7 +214,7 @@ void before(Object object, String message) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(Object object, String message) { assertThat(object).withFailMessage(message).isNotNull(); } @@ -227,7 +227,7 @@ void before(Object actual, Object expected) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(Object actual, Object expected) { assertThat(actual).isSameAs(expected); } @@ -240,7 +240,7 @@ void before(Object actual, Object expected, String message) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(Object actual, Object expected, String message) { assertThat(actual).withFailMessage(message).isSameAs(expected); } @@ -253,7 +253,7 @@ void before(Object actual, Object expected) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(Object actual, Object expected) { assertThat(actual).isNotSameAs(expected); } @@ -266,7 +266,7 @@ void before(Object actual, Object expected, String message) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(Object actual, Object expected, String message) { assertThat(actual).withFailMessage(message).isNotSameAs(expected); } @@ -329,7 +329,7 @@ void before(Map actual, Map expected) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(Object actual, Object expected) { assertThat(actual).isEqualTo(expected); } @@ -392,7 +392,7 @@ void before(Map actual, Map expected, String message) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(Object actual, Object expected, String message) { assertThat(actual).withFailMessage(message).isEqualTo(expected); } @@ -405,7 +405,7 @@ void before(float actual, float expected, float delta) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(float actual, float expected, float delta) { assertThat(actual).isCloseTo(expected, offset(delta)); } @@ -418,7 +418,7 @@ void before(float actual, float expected, float delta, String message) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(float actual, float expected, float delta, String message) { assertThat(actual).withFailMessage(message).isCloseTo(expected, offset(delta)); } @@ -431,7 +431,7 @@ void before(double actual, double expected, double delta) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(double actual, double expected, double delta) { assertThat(actual).isCloseTo(expected, offset(delta)); } @@ -444,7 +444,7 @@ void before(double actual, double expected, double delta, String message) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(double actual, double expected, double delta, String message) { assertThat(actual).withFailMessage(message).isCloseTo(expected, offset(delta)); } @@ -497,7 +497,7 @@ void before(Object[] actual, Object[] expected) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(Object[] actual, Object[] expected) { assertThat(actual).containsExactly(expected); } @@ -550,7 +550,7 @@ void before(Object[] actual, Object[] expected, String message) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(Object[] actual, Object[] expected, String message) { assertThat(actual).withFailMessage(message).containsExactly(expected); } @@ -563,7 +563,7 @@ void before(Object[] actual, Object[] expected) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(Object[] actual, Object[] expected) { assertThat(actual).containsExactlyInAnyOrder(expected); } @@ -576,7 +576,7 @@ void before(Object[] actual, Object[] expected, String message) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(Object[] actual, Object[] expected, String message) { assertThat(actual).withFailMessage(message).containsExactlyInAnyOrder(expected); } @@ -589,7 +589,7 @@ void before(Iterator actual, Iterator expected) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(Iterator actual, Iterator expected) { // XXX: This is not `null`-safe. // XXX: The `ImmutableList.copyOf` should actually *not* be imported statically. @@ -604,7 +604,7 @@ void before(Iterator actual, Iterator expected, String message) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(Iterator actual, Iterator expected, String message) { // XXX: This is not `null`-safe. // XXX: The `ImmutableList.copyOf` should actually *not* be imported statically. @@ -629,7 +629,7 @@ void before(Collection actual, Collection expected) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(Iterable actual, Iterable expected) { assertThat(actual).containsExactlyElementsOf(expected); } @@ -647,7 +647,7 @@ void before(Collection actual, Collection expected, String message) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(Iterable actual, Iterable expected, String message) { assertThat(actual).withFailMessage(message).containsExactlyElementsOf(expected); } @@ -660,7 +660,7 @@ void before(Set actual, Set expected) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(Set actual, Set expected) { assertThat(actual).hasSameElementsAs(expected); } @@ -673,7 +673,7 @@ void before(Set actual, Set expected, String message) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(Set actual, Set expected, String message) { assertThat(actual).withFailMessage(message).hasSameElementsAs(expected); } @@ -741,7 +741,7 @@ void before(Map actual, Map expected) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(Object actual, Object expected) { assertThat(actual).isNotEqualTo(expected); } @@ -809,7 +809,7 @@ void before(Map actual, Map expected, String message) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(Object actual, Object expected, String message) { assertThat(actual).withFailMessage(message).isNotEqualTo(expected); } @@ -822,7 +822,7 @@ void before(float actual, float expected, float delta) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(float actual, float expected, float delta) { assertThat(actual).isNotCloseTo(expected, offset(delta)); } @@ -835,7 +835,7 @@ void before(float actual, float expected, float delta, String message) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(float actual, float expected, float delta, String message) { assertThat(actual).withFailMessage(message).isNotCloseTo(expected, offset(delta)); } @@ -848,7 +848,7 @@ void before(double actual, double expected, double delta) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(double actual, double expected, double delta) { assertThat(actual).isNotCloseTo(expected, offset(delta)); } @@ -861,7 +861,7 @@ void before(double actual, double expected, double delta, String message) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(double actual, double expected, double delta, String message) { assertThat(actual).withFailMessage(message).isNotCloseTo(expected, offset(delta)); } @@ -874,7 +874,7 @@ void before(ThrowingRunnable runnable) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(ThrowingCallable runnable) { assertThatThrownBy(runnable); } @@ -887,7 +887,7 @@ void before(ThrowingRunnable runnable, Class clazz) { } @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) + @UseImportPolicy(STATIC_IMPORT_ALWAYS) void after(ThrowingCallable runnable, Class clazz) { assertThatThrownBy(runnable).isInstanceOf(clazz); } From f03258b8db9dfd2c401017f9c1e2c26b47d98f58 Mon Sep 17 00:00:00 2001 From: Rick Ossendrijver Date: Thu, 17 Mar 2022 10:13:38 +0100 Subject: [PATCH 3/6] Suggestions for the `StaticImport` tests --- .../bugpatterns/StaticImportCheckTest.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/StaticImportCheckTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/StaticImportCheckTest.java index 95ec6875c0..e8ed66926b 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/StaticImportCheckTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/StaticImportCheckTest.java @@ -47,6 +47,7 @@ void identification() { "import com.google.common.collect.ImmutableMultiset;", "import com.google.common.collect.ImmutableSet;", "import com.google.errorprone.refaster.ImportPolicy;", + "import com.google.errorprone.refaster.annotation.AfterTemplate;", "import com.google.errorprone.refaster.annotation.UseImportPolicy;", "import java.nio.charset.StandardCharsets;", "import java.util.Optional;", @@ -101,6 +102,9 @@ void identification() { "", " // BUG: Diagnostic contains:", " @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS)", + " @AfterTemplate", + " void m2() {}", + "", " void toImmutableMultiset() {}", "}") .doTest(); @@ -119,6 +123,7 @@ void replacement() { "import com.google.errorprone.BugPattern;", "import com.google.errorprone.BugPattern.SeverityLevel;", "import com.google.errorprone.refaster.ImportPolicy;", + "import com.google.errorprone.refaster.annotation.AfterTemplate;", "import com.google.errorprone.refaster.annotation.UseImportPolicy;", "import java.nio.charset.StandardCharsets;", "import java.util.Objects;", @@ -131,7 +136,6 @@ void replacement() { "import org.springframework.http.MediaType;", "", "class A {", - " @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS)", " void m1() {", " ImmutableMap.toImmutableMap(v -> v, v -> v);", " ImmutableMap.toImmutableMap(v -> v, v -> v);", @@ -177,6 +181,10 @@ void replacement() { " severity = SeverityLevel.SUGGESTION,", " tags = BugPattern.StandardTags.SIMPLIFICATION)", " static final class TestBugPattern {}", + "", + " @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS)", + " @AfterTemplate", + " void m4() {}", "}") .addOutputLines( "out/A.java", @@ -203,6 +211,7 @@ void replacement() { "import com.google.errorprone.BugPattern;", "import com.google.errorprone.BugPattern.SeverityLevel;", "import com.google.errorprone.refaster.ImportPolicy;", + "import com.google.errorprone.refaster.annotation.AfterTemplate;", "import com.google.errorprone.refaster.annotation.UseImportPolicy;", "import java.nio.charset.StandardCharsets;", "import java.util.Objects;", @@ -215,7 +224,6 @@ void replacement() { "import org.springframework.http.MediaType;", "", "class A {", - " @UseImportPolicy(STATIC_IMPORT_ALWAYS)", " void m1() {", " toImmutableMap(v -> v, v -> v);", " ImmutableMap.toImmutableMap(v -> v, v -> v);", @@ -261,6 +269,10 @@ void replacement() { " severity = SUGGESTION,", " tags = SIMPLIFICATION)", " static final class TestBugPattern {}", + "", + " @UseImportPolicy(STATIC_IMPORT_ALWAYS)", + " @AfterTemplate", + " void m4() {}", "}") .doTest(TestMode.TEXT_MATCH); } From 880f10269182b06eccb25e9b5944259f4c93817a Mon Sep 17 00:00:00 2001 From: Pieter Dirk Soels Date: Fri, 18 Mar 2022 09:54:29 +0100 Subject: [PATCH 4/6] Remove testcase in replacement test and use different import --- .../bugpatterns/StaticImportCheckTest.java | 26 ++++--------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/StaticImportCheckTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/StaticImportCheckTest.java index e8ed66926b..5fcf6b18be 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/StaticImportCheckTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/StaticImportCheckTest.java @@ -101,7 +101,7 @@ void identification() { " }", "", " // BUG: Diagnostic contains:", - " @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS)", + " @UseImportPolicy(ImportPolicy.IMPORT_TOP_LEVEL)", " @AfterTemplate", " void m2() {}", "", @@ -120,11 +120,6 @@ void replacement() { "import com.google.common.base.Predicates;", "import com.google.common.collect.ImmutableMap;", "import com.google.common.collect.ImmutableSet;", - "import com.google.errorprone.BugPattern;", - "import com.google.errorprone.BugPattern.SeverityLevel;", - "import com.google.errorprone.refaster.ImportPolicy;", - "import com.google.errorprone.refaster.annotation.AfterTemplate;", - "import com.google.errorprone.refaster.annotation.UseImportPolicy;", "import java.nio.charset.StandardCharsets;", "import java.util.Objects;", "import java.util.regex.Pattern;", @@ -171,9 +166,6 @@ void replacement() { " @DateTimeFormat(iso = ISO.DATE_TIME) String dateTime,", " @DateTimeFormat(iso = ISO.TIME) String time) {}", "", - " @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)", - " final class Test {}", - "", " @BugPattern(", " name = \"TestBugPattern\",", " summary = \"\",", @@ -182,17 +174,13 @@ void replacement() { " tags = BugPattern.StandardTags.SIMPLIFICATION)", " static final class TestBugPattern {}", "", - " @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS)", - " @AfterTemplate", - " void m4() {}", + " @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)", + " final class Test {}", "}") .addOutputLines( "out/A.java", "import static com.google.common.collect.ImmutableMap.toImmutableMap;", "import static com.google.common.collect.ImmutableSet.toImmutableSet;", - "import static com.google.errorprone.BugPattern.LinkType.NONE;", - "import static com.google.errorprone.BugPattern.SeverityLevel.SUGGESTION;", - "import static com.google.errorprone.BugPattern.StandardTags.SIMPLIFICATION;", "import static java.nio.charset.StandardCharsets.UTF_8;", "import static java.util.Objects.requireNonNull;", "import static java.util.function.Predicate.not;", @@ -259,9 +247,6 @@ void replacement() { " @DateTimeFormat(iso = DATE_TIME) String dateTime,", " @DateTimeFormat(iso = TIME) String time) {}", "", - " @SpringBootTest(webEnvironment = RANDOM_PORT)", - " final class Test {}", - "", " @BugPattern(", " name = \"TestBugPattern\",", " summary = \"\",", @@ -270,9 +255,8 @@ void replacement() { " tags = SIMPLIFICATION)", " static final class TestBugPattern {}", "", - " @UseImportPolicy(STATIC_IMPORT_ALWAYS)", - " @AfterTemplate", - " void m4() {}", + " @SpringBootTest(webEnvironment = RANDOM_PORT)", + " final class Test {}", "}") .doTest(TestMode.TEXT_MATCH); } From 03b1a57dced5b1b763213652f0c4b5a197f336b2 Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Sun, 10 Apr 2022 13:25:08 +0200 Subject: [PATCH 5/6] Suggestion --- .../picnic/errorprone/bugpatterns/StaticImportCheckTest.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/StaticImportCheckTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/StaticImportCheckTest.java index 5fcf6b18be..e477383aa8 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/StaticImportCheckTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/StaticImportCheckTest.java @@ -47,7 +47,6 @@ void identification() { "import com.google.common.collect.ImmutableMultiset;", "import com.google.common.collect.ImmutableSet;", "import com.google.errorprone.refaster.ImportPolicy;", - "import com.google.errorprone.refaster.annotation.AfterTemplate;", "import com.google.errorprone.refaster.annotation.UseImportPolicy;", "import java.nio.charset.StandardCharsets;", "import java.util.Optional;", @@ -102,8 +101,7 @@ void identification() { "", " // BUG: Diagnostic contains:", " @UseImportPolicy(ImportPolicy.IMPORT_TOP_LEVEL)", - " @AfterTemplate", - " void m2() {}", + " void refasterAfterTemplate() {}", "", " void toImmutableMultiset() {}", "}") From d4b46a0a211dfcf53ca98405d42750fa07924f05 Mon Sep 17 00:00:00 2001 From: Rick Ossendrijver Date: Mon, 11 Apr 2022 10:27:14 +0200 Subject: [PATCH 6/6] Post rebase fix --- .../errorprone/bugpatterns/StaticImportCheckTest.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/StaticImportCheckTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/StaticImportCheckTest.java index e477383aa8..2a3ccf4a77 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/StaticImportCheckTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/StaticImportCheckTest.java @@ -118,6 +118,8 @@ void replacement() { "import com.google.common.base.Predicates;", "import com.google.common.collect.ImmutableMap;", "import com.google.common.collect.ImmutableSet;", + "import com.google.errorprone.BugPattern;", + "import com.google.errorprone.BugPattern.SeverityLevel;", "import java.nio.charset.StandardCharsets;", "import java.util.Objects;", "import java.util.regex.Pattern;", @@ -179,6 +181,9 @@ void replacement() { "out/A.java", "import static com.google.common.collect.ImmutableMap.toImmutableMap;", "import static com.google.common.collect.ImmutableSet.toImmutableSet;", + "import static com.google.errorprone.BugPattern.LinkType.NONE;", + "import static com.google.errorprone.BugPattern.SeverityLevel.SUGGESTION;", + "import static com.google.errorprone.BugPattern.StandardTags.SIMPLIFICATION;", "import static java.nio.charset.StandardCharsets.UTF_8;", "import static java.util.Objects.requireNonNull;", "import static java.util.function.Predicate.not;", @@ -196,9 +201,6 @@ void replacement() { "import com.google.common.collect.ImmutableSet;", "import com.google.errorprone.BugPattern;", "import com.google.errorprone.BugPattern.SeverityLevel;", - "import com.google.errorprone.refaster.ImportPolicy;", - "import com.google.errorprone.refaster.annotation.AfterTemplate;", - "import com.google.errorprone.refaster.annotation.UseImportPolicy;", "import java.nio.charset.StandardCharsets;", "import java.util.Objects;", "import java.util.regex.Pattern;",