-
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
Add baseline functionality to ktlint #707
Conversation
I wonder if it would be cleaner to make your own reporter rather than rely on checkstyle. Seems like a non-obvious dependency that changing checkstyle could potentially break this functionality. Also - it looks like the |
We'd also want to build a set of tests. |
Fair point, just wasn't sure if that would be too large of a change. I'll add in a new reporter tonight.
That is how it works with Android lint so I copied that model. If it exists then it loads otherwise it generates so that it can be run against the next time. I'm not sure if it makes sense to have two flags when you wouldn't know if you had a baseline file or not though happy to add in if you prefer
I'll add some tonight as well where possible |
58fc19a
to
4139cc4
Compare
So now there is an interesting issue - I can't have test resources that fail because they don't follow Edit: fun fact, I tried adding the baseline flag to the |
4139cc4
to
513a605
Compare
7012961
to
b2a69a8
Compare
b2a69a8
to
f5bea8d
Compare
fd8f5e8
to
de7ee91
Compare
@shashachu how does this PR look now? This is a much needed feature! |
Any update? Need this feature |
Currently this prevents our team from adopting ktlint, the feature is critical for large projects with huge poorly formatted legacy codebase |
… and add in tests for baseline functionality
de7ee91
to
9d6b1c4
Compare
I implemented ktlint in old multi module project with baseline, but it generates a baseline file for each module. Is there any way to generate one baseline file for all modules? |
Not in how this is intended to work. Feel free to file a feature request |
Great feature @joshfeinberg. I have a question, if you run ktlint with the baseline and the |
The baseline functionality does not affect the formatter option at all. You can configure ktlint to just run on files currently in your git stage and that should solve this issue. Feel free to file a feature request on ktlint if you have a reason to specifically want a feature to not change stuff in the baseline |
I see. We use git stage. The reason was to prevent reformatting an entire file when you only touch few lines. |
Adds in a new flag,
baseline
, that allows you to specify a baseline to check again when running your report.The functionality is similar to Android lint's baseline. It creates a snapshot file of the current errors in the project on the first run using the checkstyle reporter. On all following runs it checks against that baseline file and only reports errors that do not exist inside that file.