Skip to content

Commit

Permalink
Update dependency kotlin-stdlib
Browse files Browse the repository at this point in the history
### What's done:
* Update dependency kotlin-stdlib
* Update function createTempFile()
  • Loading branch information
Cheshiriks committed Apr 8, 2021
1 parent e1c175e commit a0e533f
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]") }
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Map<String, String>>
Expand All @@ -37,6 +38,7 @@ typealias ruleToConfig = Map<String, Map<String, String>>
* 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) },
Expand All @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@
<artifactId>kotlinpoet</artifactId>
<version>${kotlinpoet.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
Expand Down

0 comments on commit a0e533f

Please sign in to comment.