From 5e62befd87bbb0549fefd5e65a2d493706bced8c Mon Sep 17 00:00:00 2001 From: Rick Ossendrijver Date: Fri, 26 Jan 2024 08:45:23 +0100 Subject: [PATCH] Allow static import of `{ZERO,ONE} --- .../tech/picnic/errorprone/bugpatterns/NonStaticImport.java | 4 +--- .../picnic/errorprone/bugpatterns/NonStaticImportTest.java | 6 +++--- 2 files changed, 4 insertions(+), 6 deletions(-) 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 bacf57fbe56..47d4d6471da 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 @@ -136,10 +136,8 @@ public final class NonStaticImport extends BugChecker implements CompilationUnit "newBuilder", "newInstance", "of", - "ONE", "parse", - "valueOf", - "ZERO"); + "valueOf"); /** Instantiates a new {@link NonStaticImport} instance. */ public NonStaticImport() {} 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 86ef74d4e6f..bdad493c4bb 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 @@ -72,7 +72,7 @@ void identification() { "import java.time.ZoneOffset;", "import java.util.Locale;", "import java.util.Map;", - "import pkg.A.Wrapper.ZERO;", + "import pkg.A.Wrapper.INSTANCE;", "", "class A {", " private Integer MIN_VALUE = 12;", @@ -92,7 +92,7 @@ void identification() { " empty();", "", " list();", - " new ZERO();", + " new INSTANCE();", " }", "", " static final class WithMethodThatIsSelectivelyFlagged {", @@ -102,7 +102,7 @@ void identification() { " }", "", " static final class Wrapper {", - " static final class ZERO {}", + " static final class INSTANCE {}", " }", "}") .doTest();