diff --git a/diktat-gradle-plugin/src/functionalTest/kotlin/org/cqfn/diktat/plugin/gradle/DiktatGradlePluginFunctionalTest.kt b/diktat-gradle-plugin/src/functionalTest/kotlin/org/cqfn/diktat/plugin/gradle/DiktatGradlePluginFunctionalTest.kt index 05d20ee902..d571c31b43 100644 --- a/diktat-gradle-plugin/src/functionalTest/kotlin/org/cqfn/diktat/plugin/gradle/DiktatGradlePluginFunctionalTest.kt +++ b/diktat-gradle-plugin/src/functionalTest/kotlin/org/cqfn/diktat/plugin/gradle/DiktatGradlePluginFunctionalTest.kt @@ -4,7 +4,6 @@ import org.cqfn.diktat.plugin.gradle.DiktatGradlePlugin.Companion.DIKTAT_CHECK_T import org.gradle.buildinit.plugins.internal.modifiers.BuildInitDsl import org.gradle.internal.impldep.org.junit.rules.TemporaryFolder import org.gradle.testkit.runner.TaskOutcome -import org.jetbrains.kotlin.com.intellij.util.ObjectUtils.assertNotNull import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach @@ -56,7 +55,8 @@ class DiktatGradlePluginFunctionalTest { val diktatCheckBuildResult = result.task(":$DIKTAT_CHECK_TASK") requireNotNull(diktatCheckBuildResult) Assertions.assertEquals(TaskOutcome.FAILED, diktatCheckBuildResult.outcome) - val file = assertNotNull(testProjectDir.root.walkTopDown().filter { it.name == "test.txt" }.first()) + val file = testProjectDir.root.walkTopDown().filter { it.name == "test.txt" }.first() + Assertions.assertNotNull(file) Assertions.assertTrue( file.readLines().any { it.contains("[FILE_NAME_MATCH_CLASS]") } ) diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/generation/Generation.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/generation/Generation.kt index 65a54a33e5..62282fb6c9 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/generation/Generation.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/generation/Generation.kt @@ -16,6 +16,9 @@ import com.squareup.kotlinpoet.TypeSpec import java.io.File +import kotlin.io.path.ExperimentalPathApi +import kotlin.io.path.createTempFile + /** * The comment that will be added to the generated sources file. */ @@ -56,13 +59,14 @@ private fun generateWarningNames() { kotlinFile.writeTo(File("diktat-rules/src/main/kotlin")) // fixme: need to add it to pom } +@OptIn(ExperimentalPathApi::class) private fun validateYear() { val files = File("diktat-rules/src/test/resources/test/paragraph2/header") files .listFiles() .filterNot { it.name.contains("CopyrightDifferentYearTest.kt") } .forEach { file -> - val tempFile = createTempFile() + val tempFile = createTempFile().toFile() tempFile.printWriter().use { writer -> file.forEachLine { line -> writer.println(when { diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/EmptyBlock.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/EmptyBlock.kt index 8a1dd69960..19f4973aa5 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/EmptyBlock.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/EmptyBlock.kt @@ -9,14 +9,10 @@ import org.cqfn.diktat.ruleset.utils.* import com.pinterest.ktlint.core.ast.ElementType import com.pinterest.ktlint.core.ast.ElementType.CALL_EXPRESSION -import com.pinterest.ktlint.core.ast.ElementType.DOT_QUALIFIED_EXPRESSION -import com.pinterest.ktlint.core.ast.ElementType.FILE import com.pinterest.ktlint.core.ast.ElementType.FUNCTION_LITERAL import com.pinterest.ktlint.core.ast.ElementType.IDENTIFIER import com.pinterest.ktlint.core.ast.ElementType.LAMBDA_EXPRESSION -import com.pinterest.ktlint.core.ast.ElementType.LPAR import com.pinterest.ktlint.core.ast.ElementType.RBRACE -import com.pinterest.ktlint.core.ast.ElementType.VALUE_ARGUMENT import com.pinterest.ktlint.core.ast.ElementType.VALUE_ARGUMENT_LIST import com.pinterest.ktlint.core.ast.ElementType.VALUE_PARAMETER import com.pinterest.ktlint.core.ast.ElementType.WHITE_SPACE diff --git a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/smoke/DiktatSmokeTest.kt b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/smoke/DiktatSmokeTest.kt index 1bd5a84e29..5e852122e6 100644 --- a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/smoke/DiktatSmokeTest.kt +++ b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/smoke/DiktatSmokeTest.kt @@ -27,7 +27,8 @@ import org.junit.jupiter.api.Tag import org.junit.jupiter.api.Test import java.time.LocalDate - +import kotlin.io.path.ExperimentalPathApi +import kotlin.io.path.createTempFile import kotlinx.serialization.encodeToString typealias ruleToConfig = Map> @@ -37,6 +38,7 @@ typealias ruleToConfig = Map> * Note: ktlint uses initial text from a file to calculate line and column from offset. Because of that line/col of unfixed errors * may change after some changes to text or other rules. */ +@OptIn(ExperimentalPathApi::class) class DiktatSmokeTest : FixTestBase("test/smoke/src/main/kotlin", { DiktatRuleSetProvider(configFilePath) }, { lintError, _ -> unfixedLintErrors.add(lintError) }, @@ -59,7 +61,7 @@ class DiktatSmokeTest : FixTestBase("test/smoke/src/main/kotlin", rulesConfig.add(RulesConfig(warning, enabled = true, configuration = configuration)) } } - createTempFile() + createTempFile().toFile() .also { configFilePath = it.absolutePath } diff --git a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/smoke/RulesConfigValidationTest.kt b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/smoke/RulesConfigValidationTest.kt index 39ec8c226b..e5de33f855 100644 --- a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/smoke/RulesConfigValidationTest.kt +++ b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/smoke/RulesConfigValidationTest.kt @@ -12,13 +12,16 @@ import org.junit.jupiter.api.assertThrows import java.io.File import java.lang.IllegalArgumentException +import kotlin.io.path.ExperimentalPathApi +import kotlin.io.path.createTempFile +@OptIn(ExperimentalPathApi::class) class RulesConfigValidationTest { private lateinit var file: File @BeforeEach fun setUp() { - file = createTempFile() + file = createTempFile().toFile() } @AfterEach diff --git a/pom.xml b/pom.xml index b0b3fc3879..6179734f57 100644 --- a/pom.xml +++ b/pom.xml @@ -81,6 +81,11 @@ kotlinpoet ${kotlinpoet.version} + + org.jetbrains.kotlin + kotlin-stdlib + ${kotlin.version} + org.jetbrains.kotlin kotlin-stdlib-jdk8