-
-
Notifications
You must be signed in to change notification settings - Fork 38
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
Adjustable whitelines feature #244
Conversation
Pull Request Test Coverage Report for Build 5032706547Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Klavionik thank you so much for your pull request, it is beautiful. You not only fixed one of the most complained issues, but also reduced the complexity of the code and added more comments.
Sorry for taking so long to answer, please take a look at the only comment I've made and we'll be ready to merge it :)
Would you consider adding this to the CLI too, rather than relying on an environment variable? This would be useful when running with pre-commit. |
By the way this PR will probably solve also this issue #237. Can you please check if it does? If you can't it's fine |
@calumy can you try to use a config file with the |
This PR indeed solves this problem. Before:test: |
Onetwothree
Onetwothree
Onetwothree After (with
|
Thank you! I'm glad to help. Actually 4 days is a pretty fast response, so don't be hard on youself! I acted upon your review and force-pushed the changes. |
Apologies for the noise. I forgot that it was possible to configure through a config file. Thanks for highlighting this fact and thanks for the great tool. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution and kind words ^^
Included in |
I've been suffering from the same behavior that was mentioned in several issues:
So I decided to give it a try and implement a solution.
What I did was:
_fix_whitelines
method) and added a new config option,whitelines
, to make it adjustable (right now it just multiplies whitelines by zero, removing them completely)._fix_flow_style_lists
method so that it not only fixes Ruyaml's bad behavior, but also keeps the whitelines that happened to be inside the flow style list. I also made it run before_fix_whitelines
. Then I had to fixtest_fix_code_functions_emit_debug_logs
as it was comparing lists and broke after I changed the order of fixers (maybe I should've just reorder the expected list?)._add_newline_at_end_of_file
so that it won't add excessive whitelines, only make sure that there's exactly 1 newline at the end of a file.This is probably not the ideal solution, but I hope it helps to cover some common use cases.
Checklist