Skip to content
New issue

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

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

Already on GitHub? # to your account

Running ktlintFormat twice deletes files #302

Closed
donaldchen opened this issue Nov 5, 2019 · 5 comments · Fixed by #303
Closed

Running ktlintFormat twice deletes files #302

donaldchen opened this issue Nov 5, 2019 · 5 comments · Fixed by #303
Assignees
Labels

Comments

@donaldchen
Copy link

Steps to reproduce the bug

  1. Use ktlint-gradle version 9.1.0 and ktlint version 0.35.0 with the following configuration:
ktlint {
    version = "0.35.0"
    debug = true
    verbose = true
    android = true
    outputToConsole = true
    outputColorName = "RED"
    enableExperimentalRules = false
}
  1. Run ./gradlew ktlintFormat --continue once. (Then run git status, and observe that the auto-formatted files were modified)
  2. Run ./gradlew ktlintFormat --continue a second time

Expected Behavior
Running ./gradlew ktlintFormat --continue the second time should not making any additional changes. The previously modified files should still show up as modified in git status, and no files should be deleted.

Actual Behavior
All the files that were previously marked as modified are now deleted (observed via git status).

I also tried the gradle integration recommended in https://github.com/pinterest/ktlint without plugins, and running the non-plugin ktlintFormat task multiple times did not delete any files. This makes me suspect that the bug is in ktlint-gradle.

@Tapchicoma Tapchicoma added the bug label Nov 5, 2019
@Tapchicoma
Copy link
Collaborator

Thank you for the report, I've successfully reproduced it 🤔

@Tapchicoma Tapchicoma self-assigned this Nov 5, 2019
@Tapchicoma
Copy link
Collaborator

Most probably 9.0.0 version does not have such problem, as the issue in incremental task support.

@donaldchen
Copy link
Author

@Tapchicoma , thanks for the suggestion! I tried version 9.0.0 for ktlint-gradle, and I can confirm that the files no longer get deleted when I run ./gradlew ktlinFormat --continue multiple times.

@wolfs
Copy link
Contributor

wolfs commented Nov 7, 2019

Gradle currently doesn't support tasks which have the input as the output very well (if at all). Can you add the incremental support only to the lint task and not the format task?

@Tapchicoma
Copy link
Collaborator

That is my plan I want to do tomorrow...

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants