jeremymailen / kotlinter-gradle

Painless, fast ktlint plugin for Gradle

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Task formatKotlin should not fail build if it can fix problems

strindberg opened this issue · comments

When running gradle formatKotlin, the build fails if any issues are found. However, I think it would be better if the task would not fail if the formatter could fix the problems it finds: after all, after the successful formatting the code is actually fixed.

Good point, although when format did something the workspace is dirty and some CI flow might need to detect that with a distinct exit result. We have ignoreFailures to handle continuing a build after lint failure. Perhaps a similar param to control this? Can you elaborate on the workflow this is needed for?

I would find this particularly useful for interactive use. Our projects take a couple of minutes to build, and I cannot count the number of times I have started a build with gradle build, expecting it to take a while to finish (particularly if a test has run green in the IDE), only to check back a little later to find that it failed on the linting task.

I thought I would remedy this with an alias: alias build='gradle formatKotlin buildso that the formatting is always run before the build task. Of course I still expect the build to fail if the formatter cannot fix the problem, or if there is some other build issue. But it would be useful if gradle formatKotlin build would succeed if the formatter was able to fix any lint issues.