From 0183ae14998cbd452b8d3f036a5351e01adae133 Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Thu, 6 Apr 2023 14:22:02 +0300 Subject: [PATCH] cleanup debug --- .../kotlin/org/cqfn/diktat/util/CliUtils.kt | 20 +++-------- .../org/cqfn/diktat/util/CliUtilsKtTest.kt | 36 ------------------- 2 files changed, 5 insertions(+), 51 deletions(-) diff --git a/diktat-cli/src/main/kotlin/org/cqfn/diktat/util/CliUtils.kt b/diktat-cli/src/main/kotlin/org/cqfn/diktat/util/CliUtils.kt index 9f54dd6f93..ace7196ecf 100644 --- a/diktat-cli/src/main/kotlin/org/cqfn/diktat/util/CliUtils.kt +++ b/diktat-cli/src/main/kotlin/org/cqfn/diktat/util/CliUtils.kt @@ -18,21 +18,11 @@ import kotlin.io.path.exists import kotlin.io.path.walk // all roots -private val roots: Set = run { - sequenceOf( - File.listRoots() - .asSequence() - .map { - it.toPath() - }, - FileSystems.getDefault() - .rootDirectories - .asSequence() - ) - .flatten() - .map { it.absolutePathString() } - .toSet() -} +private val roots: Set = FileSystems.getDefault() + .rootDirectories + .asSequence() + .map { it.absolutePathString() } + .toSet() /** * Create a matcher and return a filter that uses it. diff --git a/diktat-cli/src/test/kotlin/org/cqfn/diktat/util/CliUtilsKtTest.kt b/diktat-cli/src/test/kotlin/org/cqfn/diktat/util/CliUtilsKtTest.kt index be3855235f..19d65f1428 100644 --- a/diktat-cli/src/test/kotlin/org/cqfn/diktat/util/CliUtilsKtTest.kt +++ b/diktat-cli/src/test/kotlin/org/cqfn/diktat/util/CliUtilsKtTest.kt @@ -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 @@ -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() }