]> source.dussan.org Git - jgit.git/commitdiff
[errorprone] Fix pattern UseCorrectAssertInTests 20/1194020/3
authorMatthias Sohn <matthias.sohn@sap.com>
Sun, 28 Apr 2024 22:55:54 +0000 (00:55 +0200)
committerMatthias Sohn <matthias.sohn@sap.com>
Mon, 29 Apr 2024 13:20:41 +0000 (15:20 +0200)
See https://errorprone.info/bugpattern/UseCorrectAssertInTests

Change-Id: Iffde63ac795ad30c3e7774764cb8189cb089ed86

org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java
tools/BUILD

index 3b0e184a42b3a023940df32364c334beed1fb030..1c2e995bbba190b251979f340dd505bde585b240 100644 (file)
@@ -14,6 +14,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.eclipse.jgit.util.FileUtils.RECURSIVE;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 import static org.junit.Assume.assumeTrue;
@@ -879,7 +880,7 @@ public class AddCommandTest extends RepositoryTestCase {
                        }
                }
                // Help null pointer analysis.
-               assert lastFile != null;
+               assertNotNull(lastFile);
                // Wait a bit. If entries are "racily clean", we'll recompute
                // hashes from the disk files, and then the second add is also slow.
                // We want to test the normal case.
@@ -1260,7 +1261,7 @@ public class AddCommandTest extends RepositoryTestCase {
                                        "[git-link-dir, mode:160000]",
                                        indexState(0));
                        Set<String> untrackedFiles = git.status().call().getUntracked();
-                       assert untrackedFiles.isEmpty();
+                       assertTrue(untrackedFiles.isEmpty());
                }
 
        }
@@ -1275,7 +1276,8 @@ public class AddCommandTest extends RepositoryTestCase {
                                ConfigConstants.CONFIG_KEY_DIRNOGITLINKS, true);
                config.save();
 
-               assert db.getConfig().get(WorkingTreeOptions.KEY).isDirNoGitLinks();
+               assertTrue(
+                               db.getConfig().get(WorkingTreeOptions.KEY).isDirNoGitLinks());
 
                try (Git git = new Git(db)) {
                        git.add().addFilepattern("nested-repo").call();
index 9cb24aa36139cdff9a1bbd2a31ddb922e483ec3f..546ca34b1a057f519d10c0661aff981542be2582 100644 (file)
@@ -410,7 +410,7 @@ java_package_configuration(
         "-Xep:UnusedVariable:ERROR",
         "-Xep:URLEqualsHashCode:ERROR",
         "-Xep:UseBinds:ERROR",
-        "-Xep:UseCorrectAssertInTests:WARN",
+        "-Xep:UseCorrectAssertInTests:ERROR",
         "-Xep:VariableNameSameAsType:ERROR",
         "-Xep:VarTypeName:ERROR",
         "-Xep:WaitNotInLoop:ERROR",