[errorprone] Remove unnecessary parentheses

see https://errorprone.info/bugpattern/UnnecessaryParentheses

Change-Id: Id08cf0e05b3d35f139fc34e0aa83882555a8a81a
This commit is contained in:
Matthias Sohn 2023-09-16 22:09:11 +02:00
parent d65170603f
commit 4cf246c9ab
18 changed files with 24 additions and 26 deletions

View File

@ -13,6 +13,7 @@
import static org.eclipse.jgit.util.HttpSupport.HDR_ACCEPT; import static org.eclipse.jgit.util.HttpSupport.HDR_ACCEPT;
import static org.eclipse.jgit.util.HttpSupport.HDR_ACCEPT_ENCODING; import static org.eclipse.jgit.util.HttpSupport.HDR_ACCEPT_ENCODING;
import static org.eclipse.jgit.util.HttpSupport.HDR_CONTENT_TYPE; import static org.eclipse.jgit.util.HttpSupport.HDR_CONTENT_TYPE;
import static org.eclipse.jgit.lib.Constants.DEFAULT_REMOTE_NAME;
import java.io.IOException; import java.io.IOException;
import java.net.ProxySelector; import java.net.ProxySelector;
@ -128,8 +129,7 @@ private static String getLfsUrl(Repository db, String purpose,
// This could be done better (more precise logic), but according // This could be done better (more precise logic), but according
// to https://github.com/git-lfs/git-lfs/issues/1759 git-lfs // to https://github.com/git-lfs/git-lfs/issues/1759 git-lfs
// generally only supports 'origin' in an integrated workflow. // generally only supports 'origin' in an integrated workflow.
if (lfsUrl == null && (remote.equals( if (lfsUrl == null && remote.equals(DEFAULT_REMOTE_NAME)) {
org.eclipse.jgit.lib.Constants.DEFAULT_REMOTE_NAME))) {
remoteUrl = config.getString( remoteUrl = config.getString(
ConfigConstants.CONFIG_KEY_REMOTE, remote, ConfigConstants.CONFIG_KEY_REMOTE, remote,
ConfigConstants.CONFIG_KEY_URL); ConfigConstants.CONFIG_KEY_URL);

View File

@ -355,8 +355,7 @@ static void configureHttpProxy() throws MalformedURLException {
continue; continue;
} }
final URL u = new URL( URL u = new URL(!s.contains("://") ? protocol + "://" + s : s); //$NON-NLS-1$ //$NON-NLS-2$
(!s.contains("://")) ? protocol + "://" + s : s); //$NON-NLS-1$ //$NON-NLS-2$
if (!u.getProtocol().startsWith("http")) //$NON-NLS-1$ if (!u.getProtocol().startsWith("http")) //$NON-NLS-1$
throw new MalformedURLException(MessageFormat.format( throw new MalformedURLException(MessageFormat.format(
CLIText.get().invalidHttpProxyOnlyHttpSupported, s)); CLIText.get().invalidHttpProxyOnlyHttpSupported, s));

View File

@ -226,7 +226,7 @@ private void printLongStatus(org.eclipse.jgit.api.Status status)
firstHeader = false; firstHeader = false;
} }
int nbUntracked = untracked.size(); int nbUntracked = untracked.size();
if (nbUntracked > 0 && ("all".equals(untrackedFilesMode))) { //$NON-NLS-1$ if (nbUntracked > 0 && "all".equals(untrackedFilesMode)) { //$NON-NLS-1$
if (!firstHeader) if (!firstHeader)
printSectionHeader(""); //$NON-NLS-1$ printSectionHeader(""); //$NON-NLS-1$
printSectionHeader(CLIText.get().untrackedFiles); printSectionHeader(CLIText.get().untrackedFiles);

View File

@ -614,7 +614,7 @@ private void processOptions(RepositoryState state, RevWalk rw)
// specified the commit should not be empty. This behaviour differs // specified the commit should not be empty. This behaviour differs
// from native git but can only be adapted in the next release. // from native git but can only be adapted in the next release.
// TODO(ch) align the defaults with native git // TODO(ch) align the defaults with native git
allowEmpty = (only.isEmpty()) ? Boolean.TRUE : Boolean.FALSE; allowEmpty = only.isEmpty() ? Boolean.TRUE : Boolean.FALSE;
// when doing a merge commit parse MERGE_HEAD and MERGE_MSG files // when doing a merge commit parse MERGE_HEAD and MERGE_MSG files
if (state == RepositoryState.MERGING_RESOLVED if (state == RepositoryState.MERGING_RESOLVED

View File

@ -107,7 +107,7 @@ static class ExtraContent {
PersonIdent author, RemoteReader callback, PersonIdent author, RemoteReader callback,
BareWriterConfig config, BareWriterConfig config,
List<ExtraContent> extraContents) { List<ExtraContent> extraContents) {
assert (repo.isBare()); assert repo.isBare();
this.repo = repo; this.repo = repo;
this.targetUri = targetUri; this.targetUri = targetUri;
this.targetBranch = targetBranch; this.targetBranch = targetBranch;

View File

@ -64,8 +64,8 @@ RevCommit write(List<RepoProject> repoProjects)
private void addSubmodule(String name, String url, String path, private void addSubmodule(String name, String url, String path,
String revision, List<CopyFile> copyfiles, List<LinkFile> linkfiles, String revision, List<CopyFile> copyfiles, List<LinkFile> linkfiles,
Git git) throws GitAPIException, IOException { Git git) throws GitAPIException, IOException {
assert (!repo.isBare()); assert !repo.isBare();
assert (git != null); assert git != null;
if (!linkfiles.isEmpty()) { if (!linkfiles.isEmpty()) {
throw new UnsupportedOperationException( throw new UnsupportedOperationException(
JGitText.get().nonBareLinkFilesNotSupported); JGitText.get().nonBareLinkFilesNotSupported);

View File

@ -359,7 +359,7 @@ private boolean doLogExponentialBackoff(int n) {
} }
boolean searchPacksAgain(PackList old) { boolean searchPacksAgain(PackList old) {
return ((!trustFolderStat) || old.snapshot.isModified(directory)) return (!trustFolderStat || old.snapshot.isModified(directory))
&& old != scanPacks(old); && old != scanPacks(old);
} }

View File

@ -138,7 +138,7 @@ public long findOffset(AnyObjectId objId) {
int b1 = data[pos - 3] & 0xff; int b1 = data[pos - 3] & 0xff;
int b2 = data[pos - 2] & 0xff; int b2 = data[pos - 2] & 0xff;
int b3 = data[pos - 1] & 0xff; int b3 = data[pos - 1] & 0xff;
return (((long) b0) << 24) | (b1 << 16) | (b2 << 8) | (b3); return (((long) b0) << 24) | (b1 << 16) | (b2 << 8) | b3;
} }
@Override @Override

View File

@ -92,7 +92,7 @@ private static int estimateEntryCount(byte blockType, byte keyType,
} }
} }
int cnt = (int) (Math.ceil(blockLimitBytes / avgBytesPerEntry)); int cnt = (int) Math.ceil(blockLimitBytes / avgBytesPerEntry);
return Math.min(cnt, 4096); return Math.min(cnt, 4096);
} }

View File

@ -349,7 +349,7 @@ else if (!dirCacheBuilder.commit()) {
} }
private File getFile(String path) { private File getFile(String path) {
return (inCore()) ? null : new File(repo.getWorkTree(), path); return inCore() ? null : new File(repo.getWorkTree(), path);
} }
/* returns null if the path is not found. */ /* returns null if the path is not found. */

View File

@ -540,7 +540,7 @@ public static boolean containsGitModulesFile(Repository repository)
} }
File modulesFile = new File(repository.getWorkTree(), File modulesFile = new File(repository.getWorkTree(),
Constants.DOT_GIT_MODULES); Constants.DOT_GIT_MODULES);
return (modulesFile.exists()); return modulesFile.exists();
} }
private void lazyLoadModulesConfig() throws IOException, ConfigInvalidException { private void lazyLoadModulesConfig() throws IOException, ConfigInvalidException {

View File

@ -140,7 +140,7 @@ static HttpAuthMethod scanResponse(final HttpConnection conn,
valuePart[0].toUpperCase(Locale.ROOT)); valuePart[0].toUpperCase(Locale.ROOT));
if ((ignoreTypes != null) if ((ignoreTypes != null)
&& (ignoreTypes.contains(methodType))) { && ignoreTypes.contains(methodType)) {
continue; continue;
} }

View File

@ -101,7 +101,7 @@ public class HttpConfig {
private static final int DEFAULT_MAX_REDIRECTS = 5; private static final int DEFAULT_MAX_REDIRECTS = 5;
private static final int MAX_REDIRECTS = (new Supplier<Integer>() { private static final int MAX_REDIRECTS = new Supplier<Integer>() {
@Override @Override
public Integer get() { public Integer get() {
@ -119,7 +119,7 @@ public Integer get() {
} }
return value; return value;
} }
}).get().intValue(); }.get().intValue();
private static final String ENV_HTTP_USER_AGENT = "GIT_HTTP_USER_AGENT"; //$NON-NLS-1$ private static final String ENV_HTTP_USER_AGENT = "GIT_HTTP_USER_AGENT"; //$NON-NLS-1$

View File

@ -160,7 +160,7 @@ public PushConnection openPush() throws TransportException {
String commandFor(String exe) { String commandFor(String exe) {
String path = uri.getPath(); String path = uri.getPath();
if (uri.getScheme() != null && uri.getPath().startsWith("/~")) //$NON-NLS-1$ if (uri.getScheme() != null && uri.getPath().startsWith("/~")) //$NON-NLS-1$
path = (uri.getPath().substring(1)); path = uri.getPath().substring(1);
final StringBuilder cmd = new StringBuilder(); final StringBuilder cmd = new StringBuilder();
cmd.append(exe); cmd.append(exe);

View File

@ -1514,7 +1514,7 @@ public String getFilterCommand(String filterCommandType)
} }
return filterCommand.replaceAll("%f", //$NON-NLS-1$ return filterCommand.replaceAll("%f", //$NON-NLS-1$
Matcher.quoteReplacement( Matcher.quoteReplacement(
QuotedString.BOURNE.quote((getPathString())))); QuotedString.BOURNE.quote(getPathString())));
} }
/** /**
@ -1564,7 +1564,7 @@ public String getSmudgeCommand(Attributes attributes) throws IOException {
} }
return filterCommand.replaceAll("%f", //$NON-NLS-1$ return filterCommand.replaceAll("%f", //$NON-NLS-1$
Matcher.quoteReplacement( Matcher.quoteReplacement(
QuotedString.BOURNE.quote((getPathString())))); QuotedString.BOURNE.quote(getPathString())));
} }
/** /**

View File

@ -374,8 +374,8 @@ public boolean createNewFile(File lock) throws IOException {
link = Files.createLink( link = Files.createLink(
Paths.get(lock.getAbsolutePath() + ".lnk"), //$NON-NLS-1$ Paths.get(lock.getAbsolutePath() + ".lnk"), //$NON-NLS-1$
lockPath); lockPath);
Integer nlink = (Integer) (Files.getAttribute(lockPath, Integer nlink = (Integer) Files.getAttribute(lockPath,
"unix:nlink")); //$NON-NLS-1$ "unix:nlink"); //$NON-NLS-1$
if (nlink > 2) { if (nlink > 2) {
LOG.warn(MessageFormat.format( LOG.warn(MessageFormat.format(
JGitText.get().failedAtomicFileCreation, lockPath, JGitText.get().failedAtomicFileCreation, lockPath,
@ -447,8 +447,7 @@ public LockToken createNewFileAtomic(File file) throws IOException {
return token(true, null); return token(true, null);
} }
link = Files.createLink(Paths.get(uniqueLinkPath(file)), path); link = Files.createLink(Paths.get(uniqueLinkPath(file)), path);
Integer nlink = (Integer) (Files.getAttribute(path, Integer nlink = (Integer) Files.getAttribute(path, "unix:nlink"); //$NON-NLS-1$
"unix:nlink")); //$NON-NLS-1$
if (nlink.intValue() > 2) { if (nlink.intValue() > 2) {
LOG.warn(MessageFormat.format( LOG.warn(MessageFormat.format(
JGitText.get().failedAtomicFileCreation, path, nlink)); JGitText.get().failedAtomicFileCreation, path, nlink));

View File

@ -28,7 +28,7 @@ public abstract class GSSManagerFactory {
* @return detected GSSManager factory * @return detected GSSManager factory
*/ */
public static GSSManagerFactory detect() { public static GSSManagerFactory detect() {
return (SunGSSManagerFactory.isSupported()) ? new SunGSSManagerFactory() return SunGSSManagerFactory.isSupported() ? new SunGSSManagerFactory()
: new DefaultGSSManagerFactory(); : new DefaultGSSManagerFactory();
} }

View File

@ -407,7 +407,7 @@ private void recompress(int t) {
private static int s1(int a, int b, int c, int d, int w_t) { private static int s1(int a, int b, int c, int d, int w_t) {
return rotateLeft(a, 5) return rotateLeft(a, 5)
// f: 0 <= t <= 19 // f: 0 <= t <= 19
+ ((b & c) | ((~b) & d)) + ((b & c) | (~b & d))
+ 0x5A827999 + w_t; + 0x5A827999 + w_t;
} }