]> source.dussan.org Git - jgit.git/commitdiff
[errorprone] Remove unnecessary parentheses 49/204549/2
authorMatthias Sohn <matthias.sohn@sap.com>
Sat, 16 Sep 2023 20:09:11 +0000 (22:09 +0200)
committerMatthias Sohn <matthias.sohn@sap.com>
Fri, 22 Sep 2023 21:31:27 +0000 (23:31 +0200)
see https://errorprone.info/bugpattern/UnnecessaryParentheses

Change-Id: Id08cf0e05b3d35f139fc34e0aa83882555a8a81a

18 files changed:
org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal/LfsConnectionFactory.java
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Status.java
org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/BareSuperprojectWriter.java
org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RegularSuperprojectWriter.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackDirectory.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackIndexV1.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/BlockWriter.java
org.eclipse.jgit/src/org/eclipse/jgit/patch/PatchApplier.java
org.eclipse.jgit/src/org/eclipse/jgit/submodule/SubmoduleWalk.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/HttpAuthMethod.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/HttpConfig.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportGitSsh.java
org.eclipse.jgit/src/org/eclipse/jgit/treewalk/TreeWalk.java
org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java
org.eclipse.jgit/src/org/eclipse/jgit/util/GSSManagerFactory.java
org.eclipse.jgit/src/org/eclipse/jgit/util/sha1/SHA1Java.java

index f9c623d8b7df4e6832be63e632a33da51a5f6327..08fec341a8e72ec047fd80f955644fe8523477de 100644 (file)
@@ -13,6 +13,7 @@ import static org.eclipse.jgit.util.HttpSupport.ENCODING_GZIP;
 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_CONTENT_TYPE;
+import static org.eclipse.jgit.lib.Constants.DEFAULT_REMOTE_NAME;
 
 import java.io.IOException;
 import java.net.ProxySelector;
@@ -128,8 +129,7 @@ public class LfsConnectionFactory {
                                // This could be done better (more precise logic), but according
                                // to https://github.com/git-lfs/git-lfs/issues/1759 git-lfs
                                // generally only supports 'origin' in an integrated workflow.
-                               if (lfsUrl == null && (remote.equals(
-                                               org.eclipse.jgit.lib.Constants.DEFAULT_REMOTE_NAME))) {
+                               if (lfsUrl == null && remote.equals(DEFAULT_REMOTE_NAME)) {
                                        remoteUrl = config.getString(
                                                        ConfigConstants.CONFIG_KEY_REMOTE, remote,
                                                        ConfigConstants.CONFIG_KEY_URL);
index d059eff5d72623bd8ec55a2702322c8019b45558..8df9bad7403891f7deb454ec9456fc7279b97adb 100644 (file)
@@ -355,8 +355,7 @@ public class Main {
                                continue;
                        }
 
-                       final URL u = new URL(
-                                       (!s.contains("://")) ? protocol + "://" + s : s); //$NON-NLS-1$ //$NON-NLS-2$
+                       URL u = new URL(!s.contains("://") ? protocol + "://" + s : s); //$NON-NLS-1$ //$NON-NLS-2$
                        if (!u.getProtocol().startsWith("http")) //$NON-NLS-1$
                                throw new MalformedURLException(MessageFormat.format(
                                                CLIText.get().invalidHttpProxyOnlyHttpSupported, s));
index 1ef39a1a7d485f8e88064dd64558b7485621dbe2..c96e475613e724f83fd22a63585c7aadec3cde23 100644 (file)
@@ -226,7 +226,7 @@ class Status extends TextBuiltin {
                        firstHeader = false;
                }
                int nbUntracked = untracked.size();
-               if (nbUntracked > 0 && ("all".equals(untrackedFilesMode))) { //$NON-NLS-1$
+               if (nbUntracked > 0 && "all".equals(untrackedFilesMode)) { //$NON-NLS-1$
                        if (!firstHeader)
                                printSectionHeader(""); //$NON-NLS-1$
                        printSectionHeader(CLIText.get().untrackedFiles);
index 3b3baf5a12ef1d3d6f03a9acc1f2fcc28912284f..483b9602daa627e2f0a672d9d75727d4afc6c9ed 100644 (file)
@@ -614,7 +614,7 @@ public class CommitCommand extends GitCommand<RevCommit> {
                        // specified the commit should not be empty. This behaviour differs
                        // from native git but can only be adapted in the next release.
                        // 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
                if (state == RepositoryState.MERGING_RESOLVED
index f63cc6d64483f0d16b4f3caee7d06f5acc979634..3ce97a4ff71441bc6b458771752f34f34ee60651 100644 (file)
@@ -107,7 +107,7 @@ class BareSuperprojectWriter {
                        PersonIdent author, RemoteReader callback,
                        BareWriterConfig config,
                        List<ExtraContent> extraContents) {
-               assert (repo.isBare());
+               assert repo.isBare();
                this.repo = repo;
                this.targetUri = targetUri;
                this.targetBranch = targetBranch;
index afab9943a79467e74d9d4719fe0d5cbe89294a6c..7632b367c17144c17933075dbd50fb70375929d3 100644 (file)
@@ -64,8 +64,8 @@ class RegularSuperprojectWriter {
        private void addSubmodule(String name, String url, String path,
                        String revision, List<CopyFile> copyfiles, List<LinkFile> linkfiles,
                        Git git) throws GitAPIException, IOException {
-               assert (!repo.isBare());
-               assert (git != null);
+               assert !repo.isBare();
+               assert git != null;
                if (!linkfiles.isEmpty()) {
                        throw new UnsupportedOperationException(
                                        JGitText.get().nonBareLinkFilesNotSupported);
index 28f6250a22579f7768037abaf065c075e8cc0b6a..b1da1cb159baeeb14d3334f8bdc6685e5de4bdad 100644 (file)
@@ -359,7 +359,7 @@ class PackDirectory {
        }
 
        boolean searchPacksAgain(PackList old) {
-               return ((!trustFolderStat) || old.snapshot.isModified(directory))
+               return (!trustFolderStat || old.snapshot.isModified(directory))
                                && old != scanPacks(old);
        }
 
index 860ebaefc2e0a3e0e232acd33996fe0840095ce6..4563c9039ca278d2446d16b37fec03ab94af5367 100644 (file)
@@ -138,7 +138,7 @@ class PackIndexV1 extends PackIndex {
                int b1 = data[pos - 3] & 0xff;
                int b2 = data[pos - 2] & 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
index e3c0fc94aa56ce6d419ac750d8d53ed2d003c9bf..c70f2e4914f853a51c0823d4daa7daedcbb24d41 100644 (file)
@@ -92,7 +92,7 @@ class BlockWriter {
                        }
                }
 
-               int cnt = (int) (Math.ceil(blockLimitBytes / avgBytesPerEntry));
+               int cnt = (int) Math.ceil(blockLimitBytes / avgBytesPerEntry);
                return Math.min(cnt, 4096);
        }
 
index 7cfc162d77590a361fe169d66d8c9c0899813128..6c61cdf2bb92d6c665aab881aa14653e74d1e115 100644 (file)
@@ -349,7 +349,7 @@ public class PatchApplier {
        }
 
        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. */
index 7d5836ece2c67de68706bd39a3a8a23690c7e828..becc8082ba9df0f739da77f10a77ad03601fe271 100644 (file)
@@ -540,7 +540,7 @@ public class SubmoduleWalk implements AutoCloseable {
                }
                File modulesFile = new File(repository.getWorkTree(),
                                Constants.DOT_GIT_MODULES);
-               return (modulesFile.exists());
+               return modulesFile.exists();
        }
 
        private void lazyLoadModulesConfig() throws IOException, ConfigInvalidException {
index 3db0421d6933b2d973479bd50b338b5b9ca127bb..c2d8c1b73f1b7f92f2502436645eecd054ce9508 100644 (file)
@@ -140,7 +140,7 @@ abstract class HttpAuthMethod {
                                                                                valuePart[0].toUpperCase(Locale.ROOT));
 
                                                                if ((ignoreTypes != null)
-                                                                               && (ignoreTypes.contains(methodType))) {
+                                                                               && ignoreTypes.contains(methodType)) {
                                                                        continue;
                                                                }
 
index dc82f46197c81c04b4d212ee9c478a4d5f140a32..73eddb8e21d59435697df0f672f9683ff3c377c1 100644 (file)
@@ -101,7 +101,7 @@ public class HttpConfig {
 
        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
                public Integer get() {
@@ -119,7 +119,7 @@ public class HttpConfig {
                        }
                        return value;
                }
-       }).get().intValue();
+       }.get().intValue();
 
        private static final String ENV_HTTP_USER_AGENT = "GIT_HTTP_USER_AGENT"; //$NON-NLS-1$
 
index a2273b21be56940354ef9cef6942555b49e12beb..0fc9710ecb2cd3044e21a00e533c299c6d18217b 100644 (file)
@@ -160,7 +160,7 @@ public class TransportGitSsh extends SshTransport implements PackTransport {
        String commandFor(String exe) {
                String path = uri.getPath();
                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();
                cmd.append(exe);
index e0a8af1800b7817cdf471deed5886d8ff7700789..1cad8cde66226b0535d8de0bfd89098426e68964 100644 (file)
@@ -1514,7 +1514,7 @@ public class TreeWalk implements AutoCloseable, AttributesProvider {
                }
                return filterCommand.replaceAll("%f", //$NON-NLS-1$
                                Matcher.quoteReplacement(
-                                               QuotedString.BOURNE.quote((getPathString()))));
+                                               QuotedString.BOURNE.quote(getPathString())));
        }
 
        /**
@@ -1564,7 +1564,7 @@ public class TreeWalk implements AutoCloseable, AttributesProvider {
                }
                return filterCommand.replaceAll("%f", //$NON-NLS-1$
                                Matcher.quoteReplacement(
-                                               QuotedString.BOURNE.quote((getPathString()))));
+                                               QuotedString.BOURNE.quote(getPathString())));
        }
 
        /**
index 6f31847996894c8206ab80b16f67d2d9df15182c..d91f37b51a50503a8aa37e8363c08e2a3c64ceb9 100644 (file)
@@ -374,8 +374,8 @@ public class FS_POSIX extends FS {
                        link = Files.createLink(
                                        Paths.get(lock.getAbsolutePath() + ".lnk"), //$NON-NLS-1$
                                        lockPath);
-                       Integer nlink = (Integer) (Files.getAttribute(lockPath,
-                                       "unix:nlink")); //$NON-NLS-1$
+                       Integer nlink = (Integer) Files.getAttribute(lockPath,
+                                       "unix:nlink"); //$NON-NLS-1$
                        if (nlink > 2) {
                                LOG.warn(MessageFormat.format(
                                                JGitText.get().failedAtomicFileCreation, lockPath,
@@ -447,8 +447,7 @@ public class FS_POSIX extends FS {
                                return token(true, null);
                        }
                        link = Files.createLink(Paths.get(uniqueLinkPath(file)), path);
-                       Integer nlink = (Integer) (Files.getAttribute(path,
-                                       "unix:nlink")); //$NON-NLS-1$
+                       Integer nlink = (Integer) Files.getAttribute(path, "unix:nlink"); //$NON-NLS-1$
                        if (nlink.intValue() > 2) {
                                LOG.warn(MessageFormat.format(
                                                JGitText.get().failedAtomicFileCreation, path, nlink));
index be56e5ecf52a13df01f7ebfd15a838068544b04f..ba0df932ce5c4b2536823ff88fe85c29ff9eb9cf 100644 (file)
@@ -28,7 +28,7 @@ public abstract class GSSManagerFactory {
         * @return detected GSSManager factory
         */
        public static GSSManagerFactory detect() {
-               return (SunGSSManagerFactory.isSupported()) ? new SunGSSManagerFactory()
+               return SunGSSManagerFactory.isSupported() ? new SunGSSManagerFactory()
                                : new DefaultGSSManagerFactory();
        }
 
index 213ee975311beb5b4fa96faac595f8d8488198e6..33e687588385fc03a3e650c6be1f226be61299fb 100644 (file)
@@ -407,7 +407,7 @@ class SHA1Java extends SHA1 {
        private static int s1(int a, int b, int c, int d, int w_t) {
                return rotateLeft(a, 5)
                                // f: 0 <= t <= 19
-                               + ((b & c) | ((~b) & d))
+                               + ((b & c) | (~b & d))
                                + 0x5A827999 + w_t;
        }