Uh oh!
There was an error while loading. Please reload this page.
[WIP] tools: use clang-format to format C++ code - #16122
Conversation
joyeecheung
commented
Oct 10, 2017
danbev
commented
Oct 10, 2017
Should this be applied to |
bnoordhuis
commented
Oct 10, 2017
Yes, and test/addons and test/addons-napi as well. The problem of course is that it results in humongous diffs. It:
That might be a good solution, because
|
641f51b to
6969062Comparejoyeecheung
commented
Oct 10, 2017
@danbev@bnoordhuis Just noticed I have missed
I think we can try to relax the rules a bit and make them more about capturing what we have right now, then tighten the rules one by one later, so there will be less conflicts to start with. Basically by doing
That I've described in the OP. I will try to tweak with it a bit, maybe after #16090 lands.
Yeah the npm module does keep track of the revision of its binaries. Also we can do something like what |
joyeecheung
commented
Oct 10, 2017
Did a bit of archaeology and found #1539 , let's see if clang-format is flexible enough to do this kind of stuff again |
joyeecheung
commented
Oct 20, 2017
#16090 has already landed. Will try to tweak the .clang-format over the weekend. |
gibfahn
commented
Oct 25, 2017
From an LTS/backporting perspective if we're going to do this I'd rather do it all at once, and backport it ASAP, rather than the "death by a thousand cuts" style of making changes. I assume that's better for open Pull Requests too. |
@gibfahn hmm now come to think of it, I think this one can be backported by running the final clang-format on all branches instead of manually backporting them? Also for conflicts in other PRs we can do that as well, so it might not be that hard... I will give this another try over the weekend |
- Initializes .clang-format - Add `make format` to Makefile
6969062 to
ab13553CompareBTW: I am still pursuing this. One outstanding issue is when is appropriate for this to land, if it ever gets landed. Any patches to C++ code landed prior to this patch would not land cleanly anymore, even when this patch is backported to different release lines asap, and the conflict would look pretty scary. To land those C++ changes one has to manually recreate the commits by copying files via |
bnoordhuis
commented
Jan 15, 2018
@joyeecheunghttp://clang.llvm.org/docs/ClangFormat.html#script-for-patch-reformatting - can be used to reformat commits when applying them. The CI can probably be made to do it automatically when rebasing onto the target branch. |
joyeecheung
commented
Jan 15, 2018
@bnoordhuis Ooh, that looks pretty nice! Thanks for discovering that. I'll see if I can integrate it somehow. |
BridgeAR
commented
Apr 22, 2018
@joyeecheung is this something you still work on? I believe it would still be great to have something like this. |
bnoordhuis
commented
Apr 24, 2018
FWIW, I still think it's a good idea and the practical issues are tractable. |
joyeecheung
commented
Apr 24, 2018
@BridgeAR I have not forgotten about this, just need to find some time to tweak this again... |
mmarchini
commented
May 1, 2018
If I'm not mistaken, |
joyeecheung
commented
Jul 27, 2018
Closed in favor of #21997 |
I think we have discussed briefly about this during the collaboration summit @BridgeAR@Fishrock123 This is just an attempt to see how everybody feels about using an automatic formatting tool to reduce style inconsistencies and nits in PRs. We use
clang-formatin llnode and v8 uses it as well so this sounds like a good candidate..clang-formatfile based on Google styles (since previously we usecpplint.pythat lints C++ code using the Google style guide). We have our own "extensions" to the style guide (e.g. the ones being added in doc: add basic C++ style guide #16090) so we need to work out more rules in the.clang-formatbased on our needs.clang-format -style=google -dump-config > .clang-formatand start from that as well..ccundersrcwith the initalized.clang-format(clang-format -style=file -i src/**/*.cc)clang-formatcan be obtained by compiling from the clang source code as well. Also you can get a python wrapper if you happen to havedepot_toolsand a V8/Chromium checkout on your machine. I am not sure whether we should bundle it in the codebase like what we do with eslint, but definitely doesn't hurt to add some commands to the Makefile (maybe along witheslint --fix).Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
src, tools