-
Notifications
You must be signed in to change notification settings - Fork 503
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
Ktlint.format does not invoke callback for auto corrected errors #1491
Comments
The callback The
I have included the flag
The output of test above is:
Note that for the second error, the flag When the same is done for the format function:
the output is:
Note that the errors which are automatically corrected, are not included in the list. |
That's the issue, why are they not in the list? What's the point of the |
My example was supposed to use |
As far, as I can tell it was designed like this. But, I do admit that it does not seem logical. I expect that the behavior can be changed without affecting the Ktlint CLI. But that would mean, that it would only have value for API users that are calling the |
Currently Gradle plugins for ktlint have a format and a check task that call format/lint on ktlint. My idea is to have a general task that runs format and collects the formatted output as well as all errors. The check and format tasks would use that as input instead of running ktlint themselves and then just print the errors or apply the formatting changes. The collection task can then also use the build cache regardless of whether you're linting or formatting (we lint on ci that would fill the build cache and a dev running format locally can benefit from it) |
I can not envision whether this will work and/or when it becomes beneficial but that of course is up to you. How long does it take to run ktlint on your codebase? I use a couple of opensource projects with 400K lines to test ktlint which takes less than 30 seconds to complete. |
Expected Behavior
The
cb
parameter ofExperimentalParams
is invoked for all errors with the correct value forcorrect
.Observed Behavior
cb
is only invoked for errors that aren't auto correctable. From both the description of the parameter "callback invoked for each lint error" and the signature(e: LintError, corrected: Boolean) -> Unit
this seems weird. In practice I'm never seeingcorrected
beingtrue
because those errors aren't reported at all.Steps to Reproduce
Run the following snippet on a file that has both correctable and not correctable errors:
Your Environment
.editorconfig
settingsThe text was updated successfully, but these errors were encountered: