Skip to content

Commit

Permalink
exclude deleted files from incremental checks (fixes #679)
Browse files Browse the repository at this point in the history
  • Loading branch information
wakingrufus committed Jun 21, 2023
1 parent cb6f708 commit b94c055
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/).

- update latest version text file manually [#674](https://github.com/JLLeitschuh/ktlint-gradle/pull/674)
- decrease plugin build workers to 4 to prevent thrashing [#675](https://github.com/JLLeitschuh/ktlint-gradle/pull/675)
- exclude deleted files from incremental checks [#681](https://github.com/JLLeitschuh/ktlint-gradle/pull/681)

## [11.4.0] - 2023-06-06

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ abstract class BaseKtLintCheckTask @Inject constructor(
.create()
.loadErrors(discoveredErrors.asFile.get())
.map { it.lintedFile }
.filter { it.exists() }
.toSet()
} else {
emptySet()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -731,4 +731,46 @@ class KtlintPluginTest : AbstractPluginTest() {
build(CHECK_PARENT_TASK_NAME)
}
}

@DisplayName("Lint check should pass after file is deleted")
@CommonTest
fun checkAfterFileDelete(gradleVersion: GradleVersion) {
project(gradleVersion) {
val fileOne = "src/main/kotlin/FileOne.kt"
createSourceFile(
fileOne,
"""
val foo = "bar"
""".trimIndent()
)

val fileTwo = "src/main/kotlin/FileTwo.kt"
createSourceFile(
fileTwo,
"""
val bar = "foo"
""".trimIndent()
)

build(CHECK_PARENT_TASK_NAME) {
assertThat(task(":$mainSourceSetCheckTaskName")?.outcome).isEqualTo(TaskOutcome.SUCCESS)
}

removeSourceFile(fileOne)
val fileThree = "src/main/kotlin/FileThree.kt"
createSourceFile( // Need to add or modify a source to repro file not found error.
fileThree,
"""
val bar = "foo"
""".trimIndent()
)

build(CHECK_PARENT_TASK_NAME, "--info") { // <-- Fails, file one is not found.
assertThat(task(":$mainSourceSetCheckTaskName")?.outcome).isEqualTo(TaskOutcome.SUCCESS)
}
}
}
}

0 comments on commit b94c055

Please sign in to comment.