-
Notifications
You must be signed in to change notification settings - Fork 506
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
Format (-F) command is not honouring the baseline file #1072
Comments
Current baseline implementation does not prevent linting, but rather it just suppresses found errors. So in case of |
I also ran into this inconvenience. I am looking for a workaround. |
same! ^^^ would love if we could filter formatting with the baseline file |
Please feel free to contribute a PR ;-) |
@paul-dingemans Could you validate this issue? I believe it should be fixed in |
Unfortunately it is not solved. Also, I have some major doubts whether we will be able to solve it in a good way. The baseline functionality is functionality that lives only in Ktlint CLI. So the KtlintRuleEngine and the Rules don't know anything about the baseline. An interesting idea would be to introduce a new kind of callback which "asks" permission to autocorrect a LintError before actually applying a fix. API Consumers could use this functionality for a kind of step-through linting/formatting where the user can determine per case whether the fix should be applied, or the API consumer could try to automatically add But this will not solve the issue with the Ktlint CLI Baseline. The baseline contains information about a line number, an offset on the line and a rule-id. This location does not necessarily matches with the current location of the node that caused the issue when the baseline was created. Reasons for this:
|
This issue should not be marked as bug. It can be seen as an enhancement. A possbile way to solve would be as follows:
Introduction of the annotation above also have other implecations that need to be mitigated:
This change will require a considerable refactoring. I will not implement it myself as I am not convinced that it is worth to maintain the baseline functionality in the long term. I am a strong believer that a project that implements ktlint also should take the effort to resolve existing problems. |
Fixed by #2671 for rules that implement the new |
I created a baseline file from the below command,
ktlint --baseline=ktlint-baseline.xml
and I could see no errors are reported if I run it again since there are no changes against the baseline file. But when I add the format flag, the baseline file is getting ignored and the terminal spit out the fixed errors,
ktlint --baseline=ktlint-baseline.xml -F
does not work as expected!Can anyone help?
The text was updated successfully, but these errors were encountered: