Open simmplecoder opened 4 years ago
First, I'm a huge supporter of incorporating clang-format. I'm happy to be not a lonely one :)
Have you seen these?
Perhaps I could submit a PR then to update the file, and the people who want it will just
ln -s $PWD/example/clang-format/.clang-format $PWD/.clang-format
?
I believe that would be a reasonable tradeoff. @lpranam @codejaeger @stefanseefeld what do you think?
Perhaps we could try testing it on latest PRs and put it at the root of the project?
I personally give
As long as the coding style makes code readable, compact, horizontally limited, I'm fine with it.
The lack of consistency in GIL, especially in parts of IO, have been annoying, but manual improvements and maintenance cost lots of time. Hence, I'm eager to require use of clang-format, even if I need to trade personal preferences :-)
Perhaps we could try testing it on latest PRs and put it at the root of the project?
I agree with this. At least we can have consistent styling in new code.
I'd add to the overall discussion this RFC of mine https://trac.osgeo.org/geos/wiki/RFC4 where some details and implications are discussed, including external references, especially three parts of MongoDB story how they managed the "big reformat":
We should give this a try :-)
https://www.youtube.com/watch?v=_EaU3VsDOJM
Clang Format Detector automatically finds the best matching Clang-Format Style for your code files.
I am also all in for clang-format.
To avoid introducing a git diff
barrier, making difficult to compare code before and after the "big reformat", we recently end-up rewriting the all repos history with git filter-repo
. We kept "replace reference" for the old commits so that it did not break the reference to the commits in the master project (and since GIL is a git submodule for Boost we are in the same situation). Note that sometimes clang-format
needs to be applied several times (or even does not converge!), aka first run leads some reformating, reapplying leads to more reformating. At least that's my experience with my repo.
Once we agree on the definition of .clang-format, I don't mind either exploring the history rewrite option or just swallowing the "big reformat" pill.
In past, I have used git filter-branch --tree-filter
to reformate the entire code base while also maintaining the git commit history for blaming but I think this too would require force push and actually rewriting history. I have never used git filter-repo
but I suspect it would be doing the same thing and would rewrite the history...
Quoting the git filter-branch
doc:
The
git filter-repo
tool is an alternative togit-filter-branch
which does not suffer from these performance problems or the safety problems (mentioned below).
Is there any Boost wide .clang-format
that we could use?
@sdebionne
Is there any Boost wide .clang-format that we could use?
No, or I don't know about any, but some individual libraries have some (including us):
/d/boost.win (develop u= origin/develop) $ find . -name .clang-format
./libs/gil/example/clang-format/.clang-format
./libs/graph/.clang-format
./libs/histogram/.clang-format
./libs/multiprecision/.clang-format
./libs/nowide/.clang-format
./libs/numeric/ublas/.clang-format
./libs/outcome/.clang-format
./libs/yap/.clang-format
Is your feature request related to a problem? Please describe.
During PRs developers spend time on making formatting consistent across the project. That takes time and a thing that could be totally automated.
Describe the solution you'd like
Add a
.clang-format
file that would dictate how files are formatted, and possibly create a hook so that it gets reformatted automaticallyDescribe alternatives you've considered
I haven't found any formatting engine that would be as good as clang-format. Other IDEs either have their proprietary version or have moved to clang-format
Proposed .clang-format
I have tried this out, and it works for our codebase. The only problem being
BeforeLambdaBody
is introduced in clang-format 12 I believe, which is yet to be released.