Closed fawzi closed 1 year ago
personally I find spaces better in a public project, cause tabs can be either 8 (unix/emacs/vi default) or 4 (windows, several editors) so using spaces is non ambiguous, but here I just tried to mirror what you seem to use.
Sorry about the delay, with the holiday break this fell out of my radar.
While clang-format is nice, it often requires heavy customization to start being useful. The Linux kernel (which also uses tabs) doesn't enforce their clang-format formatting to my knowledge.
I will use clang-format to help split the longest lines and help reorder includes, but I don't think it's worth maintaining a complex clang-format file.
No worries, yes the linux kernel is one notable project that uses tabs, and their clang-format is scary, I cannot imagine wasting so much time customizing it. My view of clang-format is different that yours, I do not think that it should be enforced, but rather I see it as a help, especially for new/external contributions to conform to the style of a project. You have for sure your editor configured correctly to use tabs, and are used to your indentation style, so that it comes natural to you. I am not, and I do not want to loose too much time thinking about formatting, but I want to have something sane and that reasonably conforms with the project style. A .clang-format file does that, and one can use to reformat just the parts one has edited (git clang-format does by default), to make them reasonable, and if the suggestions of clang format look ugly you can just ignore them (your version is staged in, and you can review the unstaged changes generated by clang-format and see if they or ok). So to me it is not an all or nothing proposition, but just a help for newcomers to conform to the style of the project, and it is ok to have a small and non perfect clang format, maybe with a comment like:
# this clang format is provided on a best effort basis to help having a good formatting
# it is *NOT* prescriptive, the reviewer opinion of the best formatting will always trump it
If you want to contribute a patch to the code, please do! I will tell you if I see a problem with the formatting (but I don't have strict rules either) and that should be easy to fix :)
Add a .clang-format file with settings that try to mirror formatting options currently used in the projet (use tabs, attach braces, but not for functions,...)
With this if clang-format is installed (and its companion git-clang-format), and one has staged all the changes then executing git clang-format wil reformat the changes according to the style defined, and one can review the changes comparing staged and non staged changes.
Signed-off-by: Fawzi Mohamed fawzi.mohamed@cscs.ch