Skip to content

Commit 215f256

Browse files
cpovirkGoogle Java Core Libraries
authored and
Google Java Core Libraries
committed
Fix or suppress IdentifierName (and sometimes ConstantNameForConstants) warnings.
RELNOTES=n/a PiperOrigin-RevId: 710181163
1 parent 9b05674 commit 215f256

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+315
-253
lines changed

android/guava-testlib/test/com/google/common/testing/AbstractPackageSanityTestsTest.java

+1
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ static class EmptyTestSuite {}
110110

111111
static class Foo {}
112112

113+
@SuppressWarnings("IdentifierName") // We're testing that we ignore classes with underscores.
113114
static class Foo_Bar {}
114115

115116
public static class PublicFoo {}

android/guava-tests/benchmark/com/google/common/util/concurrent/ExecutionListBenchmark.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public Object getImpl() {
8989
@Override
9090
ExecutionListWrapper newExecutionList() {
9191
return new ExecutionListWrapper() {
92-
final ExecutionListCAS list = new ExecutionListCAS();
92+
final ExecutionListUsingCompareAndSwap list = new ExecutionListUsingCompareAndSwap();
9393

9494
@Override
9595
public void add(Runnable runnable, Executor executor) {
@@ -581,8 +581,8 @@ private static final class RunnableExecutorPair {
581581

582582
// A version of the list that uses compare and swap to manage the stack without locks.
583583
@SuppressWarnings({"SunApi", "removal"}) // b/345822163
584-
private static final class ExecutionListCAS {
585-
static final Logger log = Logger.getLogger(ExecutionListCAS.class.getName());
584+
private static final class ExecutionListUsingCompareAndSwap {
585+
static final Logger log = Logger.getLogger(ExecutionListUsingCompareAndSwap.class.getName());
586586

587587
private static final Unsafe UNSAFE;
588588
private static final long HEAD_OFFSET;
@@ -596,7 +596,9 @@ private static final class ExecutionListCAS {
596596
static {
597597
try {
598598
UNSAFE = getUnsafe();
599-
HEAD_OFFSET = UNSAFE.objectFieldOffset(ExecutionListCAS.class.getDeclaredField("head"));
599+
HEAD_OFFSET =
600+
UNSAFE.objectFieldOffset(
601+
ExecutionListUsingCompareAndSwap.class.getDeclaredField("head"));
600602
} catch (Exception ex) {
601603
throw new Error(ex);
602604
}

android/guava-tests/test/com/google/common/base/PredicatesTest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ public void testIn_serialization() {
717717
}
718718

719719
public void testIn_handlesNullPointerException() {
720-
class CollectionThatThrowsNPE<T> extends ArrayList<T> {
720+
class CollectionThatThrowsNullPointerException<T> extends ArrayList<T> {
721721
@J2ktIncompatible // Kotlin doesn't support companions for inner classes
722722
private static final long serialVersionUID = 1L;
723723

@@ -727,13 +727,13 @@ public boolean contains(@Nullable Object element) {
727727
return super.contains(element);
728728
}
729729
}
730-
Collection<Integer> nums = new CollectionThatThrowsNPE<>();
730+
Collection<Integer> nums = new CollectionThatThrowsNullPointerException<>();
731731
Predicate<@Nullable Integer> isFalse = Predicates.in(nums);
732732
assertFalse(isFalse.apply(null));
733733
}
734734

735735
public void testIn_handlesClassCastException() {
736-
class CollectionThatThrowsCCE<T> extends ArrayList<T> {
736+
class CollectionThatThrowsClassCastException<T> extends ArrayList<T> {
737737
@J2ktIncompatible // Kotlin doesn't support companions for inner classes
738738
private static final long serialVersionUID = 1L;
739739

@@ -742,7 +742,7 @@ public boolean contains(@Nullable Object element) {
742742
throw new ClassCastException("");
743743
}
744744
}
745-
Collection<Integer> nums = new CollectionThatThrowsCCE<>();
745+
Collection<Integer> nums = new CollectionThatThrowsClassCastException<>();
746746
nums.add(3);
747747
Predicate<Integer> isThree = Predicates.in(nums);
748748
assertFalse(isThree.apply(3));

android/guava-tests/test/com/google/common/base/SuppliersTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,11 @@ private void memoizeTest(CountingSupplier countingSupplier) {
107107
}
108108

109109
public void testMemoize_redudantly() {
110-
memoize_redudantlyTest(new CountingSupplier());
111-
memoize_redudantlyTest(new SerializableCountingSupplier());
110+
memoizeRedudantlyTest(new CountingSupplier());
111+
memoizeRedudantlyTest(new SerializableCountingSupplier());
112112
}
113113

114-
private void memoize_redudantlyTest(CountingSupplier countingSupplier) {
114+
private void memoizeRedudantlyTest(CountingSupplier countingSupplier) {
115115
Supplier<Integer> memoizedSupplier = Suppliers.memoize(countingSupplier);
116116
assertSame(memoizedSupplier, Suppliers.memoize(memoizedSupplier));
117117
}

android/guava-tests/test/com/google/common/collect/OrderingTest.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ public void testReverseOfReverseSameAsForward() {
358358
}
359359

360360
private enum StringLengthFunction implements Function<String, Integer> {
361-
StringLength;
361+
STRING_LENGTH;
362362

363363
@Override
364364
public Integer apply(String string) {
@@ -370,35 +370,35 @@ public Integer apply(String string) {
370370

371371
public void testOnResultOf_natural() {
372372
Comparator<String> comparator =
373-
Ordering.<Integer>natural().onResultOf(StringLengthFunction.StringLength);
373+
Ordering.<Integer>natural().onResultOf(StringLengthFunction.STRING_LENGTH);
374374
assertTrue(comparator.compare("to", "be") == 0);
375375
assertTrue(comparator.compare("or", "not") < 0);
376376
assertTrue(comparator.compare("that", "to") > 0);
377377

378378
new EqualsTester()
379379
.addEqualityGroup(
380-
comparator, Ordering.<Integer>natural().onResultOf(StringLengthFunction.StringLength))
380+
comparator, Ordering.<Integer>natural().onResultOf(StringLengthFunction.STRING_LENGTH))
381381
.addEqualityGroup(DECREASING_INTEGER)
382382
.testEquals();
383383
reserializeAndAssert(comparator);
384-
assertEquals("Ordering.natural().onResultOf(StringLength)", comparator.toString());
384+
assertEquals("Ordering.natural().onResultOf(STRING_LENGTH)", comparator.toString());
385385
}
386386

387387
public void testOnResultOf_chained() {
388388
Comparator<String> comparator =
389-
DECREASING_INTEGER.onResultOf(StringLengthFunction.StringLength);
389+
DECREASING_INTEGER.onResultOf(StringLengthFunction.STRING_LENGTH);
390390
assertTrue(comparator.compare("to", "be") == 0);
391391
assertTrue(comparator.compare("not", "or") < 0);
392392
assertTrue(comparator.compare("to", "that") > 0);
393393

394394
new EqualsTester()
395395
.addEqualityGroup(
396-
comparator, DECREASING_INTEGER.onResultOf(StringLengthFunction.StringLength))
396+
comparator, DECREASING_INTEGER.onResultOf(StringLengthFunction.STRING_LENGTH))
397397
.addEqualityGroup(DECREASING_INTEGER.onResultOf(Functions.constant(1)))
398398
.addEqualityGroup(Ordering.natural())
399399
.testEquals();
400400
reserializeAndAssert(comparator);
401-
assertEquals("Ordering.natural().reverse().onResultOf(StringLength)", comparator.toString());
401+
assertEquals("Ordering.natural().reverse().onResultOf(STRING_LENGTH)", comparator.toString());
402402
}
403403

404404
public void testLexicographical() {

android/guava-tests/test/com/google/common/collect/QueuesTest.java

+12-12
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,11 @@ private void testMultipleProducers(BlockingQueue<Object> q) throws InterruptedEx
125125

126126
public void testDrainTimesOut() throws Exception {
127127
for (BlockingQueue<Object> q : blockingQueues()) {
128-
testDrainTimesOut(q);
128+
checkDrainTimesOut(q);
129129
}
130130
}
131131

132-
private void testDrainTimesOut(BlockingQueue<Object> q) throws Exception {
132+
private void checkDrainTimesOut(BlockingQueue<Object> q) throws Exception {
133133
for (boolean interruptibly : new boolean[] {true, false}) {
134134
assertEquals(0, Queues.drain(q, ImmutableList.of(), 1, 10, MILLISECONDS));
135135

@@ -157,11 +157,11 @@ private void testDrainTimesOut(BlockingQueue<Object> q) throws Exception {
157157

158158
public void testZeroElements() throws Exception {
159159
for (BlockingQueue<Object> q : blockingQueues()) {
160-
testZeroElements(q);
160+
checkZeroElements(q);
161161
}
162162
}
163163

164-
private void testZeroElements(BlockingQueue<Object> q) throws InterruptedException {
164+
private void checkZeroElements(BlockingQueue<Object> q) throws InterruptedException {
165165
for (boolean interruptibly : new boolean[] {true, false}) {
166166
// asking to drain zero elements
167167
assertEquals(0, drain(q, ImmutableList.of(), 0, 10, MILLISECONDS, interruptibly));
@@ -170,21 +170,21 @@ private void testZeroElements(BlockingQueue<Object> q) throws InterruptedExcepti
170170

171171
public void testEmpty() throws Exception {
172172
for (BlockingQueue<Object> q : blockingQueues()) {
173-
testEmpty(q);
173+
checkEmpty(q);
174174
}
175175
}
176176

177-
private void testEmpty(BlockingQueue<Object> q) {
177+
private void checkEmpty(BlockingQueue<Object> q) {
178178
assertDrained(q);
179179
}
180180

181181
public void testNegativeMaxElements() throws Exception {
182182
for (BlockingQueue<Object> q : blockingQueues()) {
183-
testNegativeMaxElements(q);
183+
checkNegativeMaxElements(q);
184184
}
185185
}
186186

187-
private void testNegativeMaxElements(BlockingQueue<Object> q) throws InterruptedException {
187+
private void checkNegativeMaxElements(BlockingQueue<Object> q) throws InterruptedException {
188188
@SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
189189
Future<?> possiblyIgnoredError = threadPool.submit(new Producer(q, 1));
190190

@@ -199,11 +199,11 @@ private void testNegativeMaxElements(BlockingQueue<Object> q) throws Interrupted
199199

200200
public void testDrain_throws() throws Exception {
201201
for (BlockingQueue<Object> q : blockingQueues()) {
202-
testDrain_throws(q);
202+
checkDrainThrows(q);
203203
}
204204
}
205205

206-
private void testDrain_throws(BlockingQueue<Object> q) {
206+
private void checkDrainThrows(BlockingQueue<Object> q) {
207207
@SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
208208
Future<?> possiblyIgnoredError = threadPool.submit(new Interrupter(currentThread()));
209209
try {
@@ -215,11 +215,11 @@ private void testDrain_throws(BlockingQueue<Object> q) {
215215

216216
public void testDrainUninterruptibly_doesNotThrow() throws Exception {
217217
for (BlockingQueue<Object> q : blockingQueues()) {
218-
testDrainUninterruptibly_doesNotThrow(q);
218+
testDrainUninterruptiblyDoesNotThrow(q);
219219
}
220220
}
221221

222-
private void testDrainUninterruptibly_doesNotThrow(final BlockingQueue<Object> q) {
222+
private void testDrainUninterruptiblyDoesNotThrow(final BlockingQueue<Object> q) {
223223
final Thread mainThread = currentThread();
224224
@SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
225225
Future<?> possiblyIgnoredError =

android/guava-tests/test/com/google/common/math/BigDecimalMathTest.java

+12-8
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,15 @@ public void testRoundToDouble_twoToThe54PlusFour() {
181181
}
182182

183183
public void testRoundToDouble_maxDouble() {
184-
BigDecimal maxDoubleAsBD = new BigDecimal(Double.MAX_VALUE);
185-
new RoundToDoubleTester(maxDoubleAsBD).setExpectation(Double.MAX_VALUE, values()).test();
184+
BigDecimal maxDoubleAsBigDecimal = new BigDecimal(Double.MAX_VALUE);
185+
new RoundToDoubleTester(maxDoubleAsBigDecimal)
186+
.setExpectation(Double.MAX_VALUE, values())
187+
.test();
186188
}
187189

188190
public void testRoundToDouble_maxDoublePlusOne() {
189-
BigDecimal maxDoubleAsBD = new BigDecimal(Double.MAX_VALUE).add(BigDecimal.ONE);
190-
new RoundToDoubleTester(maxDoubleAsBD)
191+
BigDecimal maxDoubleAsBigDecimal = new BigDecimal(Double.MAX_VALUE).add(BigDecimal.ONE);
192+
new RoundToDoubleTester(maxDoubleAsBigDecimal)
191193
.setExpectation(Double.MAX_VALUE, DOWN, FLOOR, HALF_EVEN, HALF_UP, HALF_DOWN)
192194
.setExpectation(Double.POSITIVE_INFINITY, UP, CEILING)
193195
.roundUnnecessaryShouldThrow()
@@ -247,13 +249,15 @@ public void testRoundToDouble_negativeTwoToThe54MinusFour() {
247249
}
248250

249251
public void testRoundToDouble_minDouble() {
250-
BigDecimal minDoubleAsBD = new BigDecimal(-Double.MAX_VALUE);
251-
new RoundToDoubleTester(minDoubleAsBD).setExpectation(-Double.MAX_VALUE, values()).test();
252+
BigDecimal minDoubleAsBigDecimal = new BigDecimal(-Double.MAX_VALUE);
253+
new RoundToDoubleTester(minDoubleAsBigDecimal)
254+
.setExpectation(-Double.MAX_VALUE, values())
255+
.test();
252256
}
253257

254258
public void testRoundToDouble_minDoubleMinusOne() {
255-
BigDecimal minDoubleAsBD = new BigDecimal(-Double.MAX_VALUE).subtract(BigDecimal.ONE);
256-
new RoundToDoubleTester(minDoubleAsBD)
259+
BigDecimal minDoubleAsBigDecimal = new BigDecimal(-Double.MAX_VALUE).subtract(BigDecimal.ONE);
260+
new RoundToDoubleTester(minDoubleAsBigDecimal)
257261
.setExpectation(-Double.MAX_VALUE, DOWN, CEILING, HALF_EVEN, HALF_UP, HALF_DOWN)
258262
.setExpectation(Double.NEGATIVE_INFINITY, UP, FLOOR)
259263
.roundUnnecessaryShouldThrow()

android/guava-tests/test/com/google/common/math/BigIntegerMathTest.java

+12-8
Original file line numberDiff line numberDiff line change
@@ -621,16 +621,18 @@ public void testRoundToDouble_twoToThe54PlusFour() {
621621
@J2ktIncompatible
622622
@GwtIncompatible
623623
public void testRoundToDouble_maxDouble() {
624-
BigInteger maxDoubleAsBI = DoubleMath.roundToBigInteger(Double.MAX_VALUE, UNNECESSARY);
625-
new RoundToDoubleTester(maxDoubleAsBI).setExpectation(Double.MAX_VALUE, values()).test();
624+
BigInteger maxDoubleAsBigInteger = DoubleMath.roundToBigInteger(Double.MAX_VALUE, UNNECESSARY);
625+
new RoundToDoubleTester(maxDoubleAsBigInteger)
626+
.setExpectation(Double.MAX_VALUE, values())
627+
.test();
626628
}
627629

628630
@J2ktIncompatible
629631
@GwtIncompatible
630632
public void testRoundToDouble_maxDoublePlusOne() {
631-
BigInteger maxDoubleAsBI =
633+
BigInteger maxDoubleAsBigInteger =
632634
DoubleMath.roundToBigInteger(Double.MAX_VALUE, UNNECESSARY).add(BigInteger.ONE);
633-
new RoundToDoubleTester(maxDoubleAsBI)
635+
new RoundToDoubleTester(maxDoubleAsBigInteger)
634636
.setExpectation(Double.MAX_VALUE, DOWN, FLOOR, HALF_EVEN, HALF_UP, HALF_DOWN)
635637
.setExpectation(Double.POSITIVE_INFINITY, UP, CEILING)
636638
.roundUnnecessaryShouldThrow()
@@ -706,16 +708,18 @@ public void testRoundToDouble_negativeTwoToThe54MinusFour() {
706708
@J2ktIncompatible
707709
@GwtIncompatible
708710
public void testRoundToDouble_minDouble() {
709-
BigInteger minDoubleAsBI = DoubleMath.roundToBigInteger(-Double.MAX_VALUE, UNNECESSARY);
710-
new RoundToDoubleTester(minDoubleAsBI).setExpectation(-Double.MAX_VALUE, values()).test();
711+
BigInteger minDoubleAsBigInteger = DoubleMath.roundToBigInteger(-Double.MAX_VALUE, UNNECESSARY);
712+
new RoundToDoubleTester(minDoubleAsBigInteger)
713+
.setExpectation(-Double.MAX_VALUE, values())
714+
.test();
711715
}
712716

713717
@J2ktIncompatible
714718
@GwtIncompatible
715719
public void testRoundToDouble_minDoubleMinusOne() {
716-
BigInteger minDoubleAsBI =
720+
BigInteger minDoubleAsBigInteger =
717721
DoubleMath.roundToBigInteger(-Double.MAX_VALUE, UNNECESSARY).subtract(BigInteger.ONE);
718-
new RoundToDoubleTester(minDoubleAsBI)
722+
new RoundToDoubleTester(minDoubleAsBigInteger)
719723
.setExpectation(-Double.MAX_VALUE, DOWN, CEILING, HALF_EVEN, HALF_UP, HALF_DOWN)
720724
.setExpectation(Double.NEGATIVE_INFINITY, UP, FLOOR)
721725
.roundUnnecessaryShouldThrow()

android/guava-tests/test/com/google/common/net/InetAddressesTest.java

+2
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,7 @@ public void testIsMaximum() throws UnknownHostException {
735735
assertTrue(InetAddresses.isMaximum(address));
736736
}
737737

738+
@SuppressWarnings("IdentifierName") // the best we could do for adjacent digit blocks
738739
public void testIncrementIPv4() throws UnknownHostException {
739740
InetAddress address_66_0 = InetAddress.getByName("172.24.66.0");
740741
InetAddress address_66_255 = InetAddress.getByName("172.24.66.255");
@@ -753,6 +754,7 @@ public void testIncrementIPv4() throws UnknownHostException {
753754
assertThrows(IllegalArgumentException.class, () -> InetAddresses.increment(address_ffffff));
754755
}
755756

757+
@SuppressWarnings("IdentifierName") // the best we could do for adjacent digit blocks
756758
public void testIncrementIPv6() throws UnknownHostException {
757759
InetAddress addressV6_66_0 = InetAddress.getByName("2001:db8::6600");
758760
InetAddress addressV6_66_ff = InetAddress.getByName("2001:db8::66ff");

android/guava-tests/test/com/google/common/reflect/AbstractInvocationHandlerTest.java

-4
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@ interface A {}
5555
interface B {}
5656

5757
public void testEquals() {
58-
class AB implements A, B {}
59-
class BA implements B, A {}
60-
AB ab = new AB();
61-
BA ba = new BA();
6258
new EqualsTester()
6359
.addEqualityGroup(newDelegatingList(LIST1))
6460
// Actually, this violates List#equals contract.

android/guava-tests/test/com/google/common/reflect/TypeTokenTest.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -584,9 +584,9 @@ private abstract static class Third<T, D> extends Second<T> {}
584584

585585
private abstract static class Fourth<T, D> extends Third<D, T> {}
586586

587-
private static class ConcreteIS extends Fourth<Integer, String> {}
587+
private static class ConcreteIntegerString extends Fourth<Integer, String> {}
588588

589-
private static class ConcreteSI extends Fourth<String, Integer> {}
589+
private static class ConcreteStringInteger extends Fourth<String, Integer> {}
590590

591591
public void testAssignableClassToClass() {
592592
@SuppressWarnings("rawtypes") // To test TypeToken<List>
@@ -759,8 +759,8 @@ public void testAssignableClassToType() {
759759
assertFalse(tokenL.isSupertypeOf(List.class));
760760

761761
TypeToken<First<String>> tokenF = new TypeToken<First<String>>() {};
762-
assertTrue(tokenF.isSupertypeOf(ConcreteIS.class));
763-
assertFalse(tokenF.isSupertypeOf(ConcreteSI.class));
762+
assertTrue(tokenF.isSupertypeOf(ConcreteIntegerString.class));
763+
assertFalse(tokenF.isSupertypeOf(ConcreteStringInteger.class));
764764
}
765765

766766
public void testAssignableClassToArrayType() {
@@ -775,8 +775,8 @@ public void testAssignableParameterizedTypeToType() {
775775
assertFalse(tokenL.isSupertypeOf(IntegerList.class.getGenericInterfaces()[0]));
776776

777777
TypeToken<First<String>> tokenF = new TypeToken<First<String>>() {};
778-
assertTrue(tokenF.isSupertypeOf(ConcreteIS.class.getGenericSuperclass()));
779-
assertFalse(tokenF.isSupertypeOf(ConcreteSI.class.getGenericSuperclass()));
778+
assertTrue(tokenF.isSupertypeOf(ConcreteIntegerString.class.getGenericSuperclass()));
779+
assertFalse(tokenF.isSupertypeOf(ConcreteStringInteger.class.getGenericSuperclass()));
780780
}
781781

782782
public void testGenericArrayTypeToArrayType() {
@@ -798,8 +798,8 @@ public void testAssignableTokenToType() {
798798
assertFalse(tokenF.isSupertypeOf(new TypeToken<Third<Integer, String>>() {}));
799799
assertTrue(tokenF.isSupertypeOf(new TypeToken<Fourth<Integer, String>>() {}));
800800
assertFalse(tokenF.isSupertypeOf(new TypeToken<Fourth<String, Integer>>() {}));
801-
assertTrue(tokenF.isSupertypeOf(new TypeToken<ConcreteIS>() {}));
802-
assertFalse(tokenF.isSupertypeOf(new TypeToken<ConcreteSI>() {}));
801+
assertTrue(tokenF.isSupertypeOf(new TypeToken<ConcreteIntegerString>() {}));
802+
assertFalse(tokenF.isSupertypeOf(new TypeToken<ConcreteStringInteger>() {}));
803803
}
804804

805805
public void testAssignableWithWildcards() {

android/guava-tests/test/com/google/common/reflect/TypesTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ class LocalClass<T> {}
8484
}
8585

8686
public void testNewParameterizedType_staticLocalClass() {
87-
doTestNewParameterizedType_staticLocalClass();
87+
doTestNewParameterizedTypeStaticLocalClass();
8888
}
8989

90-
private static void doTestNewParameterizedType_staticLocalClass() {
90+
private static void doTestNewParameterizedTypeStaticLocalClass() {
9191
class LocalClass<T> {}
9292
Type jvmType = new LocalClass<String>() {}.getClass().getGenericSuperclass();
9393
Type ourType = Types.newParameterizedType(LocalClass.class, String.class);

0 commit comments

Comments
 (0)