Skip to content

Commit 42be787

Browse files
committed
ICU-23054 Fix all Errorprone complaints at error level
1 parent 4b44432 commit 42be787

File tree

8 files changed

+17
-18
lines changed

8 files changed

+17
-18
lines changed

icu4j/main/charset/src/test/java/com/ibm/icu/dev/test/charset/TestCharset.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5818,7 +5818,8 @@ public void TestBufferOverflowErrorUsingJavagetBytes() {
58185818
String testCase = "\u7d42";
58195819

58205820
try {
5821-
testCase.getBytes(charsetName);
5821+
// We don't expect any particular value.
5822+
var unused = testCase.getBytes(charsetName);
58225823
} catch (Exception ex) {
58235824
errln("Error calling getBytes(): " + ex);
58245825
}

icu4j/main/collate/src/test/java/com/ibm/icu/dev/test/collator/CollationAPITest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ public void TestElemIter() {
313313

314314
// Code coverage for dummy "not designed" hashCode() which does "assert false".
315315
try {
316-
iterator1.hashCode(); // We don't expect any particular value.
316+
var unused = iterator1.hashCode(); // We don't expect any particular value.
317317
} catch (AssertionError ignored) {
318318
// Expected to be thrown if assertions are enabled.
319319
}

icu4j/main/core/src/main/java/com/ibm/icu/impl/UnicodeMap.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,7 @@ public UnicodeMap<T> putAll(Map<? extends String, ? extends T> map) {
857857
* Utility for extracting map
858858
* @deprecated
859859
*/
860+
@Deprecated
860861
public UnicodeMap<T> putAllIn(Map<? super String, ? super T> map) {
861862
for (String key : keySet()) {
862863
map.put(key, get(key));

icu4j/main/core/src/test/java/com/ibm/icu/dev/test/TestBoilerplate.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public abstract class TestBoilerplate<T> extends TestFmwk {
3939

4040
protected static Random random = new Random(12345);
4141

42+
@SuppressWarnings({"SelfEquals", "EqualsNull"})
4243
protected final void _test() throws Exception {
4344
List<T> list = new LinkedList<T>();
4445
while (_addTestObject(list)) {

icu4j/tools/build/src/main/java/com/ibm/icu/dev/tool/docs/APIInfo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public boolean equals(Object rhs) {
8080
this.name.equals(that.name) &&
8181
this.sig.equals(that.sig) &&
8282
this.exc.equals(that.exc) &&
83-
this.stver.equals(this.stver);
83+
this.stver.equals(that.stver);
8484
}
8585
catch (ClassCastException e) {
8686
return false;

icu4j/tools/misc/src/main/java/com/ibm/icu/dev/tool/charsetdet/mbcs/BIG5Tool.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ void processDir(File dir) {
234234
// WARNING: this class's natural ordering (from Comparable) and equals()
235235
// are inconsistent.
236236

237-
static class ChEl implements Comparable {
237+
static class ChEl implements Comparable<ChEl> {
238238
int charCode;
239239
int occurences;
240240

@@ -258,10 +258,9 @@ public int hashCode() {
258258

259259
// We want to be able to sort the results by frequency of occurrence
260260
// Compare backwards. We want most frequent chars first.
261-
public int compareTo(Object other) {
262-
ChEl o = (ChEl)other;
263-
return (this.occurences> o.occurences? -1 :
264-
(this.occurences==o.occurences? 0 : 1));
261+
public int compareTo(ChEl other) {
262+
return (this.occurences> other.occurences? -1 :
263+
(this.occurences==other.occurences? 0 : 1));
265264
}
266265

267266
}

icu4j/tools/misc/src/main/java/com/ibm/icu/dev/tool/charsetdet/mbcs/EUCTool.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ void processDir(File dir) {
234234
// WARNING: this class's natural ordering (from Comparable) and equals()
235235
// are inconsistent.
236236

237-
static class ChEl implements Comparable {
237+
static class ChEl implements Comparable<ChEl> {
238238
int charCode;
239239
int occurences;
240240

@@ -258,10 +258,9 @@ public int hashCode() {
258258

259259
// We want to be able to sort the results by frequency of occurrence
260260
// Compare backwards. We want most frequent chars first.
261-
public int compareTo(Object other) {
262-
ChEl o = (ChEl)other;
263-
return (this.occurences> o.occurences? -1 :
264-
(this.occurences==o.occurences? 0 : 1));
261+
public int compareTo(ChEl other) {
262+
return (this.occurences> other.occurences? -1 :
263+
(this.occurences==other.occurences? 0 : 1));
265264
}
266265

267266
}

icu4j/tools/misc/src/main/java/com/ibm/icu/dev/tool/charsetdet/sbcs/NGramList.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public interface NGramKeyMapper
2626
Object mapKey(String key);
2727
}
2828

29-
public static final class NGram implements Comparable
29+
public static final class NGram implements Comparable<NGram>
3030
{
3131
private String value;
3232
private int refCount;
@@ -63,11 +63,9 @@ public final void incrementRefCount()
6363
}
6464

6565
// Note: This makes higher refCounts come *before* lower refCounts...
66-
public int compareTo(Object o)
66+
public int compareTo(NGram o)
6767
{
68-
NGram ng = (NGram) o;
69-
70-
return ng.getRefCount() - refCount;
68+
return o.getRefCount() - refCount;
7169
}
7270
}
7371

0 commit comments

Comments
 (0)