question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Running ktlintFormat twice deletes files

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
Tapchicomacommented, Nov 5, 2019

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

0reactions
Tapchicomacommented, Nov 7, 2019

That is my plan I want to do tomorrow…

Read more comments on GitHub >

github_iconTop Results From Across the Web

android - Problems running ktlint from module - Stack Overflow
So, this is how i resolved my problem and run ktlint. First I was update my root build.gradle : // Top-level build file...
Read more >
Squash Kotlin bugs quickly with ktlint and detekt static analysis
The ktlint.gradle task is a verifier: It checks all your Kotlin files to ensure you are following the right code style. To run...
Read more >
Diff - platform/external/ktlint - Google Git
To run formatter - `gradle ktlintFormat`. -**Another option** is to use Gradle plugin (in order of appearance): -- [jlleitschuh/ktlint-gradle](https ...
Read more >
Configuring and running Ktlin on Android Studio
To do it you can go to File->Sync project with gradle files on Android Studio or click on the sync shortcut button as...
Read more >
Static Analysis Tools - ktlint - The Android Arsenal
(without a plugin) ... To check code style - gradle ktlint (it's also bound to gradle check ). To run formatter - gradle...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found