Skip to content

Commit bd1237d

Browse files
committed
chore: Replace !! with checkNotNull() in test code
`checkNotNull()` has clearer semantics and avoids Detekt issues. Signed-off-by: Sebastian Schuberth <[email protected]>
1 parent 8a8e36d commit bd1237d

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

downloader/src/funTest/kotlin/VersionControlSystemFunTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class VersionControlSystemFunTest : WordSpec({
4141
val absProjDir = relProjDir.absoluteFile
4242

4343
"For an absolute working directory, getPathToRoot()" should {
44-
val absVcsDir = VersionControlSystem.forDirectory(absProjDir)!!
44+
val absVcsDir = checkNotNull(VersionControlSystem.forDirectory(absProjDir))
4545

4646
"work if given absolute paths" {
4747
absVcsDir.getPathToRoot(vcsRoot) shouldBe ""
@@ -57,7 +57,7 @@ class VersionControlSystemFunTest : WordSpec({
5757
}
5858

5959
"For a relative working directory, getPathToRoot()" should {
60-
val relVcsDir = VersionControlSystem.forDirectory(relProjDir)!!
60+
val relVcsDir = checkNotNull(VersionControlSystem.forDirectory(relProjDir))
6161

6262
"work if given absolute paths" {
6363
relVcsDir.getPathToRoot(vcsRoot) shouldBe ""

utils/test/src/main/kotlin/Matchers.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ fun matchExpectedResult(
9292
if (multiLineDiff != "unified") return EqMatcher(expected)
9393

9494
return Matcher { actual ->
95-
val vcsDir = VersionControlSystem.forDirectory(expectedResultFile)!!
95+
val vcsDir = checkNotNull(VersionControlSystem.forDirectory(expectedResultFile))
9696
val relativeExpectedResultFile = vcsDir.getPathToRoot(expectedResultFile)
9797

9898
val expectedLines = expected.lines()

utils/test/src/main/kotlin/Utils.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ fun patchExpectedResult(
8989

9090
if (definitionFile != null) {
9191
val projectDir = definitionFile.parentFile
92-
val vcsDir = VersionControlSystem.forDirectory(projectDir)!!
92+
val vcsDir = checkNotNull(VersionControlSystem.forDirectory(projectDir))
9393
val url = vcsDir.getRemoteUrl()
9494
val path = vcsDir.getPathToRoot(projectDir)
9595

0 commit comments

Comments
 (0)