Skip to content

Commit 91cb9a6

Browse files
committed
Fix errorprone warnings that should be errors
This commit is part of a large scale change to fix errorprone errors that have been downgraded to warnings in the android source tree, so that they can be promoted to errors again. The full list of changes include the following, but not all will be present in any one individual commit: BadAnnotationImplementation BadShiftAmount BanJNDI BoxedPrimitiveEquality ComparableType ComplexBooleanConstant CollectionToArraySafeParameter ConditionalExpressionNumericPromotion DangerousLiteralNull DoubleBraceInitialization DurationFrom DurationTemporalUnit EmptyTopLevelDeclaration EqualsNull EqualsReference FormatString FromTemporalAccessor GetClassOnAnnotation GetClassOnClass HashtableContains IdentityBinaryExpression IdentityHashMapBoxing InstantTemporalUnit InvalidTimeZoneID InvalidZoneId IsInstanceIncompatibleType JUnitParameterMethodNotFound LockOnBoxedPrimitive MathRoundIntLong MislabeledAndroidString MisusedDayOfYear MissingSuperCall MisusedWeekYear ModifyingCollectionWithItself NoCanIgnoreReturnValueOnClasses NonRuntimeAnnotation NullableOnContainingClass NullTernary OverridesJavaxInjectableMethod ParcelableCreator PeriodFrom PreconditionsInvalidPlaceholder ProtoBuilderReturnValueIgnored ProtoFieldNullComparison RandomModInteger RectIntersectReturnValueIgnored ReturnValueIgnored SelfAssignment SelfComparison SelfEquals SizeGreaterThanOrEqualsZero StringBuilderInitWithChar TreeToString TryFailThrowable UnnecessaryCheckNotNull UnusedCollectionModifiedInPlace XorPower See https://errorprone.info/bugpatterns for more information on the checks. Bug: 253827323 Test: m RUN_ERROR_PRONE=true javac-check Change-Id: I454a105ae82484a2d19aff1808e8d9dd55ba64f4
1 parent 370d41d commit 91cb9a6

6 files changed

Lines changed: 7 additions & 6 deletions

File tree

java/src/com/android/inputmethod/keyboard/PointerTracker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ private void callListenerOnCodeInput(final Key key, final int primaryCode, final
281281
if (DEBUG_LISTENER) {
282282
final String output = code == Constants.CODE_OUTPUT_TEXT
283283
? key.getOutputText() : Constants.printableCode(code);
284-
Log.d(TAG, String.format("[%d] onCodeInput: %4d %4d %s%s%s", mPointerId, x, y,
284+
Log.d(TAG, String.format("[%d] onCodeInput: %4d %4d %s%s%s%s", mPointerId, x, y,
285285
output, ignoreModifierKey ? " ignoreModifier" : "",
286286
altersCode ? " altersCode" : "", key.isEnabled() ? "" : " disabled"));
287287
}

java/src/com/android/inputmethod/latin/utils/CursorAnchorInfoUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ private static CursorAnchorInfo extractFromTextViewInternal(@Nonnull final TextV
216216
if (isTopLeftVisible || isBottomRightVisible) {
217217
characterBoundsFlags |= CursorAnchorInfo.FLAG_HAS_VISIBLE_REGION;
218218
}
219-
if (!isTopLeftVisible || !isTopLeftVisible) {
219+
if (!isTopLeftVisible || !isBottomRightVisible) {
220220
characterBoundsFlags |= CursorAnchorInfo.FLAG_HAS_INVISIBLE_REGION;
221221
}
222222
if (isRtl) {

tests/src/com/android/inputmethod/keyboard/layout/expected/ExpectedKeyOutput.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ ExpectedKeyOutput preserveCase() {
131131

132132
@Override
133133
boolean hasSameKeyOutput(final String text) {
134-
return text.equals(text);
134+
return mText.equals(text);
135135
}
136136

137137
@Override

tests/src/com/android/inputmethod/latin/makedict/Ver2DictEncoder.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import java.util.HashMap;
3535
import java.util.Iterator;
3636
import java.util.Map.Entry;
37+
import java.util.Objects;
3738

3839
/**
3940
* An implementation of DictEncoder for version 2 binary dictionary.
@@ -100,7 +101,7 @@ static CodePointTable makeCodePointTable(final FusionDictionary dict) {
100101
Collections.sort(codePointOccurrenceArray, new Comparator<Entry<Integer, Integer>>() {
101102
@Override
102103
public int compare(final Entry<Integer, Integer> a, final Entry<Integer, Integer> b) {
103-
if (a.getValue() != b.getValue()) {
104+
if (!Objects.equals(a.getValue(), b.getValue())) {
104105
return b.getValue().compareTo(a.getValue());
105106
}
106107
return b.getKey().compareTo(a.getKey());

tools/dicttool/tests/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtilsTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public void runTestHeaderReaderProcessorWithOneSpec(final boolean compress, fina
162162
options.put("locale", "en_US");
163163
options.put("version", Integer.toString(mRandom.nextInt()));
164164
// Add some random options for test
165-
final int numberOfOptionsToAdd = mRandom.nextInt() % (MAX_NUMBER_OF_OPTIONS_TO_ADD + 1);
165+
final int numberOfOptionsToAdd = mRandom.nextInt(MAX_NUMBER_OF_OPTIONS_TO_ADD + 1);
166166
for (int i = 0; i < numberOfOptionsToAdd; ++i) {
167167
options.put(sWords.get(2 * i), sWords.get(2 * 1 + 1));
168168
}

tools/dicttool/tests/com/android/inputmethod/latin/makedict/FusionDictionaryTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ private void prepare(final long seed) {
4747
*/
4848
private String generateWord(final Random random) {
4949
StringBuilder builder = new StringBuilder("a");
50-
int count = random.nextInt() % 30;
50+
int count = random.nextInt(30);
5151
while (count > 0) {
5252
final long r = Math.abs(random.nextInt());
5353
if (r < 0) continue;

0 commit comments

Comments
 (0)