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

errorprone :: MemberName #782

Merged
merged 1 commit into from
May 24, 2024
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
42 changes: 21 additions & 21 deletions src/main/java/emissary/kff/EditDistance.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,33 +57,33 @@ public class EditDistance {
// #define SAFE_ASSIGN(x,y) (((x) != NULL) ? (*(x) = (y)) : (y))

// #define swap_int(x,y) (_iswap = (x), (x) = (y), (y) = _iswap)
private static void swap_int(int[] x, int[] y) {
int _iswap = x[0];
private static void swapInt(int[] x, int[] y) {
int iswap = x[0];
x[0] = y[0];
y[0] = _iswap;
y[0] = iswap;
}

// #define swap_char(x,y) (_cswap = (x), (x) = (y), (y) = _cswap)
private static void swap_char(/* ref */byte[][] x, /* ref */byte[][] y) {
byte[] _cswap = x[0];
private static void swapChar(/* ref */byte[][] x, /* ref */byte[][] y) {
byte[] cswap = x[0];
x[0] = y[0];
y[0] = _cswap;
y[0] = cswap;
}

// #define min3(x,y,z) (_mx = (x), _my = (y), _mz = (z), (_mx < _my ? (_mx < _mz ? _mx : _mz) : (_mz < _my) ? _mz :
// _my))
private static int min3(int x, int y, int z) {
int _mx = x;
int _my = y;
int _mz = z;
return (_mx < _my ? (_mx < _mz ? _mx : _mz) : (_mz < _my) ? _mz : _my);
int mx = x;
int my = y;
int mz = z;
return (mx < my ? (mx < mz ? mx : mz) : (mz < my) ? mz : my);
}

// #define min2(x,y) (_mx = (x), _my = (y), (_mx < _my ? _mx : _my))
private static int min2(int x, int y) {
int _mx = x;
int _my = y;
return (_mx < _my ? _mx : _my);
int mx = x;
int my = y;
return (mx < my ? mx : my);
}

static int insert_cost = 1;
Expand Down Expand Up @@ -126,19 +126,19 @@ private static int ar(int x, int y, int index) {
return ((x == 0) ? y * del : ((y == 0) ? x * ins : buffer[mod(index)]));
}

private static int NW(int x, int y) {
private static int nw(int x, int y) {
return ar(x, y, index + from_len + 2);
}

private static int N(int x, int y) {
private static int n(int x, int y) {
return ar(x, y, index + from_len + 3);
}

private static int W(int x, int y) {
private static int w(int x, int y) {
return ar(x, y, index + radix - 1);
}

private static int NNWW(int x, int y) {
private static int nnww(int x, int y) {
return ar(x, y, index + 1);
}

Expand Down Expand Up @@ -174,12 +174,12 @@ public static int edit_distn(@Nullable byte[] from, int _from_len, @Nullable byt
int[] y = new int[1];
x[0] = from_len;
y[0] = to_len;
swap_int(x, y);
swapInt(x, y);
byte[][] xx = new byte[1][];
byte[][] yy = new byte[1][];
xx[0] = from;
yy[0] = to;
swap_char(xx, yy);
swapChar(xx, yy);
} // if from_len > to_len

/* Allocate the array storage (from the heap if necessary) */
Expand Down Expand Up @@ -233,10 +233,10 @@ public static int edit_distn(@Nullable byte[] from, int _from_len, @Nullable byt
/* Now handle the rest of the matrix */
for (row = 1; row < to_len; row++) {
for (col = 0; col < from_len; col++) {
buffer[index] = min3(NW(row, col) + ((from[col] == to[row]) ? 0 : ch), N(row, col + 1) + ins, W(row + 1, col) + del);
buffer[index] = min3(nw(row, col) + ((from[col] == to[row]) ? 0 : ch), n(row, col + 1) + ins, w(row + 1, col) + del);

if (from[col] == to[row - 1] && col > 0 && from[col - 1] == to[row]) {
buffer[index] = min2(buffer[index], NNWW(row - 1, col - 1) + swap_cost);
buffer[index] = min2(buffer[index], nnww(row - 1, col - 1) + swap_cost);
}

if (buffer[index] < low || col == 0) {
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/emissary/output/DropOffUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -480,11 +480,11 @@ public String getBestIdFrom(final IBaseDataObject d) {
}
}
if (AUTO_GENERATED_ID.equals(s)) {
return getRandomUUID(d);
return getRandomUuid(d);
}
}
// if nothing else worked, use an auto gen id
return getRandomUUID(d);
return getRandomUuid(d);
}

/**
Expand Down Expand Up @@ -738,7 +738,7 @@ public String getBestId(final IBaseDataObject d, @Nullable final IBaseDataObject
parentAutoGeneratedId = tld.getStringParameter(PARENT_AUTO_GENERATED_ID);
}
if (StringUtils.isBlank(parentAutoGeneratedId)) {
String uuid = getRandomUUID(d);
String uuid = getRandomUuid(d);
if (tld != null) {
tld.setParameter(PARENT_AUTO_GENERATED_ID, uuid);
}
Expand Down Expand Up @@ -811,7 +811,7 @@ public String getBestId(final IBaseDataObject d, @Nullable final IBaseDataObject
}

// if nothing works, auto gen an id
final String uuid = getRandomUUID(d);
final String uuid = getRandomUuid(d);
if (tld != null) {
tld.setParameter(PARENT_AUTO_GENERATED_ID, uuid);
}
Expand All @@ -824,7 +824,7 @@ public String getBestId(final IBaseDataObject d, @Nullable final IBaseDataObject
* @param d Adds a parameter indicating an auto gen id.
* @return uuid
*/
private String getRandomUUID(final IBaseDataObject d) {
private String getRandomUuid(final IBaseDataObject d) {
String uuid = UUID.randomUUID().toString();
// use the prefix
if (!StringUtils.isBlank(this.autoGeneratedIdPrefix)) {
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/emissary/output/roller/journal/JournalEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ public String toString() {
}

static JournalEntry deserialize(final ByteBuffer b) {
final int _keyLen = b.getInt();
final int keyLen = b.getInt();
validateSep(b.get());
final byte[] _keyBytes = new byte[_keyLen];
b.get(_keyBytes, 0, _keyLen);
final byte[] keyBytes = new byte[keyLen];
b.get(keyBytes, 0, keyLen);
validateSep(b.get());
final long _offset = b.getLong();
return new JournalEntry(new String(_keyBytes), _offset);
final long offset = b.getLong();
return new JournalEntry(new String(keyBytes), offset);
}

static void validateSep(final byte b) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/emissary/pickup/WorkSpace.java
Original file line number Diff line number Diff line change
Expand Up @@ -1196,11 +1196,11 @@ protected int collectFiles(final PriorityDirectory dir, final boolean wantDirect
long bytesInBundle = 0;

try {
int ff_options = FileFind.FILES_FLAG;
int ffOptions = FileFind.FILES_FLAG;
if (wantDirectories) {
ff_options |= FileFind.DIRECTORIES_FLAG;
ffOptions |= FileFind.DIRECTORIES_FLAG;
}
final FileFind ff = new FileFind(ff_options);
final FileFind ff = new FileFind(ffOptions);
final Iterator<?> f = ff.find(dir.getDirectoryName());

WorkBundle paths = new WorkBundle(basePath);
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/emissary/server/EmissaryServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public Server startServer() {
lbConfigHandler.setContextPath("/lbConfig");
ContextHandler apiHandler = buildApiHandler();
apiHandler.setContextPath("/api");
ContextHandler mvcHandler = buildMVCHandler();
ContextHandler mvcHandler = buildMvcHandler();
mvcHandler.setContextPath("/emissary");
// needs to be loaded last into the server so other contexts can match or fall through
ContextHandler staticHandler = buildStaticHandler();
Expand Down Expand Up @@ -182,8 +182,8 @@ public Server startServer() {
LOG.debug("Removing old {}", envsh.toAbsolutePath());
Files.delete(envsh);
}
String envURI = serverLocation + "/api/env.sh";
EmissaryResponse er = new EmissaryClient().send(new HttpGet(envURI));
String envUri = serverLocation + "/api/env.sh";
EmissaryResponse er = new EmissaryClient().send(new HttpGet(envUri));
String envString = er.getContentString();
Files.createFile(envsh);
Files.write(envsh, envString.getBytes());
Expand Down Expand Up @@ -612,7 +612,7 @@ private ContextHandler buildApiHandler() {
return apiHolderContext;
}

private ContextHandler buildMVCHandler() {
private ContextHandler buildMvcHandler() {

final ResourceConfig application = new ResourceConfig();
application.setApplicationName("mvc");
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/emissary/transform/decode/HtmlEscape.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public static String unescapeEntities(String s, @Nullable CharacterCounterSet co
}

if (ent != null) {
String val = getValueForHTMLEntity(ent);
String val = getValueForHtmlEntity(ent);
if (val != null) {
sb.append(val);
if (counters != null) {
Expand Down Expand Up @@ -327,7 +327,7 @@ public static byte[] unescapeEntities(byte[] s, @Nullable CharacterCounterSet co
}

@Nullable
private static String getValueForHTMLEntity(String entity) {
private static String getValueForHtmlEntity(String entity) {
String s = HTML_ENTITY_MAP.getValueForHTMLEntity(entity);
if (s != null) {
return s;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/emissary/util/CharsetUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@
* specific language governing permissions and limitations under the License.
*/
public class CharsetUtil {
private static final int[] TrailingBytesForUTF8 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
private static final int[] trailingBytesForUtF8 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
drivenflywheel marked this conversation as resolved.
Show resolved Hide resolved
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5};

@SuppressWarnings("unused")
private static final long[] OffsetsFromUTF8 = {0x00000000L, 0x00003080L, 0x000e2080L, 0x03c82080L, 0xfa082080L, 0x82082080L};
private static final long[] offsetsFromUtF8 = {0x00000000L, 0x00003080L, 0x000e2080L, 0x03c82080L, 0xfa082080L, 0x82082080L};

// Our logger
private static final Logger logger = LoggerFactory.getLogger(CharsetUtil.class);
Expand Down Expand Up @@ -243,7 +243,7 @@ public static boolean isUTF8(final byte[] data, final int offs, final int dlen)
while (pos < dlen) {
try {
final int val = data[pos] & 0xff;
final int len = TrailingBytesForUTF8[val] + 1;
final int len = trailingBytesForUtF8[val] + 1;
int srcptr = pos + len;

switch (len) {
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/emissary/util/ConstructorLookupCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,17 @@ public Constructor<?> getConstructor(final Class<?> desiredClazz, final Class<?>
private static final ThreadLocal<SoftReference<KnownConstructor>> cachedConstructorLookup = new ThreadLocal<>();

/** A table mapping boxed classes to their primitive types. */
private static final Map<Class<?>, Class<?>> PrimClass = new HashMap<>();
private static final Map<Class<?>, Class<?>> primClass = new HashMap<>();

// Initialize the mappings.
static {
PrimClass.put(Integer.class, Integer.TYPE);
PrimClass.put(Boolean.class, Boolean.TYPE);
PrimClass.put(Float.class, Float.TYPE);
PrimClass.put(Character.class, Character.TYPE);
PrimClass.put(Long.class, Long.TYPE);
PrimClass.put(Double.class, Double.TYPE);
PrimClass.put(Byte.class, Byte.TYPE);
primClass.put(Integer.class, Integer.TYPE);
primClass.put(Boolean.class, Boolean.TYPE);
primClass.put(Float.class, Float.TYPE);
primClass.put(Character.class, Character.TYPE);
primClass.put(Long.class, Long.TYPE);
primClass.put(Double.class, Double.TYPE);
primClass.put(Byte.class, Byte.TYPE);
}

/**
Expand All @@ -120,7 +120,7 @@ public Constructor<?> getConstructor(final Class<?> desiredClazz, final Class<?>
* @return If {@code clazz} is a boxed primitive, return the primitive type; otherwise just return {@code clazz}.
*/
private static Class<?> getPrim(final Class<?> clazz) {
final Class<?> prim = PrimClass.get(clazz);
final Class<?> prim = primClass.get(clazz);
return (prim != null) ? prim : clazz;
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/emissary/util/Entropy.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public static boolean checkText(final byte[] data, int length) {
// ******************************************************************
// ****************** scan the document ******************
// ******************************************************************
for (int cur_pos = 0; cur_pos < size; ++cur_pos) {
++histogramArray[data[cur_pos] & 0xff];
for (int curPos = 0; curPos < size; ++curPos) {
++histogramArray[data[curPos] & 0xff];
++bytes;
}

Expand Down
12 changes: 6 additions & 6 deletions src/main/java/emissary/util/PkiUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,24 +87,24 @@ public static char[] loadPW(@Nullable final String pazz) throws IOException {
if (pazz == null) {
return null;
}
String realPW;
String realPw;
if (pazz.startsWith(FILE_PRE)) {
final String pth = pazz.substring(FILE_PRE.length());
log.debug("Loading key password from file " + pth);
try (BufferedReader r = new BufferedReader(new FileReader(pth))) {
realPW = r.readLine();
realPw = r.readLine();
}
if (realPW == null) {
if (realPw == null) {
throw new IOException("Unable to load store password from " + pazz);
}
} else {
Matcher matcher = ENV_VARIABLE_PATTERN.matcher(pazz);
if (matcher.matches()) {
realPW = System.getenv(matcher.group(1));
realPw = System.getenv(matcher.group(1));
} else {
realPW = pazz;
realPw = pazz;
}
}
return realPW.toCharArray();
return realPw.toCharArray();
}
}