Skip to content

Commit

Permalink
support ktlint 0.45-0.48
Browse files Browse the repository at this point in the history
  • Loading branch information
wakingrufus committed Jan 17, 2023
1 parent 01c2d3d commit 8ded75c
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,32 +30,32 @@ abstract class AbstractPluginTest {

protected
fun File.withCleanSources() = createSourceFile(
"src/main/kotlin/clean-source.kt",
"src/main/kotlin/CleanSource.kt",
"""
val foo = "bar"
""".trimIndent()
)

protected fun File.withCleanKotlinScript() = createSourceFile(
"kotlin-script.kts",
"""
println("zzz")
""".trimIndent()
)

protected fun File.withFailingKotlinScript() = createSourceFile(
"kotlin-script-fail.kts",
"""
println("zzz")
println("zzz")
""".trimIndent()
)

protected
fun File.withAlternativeFailingSources(baseDir: String) =
createSourceFile("$baseDir/fail-source.kt", """val foo = "bar"""")
createSourceFile("$baseDir/FailSource.kt", """val foo = "bar"""")

protected
fun File.createSourceFile(sourceFilePath: String, contents: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ConfigurationCacheTest : AbstractPluginTest() {
internal fun configurationCacheForCheckTask(gradleVersion: GradleVersion) {
project(gradleVersion) {
createSourceFile(
"src/main/kotlin/clean-source.kt",
"src/main/kotlin/CleanSource.kt",
"""
val foo = "bar"
Expand Down Expand Up @@ -51,7 +51,7 @@ class ConfigurationCacheTest : AbstractPluginTest() {
fun configurationCacheForFormatTasks(gradleVersion: GradleVersion) {
project(gradleVersion) {
createSourceFile(
"src/main/kotlin/clean-source.kt",
"src/main/kotlin/CleanSource.kt",
"""
val foo = "bar"
""".trimIndent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ class DisabledRulesTest : AbstractPluginTest() {
//language=Groovy
buildGradle.appendText(
"""
ktlint.disabledRules = ["final-newline"]
""".trimIndent()
)

createSourceFile(
"src/main/kotlin/clean-source.kt",
"src/main/kotlin/CleanSource.kt",
"""
val foo = "bar"
""".trimIndent()
Expand All @@ -46,20 +46,20 @@ class DisabledRulesTest : AbstractPluginTest() {
//language=Groovy
buildGradle.appendText(
"""
ktlint.disabledRules = ["final-newline", "no-consecutive-blank-lines"]
""".trimIndent()
)

createSourceFile(
"src/main/kotlin/clean-source.kt",
"src/main/kotlin/CleanSource.kt",
"""
fun some() {
print("Woohoo!")
}
val foo = "bar"
""".trimIndent()
)
Expand All @@ -75,18 +75,18 @@ class DisabledRulesTest : AbstractPluginTest() {
fun lintRuleDisabledInTheCode(gradleVersion: GradleVersion) {
project(gradleVersion) {
createSourceFile(
"src/main/kotlin/clean-source.kt",
"src/main/kotlin/CleanSource.kt",
"""
/* ktlint-disable no-consecutive-blank-lines */
fun some() {
print("Woohoo!")
}
/* ktlint-enable no-consecutive-blank-lines */
val foo = "bar"
""".trimIndent()
)

Expand All @@ -103,7 +103,7 @@ class DisabledRulesTest : AbstractPluginTest() {
//language=Groovy
buildGradle.appendText(
"""
ktlint.version = "0.34.0"
ktlint.disabledRules = ["final-newline"]
""".trimIndent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class KtlintBaselineSupportTest : AbstractPluginTest() {
<?xml version="1.0" encoding="utf-8"?>
<baseline version="1.0">
</baseline>
""".trimIndent()
)
}
Expand All @@ -58,7 +58,7 @@ class KtlintBaselineSupportTest : AbstractPluginTest() {
| <file name="kotlin-script-fail.kts">
| <error line="1" column="15" source="no-trailing-spaces" />
| </file>
| <file name="src/main/kotlin/fail-source.kt">
| <file name="src/main/kotlin/FailSource.kt">
| <error line="1" column="5" source="no-multi-spaces" />
| <error line="1" column="10" source="no-multi-spaces" />
| <error line="1" column="15" source="no-multi-spaces" />
Expand Down Expand Up @@ -90,7 +90,7 @@ class KtlintBaselineSupportTest : AbstractPluginTest() {
<?xml version="1.0" encoding="utf-8"?>
<baseline version="1.0">
</baseline>
""".trimIndent()
)
}
Expand All @@ -106,7 +106,7 @@ class KtlintBaselineSupportTest : AbstractPluginTest() {
//language=Groovy
buildGradle.appendText(
"""
ktlint {
version.set("0.40.0")
}
Expand Down Expand Up @@ -157,7 +157,7 @@ class KtlintBaselineSupportTest : AbstractPluginTest() {
//language=Groovy
buildGradle.appendText(
"""
ktlint {
version.set("0.40.0")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class KtlintPluginTest : AbstractPluginTest() {
buildGradle.appendText(
"""
ktlint.filter { exclude("**/fail-source.kt") }
ktlint.filter { exclude("**/FailSource.kt") }
""".trimIndent()
)

Expand Down Expand Up @@ -313,7 +313,7 @@ class KtlintPluginTest : AbstractPluginTest() {

build(
":$CHECK_PARENT_TASK_NAME",
"-P$FILTER_INCLUDE_PROPERTY_NAME=src/main/kotlin/clean-source.kt"
"-P$FILTER_INCLUDE_PROPERTY_NAME=src/main/kotlin/CleanSource.kt"
) {
assertThat(task(":$mainSourceSetCheckTaskName")?.outcome).isEqualTo(TaskOutcome.SUCCESS)
}
Expand All @@ -330,7 +330,7 @@ class KtlintPluginTest : AbstractPluginTest() {

build(
":$CHECK_PARENT_TASK_NAME",
"-P$FILTER_INCLUDE_PROPERTY_NAME=src\\main\\kotlin\\clean-source.kt"
"-P$FILTER_INCLUDE_PROPERTY_NAME=src\\main\\kotlin\\CleanSource.kt"
) {
assertThat(task(":$mainSourceSetCheckTaskName")?.outcome).isEqualTo(TaskOutcome.SUCCESS)
}
Expand All @@ -346,13 +346,13 @@ class KtlintPluginTest : AbstractPluginTest() {
buildGradle.appendText(
"""
ktlint.filter { exclude("**/fail-source.kt") }
ktlint.filter { exclude("**/FailSource.kt") }
""".trimIndent()
)

build(
":$CHECK_PARENT_TASK_NAME",
"-P$FILTER_INCLUDE_PROPERTY_NAME=src/main/kotlin/fail-source.kt"
"-P$FILTER_INCLUDE_PROPERTY_NAME=src/main/kotlin/FailSource.kt"
) {
assertThat(task(":$mainSourceSetCheckTaskName")?.outcome).isEqualTo(TaskOutcome.SKIPPED)
}
Expand Down

0 comments on commit 8ded75c

Please sign in to comment.