[errorprone] Fix BadImport

See https://errorprone.info/bugpattern/BadImport

Change-Id: Iea98b15862ed0bc4bcad759a7240133769680808
This commit is contained in:
Matthias Sohn 2023-09-22 01:30:04 +02:00
parent a7edc7889c
commit d56ae55c83
16 changed files with 55 additions and 74 deletions

View File

@ -10,8 +10,6 @@
package org.eclipse.jgit.http.server.glue;
import static java.lang.Integer.valueOf;
import java.io.IOException;
import java.text.MessageFormat;
@ -45,7 +43,8 @@ public class RegexGroupFilter implements Filter {
public RegexGroupFilter(int groupIdx) {
if (groupIdx < 1)
throw new IllegalArgumentException(MessageFormat.format(
HttpServerText.get().invalidIndex, valueOf(groupIdx)));
HttpServerText.get().invalidIndex,
Integer.valueOf(groupIdx)));
this.groupIdx = groupIdx - 1;
}
@ -69,7 +68,7 @@ public void doFilter(final ServletRequest request,
else
throw new ServletException(MessageFormat.format(
HttpServerText.get().invalidRegexGroup,
valueOf(groupIdx + 1)));
Integer.valueOf(groupIdx + 1)));
}
private static WrappedRequest[] groupsFor(ServletRequest r) {

View File

@ -9,8 +9,6 @@
*/
package org.eclipse.jgit.junit;
import static java.lang.Boolean.valueOf;
/**
* Assertion class
*/
@ -25,7 +23,8 @@ public class Assert {
* actual value
*/
public static void assertEquals(boolean expect, boolean actual) {
org.junit.Assert.assertEquals(valueOf(expect), valueOf(actual));
org.junit.Assert.assertEquals(Boolean.valueOf(expect),
Boolean.valueOf(actual));
}
/**
@ -41,6 +40,7 @@ public static void assertEquals(boolean expect, boolean actual) {
public static void assertEquals(String message, boolean expect,
boolean actual) {
org.junit.Assert
.assertEquals(message, valueOf(expect), valueOf(actual));
.assertEquals(message, Boolean.valueOf(expect),
Boolean.valueOf(actual));
}
}

View File

@ -14,8 +14,6 @@
package org.eclipse.jgit.pgm;
import static java.lang.Character.valueOf;
import java.io.IOException;
import java.text.MessageFormat;
@ -59,8 +57,8 @@ protected void showFetchResult(FetchResult r) throws IOException {
shownURI = true;
}
outw.format(" %c %-17s %-10s -> %s", valueOf(type), longType, //$NON-NLS-1$
src, dst);
outw.format(" %c %-17s %-10s -> %s", Character.valueOf(type), //$NON-NLS-1$
longType, src, dst);
outw.println();
}
}

View File

@ -11,8 +11,6 @@
package org.eclipse.jgit.pgm;
import static java.lang.Integer.valueOf;
import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
@ -66,7 +64,7 @@ protected void run() throws Exception {
if (n < 0)
throw new EOFException(MessageFormat.format(
CLIText.get().expectedNumberOfbytes,
valueOf(len)));
Integer.valueOf(len)));
outs.write(tmp, 0, n);
len -= n;
}

View File

@ -13,8 +13,6 @@
package org.eclipse.jgit.pgm;
import static java.lang.Integer.valueOf;
import static java.lang.Long.valueOf;
import static org.eclipse.jgit.lib.Constants.OBJECT_ID_ABBREV_STRING_LENGTH;
import static org.eclipse.jgit.lib.Constants.OBJECT_ID_STRING_LENGTH;
@ -197,13 +195,14 @@ && sameCommit(blame.getSourceCommit(line + 1), c)) {
maxSourceLine = Math.max(maxSourceLine, blame.getSourceLine(line));
}
String pathFmt = MessageFormat.format(" %{0}s", valueOf(pathWidth)); //$NON-NLS-1$
String pathFmt = MessageFormat.format(" %{0}s", //$NON-NLS-1$
Integer.valueOf(pathWidth));
String numFmt = MessageFormat.format(" %{0}d", //$NON-NLS-1$
valueOf(1 + (int) Math.log10(maxSourceLine + 1)));
Integer.valueOf(1 + (int) Math.log10(maxSourceLine + 1)));
String lineFmt = MessageFormat.format(" %{0}d) ", //$NON-NLS-1$
valueOf(1 + (int) Math.log10(end + 1)));
Integer.valueOf(1 + (int) Math.log10(end + 1)));
String authorFmt = MessageFormat.format(" (%-{0}s %{1}s", //$NON-NLS-1$
valueOf(authorWidth), valueOf(dateWidth));
Integer.valueOf(authorWidth), Integer.valueOf(dateWidth));
for (int line = begin; line < end;) {
RevCommit c = blame.getSourceCommit(line);
@ -220,12 +219,13 @@ && sameCommit(blame.getSourceCommit(line + 1), c)) {
outw.format(pathFmt, path(line));
}
if (showSourceLine) {
outw.format(numFmt, valueOf(blame.getSourceLine(line) + 1));
outw.format(numFmt,
Integer.valueOf(blame.getSourceLine(line) + 1));
}
if (!noAuthor) {
outw.format(authorFmt, author, date);
}
outw.format(lineFmt, valueOf(line + 1));
outw.format(lineFmt, Integer.valueOf(line + 1));
outw.flush();
blame.getResultContents().writeLine(outs, line);
outs.flush();
@ -339,7 +339,7 @@ private String date(int line) {
if (!showRawTimestamp)
return dateFmt.format(author.getWhen());
return String.format("%d %s", //$NON-NLS-1$
valueOf(author.getWhen().getTime() / 1000L),
Long.valueOf(author.getWhen().getTime() / 1000L),
dateFmt.format(author.getWhen()));
}

View File

@ -12,7 +12,6 @@
package org.eclipse.jgit.pgm;
import static java.lang.Integer.valueOf;
import static org.eclipse.jgit.lib.Constants.HEAD;
import static org.eclipse.jgit.lib.Constants.OBJECT_ID_STRING_LENGTH;
@ -228,13 +227,15 @@ static void nameStatus(ThrowingPrintWriter out, List<DiffEntry> files)
out.println("M\t" + ent.getNewPath()); //$NON-NLS-1$
break;
case COPY:
out.format("C%1$03d\t%2$s\t%3$s", valueOf(ent.getScore()), // //$NON-NLS-1$
ent.getOldPath(), ent.getNewPath());
out.format("C%1$03d\t%2$s\t%3$s", //$NON-NLS-1$
Integer.valueOf(ent.getScore()), ent.getOldPath(),
ent.getNewPath());
out.println();
break;
case RENAME:
out.format("R%1$03d\t%2$s\t%3$s", valueOf(ent.getScore()), // //$NON-NLS-1$
ent.getOldPath(), ent.getNewPath());
out.format("R%1$03d\t%2$s\t%3$s", //$NON-NLS-1$
Integer.valueOf(ent.getScore()), ent.getOldPath(),
ent.getNewPath());
out.println();
break;
}

View File

@ -41,7 +41,6 @@
import org.eclipse.jgit.errors.RevisionSyntaxException;
import org.eclipse.jgit.internal.diffmergetool.ExternalMergeTool;
import org.eclipse.jgit.internal.diffmergetool.FileElement;
import org.eclipse.jgit.internal.diffmergetool.FileElement.Type;
import org.eclipse.jgit.internal.diffmergetool.MergeTools;
import org.eclipse.jgit.internal.diffmergetool.ToolException;
import org.eclipse.jgit.lib.Constants;
@ -218,8 +217,8 @@ private MergeResult mergeModified(String mergedFilePath, boolean showPrompt)
FileElement base = null;
FileElement local = null;
FileElement remote = null;
FileElement merged = new FileElement(mergedFilePath, Type.MERGED,
db.getWorkTree());
FileElement merged = new FileElement(mergedFilePath,
FileElement.Type.MERGED, db.getWorkTree());
DirCache cache = db.readDirCache();
try (RevWalk revWalk = new RevWalk(db);
TreeWalk treeWalk = new TreeWalk(db,
@ -249,7 +248,8 @@ private MergeResult mergeModified(String mergedFilePath, boolean showPrompt)
ObjectId id = entry.getObjectId();
switch (entry.getStage()) {
case DirCacheEntry.STAGE_1:
base = new FileElement(mergedFilePath, Type.BASE);
base = new FileElement(mergedFilePath,
FileElement.Type.BASE);
DirCacheCheckout.getContent(db, mergedFilePath,
checkoutMetadata,
baseSource.open(mergedFilePath, id), opt,
@ -257,7 +257,8 @@ private MergeResult mergeModified(String mergedFilePath, boolean showPrompt)
base.createTempFile(tempFilesParent)));
break;
case DirCacheEntry.STAGE_2:
local = new FileElement(mergedFilePath, Type.LOCAL);
local = new FileElement(mergedFilePath,
FileElement.Type.LOCAL);
DirCacheCheckout.getContent(db, mergedFilePath,
checkoutMetadata,
localSource.open(mergedFilePath, id), opt,
@ -265,7 +266,8 @@ private MergeResult mergeModified(String mergedFilePath, boolean showPrompt)
local.createTempFile(tempFilesParent)));
break;
case DirCacheEntry.STAGE_3:
remote = new FileElement(mergedFilePath, Type.REMOTE);
remote = new FileElement(mergedFilePath,
FileElement.Type.REMOTE);
DirCacheCheckout.getContent(db, mergedFilePath,
checkoutMetadata,
remoteSource.open(mergedFilePath, id), opt,

View File

@ -11,8 +11,6 @@
package org.eclipse.jgit.pgm;
import static java.lang.Character.valueOf;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.ArrayList;
@ -233,7 +231,7 @@ private static String safeAbbreviate(ObjectReader reader, ObjectId id) {
private void printUpdateLine(final char flag, final String summary,
final String srcRef, final String destRef, final String message)
throws IOException {
outw.format(" %c %-17s", valueOf(flag), summary); //$NON-NLS-1$
outw.format(" %c %-17s", Character.valueOf(flag), summary); //$NON-NLS-1$
if (srcRef != null)
outw.format(" %s ->", abbreviateRef(srcRef, true)); //$NON-NLS-1$

View File

@ -10,9 +10,6 @@
package org.eclipse.jgit.pgm.debug;
import static java.lang.Integer.valueOf;
import static java.lang.Long.valueOf;
import java.io.File;
import java.lang.management.ManagementFactory;
import java.lang.management.ThreadMXBean;
@ -216,10 +213,10 @@ private void run(Repository repo) throws Exception {
outw.println(name + ": start at " + startId.name()); //$NON-NLS-1$
}
outw.format(" %12d files, %8d commits\n", valueOf(files), //$NON-NLS-1$
valueOf(commits));
outw.format(" N=%10d min lines, %8d max lines\n", valueOf(minN), //$NON-NLS-1$
valueOf(maxN));
outw.format(" %12d files, %8d commits\n", Long.valueOf(files), //$NON-NLS-1$
Integer.valueOf(commits));
outw.format(" N=%10d min lines, %8d max lines\n", //$NON-NLS-1$
Integer.valueOf(minN), Integer.valueOf(maxN));
outw.format("%-25s %12s ( %12s %12s )\n", //$NON-NLS-1$
"Algorithm", "Time(ns)", "Time(ns) on", "Time(ns) on"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@ -231,9 +228,9 @@ private void run(Repository repo) throws Exception {
for (Test test : all) {
outw.format("%-25s %12d ( %12d %12d )", // //$NON-NLS-1$
test.algorithm.name, //
valueOf(test.runningTimeNanos), //
valueOf(test.minN.runningTimeNanos), //
valueOf(test.maxN.runningTimeNanos));
Long.valueOf(test.runningTimeNanos), //
Long.valueOf(test.minN.runningTimeNanos), //
Long.valueOf(test.maxN.runningTimeNanos));
outw.println();
}
outw.println();

View File

@ -11,8 +11,6 @@
package org.eclipse.jgit.pgm.debug;
import static java.lang.Integer.valueOf;
import java.io.IOException;
import java.text.MessageFormat;
@ -33,8 +31,8 @@ protected void run() throws Exception {
private void show(DirCacheTree tree) throws IOException {
outw.println(MessageFormat.format(CLIText.get().cacheTreePathInfo,
tree.getPathString(), valueOf(tree.getEntrySpan()),
valueOf(tree.getChildCount())));
tree.getPathString(), Integer.valueOf(tree.getEntrySpan()),
Integer.valueOf(tree.getChildCount())));
for (int i = 0; i < tree.getChildCount(); i++)
show(tree.getChild(i));

View File

@ -11,8 +11,6 @@
package org.eclipse.jgit.pgm.debug;
import static java.lang.Long.valueOf;
import java.text.MessageFormat;
import org.eclipse.jgit.pgm.Command;
@ -30,6 +28,6 @@ protected void run() throws Exception {
final long end = System.currentTimeMillis();
outw.print(" "); //$NON-NLS-1$
outw.println(MessageFormat.format(CLIText.get().averageMSPerRead,
valueOf((end - start) / cnt)));
Long.valueOf((end - start) / cnt)));
}
}

View File

@ -11,8 +11,6 @@
package org.eclipse.jgit.pgm.debug;
import static java.lang.Integer.valueOf;
import java.io.IOException;
import java.text.MessageFormat;
@ -35,8 +33,8 @@ protected void run() throws Exception {
private void show(DirCacheTree tree) throws IOException {
outw.println(MessageFormat.format(CLIText.get().cacheTreePathInfo,
tree.getPathString(), valueOf(tree.getEntrySpan()),
valueOf(tree.getChildCount())));
tree.getPathString(), Integer.valueOf(tree.getEntrySpan()),
Integer.valueOf(tree.getChildCount())));
for (int i = 0; i < tree.getChildCount(); i++)
show(tree.getChild(i));

View File

@ -13,8 +13,6 @@
package org.eclipse.jgit.pgm.debug;
import static java.lang.Integer.valueOf;
import java.time.Instant;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
@ -49,7 +47,7 @@ protected void run() throws Exception {
final int stage = ent.getStage();
outw.print(mode);
outw.format(" %6d", valueOf(len)); //$NON-NLS-1$
outw.format(" %6d", Integer.valueOf(len)); //$NON-NLS-1$
outw.print(' ');
if (millis) {
outw.print(mtime.toEpochMilli());

View File

@ -10,9 +10,6 @@
package org.eclipse.jgit.pgm.debug;
import static java.lang.Integer.valueOf;
import static java.lang.Long.valueOf;
import java.io.File;
import java.lang.reflect.Field;
import java.security.MessageDigest;
@ -313,8 +310,8 @@ private void run(Repository repo) throws Exception {
outw.println(name + ":"); //$NON-NLS-1$
}
outw.format(" %6d files; %5d avg. unique lines/file\n", //$NON-NLS-1$
valueOf(fileCnt), //
valueOf(lineCnt / fileCnt));
Long.valueOf(fileCnt), //
Long.valueOf(lineCnt / fileCnt));
outw.format("%-20s %-15s %9s\n", "Hash", "Fold", "Max Len"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
outw.println("-----------------------------------------------"); //$NON-NLS-1$
String lastHashName = null;
@ -325,7 +322,7 @@ private void run(Repository repo) throws Exception {
outw.format("%-20s %-15s %9d\n", // //$NON-NLS-1$
hashName, //
fun.fold.name, //
valueOf(fun.maxChainLength));
Integer.valueOf(fun.maxChainLength));
lastHashName = fun.hash.name;
}
outw.println();

View File

@ -26,14 +26,13 @@
import java.util.TreeMap;
import org.eclipse.jgit.internal.JGitText;
import org.eclipse.jgit.internal.diffmergetool.FileElement.Type;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.StoredConfig;
import org.eclipse.jgit.lib.internal.BooleanTriState;
import org.eclipse.jgit.treewalk.TreeWalk;
import org.eclipse.jgit.util.FS;
import org.eclipse.jgit.util.StringUtils;
import org.eclipse.jgit.util.FS.ExecutionResult;
import org.eclipse.jgit.util.StringUtils;
/**
* Manages merge tools.
@ -242,7 +241,7 @@ private FileElement createBackupFile(FileElement from, File toParentDir)
FileElement backup = null;
Path path = Paths.get(from.getPath());
if (Files.exists(path)) {
backup = new FileElement(from.getPath(), Type.BACKUP);
backup = new FileElement(from.getPath(), FileElement.Type.BACKUP);
Files.copy(path, backup.createTempFile(toParentDir).toPath(),
StandardCopyOption.REPLACE_EXISTING);
}

View File

@ -95,7 +95,6 @@
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.StoredConfig;
import org.eclipse.jgit.lib.SymbolicRef;
import org.eclipse.jgit.transport.HttpAuthMethod.Type;
import org.eclipse.jgit.transport.HttpConfig.HttpRedirectMode;
import org.eclipse.jgit.transport.http.HttpConnection;
import org.eclipse.jgit.transport.http.HttpConnectionFactory;
@ -647,7 +646,7 @@ private HttpConnection connect(String service,
}
int authAttempts = 1;
int redirects = 0;
Collection<Type> ignoreTypes = null;
Collection<HttpAuthMethod.Type> ignoreTypes = null;
for (;;) {
try {
final HttpConnection conn = httpOpen(METHOD_GET, u, AcceptEncoding.GZIP);
@ -1666,7 +1665,8 @@ void sendRequest() throws IOException {
}
HttpAuthMethod authenticator = null;
Collection<Type> ignoreTypes = EnumSet.noneOf(Type.class);
Collection<HttpAuthMethod.Type> ignoreTypes = EnumSet
.noneOf(HttpAuthMethod.Type.class);
// Counts number of repeated authentication attempts using the same
// authentication scheme
int authAttempts = 1;