From: Matthias Sohn Date: Sun, 28 Apr 2024 22:55:54 +0000 (+0200) Subject: [errorprone] Fix pattern UseCorrectAssertInTests X-Git-Tag: v6.10.0.202405212237-m3~33 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=07e77293b1e84fddfdc5edbb378021a93427c971;p=jgit.git [errorprone] Fix pattern UseCorrectAssertInTests See https://errorprone.info/bugpattern/UseCorrectAssertInTests Change-Id: Iffde63ac795ad30c3e7774764cb8189cb089ed86 --- diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java index 3b0e184a42..1c2e995bbb 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java @@ -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 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(); diff --git a/tools/BUILD b/tools/BUILD index 9cb24aa361..546ca34b1a 100644 --- a/tools/BUILD +++ b/tools/BUILD @@ -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",