File tree 2 files changed +43
-0
lines changed
main/kotlin/org/jlleitschuh/gradle/ktlint/tasks
test/kotlin/org/jlleitschuh/gradle/ktlint
2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -201,6 +201,7 @@ abstract class BaseKtLintCheckTask @Inject constructor(
201
201
.create()
202
202
.loadErrors(discoveredErrors.asFile.get())
203
203
.map { it.lintedFile }
204
+ .filter { it.exists() }
204
205
.toSet()
205
206
} else {
206
207
emptySet()
Original file line number Diff line number Diff line change @@ -731,4 +731,46 @@ class KtlintPluginTest : AbstractPluginTest() {
731
731
build(CHECK_PARENT_TASK_NAME )
732
732
}
733
733
}
734
+
735
+ @DisplayName(" Lint check should pass after file is deleted" )
736
+ @CommonTest
737
+ fun checkAfterFileDelete (gradleVersion : GradleVersion ) {
738
+ project(gradleVersion) {
739
+ val fileOne = " src/main/kotlin/FileOne.kt"
740
+ createSourceFile(
741
+ fileOne,
742
+ """
743
+ val foo = "bar"
744
+
745
+ """ .trimIndent()
746
+ )
747
+
748
+ val fileTwo = " src/main/kotlin/FileTwo.kt"
749
+ createSourceFile(
750
+ fileTwo,
751
+ """
752
+ val bar = "foo"
753
+
754
+ """ .trimIndent()
755
+ )
756
+
757
+ build(CHECK_PARENT_TASK_NAME ) {
758
+ assertThat(task(" :$mainSourceSetCheckTaskName " )?.outcome).isEqualTo(TaskOutcome .SUCCESS )
759
+ }
760
+
761
+ removeSourceFile(fileOne)
762
+ val fileThree = " src/main/kotlin/FileThree.kt"
763
+ createSourceFile( // Need to add or modify a source to repro file not found error.
764
+ fileThree,
765
+ """
766
+ val bar = "foo"
767
+
768
+ """ .trimIndent()
769
+ )
770
+
771
+ build(CHECK_PARENT_TASK_NAME , " --info" ) { // <-- Fails, file one is not found.
772
+ assertThat(task(" :$mainSourceSetCheckTaskName " )?.outcome).isEqualTo(TaskOutcome .SUCCESS )
773
+ }
774
+ }
775
+ }
734
776
}
You can’t perform that action at this time.
0 commit comments