From a926e5534c6e6cd3612119ee20dad608379080b7 Mon Sep 17 00:00:00 2001 From: Rick Ossendrijver Date: Sun, 28 Jan 2024 19:32:15 +0100 Subject: [PATCH] Allow static imports of `ZERO` and `ONE` identifiers (#996) --- .../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 bacf57fbe5..47d4d6471d 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 86ef74d4e6..bdad493c4b 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();