From 4f630fc668d107b7801281ce527e1a83a782dc1b Mon Sep 17 00:00:00 2001 From: ghm Date: Tue, 15 Oct 2024 11:01:20 -0700 Subject: [PATCH] Rename MemberName to SymbolName, given it's handling classes too now. SymbolName feels a bit cheesy: symbol is a very javac concept. I'd welcome better suggestions. PiperOrigin-RevId: 686166562 --- .../bugpatterns/{MemberName.java => IdentifierName.java} | 3 ++- .../errorprone/scanner/BuiltInCheckerSuppliers.java | 4 ++-- .../{MemberNameTest.java => IdentifierNameTest.java} | 8 ++++---- docs/bugpattern/{MemberName.md => IdentifierName.md} | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) rename core/src/main/java/com/google/errorprone/bugpatterns/{MemberName.java => IdentifierName.java} (99%) rename core/src/test/java/com/google/errorprone/bugpatterns/{MemberNameTest.java => IdentifierNameTest.java} (98%) rename docs/bugpattern/{MemberName.md => IdentifierName.md} (98%) diff --git a/core/src/main/java/com/google/errorprone/bugpatterns/MemberName.java b/core/src/main/java/com/google/errorprone/bugpatterns/IdentifierName.java similarity index 99% rename from core/src/main/java/com/google/errorprone/bugpatterns/MemberName.java rename to core/src/main/java/com/google/errorprone/bugpatterns/IdentifierName.java index 38a81576398..a34c5f1ef3b 100644 --- a/core/src/main/java/com/google/errorprone/bugpatterns/MemberName.java +++ b/core/src/main/java/com/google/errorprone/bugpatterns/IdentifierName.java @@ -67,9 +67,10 @@ @BugPattern( severity = WARNING, summary = "Methods and non-static variables should be named in lowerCamelCase", + altNames = {"MemberName"}, linkType = CUSTOM, link = "https://google.github.io/styleguide/javaguide.html#s5.2-specific-identifier-names") -public final class MemberName extends BugChecker +public final class IdentifierName extends BugChecker implements ClassTreeMatcher, MethodTreeMatcher, VariableTreeMatcher { private static final Supplier> EXEMPTED_CLASS_ANNOTATIONS = VisitorState.memoize( diff --git a/core/src/main/java/com/google/errorprone/scanner/BuiltInCheckerSuppliers.java b/core/src/main/java/com/google/errorprone/scanner/BuiltInCheckerSuppliers.java index 63501d2466b..6cb6218f418 100644 --- a/core/src/main/java/com/google/errorprone/scanner/BuiltInCheckerSuppliers.java +++ b/core/src/main/java/com/google/errorprone/scanner/BuiltInCheckerSuppliers.java @@ -166,6 +166,7 @@ import com.google.errorprone.bugpatterns.HashtableContains; import com.google.errorprone.bugpatterns.HidingField; import com.google.errorprone.bugpatterns.ICCProfileGetInstance; +import com.google.errorprone.bugpatterns.IdentifierName; import com.google.errorprone.bugpatterns.IdentityBinaryExpression; import com.google.errorprone.bugpatterns.IdentityHashMapBoxing; import com.google.errorprone.bugpatterns.IdentityHashMapUsage; @@ -232,7 +233,6 @@ import com.google.errorprone.bugpatterns.LossyPrimitiveCompare; import com.google.errorprone.bugpatterns.MathAbsoluteNegative; import com.google.errorprone.bugpatterns.MathRoundIntLong; -import com.google.errorprone.bugpatterns.MemberName; import com.google.errorprone.bugpatterns.MemoizeConstantVisitorStateLookups; import com.google.errorprone.bugpatterns.MethodCanBeStatic; import com.google.errorprone.bugpatterns.MisformattedTestData; @@ -1178,6 +1178,7 @@ public static ScannerSupplier warningChecks() { ForEachIterable.class, FunctionalInterfaceClash.class, HardCodedSdCardPath.class, + IdentifierName.class, ImmutableMemberCollection.class, ImmutableRefactoring.class, ImmutableSetForContains.class, @@ -1193,7 +1194,6 @@ public static ScannerSupplier warningChecks() { Java8ApiChecker.class, LambdaFunctionalInterface.class, LongLiteralLowerCaseSuffix.class, - MemberName.class, MethodCanBeStatic.class, MissingBraces.class, MissingDefault.class, diff --git a/core/src/test/java/com/google/errorprone/bugpatterns/MemberNameTest.java b/core/src/test/java/com/google/errorprone/bugpatterns/IdentifierNameTest.java similarity index 98% rename from core/src/test/java/com/google/errorprone/bugpatterns/MemberNameTest.java rename to core/src/test/java/com/google/errorprone/bugpatterns/IdentifierNameTest.java index 509d93dcbf4..31d3f0ec22a 100644 --- a/core/src/test/java/com/google/errorprone/bugpatterns/MemberNameTest.java +++ b/core/src/test/java/com/google/errorprone/bugpatterns/IdentifierNameTest.java @@ -22,13 +22,13 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -/** Tests for {@link MemberName}. */ +/** Tests for {@link IdentifierName}. */ @RunWith(JUnit4.class) -public class MemberNameTest { +public class IdentifierNameTest { private final CompilationTestHelper helper = - CompilationTestHelper.newInstance(MemberName.class, getClass()); + CompilationTestHelper.newInstance(IdentifierName.class, getClass()); private final BugCheckerRefactoringTestHelper refactoringHelper = - BugCheckerRefactoringTestHelper.newInstance(MemberName.class, getClass()); + BugCheckerRefactoringTestHelper.newInstance(IdentifierName.class, getClass()); @Test public void nameWithUnderscores() { diff --git a/docs/bugpattern/MemberName.md b/docs/bugpattern/IdentifierName.md similarity index 98% rename from docs/bugpattern/MemberName.md rename to docs/bugpattern/IdentifierName.md index aa84c0ee3f4..206b870fbe3 100644 --- a/docs/bugpattern/MemberName.md +++ b/docs/bugpattern/IdentifierName.md @@ -1,4 +1,4 @@ -The [Google Java Style Guide §5.2][style] provides rules for naming nembers. +The [Google Java Style Guide §5.2][style] provides rules for naming identifiers. ## Test methods