diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/NonStaticImport.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/NonStaticImport.java index 47d4d6471d..459097d2ae 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/NonStaticImport.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/NonStaticImport.java @@ -33,6 +33,7 @@ import java.time.ZoneOffset; import java.util.Collections; import java.util.Locale; +import java.util.Optional; import java.util.regex.Pattern; import org.jspecify.annotations.Nullable; import tech.picnic.errorprone.bugpatterns.util.SourceCode; @@ -71,7 +72,9 @@ public final class NonStaticImport extends BugChecker implements CompilationUnit Strings.class.getCanonicalName(), VisitorState.class.getCanonicalName(), ZoneOffset.class.getCanonicalName(), - "com.google.errorprone.BugCheckerRefactoringTestHelper.TestMode"); + "com.google.errorprone.BugCheckerRefactoringTestHelper.TestMode", + "reactor.core.publisher.Flux", + "reactor.core.publisher.Mono"); /** * Type members that should never be statically imported. @@ -103,6 +106,7 @@ public final class NonStaticImport extends BugChecker implements CompilationUnit "sort", "swap") .put(Locale.class.getCanonicalName(), "ROOT") + .put(Optional.class.getCanonicalName(), "empty") .putAll(Pattern.class.getCanonicalName(), "compile", "matches", "quote") .put(Predicates.class.getCanonicalName(), "contains") .put("org.springframework.http.MediaType", "ALL") @@ -125,7 +129,6 @@ public final class NonStaticImport extends BugChecker implements CompilationUnit "builder", "copyOf", "create", - "empty", "from", "getDefaultInstance", "INSTANCE", diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/NonStaticImportTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/NonStaticImportTest.java index bdad493c4b..bfa02b583c 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/NonStaticImportTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/NonStaticImportTest.java @@ -65,6 +65,8 @@ void identification() { "// BUG: Diagnostic contains:", "import static java.util.Optional.empty;", "import static pkg.A.WithMethodThatIsSelectivelyFlagged.list;", + "// BUG: Diagnostic contains:", + "import static reactor.core.publisher.Flux.just;", "", "import com.google.common.collect.ImmutableList;", "import com.google.common.collect.ImmutableSet;", @@ -90,6 +92,7 @@ void identification() { " Locale english = ENGLISH;", " Locale root = ROOT;", " empty();", + " just();", "", " list();", " new INSTANCE();", diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/StaticImportTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/StaticImportTest.java index 4dde83f6e1..9ac112a7a6 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/StaticImportTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/StaticImportTest.java @@ -47,6 +47,7 @@ void identification() { "import com.google.common.collect.ImmutableSet;", "import com.google.errorprone.refaster.ImportPolicy;", "import com.google.errorprone.refaster.annotation.UseImportPolicy;", + "import com.mongodb.client.model.Filters;", "import java.nio.charset.StandardCharsets;", "import java.time.ZoneOffset;", "import java.util.Optional;", @@ -99,6 +100,8 @@ void identification() { " // BUG: Diagnostic contains:", " MediaType t2 = MediaType.APPLICATION_JSON;", "", + " // BUG: Diagnostic contains:", + " Filters.empty();", " Optional.empty();", "", " // BUG: Diagnostic contains:",