-
Notifications
You must be signed in to change notification settings - Fork 281
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
rule new-lines: add type: platform
configuration option
#474
Conversation
type: auto
configuration option
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.
@Cube707 thanks for this PR!
I still think type: platform
is better than type: auto
, because auto
relates to auto-detection from the file in other parts of yamllint. On the other hand, platform
causes no ambiguity.
Please see the lint results, there are some errors.
You can remove rule
from the commit title: rule new-lines: ...
, for consistency with other commits.
About the first commit explicitly check \n for type: unix, I don't understand it, and I'm not sure what kind of side-effects it could have. Please check out bullet 6 of the contributing guidelines: anyone should be able to quickly read and understand the reason for a change (in case it induces problems on some platforms, for example...)
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.
Is the commit history so acceptable? Or should I still remove the explicitly check \n for type: unix
commit? (or explain it better?)
Are you OK with having the refactoring as a separate commit? I expect this would make it easier to find the source of problems between the new option and the refactoring. But I can also make it a single commit.
Thanks for spending so much time on this!
EDIT: I will also rebase after the comments below are resolved.
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 @Cube707!
The history looks good but I would prefer:
- either merging the 2 last commits (refactor + add 'platform'),
- or applying the refactor before the 'platform' addition,
in order to reduce the diff and the hassle of git blame
.
should be good now.
|
Looks good to me, but the linter complains: you need to add an extra line before the new import
|
found the problem. There was a
|
To be more consistent with the other types, unix now also checks against the expected newline character (`\n`) instead of checking if a wrong character (`\r`) is present
Both options where using identical code. Now the newline character is determined beforehand depending on the selected option and then the same code can be used for all options
The new option infers the correct newline character(s) from the operating system running yamllint.
rebased onto master |
type: auto
configuration optiontype: platform
configuration option
Well seen. |
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 this work Jan! 👍
This PR follows up on #456 in which it was concluded that the default for the new-lines rule should not be changed but rather a new option is to be introduced.
Problem
As explained in this comment on the parent PR yamllint currently has portability issues that make it hard to use on Windows clients. These stem from git converting line-endings to the platform default on checkout and yamllint assuming that the line-ending type should be enforced for all development platforms. This leads to windows-clients needing to be heavily reconfigured to make yamllint work there properly.
PR's content
This PR introduces a new option for the
new-lines
rule:type: auto
.The new option infers the correct newline character(s) from the operating system that is currently running yamllint. This allows developers to create yaml-files with their systems default settings and relying on git to convert them.
Projects that wish to enforce a certain type of line-ending are still able to do so by keeping one of the original two options.
Linting / Testing
flake8
,doc8
andunittest
completet without error on my local machine.