Skip to content

Commit

Permalink
cleanup debug
Browse files Browse the repository at this point in the history
  • Loading branch information
nulls committed Apr 6, 2023
1 parent 031d03b commit 0183ae1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 51 deletions.
20 changes: 5 additions & 15 deletions diktat-cli/src/main/kotlin/org/cqfn/diktat/util/CliUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,11 @@ import kotlin.io.path.exists
import kotlin.io.path.walk

// all roots
private val roots: Set<String> = run {
sequenceOf(
File.listRoots()
.asSequence()
.map {
it.toPath()
},
FileSystems.getDefault()
.rootDirectories
.asSequence()
)
.flatten()
.map { it.absolutePathString() }
.toSet()
}
private val roots: Set<String> = FileSystems.getDefault()
.rootDirectories
.asSequence()
.map { it.absolutePathString() }
.toSet()

/**
* Create a matcher and return a filter that uses it.
Expand Down
36 changes: 0 additions & 36 deletions diktat-cli/src/test/kotlin/org/cqfn/diktat/util/CliUtilsKtTest.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package org.cqfn.diktat.util

import mu.KotlinLogging
import org.assertj.core.api.Assertions
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.io.TempDir
import java.io.File
import java.nio.file.FileSystems
import java.nio.file.Path
import kotlin.io.path.absolutePathString
import kotlin.io.path.createDirectory
Expand Down Expand Up @@ -77,41 +75,7 @@ class CliUtilsKtTest {
.isEmpty()
}

@Test
fun notEmptyRoots() {
val fromFile = File.listRoots()
.also {
log.info { "listRoots is empty: ${it.iterator().hasNext()}" }
}
.iterator()
.asSequence()
.map {
it.toPath().absolutePathString()
}
.onEach {
log.info { "listRoots: $it" }
}
.toList()

val fromFileSystem = FileSystems.getDefault().rootDirectories
.also {
log.info { "rootDirectory is empty: ${it.iterator().hasNext()}" }
}
.asSequence()
.map { it.absolutePathString() }
.onEach {
log.info { "rootDirectory: $it" }
}
.toList()

assert(fromFileSystem.isEmpty() && fromFile.isEmpty()) {
"FileSystems.getDefault().rootDirectories is not empty: ${fromFileSystem.joinToString()} and File.listRoots is not empty: ${fromFile.joinToString()}"
}
}

companion object {
private val log = KotlinLogging.logger {}

private fun Path.resolveAndCreateDirectory(name: String): Path = resolve(name).also {
it.createDirectory()
}
Expand Down

0 comments on commit 0183ae1

Please sign in to comment.