Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade errorprone to 2.36.0 #14216

Merged
merged 1 commit into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 99 additions & 1 deletion gradle/validation/error-prone.gradle

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ protected void searchPatterns(char[] word, int index, byte[] il) {
} else {
q = lo[q];

/**
/*
* actually the code should be: q = sc[q] < 0 ? hi[q] : lo[q]; but java chars are
* unsigned
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,7 @@ protected ArrayList<Object> normalizeException(ArrayList<?> ex) {
ArrayList<Object> res = new ArrayList<>();
for (int i = 0; i < ex.size(); i++) {
Object item = ex.get(i);
if (item instanceof String) {
String str = (String) item;
if (item instanceof String str) {
StringBuilder buf = new StringBuilder();
for (int j = 0; j < str.length(); j++) {
char c = str.charAt(j);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -822,12 +822,12 @@ private boolean endsIn(char a, char b, char c, char d) {
}

private DictEntry wordInDict() {
/***
/*
* if (matchedEntry != null) { if (dict_ht.get(word.getArray(), 0,
* word.size()) != matchedEntry) {
* System.out.println("Uh oh... cached entry doesn't match"); } return
* matchedEntry; }
***/
*/
if (matchedEntry != null) return matchedEntry;
DictEntry e = dict_ht.get(word.getArray(), 0, word.length());
if (e != null && !e.exception) {
Expand Down Expand Up @@ -861,11 +861,11 @@ private void plural() {
* common
*/

/****
/*
* YCS: this was the one place where lookup was not followed by return.
* So restructure it. if ((j>0)&&(lookup(word.toString())) &&
* !((word.charAt(j) == 's') && (word.charAt(j-1) == 's'))) return;
*****/
*/
boolean tryE = j > 0 && !((word.charAt(j) == 's') && (word.charAt(j - 1) == 's'));
if (tryE && lookup()) return;

Expand Down Expand Up @@ -913,15 +913,15 @@ private void setSuff(String s, int len) {
DictEntry matchedEntry = null;

private boolean lookup() {
/******
/*
* debugging code String thisLookup = word.toString(); boolean added =
* lookups.add(thisLookup); if (!added) {
* System.out.println("######extra lookup:" + thisLookup); // occaasional
* extra lookups aren't necessarily errors... could happen by diff
* manipulations // throw new RuntimeException("######extra lookup:" +
* thisLookup); } else { // System.out.println("new lookup:" + thisLookup);
* }
******/
*/

matchedEntry = dict_ht.get(word.getArray(), 0, word.size());
return matchedEntry != null;
Expand Down Expand Up @@ -1742,11 +1742,11 @@ int getLength() {
String result;

private boolean matched() {
/***
/*
* if (!lookups.contains(word.toString())) { throw new
* RuntimeException("didn't look up "+word.toString()+" prev="+prevLookup);
* }
***/
*/
// lookup();
return matchedEntry != null;
}
Expand All @@ -1772,13 +1772,13 @@ boolean stem(char[] term, int len) {
return false;
}

/***
/*
* caching off is normally faster if (cache == null) initializeStemHash();
*
* // now check the cache, before we copy chars to "word" if (cache != null)
* { String val = cache.get(term, 0, len); if (val != null) { if (val !=
* SAME) { result = val; return true; } return false; } }
***/
*/

word.reset();
// allocate enough space so that an expansion is never needed
Expand All @@ -1792,9 +1792,9 @@ boolean stem(char[] term, int len) {
}

matchedEntry = null;
/***
/*
* lookups.clear(); lookups.add(word.toString());
***/
*/

/*
* This while loop will never be executed more than one time; it is here
Expand Down Expand Up @@ -1851,20 +1851,20 @@ boolean stem(char[] term, int len) {
result = entry.root; // may be null, which means that "word" is the stem
}

/***
/*
* caching off is normally faster if (cache != null && cache.size() <
* maxCacheSize) { char[] key = new char[len]; System.arraycopy(term, 0,
* key, 0, len); if (result != null) { cache.put(key, result); } else {
* cache.put(key, word.toString()); } }
***/
*/

/***
/*
* if (entry == null) { if (!word.toString().equals(new String(term,0,len)))
* { System.out.println("CASE:" + word.toString() + "," + new
* String(term,0,len));
*
* } }
***/
*/

// no entry matched means result is "word"
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.lucene.analysis.minhash;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.TreeSet;
Expand Down Expand Up @@ -160,7 +161,7 @@ public final boolean incrementToken() throws IOException {
String current = new String(termAttribute.buffer(), 0, termAttribute.length());

for (int i = 0; i < hashCount; i++) {
byte[] bytes = current.getBytes("UTF-16LE");
byte[] bytes = current.getBytes(StandardCharsets.UTF_16LE);
LongPair hash = new LongPair();
murmurhash3_x64_128(bytes, 0, bytes.length, 0, hash);
LongPair rehashed = combineOrdered(hash, getIntHash(i));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ public boolean recursivelyValidate(
return accept;
}

/**
/*
* This method checks if strings that lead to the accept state of the not flattened TokenStream
* also lead to the accept state in the flattened TokenStream. This gets complicated when you
* factor in holes. The FlattenGraphFilter will remove alternate paths that are made entirely of
Expand All @@ -840,7 +840,7 @@ public boolean recursivelyValidate(
notFlattened.close();
}*/

/**
/*
* gets up to 10000 strings that lead to accept state in the given automaton.
*
* @param automaton automaton
Expand All @@ -856,7 +856,7 @@ public boolean recursivelyValidate(
return acceptedSequences;
}*/

/**
/*
* @param automaton automaton to generate strings from
* @param state state to start at
* @param prefix string prefix
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import java.io.IOException;
import java.io.StringReader;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
Expand Down Expand Up @@ -47,16 +47,16 @@ public void testIntHash() {
}

@Test
public void testStringHash() throws UnsupportedEncodingException {
public void testStringHash() {
LongPair hash = new LongPair();
byte[] bytes = "woof woof woof woof woof".getBytes("UTF-16LE");
byte[] bytes = "woof woof woof woof woof".getBytes(StandardCharsets.UTF_16LE);
MinHashFilter.murmurhash3_x64_128(bytes, 0, bytes.length, 0, hash);
assertEquals(7638079586852243959L, hash.val1);
assertEquals(4378804943379391304L, hash.val2);
}

@Test
public void testSimpleOrder() throws UnsupportedEncodingException {
public void testSimpleOrder() {
LongPair hash1 = new LongPair();
hash1.val1 = 1;
hash1.val2 = 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ void setGraphvizFormatter(GraphvizFormatter<JaMorphData> dotOut) {
protected void backtrace(Position endPosData, int fromIDX) throws IOException {
final int endPos = endPosData.getPos();

/**
/*
* LUCENE-10059: If the endPos is the same as lastBackTracePos, we don't want to backtrace to
* avoid an assertion error {@link RollingCharBuffer#get(int)} when it tries to generate an
* empty buffer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,7 @@ public void setText(CharacterIterator newText) {

private String characterIteratorToString() {
String fullText;
if (text instanceof CharArrayIterator) {
CharArrayIterator charArrayIterator = (CharArrayIterator) text;
if (text instanceof CharArrayIterator charArrayIterator) {
fullText =
new String(
charArrayIterator.getText(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public Relation compare(byte[] minPackedValue, byte[] maxPackedValue) {

@Override
public void merge(MergeState mergeState) throws IOException {
/**
/*
* If indexSort is activated and some of the leaves are not sorted the next test will catch that
* and the non-optimized merge will run. If the readers are all sorted then it's safe to perform
* a bulk merge of the points.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,7 @@ private byte[] packIndex(long[] leafBlockFPs, byte[] splitPackedValues) throws I
}
}

/** Reused while packing the index */
/* Reused while packing the index */
ByteBuffersDataOutput writeBuffer = new ByteBuffersDataOutput();

// This is the "file" we append the byte[] to:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public Relation compare(byte[] minPackedValue, byte[] maxPackedValue) {

@Override
public void merge(MergeState mergeState) throws IOException {
/**
/*
* If indexSort is activated and some of the leaves are not sorted the next test will catch that
* and the non-optimized merge will run. If the readers are all sorted then it's safe to perform
* a bulk merge of the points.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private static Map<String, MethodHandle> getFunctions() {
m.put("mh_identity", MethodHandles.identity(double.class));
return Collections.unmodifiableMap(m);
} catch (ReflectiveOperationException e) {
throw new AssertionError(e);
throw new LinkageError("Couldn't find function", e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,7 @@ public static ShapeConverter makeShapeConverter(
return new ShapeConverter() {
@Override
public Shape convert(Shape shape) {
if (shape instanceof Point && (radiusDegrees != 0.0 || plusMinus != 0.0)) {
Point point = (Point) shape;
if (shape instanceof Point point && (radiusDegrees != 0.0 || plusMinus != 0.0)) {
double radius = radiusDegrees;
if (plusMinus > 0.0) {
Random random =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public String getName() {
if (params == null) {
return name;
}
return new StringBuilder(name).append('(').append(params).append(')').toString();
return name + '(' + params + ')';
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,7 @@ private void updateExhausted(PerfTask task) {
if (task instanceof ResetInputsTask) {
exhausted = false;
resetExhausted = true;
} else if (task instanceof TaskSequence) {
TaskSequence t = (TaskSequence) task;
} else if (task instanceof TaskSequence t) {
if (t.resetExhausted) {
exhausted = false;
resetExhausted = true;
Expand Down Expand Up @@ -384,8 +383,7 @@ private int doParallelTasks() throws Exception {
for (int i = 0; i < t.length; i++) {
t[i].join();
count += t[i].count;
if (t[i].task instanceof TaskSequence) {
TaskSequence sub = (TaskSequence) t[i].task;
if (t[i].task instanceof TaskSequence sub) {
if (sub.countsByTime != null) {
if (countsByTime == null) {
countsByTime = new int[sub.countsByTime.length];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,18 +288,15 @@ public int newRound() {
for (final Map.Entry<String, Object> entry : valByRound.entrySet()) {
final String name = entry.getKey();
Object a = entry.getValue();
if (a instanceof int[]) {
int[] ai = (int[]) a;
if (a instanceof int[] ai) {
int n1 = (roundNumber - 1) % ai.length;
int n2 = roundNumber % ai.length;
sb.append(" ").append(name).append(":").append(ai[n1]).append("-->").append(ai[n2]);
} else if (a instanceof double[]) {
double[] ad = (double[]) a;
} else if (a instanceof double[] ad) {
int n1 = (roundNumber - 1) % ad.length;
int n2 = roundNumber % ad.length;
sb.append(" ").append(name).append(":").append(ad[n1]).append("-->").append(ad[n2]);
} else if (a instanceof String[]) {
String[] ad = (String[]) a;
} else if (a instanceof String[] ad) {
int n1 = (roundNumber - 1) % ad.length;
int n2 = roundNumber % ad.length;
sb.append(" ").append(name).append(":").append(ad[n1]).append("-->").append(ad[n2]);
Expand Down Expand Up @@ -423,16 +420,13 @@ public String getColsValuesForValsByRound(int roundNum) {

// append actual values, for that round
Object a = valByRound.get(valByRoundName);
if (a instanceof int[]) {
int[] ai = (int[]) a;
if (a instanceof int[] ai) {
int n = roundNum % ai.length;
sb.append(Format.format(ai[n], template));
} else if (a instanceof double[]) {
double[] ad = (double[]) a;
} else if (a instanceof double[] ad) {
int n = roundNum % ad.length;
sb.append(Format.format(2, ad[n], template));
} else if (a instanceof String[]) {
String[] ad = (String[]) a;
} else if (a instanceof String[] ad) {
int n = roundNum % ad.length;
sb.append(ad[n]);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,13 +375,13 @@ public SeekStatus seekCeil(final BytesRef target) throws IOException {
// target.utf8ToString() + " " + target + " current=" + term().utf8ToString() + " " + term()
// + " indexIsCurrent=" + indexIsCurrent + " didIndexNext=" + didIndexNext + " seekPending="
// + seekPending + " divisor=" + indexReader.getDivisor() + " this=" + this);
if (didIndexNext) {
if (nextIndexTerm == null) {
// System.out.println(" nextIndexTerm=null");
} else {
// System.out.println(" nextIndexTerm=" + nextIndexTerm.utf8ToString());
}
}
// if (didIndexNext) {
// if (nextIndexTerm == null) {
// // System.out.println(" nextIndexTerm=null");
// } else {
// // System.out.println(" nextIndexTerm=" + nextIndexTerm.utf8ToString());
// }
// }

boolean doSeek = true;

Expand Down
Loading