]> source.dussan.org Git - jgit.git/commitdiff
Enable and fix "Statement unnecessarily nested within else clause" warnings 03/151203/2
authorDavid Pursehouse <david.pursehouse@gmail.com>
Thu, 17 Oct 2019 00:01:25 +0000 (09:01 +0900)
committerDavid Pursehouse <david.pursehouse@gmail.com>
Thu, 17 Oct 2019 01:20:14 +0000 (10:20 +0900)
Since [1] the gerrit project includes jgit as a submodule, and has this
warning enabled, resulting in 100s of warnings in the console.

Also enable the warning here, and fix them.

At the same time, add missing braces around adjacent and nearby one-line
blocks.

[1] https://gerrit-review.googlesource.com/c/gerrit/+/227897

Change-Id: I81df3fc7ed6eedf6874ce1a3bedfa727a1897e4c
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
122 files changed:
org.eclipse.jgit.ant.test/.settings/org.eclipse.jdt.core.prefs
org.eclipse.jgit.ant/.settings/org.eclipse.jdt.core.prefs
org.eclipse.jgit.archive/.settings/org.eclipse.jdt.core.prefs
org.eclipse.jgit.http.apache/.settings/org.eclipse.jdt.core.prefs
org.eclipse.jgit.http.server/.settings/org.eclipse.jdt.core.prefs
org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/ServletBinderImpl.java
org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/DefaultUploadPackFactory.java
org.eclipse.jgit.http.test/.settings/org.eclipse.jdt.core.prefs
org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java
org.eclipse.jgit.junit.http/.settings/org.eclipse.jdt.core.prefs
org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/AppServer.java
org.eclipse.jgit.junit.ssh/.settings/org.eclipse.jdt.core.prefs
org.eclipse.jgit.junit/.settings/org.eclipse.jdt.core.prefs
org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
org.eclipse.jgit.lfs.server.test/.settings/org.eclipse.jdt.core.prefs
org.eclipse.jgit.lfs.server/.settings/org.eclipse.jdt.core.prefs
org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/fs/FileLfsRepository.java
org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/s3/SignerV4.java
org.eclipse.jgit.lfs.test/.settings/org.eclipse.jdt.core.prefs
org.eclipse.jgit.lfs/.settings/org.eclipse.jdt.core.prefs
org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/BuiltinLFS.java
org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/CleanFilter.java
org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal/LfsConnectionFactory.java
org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/lib/AnyLongObjectId.java
org.eclipse.jgit.pgm.test/.settings/org.eclipse.jdt.core.prefs
org.eclipse.jgit.pgm/.settings/org.eclipse.jdt.core.prefs
org.eclipse.jgit.pgm/src/org/eclipse/jgit/console/ConsoleCredentialsProvider.java
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Status.java
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/TextHashFunctions.java
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/CmdLineParser.java
org.eclipse.jgit.ssh.apache.test/.settings/org.eclipse.jdt.core.prefs
org.eclipse.jgit.ssh.apache/.settings/org.eclipse.jdt.core.prefs
org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/JGitClientSession.java
org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/OpenSshServerKeyDatabase.java
org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/proxy/HttpParser.java
org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/proxy/Socks5ClientConnector.java
org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/transport/sshd/SshdSession.java
org.eclipse.jgit.test/.settings/org.eclipse.jdt.core.prefs
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackFileSnapshotTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectIdSerializerTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RefDatabaseConflictingNamesTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/HttpAuthTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/WalkEncryptionTest.java
org.eclipse.jgit.ui/.settings/org.eclipse.jdt.core.prefs
org.eclipse.jgit/.settings/org.eclipse.jdt.core.prefs
org.eclipse.jgit/src/org/eclipse/jgit/api/BlameCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/DiffCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/GarbageCollectCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/PullCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/ResetCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleSyncCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameResult.java
org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java
org.eclipse.jgit/src/org/eclipse/jgit/diff/Edit.java
org.eclipse.jgit/src/org/eclipse/jgit/diff/RawText.java
org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java
org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java
org.eclipse.jgit/src/org/eclipse/jgit/fnmatch/AbstractHead.java
org.eclipse.jgit/src/org/eclipse/jgit/fnmatch/FileNameMatcher.java
org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java
org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoProject.java
org.eclipse.jgit/src/org/eclipse/jgit/ignore/internal/PathMatcher.java
org.eclipse.jgit/src/org/eclipse/jgit/ignore/internal/Strings.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/ketch/LagCheck.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsRefDatabase.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GcLog.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectoryInserter.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectoryUpdate.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ReflogEntryImpl.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/UnpackedObject.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/UnpackedObjectCache.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableDatabase.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/RefTreeBatch.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/transport/http/NetscapeCookieFileCache.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/transport/ssh/OpenSshConfigFile.java
org.eclipse.jgit/src/org/eclipse/jgit/lib/AnyObjectId.java
org.eclipse.jgit/src/org/eclipse/jgit/lib/BaseRepositoryBuilder.java
org.eclipse.jgit/src/org/eclipse/jgit/lib/BranchConfig.java
org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java
org.eclipse.jgit/src/org/eclipse/jgit/lib/DefaultTypedConfigGetter.java
org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java
org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectReader.java
org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java
org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeConfig.java
org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeMessageFormatter.java
org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java
org.eclipse.jgit/src/org/eclipse/jgit/merge/ThreeWayMerger.java
org.eclipse.jgit/src/org/eclipse/jgit/notes/FanoutBucket.java
org.eclipse.jgit/src/org/eclipse/jgit/notes/LeafBucket.java
org.eclipse.jgit/src/org/eclipse/jgit/notes/NoteMap.java
org.eclipse.jgit/src/org/eclipse/jgit/notes/NoteMapMerger.java
org.eclipse.jgit/src/org/eclipse/jgit/notes/NoteParser.java
org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java
org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotWalk.java
org.eclipse.jgit/src/org/eclipse/jgit/revwalk/TreeRevFilter.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/CredentialsProviderUserInfo.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/HMACSHA1NonceGenerator.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/RemoteConfig.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/resolver/FileResolver.java
org.eclipse.jgit/src/org/eclipse/jgit/treewalk/FileTreeIterator.java
org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java
org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/IndexDiffFilter.java
org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/PathSuffixFilter.java
org.eclipse.jgit/src/org/eclipse/jgit/util/ChangeIdUtil.java
org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
org.eclipse.jgit/src/org/eclipse/jgit/util/IO.java
org.eclipse.jgit/src/org/eclipse/jgit/util/RefMap.java
org.eclipse.jgit/src/org/eclipse/jgit/util/SshSupport.java
org.eclipse.jgit/src/org/eclipse/jgit/util/io/LimitedInputStream.java

index 2ca78ff2d09dda7217849c9ea5d11663653bfbcb..3dd584039787ccb7d9a839a0e85e9693b52611bd 100644 (file)
@@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
 org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
 org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
 org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
 org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
 org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
 org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error
index 94a1c4f10bd9868c1083df8068c771681b818740..4335e66bf011a3a6e0cd49563a0825e115b1c538 100644 (file)
@@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
 org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
 org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
 org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
 org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
 org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
 org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
index ef6f5e732fd4d722b302964e7ad782069ff7f7f8..bc7ba1e50e708a91e2d49c32d9e2615cd57a23e7 100644 (file)
@@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
 org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
 org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
 org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
 org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
 org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
 org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
index 94a1c4f10bd9868c1083df8068c771681b818740..4335e66bf011a3a6e0cd49563a0825e115b1c538 100644 (file)
@@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
 org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
 org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
 org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
 org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
 org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
 org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
index 94a1c4f10bd9868c1083df8068c771681b818740..4335e66bf011a3a6e0cd49563a0825e115b1c538 100644 (file)
@@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
 org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
 org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
 org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
 org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
 org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
 org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
index f16749775f98e239672d1a185c3b59a5160b7c73..574e94a892a943f0ccd6836b1ace3ff6fd105326 100644 (file)
@@ -86,10 +86,10 @@ abstract class ServletBinderImpl implements ServletBinder {
         * @return the configured servlet, or singleton returning 404 if none.
         */
        protected HttpServlet getServlet() {
-               if (httpServlet != null)
+               if (httpServlet != null) {
                        return httpServlet;
-               else
-                       return new ErrorServlet(HttpServletResponse.SC_NOT_FOUND);
+               }
+               return new ErrorServlet(HttpServletResponse.SC_NOT_FOUND);
        }
 
        /**
index a69fab0afd398a3c306ffe4d8a75926123ca8a22..b9e6882556e1816c7292f74a303f19ba60e2b345 100644 (file)
@@ -83,8 +83,7 @@ public class DefaultUploadPackFactory implements
                                up.setExtraParameters(Arrays.asList(params));
                        }
                        return up;
-               } else {
-                       throw new ServiceNotEnabledException();
                }
+               throw new ServiceNotEnabledException();
        }
 }
index 2ca78ff2d09dda7217849c9ea5d11663653bfbcb..3dd584039787ccb7d9a839a0e85e9693b52611bd 100644 (file)
@@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
 org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
 org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
 org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
 org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
 org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
 org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error
index 3401e264c086a1f1dbb2688e058aaf5fd7ee73e6..99aa06b17c61092e6705ff89a938b1d25e2f5ce7 100644 (file)
@@ -331,9 +331,8 @@ public class SmartClientSmartServerTest extends AllFactoriesHttpTestCase {
                                        String fragment = u.getRawFragment();
                                        if (fragment != null) {
                                                return u.getRawPath() + '#' + fragment;
-                                       } else {
-                                               return u.getRawPath();
                                        }
+                                       return u.getRawPath();
                                } catch (URISyntaxException e) {
                                        return url;
                                }
index 2ca78ff2d09dda7217849c9ea5d11663653bfbcb..3dd584039787ccb7d9a839a0e85e9693b52611bd 100644 (file)
@@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
 org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
 org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
 org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
 org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
 org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
 org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error
index 9aef086b78a2b74044c3b57e963b92a537516739..14f54bef931b0a102d9ed7171ce57f308ac72cb4 100644 (file)
@@ -308,10 +308,10 @@ public class AppServer {
 
                @Override
                protected String[] loadRoleInfo(UserPrincipal user) {
-                       if (users.get(user.getName()) == null)
+                       if (users.get(user.getName()) == null) {
                                return null;
-                       else
-                               return new String[] { role };
+                       }
+                       return new String[] { role };
                }
 
                @Override
index 2ca78ff2d09dda7217849c9ea5d11663653bfbcb..3dd584039787ccb7d9a839a0e85e9693b52611bd 100644 (file)
@@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
 org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
 org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
 org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
 org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
 org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
 org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error
index b6750293dc09baab728a2fc51cb6a942b0c1a682..530f8f6070fb290d1600f858f560bcbd2851cdd3 100644 (file)
@@ -103,7 +103,7 @@ org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
 org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType=warning
 org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict=disabled
 org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=info
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
 org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
 org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
 org.eclipse.jdt.core.compiler.problem.unstableAutoModuleName=warning
index 362007a982cfd1b866c972d50bbc9263026f4fc5..240c4429eb70a8b6e7a658e0d64d7ca7c7d97bb7 100644 (file)
@@ -782,9 +782,8 @@ public class TestRepository<R extends Repository> implements AutoCloseable {
                        }
                        update(Constants.HEAD, result);
                        return pool.parseCommit(result);
-               } else {
-                       throw new IOException("Merge conflict");
                }
+               throw new IOException("Merge conflict");
        }
 
        /**
index 2ca78ff2d09dda7217849c9ea5d11663653bfbcb..3dd584039787ccb7d9a839a0e85e9693b52611bd 100644 (file)
@@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
 org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
 org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
 org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
 org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
 org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
 org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error
index 525ac6714280e07802592883cd9a6722bc0b1761..9fd92b10985a7dd4fbbf00ae968c280360e784ac 100644 (file)
@@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
 org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
 org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
 org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
 org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
 org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
 org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
index 0a7c37ca55086e3a0c2dc8c6691ad3d435bae65e..ad9ef7803644448f7255a8b3136f7ae560e59f1a 100644 (file)
@@ -110,9 +110,8 @@ public class FileLfsRepository implements LargeFileRepository {
                Path p = getPath(id);
                if (Files.exists(p)) {
                        return Files.size(p);
-               } else {
-                       return -1;
                }
+               return -1;
        }
 
        /**
index 7b76cecf0c3fca5e48bd427209702ede7161c6ce..4bcca4a9a195be63f4f95d1ead22c7fd3492b377 100644 (file)
@@ -352,9 +352,8 @@ class SignerV4 {
                String encodedPath = urlEncode(path, true);
                if (encodedPath.startsWith("/")) { //$NON-NLS-1$
                        return encodedPath;
-               } else {
-                       return "/" + encodedPath; //$NON-NLS-1$
                }
+               return "/" + encodedPath; //$NON-NLS-1$
        }
 
        private static byte[] hash(String s) {
index 2ca78ff2d09dda7217849c9ea5d11663653bfbcb..3dd584039787ccb7d9a839a0e85e9693b52611bd 100644 (file)
@@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
 org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
 org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
 org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
 org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
 org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
 org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error
index 525ac6714280e07802592883cd9a6722bc0b1761..9fd92b10985a7dd4fbbf00ae968c280360e784ac 100644 (file)
@@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
 org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
 org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
 org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
 org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
 org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
 org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
index 56e3a12ddc9c3949b5ec4a57d1906c5188858459..3c5826362c036efd0d3d5b50e6ee89818395ed63 100644 (file)
@@ -83,9 +83,8 @@ public class BuiltinLFS extends LfsFactory {
                        Attribute attribute) throws IOException {
                if (isEnabled(db) && (attribute == null || isEnabled(db, attribute))) {
                        return LfsBlobFilter.smudgeLfsBlob(db, loader);
-               } else {
-                       return loader;
                }
+               return loader;
        }
 
        @Override
@@ -93,9 +92,8 @@ public class BuiltinLFS extends LfsFactory {
                        long length, Attribute attribute) throws IOException {
                if (isEnabled(db, attribute)) {
                        return new LfsInputStream(LfsBlobFilter.cleanLfsBlob(db, input));
-               } else {
-                       return new LfsInputStream(input, length);
                }
+               return new LfsInputStream(input, length);
        }
 
        @Override
index 80da802db48b5f649520f7e925470618f25c6302..2329ade2909235c00ae08d75257757252ab2060e 100644 (file)
@@ -138,32 +138,30 @@ public class CleanFilter extends FilterCommand {
                                aOut.write(buf, 0, length);
                                size += length;
                                return length;
+                       }
+                       aOut.close();
+                       AnyLongObjectId loid = aOut.getId();
+                       aOut = null;
+                       Path mediaFile = lfsUtil.getMediaFile(loid);
+                       if (Files.isRegularFile(mediaFile)) {
+                               long fsSize = Files.size(mediaFile);
+                               if (fsSize != size) {
+                                       throw new CorruptMediaFile(mediaFile, size, fsSize);
+                               }
+                               FileUtils.delete(tmpFile.toFile());
                        } else {
-                               aOut.close();
-                               AnyLongObjectId loid = aOut.getId();
-                               aOut = null;
-                               Path mediaFile = lfsUtil.getMediaFile(loid);
-                               if (Files.isRegularFile(mediaFile)) {
-                                       long fsSize = Files.size(mediaFile);
-                                       if (fsSize != size) {
-                                               throw new CorruptMediaFile(mediaFile, size, fsSize);
-                                       } else {
-                                               FileUtils.delete(tmpFile.toFile());
-                                       }
-                               } else {
-                                       Path parent = mediaFile.getParent();
-                                       if (parent != null) {
-                                               FileUtils.mkdirs(parent.toFile(), true);
-                                       }
-                                       FileUtils.rename(tmpFile.toFile(), mediaFile.toFile(),
-                                                       StandardCopyOption.ATOMIC_MOVE);
+                               Path parent = mediaFile.getParent();
+                               if (parent != null) {
+                                       FileUtils.mkdirs(parent.toFile(), true);
                                }
-                               LfsPointer lfsPointer = new LfsPointer(loid, size);
-                               lfsPointer.encode(out);
-                               in.close();
-                               out.close();
-                               return -1;
+                               FileUtils.rename(tmpFile.toFile(), mediaFile.toFile(),
+                                               StandardCopyOption.ATOMIC_MOVE);
                        }
+                       LfsPointer lfsPointer = new LfsPointer(loid, size);
+                       lfsPointer.encode(out);
+                       in.close();
+                       out.close();
+                       return -1;
                } catch (IOException e) {
                        if (aOut != null) {
                                aOut.abort();
index feb8b4ae5af9bbb152bd2f2c1bfa5dac2636efc0..184658d4d2aec2160b3628c213e48ca3911fdc0b 100644 (file)
@@ -179,9 +179,8 @@ public class LfsConnectionFactory {
                                        remoteUrl, u);
                        additionalHeaders.putAll(action.header);
                        return action.href;
-               } else {
-                       return remoteUrl + Protocol.INFO_LFS_ENDPOINT;
                }
+               return remoteUrl + Protocol.INFO_LFS_ENDPOINT;
        }
 
        private static Protocol.ExpiringAction getSshAuthentication(
@@ -262,9 +261,8 @@ public class LfsConnectionFactory {
 
                if (path.endsWith(org.eclipse.jgit.lib.Constants.DOT_GIT)) {
                        return path.substring(0, path.length() - 4);
-               } else {
-                       return path;
                }
+               return path;
        }
 
        /**
index b095d20e638ba18ef11d98b947f209c09f18204a..a9bd27f5c5311f758a8b875060deb37985653bf4 100644 (file)
@@ -303,10 +303,10 @@ public abstract class AnyLongObjectId implements Comparable<AnyLongObjectId> {
        /** {@inheritDoc} */
        @Override
        public final boolean equals(Object o) {
-               if (o instanceof AnyLongObjectId)
+               if (o instanceof AnyLongObjectId) {
                        return equals((AnyLongObjectId) o);
-               else
-                       return false;
+               }
+               return false;
        }
 
        /**
index 2ca78ff2d09dda7217849c9ea5d11663653bfbcb..3dd584039787ccb7d9a839a0e85e9693b52611bd 100644 (file)
@@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
 org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
 org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
 org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
 org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
 org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
 org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error
index ef6f5e732fd4d722b302964e7ad782069ff7f7f8..bc7ba1e50e708a91e2d49c32d9e2615cd57a23e7 100644 (file)
@@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
 org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
 org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
 org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
 org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
 org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
 org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
index f8442facb7baa503601c9bde1ada8c7b517fe7ce..039d0946b248441597b5d0081ff70359c13f5156 100644 (file)
@@ -136,18 +136,15 @@ public class ConsoleCredentialsProvider extends CredentialsProvider {
                        if (v != null) {
                                item.setValue(new String(v));
                                return true;
-                       } else {
-                               return false;
-                       }
-               } else {
-                       String v = cons.readLine("%s: ", item.getPromptText()); //$NON-NLS-1$
-                       if (v != null) {
-                               item.setValue(v);
-                               return true;
-                       } else {
-                               return false;
                        }
+                       return false;
+               }
+               String v = cons.readLine("%s: ", item.getPromptText()); //$NON-NLS-1$
+               if (v != null) {
+                       item.setValue(v);
+                       return true;
                }
+               return false;
        }
 
        private boolean get(CredentialItem.CharArrayType item) {
@@ -156,18 +153,15 @@ public class ConsoleCredentialsProvider extends CredentialsProvider {
                        if (v != null) {
                                item.setValueNoCopy(v);
                                return true;
-                       } else {
-                               return false;
-                       }
-               } else {
-                       String v = cons.readLine("%s: ", item.getPromptText()); //$NON-NLS-1$
-                       if (v != null) {
-                               item.setValueNoCopy(v.toCharArray());
-                               return true;
-                       } else {
-                               return false;
                        }
+                       return false;
+               }
+               String v = cons.readLine("%s: ", item.getPromptText()); //$NON-NLS-1$
+               if (v != null) {
+                       item.setValueNoCopy(v.toCharArray());
+                       return true;
                }
+               return false;
        }
 
        private boolean get(CredentialItem.InformationalMessage item) {
@@ -182,8 +176,7 @@ public class ConsoleCredentialsProvider extends CredentialsProvider {
                if (r != null) {
                        item.setValue(CLIText.get().answerYes.equalsIgnoreCase(r));
                        return true;
-               } else {
-                       return false;
                }
+               return false;
        }
 }
index c3887fe9c3bf7cbf5291e6b0d6bcafbc4b00e095..23ee9337b6c8cb7b1983273b97d90ceb2e884a42 100644 (file)
@@ -306,8 +306,8 @@ class Status extends TextBuiltin {
                        }
                        outw.flush();
                        return list.size();
-               } else
-                       return 0;
+               }
+               return 0;
        }
 
        /**
index 8948c27537c51ca371d109b11193ae231015a679..0d30f3661caa3db8247483a2b115c56ef1d0d016 100644 (file)
@@ -189,9 +189,8 @@ class RebuildCommitGraph extends TextBuiltin {
                                                                // rewritten.
                                                                queue.add(t);
                                                                continue REWRITE;
-                                                       } else {
-                                                               newParents[k] = p.newId;
                                                        }
+                                                       newParents[k] = p.newId;
                                                } else {
                                                        // We have the old parent object. Use it.
                                                        //
index a2ea8c20b49fdae9de553129e4841590afb8de9d..1242bb754b9ad14ca05c89b820d741cb3cd2dcd9 100644 (file)
@@ -138,9 +138,8 @@ class TextHashFunctions extends TextBuiltin {
                                Arrays.fill(buf16, (byte) 0);
                                System.arraycopy(raw, ptr, buf16, 0, end - ptr);
                                return rabin(buf16, 0);
-                       } else {
-                               return rabin(raw, ptr);
                        }
+                       return rabin(raw, ptr);
                }
 
                private int rabin(byte[] raw, int ptr) {
index b97aa5b7af825d82000bedc3cd4a061e4abab9d6..d3aa38cf23d6b44a35c722fe68747a14fc1744a8 100644 (file)
@@ -299,10 +299,10 @@ public class CmdLineParser extends org.kohsuke.args4j.CmdLineParser {
        /** {@inheritDoc} */
        @Override
        protected OptionHandler createOptionHandler(OptionDef o, Setter setter) {
-               if (o instanceof NamedOptionDef)
+               if (o instanceof NamedOptionDef) {
                        return super.createOptionHandler(o, setter);
-               else
-                       return super.createOptionHandler(new MyOptionDef(o), setter);
+               }
+               return super.createOptionHandler(new MyOptionDef(o), setter);
 
        }
 
index 794592dee1f6a29db02f3bb50da67480e86e4e21..822846c4d09a4911ad6f2b36f8f99a6908190003 100644 (file)
@@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
 org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
 org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
 org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
 org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
 org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
 org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error
index 13c32a6d9473869c3063b7183e7ec76623bf1135..15ef2aad5db6fa3bee370991e7f64861dba0b2f9 100644 (file)
@@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
 org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
 org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
 org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
 org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
 org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
 org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
index 1954abc75b457b64063d844e630dfd6088a8ea3e..79bd3faa0178302af92af956eadeb2dd51445cc4 100644 (file)
@@ -179,9 +179,8 @@ public class JGitClientSession extends ClientSessionImpl {
                        } catch (Exception other) {
                                throw new IOException(other.getLocalizedMessage(), other);
                        }
-               } else {
-                       return super.sendIdentification(ident);
                }
+               return super.sendIdentification(ident);
        }
 
        @Override
@@ -205,9 +204,8 @@ public class JGitClientSession extends ClientSessionImpl {
                        } catch (Exception other) {
                                throw new IOException(other.getLocalizedMessage(), other);
                        }
-               } else {
-                       return super.sendKexInit();
                }
+               return super.sendKexInit();
        }
 
        /**
index f4849ce4a39a2aeb5defc693b8cc064fb9eeeee0..9c0a79312443397bab5ea64b1454efba751c5857 100644 (file)
@@ -453,9 +453,8 @@ public class OpenSshServerKeyDatabase
                                                prompt);
                                items.add(answer);
                                return provider.get(uri, items) && answer.getValue();
-                       } else {
-                               return provider.get(uri, items);
                        }
+                       return provider.get(uri, items);
                }
 
                private Check checkMode(SocketAddress remoteAddress, boolean changed) {
index b9b32b1300de23efb8d9f79abe584a5a6b0d7e3b..02771b501c8008b9e6d817279df2b39e0d7ae943 100644 (file)
@@ -207,11 +207,10 @@ public final class HttpParser {
                                                next++;
                                        }
                                        return next;
-                               } else {
-                                       // This token must be the name of the next authentication
-                                       // scheme.
-                                       return start;
                                }
+                               // This token must be the name of the next authentication
+                               // scheme.
+                               return start;
                        }
                        int nextStart = skipWhiteSpace(header, next + 1);
                        if (nextStart >= length) {
@@ -244,11 +243,10 @@ public final class HttpParser {
                                        // token, and the equals sign is part of the token
                                        challenge.setToken(header.substring(start, end + 1));
                                        return nextStart + 1;
-                               } else {
-                                       // Key without value...
-                                       challenge.addArgument(header.substring(start, end), null);
-                                       start = nextStart + 1;
                                }
+                               // Key without value...
+                               challenge.addArgument(header.substring(start, end), null);
+                               start = nextStart + 1;
                        } else {
                                if (header.charAt(nextStart) == '"') {
                                        int nextEnd[] = { nextStart + 1 };
index 27d6f418b83fe178db15a37fac073d8005e5045c..b3681d14a562781d2446d0c7c655c14fe961f22f 100644 (file)
@@ -281,11 +281,10 @@ public class Socks5ClientConnector extends AbstractClientProxyConnector {
                }
                if (i == proposals.length) {
                        return proposals;
-               } else {
-                       byte[] result = new byte[i];
-                       System.arraycopy(proposals, 0, result, 0, i);
-                       return result;
                }
+               byte[] result = new byte[i];
+               System.arraycopy(proposals, 0, result, 0, i);
+               return result;
        }
 
        private void sendConnectInfo(IoSession session) throws Exception {
index 1e8d7d1e1e0f30c45bfcbcaab6cf9beb9538926c..3fc955ab25f00e5d23ec1fafc83394200ead278b 100644 (file)
@@ -354,9 +354,8 @@ public class SshdSession implements RemoteSession {
                        if (path.charAt(0) != '/') {
                                if (cwd.charAt(cwd.length() - 1) == '/') {
                                        return cwd + path;
-                               } else {
-                                       return cwd + '/' + path;
                                }
+                               return cwd + '/' + path;
                        }
                        return path;
                }
index 2ca78ff2d09dda7217849c9ea5d11663653bfbcb..3dd584039787ccb7d9a839a0e85e9693b52611bd 100644 (file)
@@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
 org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
 org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
 org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
 org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
 org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
 org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error
index d5bc61a692656361f968f5ea7371a4fba0ac44e9..9016a02b0bf74b8c327ccaba384ec5c52a37e512 100644 (file)
@@ -295,9 +295,8 @@ public class PackFileSnapshotTest extends RepositoryTestCase {
                                Files.copy(src, dstOut);
                                return dst;
                        }
-               } else {
-                       return Files.copy(src, dst, StandardCopyOption.REPLACE_EXISTING);
                }
+               return Files.copy(src, dst, StandardCopyOption.REPLACE_EXISTING);
        }
 
        private Path copyPack(Path base, String srcSuffix, String dstSuffix)
index d98b792d7589ccf465a5773da38ae367292558cc..f0733f478254015fddb0cec241cb7a9c01ea3022 100644 (file)
@@ -88,9 +88,8 @@ public class ObjectIdSerializerTest {
                try (InputStream in = new FileInputStream(file)) {
                        if (objectId == null) {
                                return ObjectIdSerializer.read(in);
-                       } else {
-                               return ObjectIdSerializer.readWithoutMarker(in);
                        }
+                       return ObjectIdSerializer.readWithoutMarker(in);
                }
        }
 }
index cbb47fa8290f21d58b4a5ae7b76d04182878716b..3f77ca25a3323e3c7127264a30d5b8b962896143 100644 (file)
@@ -67,9 +67,8 @@ public class RefDatabaseConflictingNamesTest {
                                existing.put("refs/heads/a/b", null /* not used */);
                                existing.put("refs/heads/q", null /* not used */);
                                return existing;
-                       } else {
-                               return Collections.emptyMap();
                        }
+                       return Collections.emptyMap();
                }
 
                @Override
index ea15ebe7deed278b1988fb5cd5d01e90a49528a9..947ca976156d7c01a351c791da0cd26473a847bf 100644 (file)
@@ -133,16 +133,15 @@ public class HttpAuthTest {
 
                @Override
                public String getHeaderField(String name) {
-                       if (!headerFields.containsKey(name))
+                       if (!headerFields.containsKey(name)) {
                                return null;
-                       else {
-                               int n = headerFields.get(name).size();
+                       }
+                       int n = headerFields.get(name).size();
 
-                               if (n > 0)
-                                       return headerFields.get(name).get(n - 1);
-                               else
-                                       return null;
+                       if (n > 0) {
+                               return headerFields.get(name).get(n - 1);
                        }
+                       return null;
                }
 
                @Override
index 4750d15b3dc7c4ffa9eff863f218830a1d730e47..d1d7a1d81d337f1bb1bffbd982de1d2efc2fefcc 100644 (file)
@@ -239,9 +239,8 @@ public class WalkEncryptionTest {
                                loadEnvVar(ENV_SECRET_KEY, SECRET_KEY, props);
                                loadEnvVar(ENV_BUCKET_NAME, TEST_BUCKET, props);
                                return props;
-                       } else {
-                               return null;
                        }
+                       return null;
                }
 
                static Properties fromEnvFile() throws Exception {
@@ -250,12 +249,10 @@ public class WalkEncryptionTest {
                                props.load(new FileInputStream(ENV_CONFIG_FILE));
                                if (checkTestProps(props)) {
                                        return props;
-                               } else {
-                                       throw new Error("Environment config file is incomplete.");
                                }
-                       } else {
-                               return null;
+                               throw new Error("Environment config file is incomplete.");
                        }
+                       return null;
                }
 
                static Properties fromSysProps() {
@@ -266,9 +263,8 @@ public class WalkEncryptionTest {
                                loadSysProp(SYS_SECRET_KEY, SECRET_KEY, props);
                                loadSysProp(SYS_BUCKET_NAME, TEST_BUCKET, props);
                                return props;
-                       } else {
-                               return null;
                        }
+                       return null;
                }
 
                static Properties fromSysFile() throws Exception {
@@ -277,12 +273,10 @@ public class WalkEncryptionTest {
                                props.load(new FileInputStream(SYS_CONFIG_FILE));
                                if (checkTestProps(props)) {
                                        return props;
-                               } else {
-                                       throw new Error("System props config file is incomplete.");
                                }
-                       } else {
-                               return null;
+                               throw new Error("System props config file is incomplete.");
                        }
+                       return null;
                }
 
                static Properties fromConfigFile(String path) throws Exception {
@@ -292,12 +286,10 @@ public class WalkEncryptionTest {
                                props.load(new FileInputStream(file));
                                if (checkTestProps(props)) {
                                        return props;
-                               } else {
-                                       throw new Error("Props config file is incomplete: " + path);
                                }
-                       } else {
-                               return null;
+                               throw new Error("Props config file is incomplete: " + path);
                        }
+                       return null;
                }
 
                /**
index 525ac6714280e07802592883cd9a6722bc0b1761..9fd92b10985a7dd4fbbf00ae968c280360e784ac 100644 (file)
@@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
 org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
 org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
 org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
 org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
 org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
 org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
index ef6f5e732fd4d722b302964e7ad782069ff7f7f8..bc7ba1e50e708a91e2d49c32d9e2615cd57a23e7 100644 (file)
@@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
 org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
 org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
 org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
 org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
 org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
 org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
index f7576e9e9bfc676e092a4ad64fd53bf03d3658bd..0c765b01cb892b4e68f5c0681896b65a2e272fb9 100644 (file)
@@ -275,13 +275,12 @@ public class BlameCommand extends GitCommand<BlameResult> {
                byte[] buffer = new byte[upperSizeLimit];
                try {
                        int read = IO.readFully(source, buffer, 0);
-                       if (read == upperSizeLimit)
+                       if (read == upperSizeLimit) {
                                return buffer;
-                       else {
-                               byte[] copy = new byte[read];
-                               System.arraycopy(buffer, 0, copy, 0, read);
-                               return copy;
                        }
+                       byte[] copy = new byte[read];
+                       System.arraycopy(buffer, 0, copy, 0, read);
+                       return copy;
                } finally {
                        source.close();
                }
index f65b5735de2029e94847afbbce19625d7d13f5be..1c3c79041eb61e04a0962f57fc482fd2481dbea2 100644 (file)
@@ -136,28 +136,32 @@ public class DiffCommand extends GitCommand<List<DiffEntry>> {
                                }
                                newTree = new DirCacheIterator(repo.readDirCache());
                        } else {
-                               if (oldTree == null)
+                               if (oldTree == null) {
                                        oldTree = new DirCacheIterator(repo.readDirCache());
-                               if (newTree == null)
+                               }
+                               if (newTree == null) {
                                        newTree = new FileTreeIterator(repo);
+                               }
                        }
 
                        diffFmt.setPathFilter(pathFilter);
 
                        List<DiffEntry> result = diffFmt.scan(oldTree, newTree);
-                       if (showNameAndStatusOnly)
-                               return result;
-                       else {
-                               if (contextLines >= 0)
-                                       diffFmt.setContext(contextLines);
-                               if (destinationPrefix != null)
-                                       diffFmt.setNewPrefix(destinationPrefix);
-                               if (sourcePrefix != null)
-                                       diffFmt.setOldPrefix(sourcePrefix);
-                               diffFmt.format(result);
-                               diffFmt.flush();
+                       if (showNameAndStatusOnly) {
                                return result;
                        }
+                       if (contextLines >= 0) {
+                               diffFmt.setContext(contextLines);
+                       }
+                       if (destinationPrefix != null) {
+                               diffFmt.setNewPrefix(destinationPrefix);
+                       }
+                       if (sourcePrefix != null) {
+                               diffFmt.setOldPrefix(sourcePrefix);
+                       }
+                       diffFmt.format(result);
+                       diffFmt.flush();
+                       return result;
                } catch (IOException e) {
                        throw new JGitInternalException(e.getMessage(), e);
                }
index 2c9c5f20ccca85df79638687f2c72f1a8657fec8..9020c58d46485ac07d3736e672c34ed1927afa7d 100644 (file)
@@ -360,17 +360,17 @@ public class FetchCommand extends TransportCommand<FetchCommand, FetchResult> {
         * @return whether to remove refs which no longer exist in the source
         */
        public boolean isRemoveDeletedRefs() {
-               if (removeDeletedRefs != null)
+               if (removeDeletedRefs != null) {
                        return removeDeletedRefs.booleanValue();
-               else { // fall back to configuration
-                       boolean result = false;
-                       StoredConfig config = repo.getConfig();
-                       result = config.getBoolean(ConfigConstants.CONFIG_FETCH_SECTION,
-                                       null, ConfigConstants.CONFIG_KEY_PRUNE, result);
-                       result = config.getBoolean(ConfigConstants.CONFIG_REMOTE_SECTION,
-                                       remote, ConfigConstants.CONFIG_KEY_PRUNE, result);
-                       return result;
                }
+               // fall back to configuration
+               boolean result = false;
+               StoredConfig config = repo.getConfig();
+               result = config.getBoolean(ConfigConstants.CONFIG_FETCH_SECTION, null,
+                               ConfigConstants.CONFIG_KEY_PRUNE, result);
+               result = config.getBoolean(ConfigConstants.CONFIG_REMOTE_SECTION,
+                               remote, ConfigConstants.CONFIG_KEY_PRUNE, result);
+               return result;
        }
 
        /**
index 7ea277157d75f559ec10dc1f8135f68f3c97d508..474e2f573603d4f72cc1a81cec5ad7ff1a905cd4 100644 (file)
@@ -243,9 +243,8 @@ public class GarbageCollectCommand extends GitCommand<Properties> {
                        if (repo instanceof FileRepository) {
                                GC gc = new GC((FileRepository) repo);
                                return toProperties(gc.getStatistics());
-                       } else {
-                               return new Properties();
                        }
+                       return new Properties();
                } catch (IOException e) {
                        throw new JGitInternalException(
                                        JGitText.get().couldNotGetRepoStatistics, e);
index f9a9baf91959529d05f06f8cfa4ce201f0902adb..9a843f63a0e38c5162145d13ed4c4477533e386d 100644 (file)
@@ -409,27 +409,24 @@ public class MergeCommand extends GitCommand<MergeResult> {
                                                        new ObjectId[] { headCommit.getId(),
                                                                        srcCommit.getId() }, mergeStatus,
                                                        mergeStrategy, null, msg);
-                               } else {
-                                       if (failingPaths != null) {
-                                               repo.writeMergeCommitMsg(null);
-                                               repo.writeMergeHeads(null);
-                                               return new MergeResult(null, merger.getBaseCommitId(),
-                                                               new ObjectId[] {
-                                                                               headCommit.getId(), srcCommit.getId() },
-                                                               MergeStatus.FAILED, mergeStrategy,
-                                                               lowLevelResults, failingPaths, null);
-                                       } else {
-                                               String mergeMessageWithConflicts = new MergeMessageFormatter()
-                                                               .formatWithConflicts(mergeMessage,
-                                                                               unmergedPaths);
-                                               repo.writeMergeCommitMsg(mergeMessageWithConflicts);
-                                               return new MergeResult(null, merger.getBaseCommitId(),
-                                                               new ObjectId[] { headCommit.getId(),
-                                                                               srcCommit.getId() },
-                                                               MergeStatus.CONFLICTING, mergeStrategy,
-                                                               lowLevelResults, null);
-                                       }
                                }
+                               if (failingPaths != null) {
+                                       repo.writeMergeCommitMsg(null);
+                                       repo.writeMergeHeads(null);
+                                       return new MergeResult(null, merger.getBaseCommitId(),
+                                                       new ObjectId[] { headCommit.getId(),
+                                                                       srcCommit.getId() },
+                                                       MergeStatus.FAILED, mergeStrategy, lowLevelResults,
+                                                       failingPaths, null);
+                               }
+                               String mergeMessageWithConflicts = new MergeMessageFormatter()
+                                               .formatWithConflicts(mergeMessage, unmergedPaths);
+                               repo.writeMergeCommitMsg(mergeMessageWithConflicts);
+                               return new MergeResult(null, merger.getBaseCommitId(),
+                                               new ObjectId[] { headCommit.getId(),
+                                                               srcCommit.getId() },
+                                               MergeStatus.CONFLICTING, mergeStrategy, lowLevelResults,
+                                               null);
                        }
                } catch (org.eclipse.jgit.errors.CheckoutConflictException e) {
                        List<String> conflicts = (dco == null) ? Collections
index bdb2d1bbc5ed6239b9eefc457ff016e92d108f85..834b68d6d0ed97735a41bcd7abb7ad6cd4386ae4 100644 (file)
@@ -315,23 +315,24 @@ public class PullCommand extends TransportCommand<PullCommand, PullResult> {
                        Ref r = null;
                        if (fetchRes != null) {
                                r = fetchRes.getAdvertisedRef(remoteBranchName);
-                               if (r == null)
+                               if (r == null) {
                                        r = fetchRes.getAdvertisedRef(Constants.R_HEADS
                                                        + remoteBranchName);
+                               }
                        }
                        if (r == null) {
                                throw new RefNotAdvertisedException(MessageFormat.format(
                                                JGitText.get().couldNotGetAdvertisedRef, remote,
                                                remoteBranchName));
-                       } else {
-                               commitToMerge = r.getObjectId();
                        }
+                       commitToMerge = r.getObjectId();
                } else {
                        try {
                                commitToMerge = repo.resolve(remoteBranchName);
-                               if (commitToMerge == null)
+                               if (commitToMerge == null) {
                                        throw new RefNotFoundException(MessageFormat.format(
                                                        JGitText.get().refNotResolved, remoteBranchName));
+                               }
                        } catch (IOException e) {
                                throw new JGitInternalException(
                                                JGitText.get().exceptionCaughtDuringExecutionOfPullCommand,
index 0dacd4dfbf6b11fe7d0c705fe4ef45c085580ab7..715d9768d8cdf0baa70258143e05b539c437e337 100644 (file)
@@ -509,10 +509,10 @@ public class RebaseCommand extends GitCommand<RebaseResult> {
                        monitor.beginTask(MessageFormat.format(
                                        JGitText.get().applyingCommit,
                                        commitToPick.getShortMessage()), ProgressMonitor.UNKNOWN);
-                       if (preserveMerges)
+                       if (preserveMerges) {
                                return cherryPickCommitPreservingMerges(commitToPick);
-                       else
-                               return cherryPickCommitFlattening(commitToPick);
+                       }
+                       return cherryPickCommitFlattening(commitToPick);
                } finally {
                        monitor.endTask();
                }
@@ -539,11 +539,11 @@ public class RebaseCommand extends GitCommand<RebaseResult> {
                                        .call();
                                switch (cherryPickResult.getStatus()) {
                                case FAILED:
-                                       if (operation == Operation.BEGIN)
+                                       if (operation == Operation.BEGIN) {
                                                return abort(RebaseResult
                                                                .failed(cherryPickResult.getFailingPaths()));
-                                       else
-                                               return stop(commitToPick, Status.STOPPED);
+                                       }
+                                       return stop(commitToPick, Status.STOPPED);
                                case CONFLICTING:
                                        return stop(commitToPick, Status.STOPPED);
                                case OK:
@@ -599,11 +599,11 @@ public class RebaseCommand extends GitCommand<RebaseResult> {
                                        CherryPickResult cherryPickResult = pickCommand.call();
                                        switch (cherryPickResult.getStatus()) {
                                        case FAILED:
-                                               if (operation == Operation.BEGIN)
+                                               if (operation == Operation.BEGIN) {
                                                        return abort(RebaseResult.failed(
                                                                        cherryPickResult.getFailingPaths()));
-                                               else
-                                                       return stop(commitToPick, Status.STOPPED);
+                                               }
+                                               return stop(commitToPick, Status.STOPPED);
                                        case CONFLICTING:
                                                return stop(commitToPick, Status.STOPPED);
                                        case OK:
index d7c9ad5e045b6ac8caac006026093077815a1980..3031a197a8d785e4e4bff1b2622f3965129329df 100644 (file)
@@ -334,10 +334,10 @@ public class ResetCommand extends GitCommand<Ref> {
        }
 
        private String getRefOrHEAD() {
-               if (ref != null)
+               if (ref != null) {
                        return ref;
-               else
-                       return Constants.HEAD;
+               }
+               return Constants.HEAD;
        }
 
        /**
index 52393695d967f2b15877e918ddab7cf070132349..74def9e89736c2dc30788b971179a1e73d16b7b1 100644 (file)
@@ -106,10 +106,10 @@ public class SubmoduleSyncCommand extends GitCommand<Map<String, String>> {
         */
        protected String getHeadBranch(Repository subRepo) throws IOException {
                Ref head = subRepo.exactRef(Constants.HEAD);
-               if (head != null && head.isSymbolic())
+               if (head != null && head.isSymbolic()) {
                        return Repository.shortenRefName(head.getLeaf().getName());
-               else
-                       return null;
+               }
+               return null;
        }
 
        /** {@inheritDoc} */
index 5fb77501fa44088d018e4e251d5ecf95dee0ddd1..394aba6a59207d902934847615f5ff5dd923bfd7 100644 (file)
@@ -267,18 +267,18 @@ public class BlameResult {
         */
        public int computeNext() throws IOException {
                BlameGenerator gen = generator;
-               if (gen == null)
+               if (gen == null) {
                        return -1;
+               }
 
                if (gen.next()) {
                        loadFrom(gen);
                        lastLength = gen.getRegionLength();
                        return gen.getResultStart();
-               } else {
-                       gen.close();
-                       generator = null;
-                       return -1;
                }
+               gen.close();
+               generator = null;
+               return -1;
        }
 
        /**
index 1cecff6fb0d2df3615cb5b0c4b61d7e716dc4942..fa552aabe14f33630a3fbcae84d515374195916a 100644 (file)
@@ -489,8 +489,8 @@ public class DiffFormatter implements AutoCloseable {
                        CanonicalTreeParser parser = new CanonicalTreeParser();
                        parser.reset(reader, tree);
                        return parser;
-               } else
-                       return new EmptyTreeIterator();
+               }
+               return new EmptyTreeIterator();
        }
 
        /**
index 5c876e87fde71a72b599f513df0ee25ce79c7d7c..831074d2e134023890941784c987447e75134027 100644 (file)
@@ -125,17 +125,17 @@ public class Edit {
         */
        public final Type getType() {
                if (beginA < endA) {
-                       if (beginB < endB)
+                       if (beginB < endB) {
                                return Type.REPLACE;
-                       else /* if (beginB == endB) */
-                               return Type.DELETE;
-
-               } else /* if (beginA == endA) */{
-                       if (beginB < endB)
-                               return Type.INSERT;
-                       else /* if (beginB == endB) */
-                               return Type.EMPTY;
+                       }
+                       return Type.DELETE;
+
+               }
+               if (beginB < endB) {
+                       return Type.INSERT;
                }
+               // beginB == endB)
+               return Type.EMPTY;
        }
 
        /**
index 6c0d90ebad356e32b1410f240905d658e5e094db..219da0e9b9913170b5d0ef4aa8ac225bcc5824a6 100644 (file)
@@ -383,15 +383,17 @@ public class RawText extends Sequence {
         * @return the line delimiter or <code>null</code>
         */
        public String getLineDelimiter() {
-               if (size() == 0)
+               if (size() == 0) {
                        return null;
+               }
                int e = getEnd(0);
-               if (content[e - 1] != '\n')
+               if (content[e - 1] != '\n') {
                        return null;
-               if (content.length > 1 && e > 1 && content[e - 2] == '\r')
+               }
+               if (content.length > 1 && e > 1 && content[e - 2] == '\r') {
                        return "\r\n"; //$NON-NLS-1$
-               else
-                       return "\n"; //$NON-NLS-1$
+               }
+               return "\n"; //$NON-NLS-1$
        }
 
        /**
index 6bc29460789b81d84426f23aaae7053ac2350f2c..1334949eb4679a57ff06a416a1a214ae6260c976 100644 (file)
@@ -517,10 +517,10 @@ public class DirCacheCheckout {
                                prescanOneTree();
 
                        if (!conflicts.isEmpty()) {
-                               if (failOnConflict)
+                               if (failOnConflict) {
                                        throw new CheckoutConflictException(conflicts.toArray(new String[0]));
-                               else
-                                       cleanUpConflicts();
+                               }
+                               cleanUpConflicts();
                        }
 
                        // update our index
@@ -895,15 +895,14 @@ public class DirCacheCheckout {
                                // the workingtree entry doesn't exist or also contains a folder
                                // -> no problem
                                return;
-                       } else {
-                               // the workingtree entry exists and is not a folder
-                               if (!idEqual(h, m)) {
-                                       // Because HEAD and MERGE differ we will try to update the
-                                       // workingtree with a folder -> return a conflict
-                                       conflict(name, null, null, null);
-                               }
-                               return;
                        }
+                       // the workingtree entry exists and is not a folder
+                       if (!idEqual(h, m)) {
+                               // Because HEAD and MERGE differ we will try to update the
+                               // workingtree with a folder -> return a conflict
+                               conflict(name, null, null, null);
+                       }
+                       return;
                }
 
                if ((ffMask == 0x00F) && f != null && FileMode.TREE.equals(f.getEntryFileMode())) {
@@ -1083,15 +1082,15 @@ public class DirCacheCheckout {
                                                        // Something in Head
 
                                                        if (!FileMode.TREE.equals(f.getEntryFileMode())
-                                                                       && FileMode.TREE.equals(iMode))
+                                                                       && FileMode.TREE.equals(iMode)) {
                                                                // The workingtree contains a file and the index semantically contains a folder.
                                                                // Git considers the workingtree file as untracked. Just keep the untracked file.
                                                                return;
-                                                       else
-                                                               // -> file is dirty and tracked but is should be
-                                                               // removed. That's a conflict
-                                                               conflict(name, dce, h, m);
-                                               } else
+                                                       }
+                                                       // -> file is dirty and tracked but is should be
+                                                       // removed. That's a conflict
+                                                       conflict(name, dce, h, m);
+                                               } else {
                                                        // file doesn't exist or is clean
                                                        // Index contains the same as Head
                                                        // Something different from a submodule in Index
@@ -1099,7 +1098,8 @@ public class DirCacheCheckout {
                                                        // Something in Head
                                                        // -> Remove from index and delete the file
                                                        remove(name);
-                                       } else
+                                               }
+                                       } else {
                                                // Index contains something different from Head
                                                // Something different from a submodule in Index
                                                // Nothing in Merge
@@ -1108,6 +1108,7 @@ public class DirCacheCheckout {
                                                // filesystem). But Merge wants the path to be removed.
                                                // Report a conflict
                                                conflict(name, dce, h, m);
+                                       }
                                }
                        } else {
                                // Something in Merge
@@ -1340,13 +1341,14 @@ public class DirCacheCheckout {
        private boolean isModified_IndexTree(String path, ObjectId iId,
                        FileMode iMode, ObjectId tId, FileMode tMode, ObjectId rootTree)
                        throws CorruptObjectException, IOException {
-               if (iMode != tMode)
+               if (iMode != tMode) {
                        return true;
+               }
                if (FileMode.TREE.equals(iMode)
-                               && (iId == null || ObjectId.zeroId().equals(iId)))
+                               && (iId == null || ObjectId.zeroId().equals(iId))) {
                        return isModifiedSubtree_IndexTree(path, rootTree);
-               else
-                       return !equalIdAndMode(iId, iMode, tId, tMode);
+               }
+               return !equalIdAndMode(iId, iMode, tId, tMode);
        }
 
        /**
index 0e91f0d7486aab2d6dc35101c4e7f17acf66ba69..cbf96e468c06d571c29bf00b8a5832152e83c84a 100644 (file)
@@ -824,10 +824,10 @@ public class DirCacheEntry {
        }
 
        private int getExtendedFlags() {
-               if (isExtended())
+               if (isExtended()) {
                        return NB.decodeUInt16(info, infoOffset + P_FLAGS2) << 16;
-               else
-                       return 0;
+               }
+               return 0;
        }
 
        private static void checkPath(byte[] path) {
index 60669bb9555f248790826df5cbcf570e72f0194a..2c93d55f4df1dd9a478553784e487d75026f7084 100644 (file)
@@ -82,10 +82,10 @@ abstract class AbstractHead implements Head {
        /** {@inheritDoc} */
        @Override
        public List<Head> getNextHeads(char c) {
-               if (matches(c))
+               if (matches(c)) {
                        return newHeads;
-               else
-                       return FileNameMatcher.EMPTY_HEAD_LIST;
+               }
+               return FileNameMatcher.EMPTY_HEAD_LIST;
        }
 
        boolean isStar() {
index bfcc580ba4787bb646de3a8121be8da44d4c079f..8125c356a6ca873b5c2bc9fbed6759b45a8be37e 100644 (file)
@@ -304,11 +304,11 @@ public class FileNameMatcher {
 
        private static AbstractHead createWildCardHead(
                        final Character invalidWildgetCharacter, final boolean star) {
-               if (invalidWildgetCharacter != null)
+               if (invalidWildgetCharacter != null) {
                        return new RestrictedWildCardHead(invalidWildgetCharacter
                                        .charValue(), star);
-               else
-                       return new WildCardHead(star);
+               }
+               return new WildCardHead(star);
        }
 
        /**
index 8e463415b8332b24b86e4fb4f4109ac42e941272..febdb9209169d9a864700f23936d2227b02692e7 100644 (file)
@@ -293,13 +293,12 @@ public class ManifestParser extends DefaultHandler {
                        String revision = defaultRevision;
                        if (remote == null) {
                                if (defaultRemote == null) {
-                                       if (filename != null)
+                                       if (filename != null) {
                                                throw new SAXException(MessageFormat.format(
                                                                RepoText.get().errorNoDefaultFilename,
                                                                filename));
-                                       else
-                                               throw new SAXException(
-                                                               RepoText.get().errorNoDefault);
+                                       }
+                                       throw new SAXException(RepoText.get().errorNoDefault);
                                }
                                remote = defaultRemote;
                        } else {
index cb62925a1f6d1ec8333d67cff65938688b65d3a0..72886780072b6b8c6c87a155785a06ca80413eb5 100644 (file)
@@ -761,18 +761,17 @@ public class RepoCommand extends GitCommand<RevCommit> {
                        } catch (GitAPIException | IOException e) {
                                throw new ManifestErrorException(e);
                        }
-               } else {
-                       try (Git git = new Git(repo)) {
-                               for (RepoProject proj : filteredProjects) {
-                                       addSubmodule(proj.getName(), proj.getUrl(), proj.getPath(),
-                                                       proj.getRevision(), proj.getCopyFiles(),
-                                                       proj.getLinkFiles(), git);
-                               }
-                               return git.commit().setMessage(RepoText.get().repoCommitMessage)
-                                               .call();
-                       } catch (GitAPIException | IOException e) {
-                               throw new ManifestErrorException(e);
+               }
+               try (Git git = new Git(repo)) {
+                       for (RepoProject proj : filteredProjects) {
+                               addSubmodule(proj.getName(), proj.getUrl(), proj.getPath(),
+                                               proj.getRevision(), proj.getCopyFiles(),
+                                               proj.getLinkFiles(), git);
                        }
+                       return git.commit().setMessage(RepoText.get().repoCommitMessage)
+                                       .call();
+               } catch (GitAPIException | IOException e) {
+                       throw new ManifestErrorException(e);
                }
        }
 
index d79dfa8b2f47130f38d9bea3dec62963b7ac5079..684d1e457f09c3b5b24d98f90578553b8e24f13e 100644 (file)
@@ -422,10 +422,10 @@ public class RepoProject implements Comparable<RepoProject> {
        }
 
        private String getPathWithSlash() {
-               if (path.endsWith("/")) //$NON-NLS-1$
+               if (path.endsWith("/")) //$NON-NLS-1$
                        return path;
-               else
-                       return path + "/"; //$NON-NLS-1$
+               }
+               return path + "/"; //$NON-NLS-1$
        }
 
        /**
index 3c0f17ab3d1877202a14d270063f4a23602c9d63..b7d6acce14db9589a3f24db2d50548294f15ce20 100644 (file)
@@ -291,26 +291,25 @@ public class PathMatcher extends AbstractMatcher {
                                        // We had a prefix match here.
                                        if (!pathMatch) {
                                                return true;
+                                       }
+                                       if (right == endExcl - 1) {
+                                               // Extra slash at the end: actually a full match.
+                                               // Must meet directory expectations
+                                               return !dirOnly || assumeDirectory;
+                                       }
+                                       // Prefix matches only if pattern ended with /**
+                                       if (wasWild) {
+                                               return true;
+                                       }
+                                       if (lastWildmatch >= 0) {
+                                               // Consider pattern **/x and input x/x.
+                                               // We've matched the prefix x/ so far: we
+                                               // must try to extend the **!
+                                               matcher = lastWildmatch + 1;
+                                               right = wildmatchBacktrackPos;
+                                               wildmatchBacktrackPos = -1;
                                        } else {
-                                               if (right == endExcl - 1) {
-                                                       // Extra slash at the end: actually a full match.
-                                                       // Must meet directory expectations
-                                                       return !dirOnly || assumeDirectory;
-                                               }
-                                               // Prefix matches only if pattern ended with /**
-                                               if (wasWild) {
-                                                       return true;
-                                               }
-                                               if (lastWildmatch >= 0) {
-                                                       // Consider pattern **/x and input x/x.
-                                                       // We've matched the prefix x/ so far: we
-                                                       // must try to extend the **!
-                                                       matcher = lastWildmatch + 1;
-                                                       right = wildmatchBacktrackPos;
-                                                       wildmatchBacktrackPos = -1;
-                                               } else {
-                                                       return false;
-                                               }
+                                               return false;
                                        }
                                }
                        } else if (lastWildmatch != -1) {
index 41923eed183fbea03cdc199b6dd35cca0f9c266d..b18aed9828f7cbf8fa313fc0adbf2572e339fb47 100644 (file)
@@ -192,22 +192,20 @@ public class Strings {
                }
                if (pattern.indexOf('?') != -1) {
                        return true;
-               } else {
-                       // check if the backslash escapes one of the glob special characters
-                       // if not, backslash is not part of a regex and treated literally
-                       int backSlash = pattern.indexOf('\\');
-                       if (backSlash >= 0) {
-                               int nextIdx = backSlash + 1;
-                               if (pattern.length() == nextIdx) {
-                                       return false;
-                               }
-                               char nextChar = pattern.charAt(nextIdx);
-                               if (escapedByBackslash(nextChar)) {
-                                       return true;
-                               } else {
-                                       return false;
-                               }
+               }
+               // check if the backslash escapes one of the glob special characters
+               // if not, backslash is not part of a regex and treated literally
+               int backSlash = pattern.indexOf('\\');
+               if (backSlash >= 0) {
+                       int nextIdx = backSlash + 1;
+                       if (pattern.length() == nextIdx) {
+                               return false;
+                       }
+                       char nextChar = pattern.charAt(nextIdx);
+                       if (escapedByBackslash(nextChar)) {
+                               return true;
                        }
+                       return false;
                }
                return false;
        }
index 53fd198006da57543cbbf195ac225217719b1ee8..a27a9bc446792f8cace2f9c00b52d0263af8080f 100644 (file)
@@ -132,9 +132,8 @@ class LagCheck implements AutoCloseable {
                        // TODO(sop) Check term to see if my leader was deposed.
                        if (rw.isMergedInto(head, remote)) {
                                return AHEAD;
-                       } else {
-                               return DIVERGENT;
                        }
+                       return DIVERGENT;
                } catch (IOException err) {
                        KetchReplica.log.error(String.format(
                                        "Cannot compare %s", //$NON-NLS-1$
index 732cd4d1c66e0fada664f72e7ba6955ca956dbf4..b3b9e39375bc0a40865ab0d20a5b4e2ad99ef728 100644 (file)
@@ -191,14 +191,11 @@ public abstract class DfsRefDatabase extends RefDatabase {
                                                rw.peel(obj).copy(),
                                                hasVersioning() ? leaf.getUpdateIndex()
                                                                : UNDEFINED_UPDATE_INDEX);
-                       } else {
-                               return new ObjectIdRef.PeeledNonTag(
-                                               leaf.getStorage(),
-                                               leaf.getName(),
-                                               leaf.getObjectId(),
-                                               hasVersioning() ? leaf.getUpdateIndex()
-                                                               : UNDEFINED_UPDATE_INDEX);
                        }
+                       return new ObjectIdRef.PeeledNonTag(leaf.getStorage(),
+                                       leaf.getName(), leaf.getObjectId(),
+                                       hasVersioning() ? leaf.getUpdateIndex()
+                                                       : UNDEFINED_UPDATE_INDEX);
                }
        }
 
index 4f5f8a613e3ecfb39da4d9705b3df7ae42ae7224..130e39b14902b72961db1d29d1634219325a9a24 100644 (file)
@@ -358,9 +358,8 @@ public class FileRepository extends Repository {
                File directory = getDirectory();
                if (directory != null) {
                        return directory.getPath();
-               } else {
-                       throw new IllegalStateException();
                }
+               throw new IllegalStateException();
        }
 
        /** {@inheritDoc} */
index 82458c1acf6a37fedb4930b389c1c4977e4084cd..13b9e79be8319e69b18006f33c9335631528e720 100644 (file)
@@ -152,11 +152,10 @@ class GcLog {
        boolean commit() {
                if (nonEmpty) {
                        return lock.commit();
-               } else {
-                       logFile.delete();
-                       lock.unlock();
-                       return true;
                }
+               logFile.delete();
+               lock.unlock();
+               return true;
        }
 
        /**
index e5a54e372c8633cb3aba5826d2fc586466504e7c..09f20216866776df8bdeaae74d30dc54b1a5e1dc 100644 (file)
@@ -109,10 +109,9 @@ class ObjectDirectoryInserter extends ObjectInserter {
                ObjectId id = idFor(type, data, off, len);
                if (!createDuplicate && db.has(id)) {
                        return id;
-               } else {
-                       File tmp = toTemp(type, data, off, len);
-                       return insertOneObject(tmp, id, createDuplicate);
                }
+               File tmp = toTemp(type, data, off, len);
+               return insertOneObject(tmp, id, createDuplicate);
        }
 
        /** {@inheritDoc} */
@@ -141,12 +140,11 @@ class ObjectDirectoryInserter extends ObjectInserter {
                        int actLen = IO.readFully(is, buf, 0);
                        return insert(type, buf, 0, actLen, createDuplicate);
 
-               } else {
-                       SHA1 md = digest();
-                       File tmp = toTemp(md, type, len, is);
-                       ObjectId id = md.toObjectId();
-                       return insertOneObject(tmp, id, createDuplicate);
                }
+               SHA1 md = digest();
+               File tmp = toTemp(md, type, len, is);
+               ObjectId id = md.toObjectId();
+               return insertOneObject(tmp, id, createDuplicate);
        }
 
        private ObjectId insertOneObject(
index 88e05af414cad89403eb5dc34ffdf6e2addb9eda..9b9c3a7dec0986293c86f12290b5cdaaae1b7397 100644 (file)
@@ -844,19 +844,20 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
                                case Constants.OBJ_TREE:
                                case Constants.OBJ_BLOB:
                                case Constants.OBJ_TAG: {
-                                       if (delta != null || sz < curs.getStreamFileThreshold())
+                                       if (delta != null || sz < curs.getStreamFileThreshold()) {
                                                data = decompress(pos + p, (int) sz, curs);
+                                       }
 
                                        if (delta != null) {
                                                type = typeCode;
                                                break SEARCH;
                                        }
 
-                                       if (data != null)
+                                       if (data != null) {
                                                return new ObjectLoader.SmallObject(typeCode, data);
-                                       else
-                                               return new LargePackedWholeObject(typeCode, sz, pos, p,
-                                                               this, curs.db);
+                                       }
+                                       return new LargePackedWholeObject(typeCode, sz, pos, p,
+                                                       this, curs.db);
                                }
 
                                case Constants.OBJ_OFS_DELTA: {
index e5cea6c010a610c9aded75f44f93d2783dbf6e7b..7733df15f9457336b221a1213adf4aabd5ac11e1 100644 (file)
@@ -594,10 +594,9 @@ public class RefDirectory extends RefDatabase {
                        if (obj instanceof RevTag) {
                                return new ObjectIdRef.PeeledTag(leaf.getStorage(), leaf
                                                .getName(), leaf.getObjectId(), rw.peel(obj).copy());
-                       } else {
-                               return new ObjectIdRef.PeeledNonTag(leaf.getStorage(), leaf
-                                               .getName(), leaf.getObjectId());
                        }
+                       return new ObjectIdRef.PeeledNonTag(leaf.getStorage(),
+                                       leaf.getName(), leaf.getObjectId());
                }
        }
 
@@ -894,10 +893,9 @@ public class RefDirectory extends RefDatabase {
                if (peeledObjectId != null) {
                        return new ObjectIdRef.PeeledTag(PACKED, f.getName(),
                                        f.getObjectId(), peeledObjectId);
-               } else {
-                       return new ObjectIdRef.PeeledNonTag(PACKED, f.getName(),
-                                       f.getObjectId());
                }
+               return new ObjectIdRef.PeeledNonTag(PACKED, f.getName(),
+                               f.getObjectId());
        }
 
        void log(boolean force, RefUpdate update, String msg, boolean deref)
@@ -1480,10 +1478,8 @@ public class RefDirectory extends RefDatabase {
                        if (peeledObjectId != null) {
                                return new LoosePeeledTag(snapShot, getName(),
                                                objectId, peeledObjectId);
-                       } else {
-                               return new LooseNonTag(snapShot, getName(),
-                                               objectId);
                        }
+                       return new LooseNonTag(snapShot, getName(), objectId);
                }
        }
 
index 1a0d6953abe13156718ef0def855f722f17f625d..dc4967fe4e58258751411a824ee37afad48547e1 100644 (file)
@@ -90,9 +90,8 @@ class RefDirectoryUpdate extends RefUpdate {
                        dst = database.findRef(name);
                        setOldObjectId(dst != null ? dst.getObjectId() : null);
                        return true;
-               } else {
-                       return false;
                }
+               return false;
        }
 
        /** {@inheritDoc} */
index 08a14b28d22ab8f18a4ca7d40ab5aa4a6697bc00..3cdd90408e390a32d582825cff3247d0ab030017 100644 (file)
@@ -140,9 +140,9 @@ public class ReflogEntryImpl implements Serializable, ReflogEntry {
        /** {@inheritDoc} */
        @Override
        public CheckoutEntry parseCheckout() {
-               if (getComment().startsWith(CheckoutEntryImpl.CHECKOUT_MOVING_FROM))
+               if (getComment().startsWith(CheckoutEntryImpl.CHECKOUT_MOVING_FROM)) {
                        return new CheckoutEntryImpl(this);
-               else
-                       return null;
+               }
+               return null;
        }
 }
index 79f1307578bbb013195a4d946a13717a048a03c2..fb06623d7e77cd41ae0fb745b16d3505601cc5cd 100644 (file)
@@ -139,49 +139,48 @@ public class UnpackedObject {
                                }
                                return new LargeObject(type, size, path, id, wc.db);
 
-                       } else {
-                               readSome(in, hdr, 2, 18);
-                               int c = hdr[0] & 0xff;
-                               int type = (c >> 4) & 7;
-                               long size = c & 15;
-                               int shift = 4;
-                               int p = 1;
-                               while ((c & 0x80) != 0) {
-                                       c = hdr[p++] & 0xff;
-                                       size += ((long) (c & 0x7f)) << shift;
-                                       shift += 7;
-                               }
+                       }
+                       readSome(in, hdr, 2, 18);
+                       int c = hdr[0] & 0xff;
+                       int type = (c >> 4) & 7;
+                       long size = c & 15;
+                       int shift = 4;
+                       int p = 1;
+                       while ((c & 0x80) != 0) {
+                               c = hdr[p++] & 0xff;
+                               size += ((long) (c & 0x7f)) << shift;
+                               shift += 7;
+                       }
 
-                               switch (type) {
-                               case Constants.OBJ_COMMIT:
-                               case Constants.OBJ_TREE:
-                               case Constants.OBJ_BLOB:
-                               case Constants.OBJ_TAG:
-                                       // Acceptable types for a loose object.
-                                       break;
-                               default:
-                                       throw new CorruptObjectException(id,
-                                                       JGitText.get().corruptObjectInvalidType);
-                               }
+                       switch (type) {
+                       case Constants.OBJ_COMMIT:
+                       case Constants.OBJ_TREE:
+                       case Constants.OBJ_BLOB:
+                       case Constants.OBJ_TAG:
+                               // Acceptable types for a loose object.
+                               break;
+                       default:
+                               throw new CorruptObjectException(id,
+                                               JGitText.get().corruptObjectInvalidType);
+                       }
 
-                               if (path == null && Integer.MAX_VALUE < size) {
-                                       LargeObjectException.ExceedsByteArrayLimit e;
-                                       e = new LargeObjectException.ExceedsByteArrayLimit();
-                                       e.setObjectId(id);
-                                       throw e;
-                               }
-                               if (size < wc.getStreamFileThreshold() || path == null) {
-                                       in.reset();
-                                       IO.skipFully(in, p);
-                                       Inflater inf = wc.inflater();
-                                       InputStream zIn = inflate(in, inf);
-                                       byte[] data = new byte[(int) size];
-                                       IO.readFully(zIn, data, 0, data.length);
-                                       checkValidEndOfStream(in, inf, id, hdr);
-                                       return new ObjectLoader.SmallObject(type, data);
-                               }
-                               return new LargeObject(type, size, path, id, wc.db);
+                       if (path == null && Integer.MAX_VALUE < size) {
+                               LargeObjectException.ExceedsByteArrayLimit e;
+                               e = new LargeObjectException.ExceedsByteArrayLimit();
+                               e.setObjectId(id);
+                               throw e;
                        }
+                       if (size < wc.getStreamFileThreshold() || path == null) {
+                               in.reset();
+                               IO.skipFully(in, p);
+                               Inflater inf = wc.inflater();
+                               InputStream zIn = inflate(in, inf);
+                               byte[] data = new byte[(int) size];
+                               IO.readFully(zIn, data, 0, data.length);
+                               checkValidEndOfStream(in, inf, id, hdr);
+                               return new ObjectLoader.SmallObject(type, data);
+                       }
+                       return new LargeObject(type, size, path, id, wc.db);
                } catch (ZipException badStream) {
                        throw new CorruptObjectException(id,
                                        JGitText.get().corruptObjectBadStream);
@@ -213,19 +212,18 @@ public class UnpackedObject {
                                                        JGitText.get().corruptObjectNegativeSize);
                                return size;
 
-                       } else {
-                               readSome(in, hdr, 2, 18);
-                               int c = hdr[0] & 0xff;
-                               long size = c & 15;
-                               int shift = 4;
-                               int p = 1;
-                               while ((c & 0x80) != 0) {
-                                       c = hdr[p++] & 0xff;
-                                       size += ((long) (c & 0x7f)) << shift;
-                                       shift += 7;
-                               }
-                               return size;
                        }
+                       readSome(in, hdr, 2, 18);
+                       int c = hdr[0] & 0xff;
+                       long size = c & 15;
+                       int shift = 4;
+                       int p = 1;
+                       while ((c & 0x80) != 0) {
+                               c = hdr[p++] & 0xff;
+                               size += ((long) (c & 0x7f)) << shift;
+                               shift += 7;
+                       }
+                       return size;
                } catch (ZipException badStream) {
                        throw new CorruptObjectException(id,
                                        JGitText.get().corruptObjectBadStream);
index ea0d2690536b7112136da386188a7b0554d8bf27..616447a651e781979645b7e26230a5e33ecfa361 100644 (file)
@@ -126,17 +126,19 @@ class UnpackedObjectCache {
                        for (int n = 0; n < MAX_CHAIN;) {
                                ObjectId obj = ids.get(i);
                                if (obj == null) {
-                                       if (ids.compareAndSet(i, null, toAdd.copy()))
+                                       if (ids.compareAndSet(i, null, toAdd.copy())) {
                                                return true;
-                                       else
-                                               continue;
+                                       }
+                                       continue;
                                }
 
-                               if (AnyObjectId.isEqual(obj, toAdd))
+                               if (AnyObjectId.isEqual(obj, toAdd)) {
                                        return true;
+                               }
 
-                               if (++i == ids.length())
+                               if (++i == ids.length()) {
                                        i = 0;
+                               }
                                n++;
                        }
                        return false;
index 2f770e96fb95e097cbb4b387f895436aa14e31e8..e4536643a71bdf4a50a8a0fcce2e13186907bfb0 100644 (file)
@@ -1751,23 +1751,23 @@ public class PackWriter implements AutoCloseable {
                                                        NullProgressMonitor.INSTANCE,
                                                        Collections.singleton(otp));
                                        continue;
-                               } else {
-                                       // Object writing already started, we cannot recover.
-                                       //
-                                       CorruptObjectException coe;
-                                       coe = new CorruptObjectException(otp, ""); //$NON-NLS-1$
-                                       coe.initCause(gone);
-                                       throw coe;
                                }
+                               // Object writing already started, we cannot recover.
+                               //
+                               CorruptObjectException coe;
+                               coe = new CorruptObjectException(otp, ""); //$NON-NLS-1$
+                               coe.initCause(gone);
+                               throw coe;
                        }
                }
 
                // If we reached here, reuse wasn't possible.
                //
-               if (otp.isDeltaRepresentation())
+               if (otp.isDeltaRepresentation()) {
                        writeDeltaObjectDeflate(out, otp);
-               else
+               } else {
                        writeWholeObjectDeflate(out, otp);
+               }
                out.endObject();
                otp.setCRC((int) crc32.getValue());
        }
index 6c8d4fc03e49e59613431af747e7b752dff43130..ce6ddb9cc69e7ef50a31516544b7492b3e5bf64e 100644 (file)
@@ -87,16 +87,14 @@ public abstract class ReftableDatabase {
                                if (newRef.isSymbolic()) {
                                        return ReceiveCommand.link(oldRef.getTarget().getName(),
                                                        newRef.getTarget().getName(), name);
-                               } else {
-                                       // This should pass in oldId for compat with
-                                       // RefDirectoryUpdate
-                                       return ReceiveCommand.unlink(oldRef.getTarget().getName(),
-                                                       newId, name);
                                }
-                       } else {
+                               // This should pass in oldId for compat with
+                               // RefDirectoryUpdate
                                return ReceiveCommand.unlink(oldRef.getTarget().getName(),
-                                               ObjectId.zeroId(), name);
+                                               newId, name);
                        }
+                       return ReceiveCommand.unlink(oldRef.getTarget().getName(),
+                                       ObjectId.zeroId(), name);
                }
 
                if (newRef != null && newRef.isSymbolic()) {
@@ -104,14 +102,12 @@ public abstract class ReftableDatabase {
                                if (oldRef.isSymbolic()) {
                                        return ReceiveCommand.link(oldRef.getTarget().getName(),
                                                        newRef.getTarget().getName(), name);
-                               } else {
-                                       return ReceiveCommand.link(oldId,
-                                                       newRef.getTarget().getName(), name);
                                }
-                       } else {
-                               return ReceiveCommand.link(ObjectId.zeroId(),
+                               return ReceiveCommand.link(oldId,
                                                newRef.getTarget().getName(), name);
                        }
+                       return ReceiveCommand.link(ObjectId.zeroId(),
+                                       newRef.getTarget().getName(), name);
                }
 
                return new ReceiveCommand(oldId, newId, name);
index da98e3fadde21e0843e646fc3fc09c7729af4b61..9c5423fb0e839f4d23251dcedb54818a70bb6770 100644 (file)
@@ -102,9 +102,8 @@ class RefTreeBatch extends BatchRefUpdate {
                                        if (isAtomic()) {
                                                ReceiveCommand.abort(getCommands());
                                                return;
-                                       } else {
-                                               continue;
                                        }
+                                       continue;
                                }
                        }
                        todo.add(new Command(rw, c));
index 882b2d055b3a3d6be5c2ffa5b67203bc530917ce..39a67afae3a5601f36b33fa06ae6a4f99ffd9985 100644 (file)
@@ -82,9 +82,8 @@ public class NetscapeCookieFileCache {
        public static NetscapeCookieFileCache getInstance(HttpConfig config) {
                if (instance == null) {
                        return new NetscapeCookieFileCache(config);
-               } else {
-                       return instance;
                }
+               return instance;
        }
 
        /**
index c1e94a0a3e1f0aa4560f5b8b23124c55cde744ab..ee6adeee98d88dcab81df395e7fbc3d6ec8b1ec0 100644 (file)
@@ -384,9 +384,8 @@ public class OpenSshConfigFile {
        private static boolean isHostMatch(String pattern, String name) {
                if (pattern.startsWith("!")) { //$NON-NLS-1$
                        return !patternMatchesHost(pattern.substring(1), name);
-               } else {
-                       return patternMatchesHost(pattern, name);
                }
+               return patternMatchesHost(pattern, name);
        }
 
        private static boolean patternMatchesHost(String pattern, String name) {
@@ -399,10 +398,9 @@ public class OpenSshConfigFile {
                        }
                        fn.append(name);
                        return fn.isMatch();
-               } else {
-                       // Not a pattern but a full host name
-                       return pattern.equals(name);
                }
+               // Not a pattern but a full host name
+               return pattern.equals(name);
        }
 
        private static String dequote(String value) {
index 4f90e69008f74086e1bb70a93f156a953ace1306..24850ee44c98a0dc89f05169f8cdf20fd45aff2d 100644 (file)
@@ -302,10 +302,10 @@ public abstract class AnyObjectId implements Comparable<AnyObjectId> {
        /** {@inheritDoc} */
        @Override
        public final boolean equals(Object o) {
-               if (o instanceof AnyObjectId)
+               if (o instanceof AnyObjectId) {
                        return equals((AnyObjectId) o);
-               else
-                       return false;
+               }
+               return false;
        }
 
        /**
index 96e50667b3c05c50832075abee50924b8114575a..98a46f3e54c0dd09298c193bc4b7dcfe330aaf06 100644 (file)
@@ -103,25 +103,29 @@ public class BaseRepositoryBuilder<B extends BaseRepositoryBuilder, R extends Re
        private static File getSymRef(File workTree, File dotGit, FS fs)
                        throws IOException {
                byte[] content = IO.readFully(dotGit);
-               if (!isSymRef(content))
+               if (!isSymRef(content)) {
                        throw new IOException(MessageFormat.format(
                                        JGitText.get().invalidGitdirRef, dotGit.getAbsolutePath()));
+               }
 
                int pathStart = 8;
                int lineEnd = RawParseUtils.nextLF(content, pathStart);
                while (content[lineEnd - 1] == '\n' ||
-                      (content[lineEnd - 1] == '\r' && SystemReader.getInstance().isWindows()))
+                               (content[lineEnd - 1] == '\r'
+                                               && SystemReader.getInstance().isWindows())) {
                        lineEnd--;
-               if (lineEnd == pathStart)
+               }
+               if (lineEnd == pathStart) {
                        throw new IOException(MessageFormat.format(
                                        JGitText.get().invalidGitdirRef, dotGit.getAbsolutePath()));
+               }
 
                String gitdirPath = RawParseUtils.decode(content, pathStart, lineEnd);
                File gitdirFile = fs.resolve(workTree, gitdirPath);
-               if (gitdirFile.isAbsolute())
+               if (gitdirFile.isAbsolute()) {
                        return gitdirFile;
-               else
-                       return new File(workTree, gitdirPath).getCanonicalFile();
+               }
+               return new File(workTree, gitdirPath).getCanonicalFile();
        }
 
        private FS fs;
@@ -723,9 +727,8 @@ public class BaseRepositoryBuilder<B extends BaseRepositoryBuilder, R extends Re
                                                                .getAbsolutePath(), err.getMessage()));
                        }
                        return cfg;
-               } else {
-                       return new Config();
                }
+               return new Config();
        }
 
        private File guessWorkTreeOrFail() throws IOException {
index be53c4b4f6ae3c40c5a2356c6b1f13a585ba9547..cad747bcffc06809339dd093fd38d06af89504b6 100644 (file)
@@ -232,9 +232,9 @@ public class BranchConfig {
 
        private String getRemoteOrDefault() {
                String remote = getRemote();
-               if (remote == null)
+               if (remote == null) {
                        return Constants.DEFAULT_REMOTE_NAME;
-               else
-                       return remote;
+               }
+               return remote;
        }
 }
index 16db7170322bd519ec0ebdbf1ec18cc59391879e..938fa2394e1037c8668fc2935fe31dc796f03cc6 100644 (file)
@@ -1395,12 +1395,11 @@ public class Config {
                                }
                                trailingSpaces.append(cc);
                                continue;
-                       } else {
-                               inLeadingSpace = false;
-                               if (trailingSpaces != null) {
-                                       value.append(trailingSpaces);
-                                       trailingSpaces.setLength(0);
-                               }
+                       }
+                       inLeadingSpace = false;
+                       if (trailingSpaces != null) {
+                               value.append(trailingSpaces);
+                               trailingSpaces.setLength(0);
                        }
 
                        if ('\\' == c) {
index e865da83b1576775ab652eec48203a0b7eb39371..23e8de0e35320ecde7bc40c71eb1fbd538128020 100644 (file)
@@ -134,11 +134,9 @@ public class DefaultTypedConfigGetter implements TypedConfigGetter {
                        throw new IllegalArgumentException(
                                        MessageFormat.format(JGitText.get().enumValueNotSupported3,
                                                        section, subsection, name, value));
-               } else {
-                       throw new IllegalArgumentException(
-                                       MessageFormat.format(JGitText.get().enumValueNotSupported2,
-                                                       section, name, value));
                }
+               throw new IllegalArgumentException(MessageFormat.format(
+                               JGitText.get().enumValueNotSupported2, section, name, value));
        }
 
        /** {@inheritDoc} */
index 88d08598426b5fd516e3cae15f9f0044d25ba7df..b87a031f58b4436dfffbdada9158002ff2bd0df8 100644 (file)
@@ -606,16 +606,17 @@ public class IndexDiff {
                }
 
                // consume the remaining work
-               if (monitor != null)
+               if (monitor != null) {
                        monitor.endTask();
+               }
 
                ignored = indexDiffFilter.getIgnoredPaths();
                if (added.isEmpty() && changed.isEmpty() && removed.isEmpty()
                                && missing.isEmpty() && modified.isEmpty()
-                               && untracked.isEmpty())
+                               && untracked.isEmpty()) {
                        return false;
-               else
-                       return true;
+               }
+               return true;
        }
 
        private boolean hasFiles(File directory) {
index 700b9dbe855f40c45948bd7a7aa4334252595843..e14fb102b7b95e243443432feb57fc94c820bf05 100644 (file)
@@ -293,9 +293,8 @@ public abstract class ObjectReader implements AutoCloseable {
                                if (idItr.hasNext()) {
                                        cur = idItr.next();
                                        return true;
-                               } else {
-                                       return false;
                                }
+                               return false;
                        }
 
                        @Override
@@ -383,9 +382,8 @@ public abstract class ObjectReader implements AutoCloseable {
                                        cur = idItr.next();
                                        sz = getObjectSize(cur, OBJ_ANY);
                                        return true;
-                               } else {
-                                       return false;
                                }
+                               return false;
                        }
 
                        @Override
index 68866ea279170390a875fcbefe8d87133506ad77..0e9cf58cf20a02a1acef4953c8c13b4c0eaa90f9 100644 (file)
@@ -503,9 +503,8 @@ public abstract class Repository implements AutoCloseable {
                        if (resolved instanceof String) {
                                final Ref ref = findRef((String) resolved);
                                return ref != null ? ref.getLeaf().getObjectId() : null;
-                       } else {
-                               return (ObjectId) resolved;
                        }
+                       return (ObjectId) resolved;
                }
        }
 
@@ -527,11 +526,12 @@ public abstract class Repository implements AutoCloseable {
                try (RevWalk rw = new RevWalk(this)) {
                        rw.setRetainBody(true);
                        Object resolved = resolve(rw, revstr);
-                       if (resolved != null)
-                               if (resolved instanceof String)
+                       if (resolved != null) {
+                               if (resolved instanceof String) {
                                        return (String) resolved;
-                               else
-                                       return ((AnyObjectId) resolved).getName();
+                               }
+                               return ((AnyObjectId) resolved).getName();
+                       }
                        return null;
                }
        }
@@ -760,15 +760,15 @@ public abstract class Repository implements AutoCloseable {
                                                if (name == null)
                                                        throw new RevisionSyntaxException(revstr);
                                        } else if (time.matches("^-\\d+$")) { //$NON-NLS-1$
-                                               if (name != null)
+                                               if (name != null) {
                                                        throw new RevisionSyntaxException(revstr);
-                                               else {
-                                                       String previousCheckout = resolveReflogCheckout(-Integer
-                                                                       .parseInt(time));
-                                                       if (ObjectId.isId(previousCheckout))
-                                                               rev = parseSimple(rw, previousCheckout);
-                                                       else
-                                                               name = previousCheckout;
+                                               }
+                                               String previousCheckout = resolveReflogCheckout(
+                                                               -Integer.parseInt(time));
+                                               if (ObjectId.isId(previousCheckout)) {
+                                                       rev = parseSimple(rw, previousCheckout);
+                                               } else {
+                                                       name = previousCheckout;
                                                }
                                        } else {
                                                if (name == null)
index cdbe3cd26c38babb78ae3f10f18c52abc7a2e3ee..12f353e0da8f14e6703f3ea51fc21c7a8e85d568 100644 (file)
@@ -166,10 +166,10 @@ public class MergeConfig {
                String mergeOptions = config.getString(
                                ConfigConstants.CONFIG_BRANCH_SECTION, branch,
                                ConfigConstants.CONFIG_KEY_MERGEOPTIONS);
-               if (mergeOptions != null)
+               if (mergeOptions != null) {
                        return mergeOptions.split("\\s"); //$NON-NLS-1$
-               else
-                       return new String[0];
+               }
+               return new String[0];
        }
 
        private static class MergeConfigSectionParser implements
@@ -188,10 +188,10 @@ public class MergeConfig {
 
                @Override
                public boolean equals(Object obj) {
-                       if (obj instanceof MergeConfigSectionParser)
+                       if (obj instanceof MergeConfigSectionParser) {
                                return branch.equals(((MergeConfigSectionParser) obj).branch);
-                       else
-                               return false;
+                       }
+                       return false;
                }
 
                @Override
index ca0e18a0efa960eaf6ffd4702e339a85e5eeb25a..ca2f37abee687311c08874ade0bbeb392aa42c7e 100644 (file)
@@ -153,15 +153,16 @@ public class MergeMessageFormatter {
        private static void addConflictsMessage(List<String> conflictingPaths,
                        StringBuilder sb) {
                sb.append("Conflicts:\n"); //$NON-NLS-1$
-               for (String conflictingPath : conflictingPaths)
+               for (String conflictingPath : conflictingPaths) {
                        sb.append('\t').append(conflictingPath).append('\n');
+               }
        }
 
        private static String joinNames(List<String> names, String singular,
                        String plural) {
-               if (names.size() == 1)
+               if (names.size() == 1) {
                        return singular + " " + names.get(0); //$NON-NLS-1$
-               else
-                       return plural + " " + StringUtils.join(names, ", ", " and "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+               }
+               return plural + " " + StringUtils.join(names, ", ", " and "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        }
 }
index 0b423fb5d49dce663e271fd760a594f1ad2cb481..e0b00c0bd791d24b33118c8bc13f86a92efd550b 100644 (file)
@@ -652,42 +652,40 @@ public class ResolveMerger extends ThreeWayMerger {
                                keep(ourDce);
                                // no checkout needed!
                                return true;
-                       } else {
-                               // same content but different mode on OURS and THEIRS.
-                               // Try to merge the mode and report an error if this is
-                               // not possible.
-                               int newMode = mergeFileModes(modeB, modeO, modeT);
-                               if (newMode != FileMode.MISSING.getBits()) {
-                                       if (newMode == modeO)
-                                               // ours version is preferred
-                                               keep(ourDce);
-                                       else {
-                                               // the preferred version THEIRS has a different mode
-                                               // than ours. Check it out!
-                                               if (isWorktreeDirty(work, ourDce))
-                                                       return false;
-                                               // we know about length and lastMod only after we have written the new content.
-                                               // This will happen later. Set these values to 0 for know.
-                                               DirCacheEntry e = add(tw.getRawPath(), theirs,
-                                                               DirCacheEntry.STAGE_0, EPOCH, 0);
-                                               addToCheckout(tw.getPathString(), e, attributes);
-                                       }
-                                       return true;
+                       }
+                       // same content but different mode on OURS and THEIRS.
+                       // Try to merge the mode and report an error if this is
+                       // not possible.
+                       int newMode = mergeFileModes(modeB, modeO, modeT);
+                       if (newMode != FileMode.MISSING.getBits()) {
+                               if (newMode == modeO) {
+                                       // ours version is preferred
+                                       keep(ourDce);
                                } else {
-                                       // FileModes are not mergeable. We found a conflict on modes.
-                                       // For conflicting entries we don't know lastModified and length.
-                                       add(tw.getRawPath(), base, DirCacheEntry.STAGE_1, EPOCH, 0);
-                                       add(tw.getRawPath(), ours, DirCacheEntry.STAGE_2, EPOCH, 0);
-                                       add(tw.getRawPath(), theirs, DirCacheEntry.STAGE_3, EPOCH,
-                                                       0);
-                                       unmergedPaths.add(tw.getPathString());
-                                       mergeResults.put(
-                                                       tw.getPathString(),
-                                                       new MergeResult<>(Collections
-                                                                       .<RawText> emptyList()));
+                                       // the preferred version THEIRS has a different mode
+                                       // than ours. Check it out!
+                                       if (isWorktreeDirty(work, ourDce)) {
+                                               return false;
+                                       }
+                                       // we know about length and lastMod only after we have
+                                       // written the new content.
+                                       // This will happen later. Set these values to 0 for know.
+                                       DirCacheEntry e = add(tw.getRawPath(), theirs,
+                                                       DirCacheEntry.STAGE_0, EPOCH, 0);
+                                       addToCheckout(tw.getPathString(), e, attributes);
                                }
                                return true;
                        }
+                       // FileModes are not mergeable. We found a conflict on modes.
+                       // For conflicting entries we don't know lastModified and
+                       // length.
+                       add(tw.getRawPath(), base, DirCacheEntry.STAGE_1, EPOCH, 0);
+                       add(tw.getRawPath(), ours, DirCacheEntry.STAGE_2, EPOCH, 0);
+                       add(tw.getRawPath(), theirs, DirCacheEntry.STAGE_3, EPOCH, 0);
+                       unmergedPaths.add(tw.getPathString());
+                       mergeResults.put(tw.getPathString(),
+                                       new MergeResult<>(Collections.<RawText> emptyList()));
+                       return true;
                }
 
                if (modeB == modeT && tw.idEqual(T_BASE, T_THEIRS)) {
@@ -716,21 +714,20 @@ public class ResolveMerger extends ThreeWayMerger {
                                        addToCheckout(tw.getPathString(), e, attributes);
                                }
                                return true;
-                       } else {
-                               // we want THEIRS ... but THEIRS contains a folder or the
-                               // deletion of the path. Delete what's in the working tree,
-                               // which we know to be clean.
-                               if (tw.getTreeCount() > T_FILE && tw.getRawMode(T_FILE) == 0) {
-                                       // Not present in working tree, so nothing to delete
-                                       return true;
-                               }
-                               if (modeT != 0 && modeT == modeB) {
-                                       // Base, ours, and theirs all contain a folder: don't delete
-                                       return true;
-                               }
-                               addDeletion(tw.getPathString(), nonTree(modeO), attributes);
+                       }
+                       // we want THEIRS ... but THEIRS contains a folder or the
+                       // deletion of the path. Delete what's in the working tree,
+                       // which we know to be clean.
+                       if (tw.getTreeCount() > T_FILE && tw.getRawMode(T_FILE) == 0) {
+                               // Not present in working tree, so nothing to delete
                                return true;
                        }
+                       if (modeT != 0 && modeT == modeB) {
+                               // Base, ours, and theirs all contain a folder: don't delete
+                               return true;
+                       }
+                       addDeletion(tw.getPathString(), nonTree(modeO), attributes);
+                       return true;
                }
 
                if (tw.isSubtree()) {
@@ -1310,10 +1307,9 @@ public class ResolveMerger extends ThreeWayMerger {
                if (getUnmergedPaths().isEmpty() && !failed()) {
                        resultTree = dircache.writeTree(getObjectInserter());
                        return true;
-               } else {
-                       resultTree = null;
-                       return false;
                }
+               resultTree = null;
+               return false;
        }
 
        /**
index 2fc0f4f073b8f84696297e6e969b0153cbe8e062..d56e5c0c1ea17f86c333c851cb1a42696f96b3df 100644 (file)
@@ -143,17 +143,17 @@ public abstract class ThreeWayMerger extends Merger {
         * @throws java.io.IOException
         */
        protected AbstractTreeIterator mergeBase() throws IOException {
-               if (baseTree != null)
+               if (baseTree != null) {
                        return openTree(baseTree);
+               }
                RevCommit baseCommit = (baseCommitId != null) ? walk
                                .parseCommit(baseCommitId) : getBaseCommit(sourceCommits[0],
                                sourceCommits[1]);
                if (baseCommit == null) {
                        baseCommitId = null;
                        return new EmptyTreeIterator();
-               } else {
-                       baseCommitId = baseCommit.toObjectId();
-                       return openTree(baseCommit.getTree());
                }
+               baseCommitId = baseCommit.toObjectId();
+               return openTree(baseCommit.getTree());
        }
 }
index 7827a9aa058ba75de55d01985d327118bea07441..c1616b3ed85d24c49b128c68b0c5adfdacd1e75e 100644 (file)
@@ -167,10 +167,10 @@ class FanoutBucket extends InMemoryNoteBucket {
 
                        @Override
                        public Note next() {
-                               if (hasNext())
+                               if (hasNext()) {
                                        return itr.next();
-                               else
-                                       throw new NoSuchElementException();
+                               }
+                               throw new NoSuchElementException();
                        }
 
                        @Override
@@ -214,30 +214,31 @@ class FanoutBucket extends InMemoryNoteBucket {
                NoteBucket b = table[cell];
 
                if (b == null) {
-                       if (noteData == null)
+                       if (noteData == null) {
                                return this;
+                       }
 
                        LeafBucket n = new LeafBucket(prefixLen + 2);
                        table[cell] = n.set(noteOn, noteData, or);
                        cnt++;
                        return this;
 
-               } else {
-                       NoteBucket n = b.set(noteOn, noteData, or);
-                       if (n == null) {
-                               table[cell] = null;
-                               cnt--;
+               }
+               NoteBucket n = b.set(noteOn, noteData, or);
+               if (n == null) {
+                       table[cell] = null;
+                       cnt--;
 
-                               if (cnt == 0)
-                                       return null;
+                       if (cnt == 0) {
+                               return null;
+                       }
 
-                               return contractIfTooSmall(noteOn, or);
+                       return contractIfTooSmall(noteOn, or);
 
-                       } else if (n != b) {
-                               table[cell] = n;
-                       }
-                       return this;
+               } else if (n != b) {
+                       table[cell] = n;
                }
+               return this;
        }
 
        InMemoryNoteBucket contractIfTooSmall(AnyObjectId noteOn, ObjectReader or)
index 6723b6309c53a871f940a93e44acdb9d3ba9afea..0fa2a6306cce0db92f594b5bbd4543e4e04fda98 100644 (file)
@@ -129,10 +129,10 @@ class LeafBucket extends InMemoryNoteBucket {
 
                        @Override
                        public Note next() {
-                               if (hasNext())
+                               if (hasNext()) {
                                        return notes[idx++];
-                               else
-                                       throw new NoSuchElementException();
+                               }
+                               throw new NoSuchElementException();
                        }
 
                        @Override
@@ -156,25 +156,23 @@ class LeafBucket extends InMemoryNoteBucket {
                                notes[p].setData(noteData.copy());
                                return this;
 
-                       } else {
-                               System.arraycopy(notes, p + 1, notes, p, cnt - p - 1);
-                               cnt--;
-                               return 0 < cnt ? this : null;
                        }
+                       System.arraycopy(notes, p + 1, notes, p, cnt - p - 1);
+                       cnt--;
+                       return 0 < cnt ? this : null;
 
                } else if (noteData != null) {
                        if (shouldSplit()) {
                                return split().set(noteOn, noteData, or);
-
-                       } else {
-                               growIfFull();
-                               p = -(p + 1);
-                               if (p < cnt)
-                                       System.arraycopy(notes, p, notes, p + 1, cnt - p);
-                               notes[p] = new Note(noteOn, noteData.copy());
-                               cnt++;
-                               return this;
                        }
+                       growIfFull();
+                       p = -(p + 1);
+                       if (p < cnt) {
+                               System.arraycopy(notes, p, notes, p + 1, cnt - p);
+                       }
+                       notes[p] = new Note(noteOn, noteData.copy());
+                       cnt++;
+                       return this;
 
                } else {
                        return this;
@@ -234,12 +232,10 @@ class LeafBucket extends InMemoryNoteBucket {
        InMemoryNoteBucket append(Note note) {
                if (shouldSplit()) {
                        return split().append(note);
-
-               } else {
-                       growIfFull();
-                       notes[cnt++] = note;
-                       return this;
                }
+               growIfFull();
+               notes[cnt++] = note;
+               return this;
        }
 
        private void growIfFull() {
index cbef61338f6518075609517098b023a918e96392..e4eef433d8a54911f099d9557b2ed90b5ae89b3c 100644 (file)
@@ -278,10 +278,10 @@ public class NoteMap implements Iterable<Note> {
        public byte[] getCachedBytes(AnyObjectId id, int sizeLimit)
                        throws LargeObjectException, MissingObjectException, IOException {
                ObjectId dataId = get(id);
-               if (dataId != null)
+               if (dataId != null) {
                        return reader.open(dataId).getCachedBytes(sizeLimit);
-               else
-                       return null;
+               }
+               return null;
        }
 
        /**
index ba7223b8f07ba876e1ca06f8c3dc6afc23c2e86f..6ff1402900ff5e0c2bf8a3ad74690f5b8ca50da5 100644 (file)
@@ -307,10 +307,10 @@ public class NoteMapMerger {
 
        private static InMemoryNoteBucket addIfNotNull(InMemoryNoteBucket result,
                        Note note) {
-               if (note != null)
+               if (note != null) {
                        return result.append(note);
-               else
-                       return result;
+               }
+               return result;
        }
 
        private NonNoteEntry mergeNonNotes(NonNoteEntry baseList,
index 8ef3af10ad2a0d90690c57b9baff1b50daf4954a..7dfc47deb0409511eda139af3a8d0544a2fc47ae 100644 (file)
@@ -181,9 +181,8 @@ final class NoteParser extends CanonicalTreeParser {
                        } catch (ArrayIndexOutOfBoundsException notHex) {
                                return -1;
                        }
-               } else {
-                       return -1;
                }
+               return -1;
        }
 
        private void storeNonNote() {
index 45508ce0274995dcb170bf089d8274534a23cd81..2bb45c55dcb11b292227e464bb7bbf9e9b70eb31 100644 (file)
@@ -391,11 +391,10 @@ public class PlotCommitList<L extends PlotLane> extends
                                        return pos.intValue();
                                }
                        return positionsAllocated++;
-               } else {
-                       final Integer min = freePositions.first();
-                       freePositions.remove(min);
-                       return min.intValue();
                }
+               final Integer min = freePositions.first();
+               freePositions.remove(min);
+               return min.intValue();
        }
 
        /**
index ee18fe7c2f21472c972c56071bcf0d3c0c9ed774..19e40b562bd444e1d7be7259d231aee096debb8b 100644 (file)
@@ -176,11 +176,10 @@ public class PlotWalk extends RevWalk {
                Collection<Ref> list = reverseRefMap.get(commitId);
                if (list == null) {
                        return PlotCommit.NO_REFS;
-               } else {
-                       Ref[] tags = list.toArray(new Ref[0]);
-                       Arrays.sort(tags, new PlotRefComparator());
-                       return tags;
                }
+               Ref[] tags = list.toArray(new Ref[0]);
+               Arrays.sort(tags, new PlotRefComparator());
+               return tags;
        }
 
        class PlotRefComparator implements Comparator<Ref> {
index f7c321885098a0f4acf79aeff9396d061e06fc9b..090d1e110c3a6f791ca1f6c316510b67b9c0750d 100644 (file)
@@ -169,19 +169,19 @@ public class TreeRevFilter extends RevFilter {
                                //
                                c.flags |= rewriteFlag;
                                return false;
-                       } else {
-                               // We have interesting items, but neither of the special
-                               // cases denoted above.
+                       }
+
+                       // We have interesting items, but neither of the special
+                       // cases denoted above.
+                       //
+                       if (adds > 0 && tw.getFilter() instanceof FollowFilter) {
+                               // One of the paths we care about was added in this
+                               // commit. We need to update our filter to its older
+                               // name, if we can discover it. Find out what that is.
                                //
-                               if (adds > 0 && tw.getFilter() instanceof FollowFilter) {
-                                       // One of the paths we care about was added in this
-                                       // commit. We need to update our filter to its older
-                                       // name, if we can discover it. Find out what that is.
-                                       //
-                                       updateFollowFilter(trees, ((FollowFilter) tw.getFilter()).cfg);
-                               }
-                               return true;
+                               updateFollowFilter(trees, ((FollowFilter) tw.getFilter()).cfg);
                        }
+                       return true;
                } else if (nParents == 0) {
                        // We have no parents to compare against. Consider us to be
                        // REWRITE only if we have no paths matching our filter.
index 954359ebaa713fef5fbe540b960716dce11e66d4..d4fa17e25ec8886e7d1852f563da54f968035493 100644 (file)
@@ -1579,14 +1579,15 @@ public abstract class BaseReceivePack {
                        RevObject o;
                        while ((o = ow.nextObject()) != null) {
                                checking.update(1);
-                               if (o.has(RevFlag.UNINTERESTING))
+                               if (o.has(RevFlag.UNINTERESTING)) {
                                        continue;
+                               }
 
                                if (providedObjects != null) {
-                                       if (providedObjects.contains(o))
+                                       if (providedObjects.contains(o)) {
                                                continue;
-                                       else
-                                               throw new MissingObjectException(o, o.getType());
+                                       }
+                                       throw new MissingObjectException(o, o.getType());
                                }
 
                                if (o instanceof RevBlob && !db.getObjectDatabase().has(o))
@@ -1597,8 +1598,9 @@ public abstract class BaseReceivePack {
                        if (baseObjects != null) {
                                for (ObjectId id : baseObjects) {
                                        o = ow.parseAny(id);
-                                       if (!o.has(RevFlag.UNINTERESTING))
+                                       if (!o.has(RevFlag.UNINTERESTING)) {
                                                throw new MissingObjectException(o, o.getType());
+                                       }
                                }
                        }
                }
index d901021788a0c70c91748d3594782b2e88af6230..6325a235305a2462e65d9997a122423c6a0e59af 100644 (file)
@@ -107,10 +107,9 @@ public class CredentialsProviderUserInfo implements UserInfo,
                if (provider.get(uri, v)) {
                        passphrase = v.getValue();
                        return true;
-               } else {
-                       passphrase = null;
-                       return false;
                }
+               passphrase = null;
+               return false;
        }
 
        /** {@inheritDoc} */
@@ -120,10 +119,9 @@ public class CredentialsProviderUserInfo implements UserInfo,
                if (provider.get(uri, p)) {
                        password = new String(p.getValue());
                        return true;
-               } else {
-                       password = null;
-                       return false;
                }
+               password = null;
+               return false;
        }
 
        private CredentialItem.StringType newPrompt(String msg) {
index 01f6fec7e48f671c0578c01f19d7b78f9bc1b059..72e95e6ba3822b4fbcf8d76c1eaa72d0840e2934 100644 (file)
@@ -135,9 +135,8 @@ public class HMACSHA1NonceGenerator implements NonceGenerator {
 
                if (nonceStampSlop <= slop) {
                        return NonceStatus.OK;
-               } else {
-                       return NonceStatus.SLOP;
                }
+               return NonceStatus.SLOP;
        }
 
        private static final String HEX = "0123456789ABCDEF"; //$NON-NLS-1$
index 0a621f19e1d61f7af3d0c08d9f795c911a28d84d..4474d1a8586e9a5eda3fb5f1bc7aab49804e87d0 100644 (file)
@@ -292,22 +292,26 @@ public class RemoteConfig implements Serializable {
 
        private String replaceUri(final String uri,
                        final Map<String, String> replacements) {
-               if (replacements.isEmpty())
+               if (replacements.isEmpty()) {
                        return uri;
+               }
                Entry<String, String> match = null;
                for (Entry<String, String> replacement : replacements.entrySet()) {
                        // Ignore current entry if not longer than previous match
                        if (match != null
-                                       && match.getKey().length() > replacement.getKey().length())
+                                       && match.getKey().length() > replacement.getKey()
+                                                       .length()) {
                                continue;
-                       if (!uri.startsWith(replacement.getKey()))
+                       }
+                       if (!uri.startsWith(replacement.getKey())) {
                                continue;
+                       }
                        match = replacement;
                }
-               if (match != null)
+               if (match != null) {
                        return match.getValue() + uri.substring(match.getKey().length());
-               else
-                       return uri;
+               }
+               return uri;
        }
 
        /**
index 0b7907035e30c5ae61baddd0a5675e96e84a848c..2382f4c3af1e18b861167d04187d06ab13d6b0cc 100644 (file)
@@ -302,11 +302,12 @@ public abstract class Transport implements AutoCloseable {
                        URISyntaxException, TransportException {
                if (local != null) {
                        final RemoteConfig cfg = new RemoteConfig(local.getConfig(), remote);
-                       if (doesNotExist(cfg))
+                       if (doesNotExist(cfg)) {
                                return open(local, new URIish(remote), null);
+                       }
                        return open(local, cfg, op);
-               } else
-                       return open(new URIish(remote));
+               }
+               return open(new URIish(remote));
 
        }
 
@@ -708,11 +709,11 @@ public abstract class Transport implements AutoCloseable {
                // try to find matching tracking refs
                for (RefSpec fetchSpec : fetchSpecs) {
                        if (fetchSpec.matchSource(remoteName)) {
-                               if (fetchSpec.isWildcard())
+                               if (fetchSpec.isWildcard()) {
                                        return fetchSpec.expandFromSource(remoteName)
                                                        .getDestination();
-                               else
-                                       return fetchSpec.getDestination();
+                               }
+                               return fetchSpec.getDestination();
                        }
                }
                return null;
index 3029327c52ccfecf4a6e87f8ebb3f15d9e75b995..2637a0273a72c9fb0a39631b8d65620b3e8be7c8 100644 (file)
@@ -698,9 +698,8 @@ public class TransportHttp extends HttpTransport implements WalkTransport,
                public CredentialItem[] items() {
                        if (forRepo == null) {
                                return new CredentialItem[] { message, now, always };
-                       } else {
-                               return new CredentialItem[] { message, now, forRepo, always };
                        }
+                       return new CredentialItem[] { message, now, forRepo, always };
                }
        }
 
@@ -1076,13 +1075,11 @@ public class TransportHttp extends HttpTransport implements WalkTransport,
                host = host.toLowerCase(Locale.ROOT);
                if (host.equals(cookieDomain)) {
                        return true;
-               } else {
-                       if (!host.endsWith(cookieDomain)) {
-                               return false;
-                       }
-                       return host
-                                       .charAt(host.length() - cookieDomain.length() - 1) == '.';
                }
+               if (!host.endsWith(cookieDomain)) {
+                       return false;
+               }
+               return host.charAt(host.length() - cookieDomain.length() - 1) == '.';
        }
 
        /**
index 7ca9cc134c78d37b2a5373d58cfd36133db95f67..d5e03ebd5720fd1bb2778bb7b5561bca681ca24f 100644 (file)
@@ -351,10 +351,7 @@ public class URIish implements Serializable {
        }
 
        private String n2e(String s) {
-               if (s == null)
-                       return ""; //$NON-NLS-1$
-               else
-                       return s;
+               return s == null ? "" : s; //$NON-NLS-1$
        }
 
        // takes care to cut of a leading slash if a windows drive letter or a
index b4a7af094d38fe11ffb0761aa8fe3bcf00b6b39d..9a08c080c33a1c92d362c96cacb7ccb9f64fd741 100644 (file)
@@ -124,8 +124,8 @@ public class FileResolver<C> implements RepositoryResolver<C> {
                                        // are responsible for closing the repository if we
                                        // complete successfully.
                                        return db;
-                               } else
-                                       throw new ServiceNotEnabledException();
+                               }
+                               throw new ServiceNotEnabledException();
 
                        } catch (RuntimeException | IOException e) {
                                db.close();
index 4f3eb05b11d4f2c242bed2f11d3730cd2ef524c8..6969ae45af72f7030e24e672c80d1eab2a428d40 100644 (file)
@@ -285,9 +285,8 @@ public class FileTreeIterator extends WorkingTreeIterator {
                        } else if (attributes.isDirectory()) {
                                if (new File(f, Constants.DOT_GIT).exists()) {
                                        return FileMode.GITLINK;
-                               } else {
-                                       return FileMode.TREE;
                                }
+                               return FileMode.TREE;
                        } else if (attributes.isExecutable()) {
                                return FileMode.EXECUTABLE_FILE;
                        } else {
@@ -425,9 +424,8 @@ public class FileTreeIterator extends WorkingTreeIterator {
                        if (attributes.isSymbolicLink()) {
                                return new ByteArrayInputStream(fs.readSymLink(getFile())
                                                .getBytes(UTF_8));
-                       } else {
-                               return new FileInputStream(getFile());
                        }
+                       return new FileInputStream(getFile());
                }
 
                /**
index 31559162325f552ca546fc92ecabec4e89019d24..88b76f71212f428f79be40f2cf77a17d4c384aa6 100644 (file)
@@ -685,10 +685,10 @@ public abstract class WorkingTreeIterator extends AbstractTreeIterator {
        public InputStream openEntryStream() throws IOException {
                InputStream rawis = current().openInputStream();
                if (getCleanFilterCommand() == null
-                               && getEolStreamType() == EolStreamType.DIRECT)
+                               && getEolStreamType() == EolStreamType.DIRECT) {
                        return rawis;
-               else
-                       return filterClean(rawis);
+               }
+               return filterClean(rawis);
        }
 
        /**
@@ -979,13 +979,13 @@ public abstract class WorkingTreeIterator extends AbstractTreeIterator {
                MetadataDiff diff = compareMetadata(entry);
                switch (diff) {
                case DIFFER_BY_TIMESTAMP:
-                       if (forceContentCheck)
+                       if (forceContentCheck) {
                                // But we are told to look at content even though timestamps
                                // tell us about modification
                                return contentCheck(entry, reader);
-                       else
-                               // We are told to assume a modification if timestamps differs
-                               return true;
+                       }
+                       // We are told to assume a modification if timestamps differs
+                       return true;
                case SMUDGED:
                        // The file is clean by timestamps but the entry was smudged.
                        // Lets do a content check
@@ -1086,14 +1086,13 @@ public abstract class WorkingTreeIterator extends AbstractTreeIterator {
                        entry.setLength((int) getEntryLength());
 
                        return false;
-               } else {
-                       if (mode == FileMode.SYMLINK.getBits()) {
-                               return !new File(readSymlinkTarget(current())).equals(
-                                               new File(readContentAsNormalizedString(entry, reader)));
-                       }
-                       // Content differs: that's a real change
-                       return true;
                }
+               if (mode == FileMode.SYMLINK.getBits()) {
+                       return !new File(readSymlinkTarget(current())).equals(
+                                       new File(readContentAsNormalizedString(entry, reader)));
+               }
+               // Content differs: that's a real change
+               return true;
        }
 
        private static String readContentAsNormalizedString(DirCacheEntry entry,
index 6cca582b3bb6e64047a9acad140f41f17a0ac4e8..52fb888291f7b42aaec17e285628f625e50aa22f 100644 (file)
@@ -212,10 +212,9 @@ public class IndexDiffFilter extends TreeFilter {
                                // If i is cnt then the path does not appear in any other tree,
                                // and this working tree entry can be safely ignored.
                                return i != cnt;
-                       } else {
-                               // In working tree and not ignored, and not in DirCache.
-                               return true;
                        }
+                       // In working tree and not ignored, and not in DirCache.
+                       return true;
                }
 
                // Always include subtrees as WorkingTreeIterator cannot provide
index 3d9f875e999df56eb6489e65d25a3e54dab3094f..11896e424241c7aaee3e845987febfbdef0ec991 100644 (file)
@@ -99,10 +99,10 @@ public class PathSuffixFilter extends TreeFilter {
        @Override
        public boolean include(TreeWalk walker) throws MissingObjectException,
                        IncorrectObjectTypeException, IOException {
-               if (walker.isSubtree())
+               if (walker.isSubtree()) {
                        return true;
-               else
-                       return walker.isPathSuffix(pathRaw, pathRaw.length);
+               }
+               return walker.isPathSuffix(pathRaw, pathRaw.length);
 
        }
 
index c8e6645f57e9df9fce9e59e10ec5516cf926d147..66f996554f69a5d85d0dd9354bea4a5d2b61e3b0 100644 (file)
@@ -173,20 +173,19 @@ public class ChangeIdUtil {
                        boolean replaceExisting) {
                int indexOfChangeId = indexOfChangeId(message, "\n"); //$NON-NLS-1$
                if (indexOfChangeId > 0) {
-                       if (!replaceExisting)
+                       if (!replaceExisting) {
                                return message;
-                       else {
-                               StringBuilder ret = new StringBuilder(message.substring(0,
-                                               indexOfChangeId));
-                               ret.append(CHANGE_ID);
-                               ret.append(" I"); //$NON-NLS-1$
-                               ret.append(ObjectId.toString(changeId));
-                               int indexOfNextLineBreak = message.indexOf("\n", //$NON-NLS-1$
-                                               indexOfChangeId);
-                               if (indexOfNextLineBreak > 0)
-                                       ret.append(message.substring(indexOfNextLineBreak));
-                               return ret.toString();
                        }
+                       StringBuilder ret = new StringBuilder(
+                                       message.substring(0, indexOfChangeId));
+                       ret.append(CHANGE_ID);
+                       ret.append(" I"); //$NON-NLS-1$
+                       ret.append(ObjectId.toString(changeId));
+                       int indexOfNextLineBreak = message.indexOf("\n", //$NON-NLS-1$
+                                       indexOfChangeId);
+                       if (indexOfNextLineBreak > 0)
+                               ret.append(message.substring(indexOfNextLineBreak));
+                       return ret.toString();
                }
 
                String[] lines = message.split("\n"); //$NON-NLS-1$
index 29519298c42aef7a7d724c34bb299d96498bdb62..068e6450fea20bca65667034e0c5e3f77ae3ec32 100644 (file)
@@ -147,15 +147,15 @@ public abstract class FS {
                 */
                public FS detect(Boolean cygwinUsed) {
                        if (SystemReader.getInstance().isWindows()) {
-                               if (cygwinUsed == null)
+                               if (cygwinUsed == null) {
                                        cygwinUsed = Boolean.valueOf(FS_Win32_Cygwin.isCygwin());
-                               if (cygwinUsed.booleanValue())
+                               }
+                               if (cygwinUsed.booleanValue()) {
                                        return new FS_Win32_Cygwin();
-                               else
-                                       return new FS_Win32();
-                       } else {
-                               return new FS_POSIX();
+                               }
+                               return new FS_Win32();
                        }
+                       return new FS_POSIX();
                }
        }
 
@@ -1197,14 +1197,13 @@ public abstract class FS {
                                        gobbler.join();
                                        if (rc == 0 && !gobbler.fail.get()) {
                                                return r;
-                                       } else {
-                                               if (debug) {
-                                                       LOG.debug("readpipe rc=" + rc); //$NON-NLS-1$
-                                               }
-                                               throw new CommandFailedException(rc,
-                                                               gobbler.errorMessage.get(),
-                                                               gobbler.exception.get());
                                        }
+                                       if (debug) {
+                                               LOG.debug("readpipe rc=" + rc); //$NON-NLS-1$
+                                       }
+                                       throw new CommandFailedException(rc,
+                                                       gobbler.errorMessage.get(),
+                                                       gobbler.exception.get());
                                } catch (InterruptedException ie) {
                                        // Stop bothering me, I have a zombie to reap.
                                }
index a07a4fd1a540d3c8593ca36439fb6e9a4507fe57..391598d8ae2587f7275e89c6110ad9b2a8e37e75 100644 (file)
@@ -345,13 +345,14 @@ public class IO {
                                        c = s.charAt(++i);
                                        l.add(sb.toString());
                                        sb.setLength(0);
-                                       if (c != '\n')
+                                       if (c != '\n') {
                                                sb.append(c);
+                                       }
                                        continue;
-                               } else { // EOF
-                                       l.add(sb.toString());
-                                       break;
                                }
+                               // EOF
+                               l.add(sb.toString());
+                               break;
                        }
                        sb.append(c);
                }
@@ -401,20 +402,18 @@ public class IO {
                                }
                                resetAndSkipFully(in, n);
                        }
-               } else {
-                       StringBuilder buf = sizeHint > 0
-                                       ? new StringBuilder(sizeHint)
-                                       : new StringBuilder();
-                       int i;
-                       while ((i = in.read()) != -1) {
-                               char c = (char) i;
-                               buf.append(c);
-                               if (c == '\n') {
-                                       break;
-                               }
+               }
+               StringBuilder buf = sizeHint > 0 ? new StringBuilder(sizeHint)
+                               : new StringBuilder();
+               int i;
+               while ((i = in.read()) != -1) {
+                       char c = (char) i;
+                       buf.append(c);
+                       if (c == '\n') {
+                               break;
                        }
-                       return buf.toString();
                }
+               return buf.toString();
        }
 
        private static void resetAndSkipFully(Reader fd, long toSkip) throws IOException {
index 9663e3cef564a697321d7db7c02c0c144a3e30a2..ce1308f334cb3a233b6eae623f60ca6938fb86ad 100644 (file)
@@ -191,12 +191,11 @@ public class RefMap extends AbstractMap<String, Ref> {
                        Ref prior = loose.get(name);
                        loose = loose.set(idx, value);
                        return prior;
-               } else {
-                       Ref prior = get(keyName);
-                       loose = loose.add(idx, value);
-                       sizeIsValid = false;
-                       return prior;
                }
+               Ref prior = get(keyName);
+               loose = loose.add(idx, value);
+               sizeIsValid = false;
+               return prior;
        }
 
        /** {@inheritDoc} */
index 913aa728675f6bed2bf21189948e4a109b9a16da..84db786b1614c4b91905a8c92e90750ffa7cc5d4 100644 (file)
@@ -109,9 +109,8 @@ public class SshSupport {
                                // wrong exception type :(
                                if (process.waitFor() == 0) {
                                        return stdout.toString();
-                               } else {
-                                       return null; // still running after timeout
                                }
+                               return null; // still running after timeout
                        } catch (InterruptedException e) {
                                return null; // error
                        }
index 9ab2caa1acc22aa8490add2de747822fac5800b5..e437c1114b13eba8c5559c4697a240f8c0f1cb9b 100644 (file)
@@ -98,15 +98,16 @@ public abstract class LimitedInputStream extends FilterInputStream {
        @Override
        public int read() throws IOException {
                if (left == 0) {
-                       if (in.available() == 0)
+                       if (in.available() == 0) {
                                return -1;
-                       else
-                               limitExceeded();
+                       }
+                       limitExceeded();
                }
 
                int result = in.read();
-               if (result != -1)
+               if (result != -1) {
                        --left;
+               }
                return result;
        }
 
@@ -114,16 +115,17 @@ public abstract class LimitedInputStream extends FilterInputStream {
        @Override
        public int read(byte[] b, int off, int len) throws IOException {
                if (left == 0) {
-                       if (in.available() == 0)
+                       if (in.available() == 0) {
                                return -1;
-                       else
-                               limitExceeded();
+                       }
+                       limitExceeded();
                }
 
                len = (int) Math.min(len, left);
                int result = in.read(b, off, len);
-               if (result != -1)
+               if (result != -1) {
                        left -= result;
+               }
                return result;
        }