Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exclude deleted files from incremental checks (fixes #679) #681

Merged
merged 1 commit into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}
}
}
}