-
-
Notifications
You must be signed in to change notification settings - Fork 359
Clean up whitespace related issues in entire project #126
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
Conversation
Removed trailing whitespace, changed line endings from CRLF to LF and removed the UTF-8 BOM
C# source files are now forced to have LF line endings
.gitattributes
Outdated
@@ -0,0 +1,2 @@ | |||
# Force C# source files to have LF line endings | |||
*.cs text eol=lf |
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.
I'd just force all text files to have LF line endings
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.
How would you go about this? We can't use *
afaik because we have some binary files (mostly images) here and there. Can you use *.{txt,md,c,cpp,cs,...}
in .gitattributes? I couldn't find documentation on whether this syntax is valid or not.
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.
I just tried. You can't use that syntax. I hope there is another way to specify a rule for more than one file type, because I'd rather have a whitelist for text files than a blacklist for binary files.
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.
* text=auto eol=lf
And also added them to .gitattributes and .editorconfig
Alright. So apparently there is no reason to group rules in .gitattributes, so I went ahead and created one rule for every file type present in .editorconfig. I also changed an OCAML file to LF and added the file extension to both configurations. |
This is obviously a needed change. Should I leave it up for more discussion or merge it soon? |
When merged, this pull request will clean up all text files. It removes trailing whitespace, converts line endings to LF, adds a .gitattribute file and improves the existing .editorconfig file.
The reason to remove unneeded whitespace is to avoid confusing diffs and merge conflicts. Many modern and popular text editors remove trailing whitespace automatically. If 2 or more contributors submit PRs that edit the same file (e. g. 2 code examples for one chapter, both editing the .md), their editors could both automatically trim the whitespace, resulting in merge conflicts down the line.
During the cleanup process, I noticed that all C# source files have been commited with CRLF (Windows) line endings, rather than LF like all other files in the repository. The files also have a UTF-8 Byte Order Mark (BOM), which is generally discouraged. According to The Unicode Standard - 2.6 Encoding Schemes:
Therefore, I converted the files to have LF line endings for consistency and removed their BOMs. I also added a .gitignore file with a rule that should force .cs files to always have LF line endings in the repository.
Lastly, I edited the existing .editorconfig file to account for more file types.