-
Notifications
You must be signed in to change notification settings - Fork 10
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
Add clang-format #56
Add clang-format #56
Conversation
Codecov Report
@@ Coverage Diff @@
## master #56 +/- ##
==========================================
+ Coverage 94.32% 94.55% +0.23%
==========================================
Files 8 8
Lines 141 147 +6
==========================================
+ Hits 133 139 +6
Misses 8 8
Continue to review full report at Codecov.
|
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.
👍
We can always tweak the .clang-format
in the future. This is a great start to getting more consistency in place.
SpacesInSquareBrackets: false | ||
Standard: Cpp11 | ||
TabWidth: 4 | ||
UseTab: Never |
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.
Flagging here: we got burned a couple of times in osrm because of slight differences in clang-format versions, as in: someone formats with clang-format-3.8 then another dev formats with clang-format-4.0 and we get annoying formatting ping-pong.
What we did was to 1/ use a fixed version for clang-format from mason (this can be different than the clang compiler we're compiling with) and 2/ provide a base line .clang-format config based on that version (clang-format -style=X -dump-config
) and tune that to your needs.
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 the input @daniel-j-h 🙌
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.
Assuming the format version mirrors the clang compiler version?
this can be different than the clang compiler we're compiling with
And sounds like it doesnt have to match, but generally 3.8 and 4.0 are the compiler versions?
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.
Also want to chime in with a thank you @daniel-j-h. I recall that ping-pong issue and that factored into the design of node-cpp-skel, in the sense that we provide a single script ./scripts/setup.sh
to make it easy to use a consistent clang++ version (currently v4.0.0 via
node-cpp-skel/scripts/setup.sh
Line 7 in dbef468
export MASON_LLVM_RELEASE="${MASON_LLVM_RELEASE:-4.0.0}" |
setup.sh
(dbef468#diff-8cfa73a13763a5d60cbae684e6ba1015R17).
So, I'm imagining all developers will run ./scripts/format.sh
locally and that is also what we'll run remotely on travis. This will ensure we avoid ping-pong
. It also means that when we upgrade that version we'll have some potential disruption if newer clang++ versions behave differently. If figure this is an acceptable tradeoff.
2/ provide a base line .clang-format config based on that version (clang-format -style=X -dump-config) and tune that to your needs.
Great to know this command. I just played around in node-cpp-skel with ./mason_packages/.link/bin/clang-format -style=llvm -dump-config > .clang-format
and seeing the differences. @GretaCB My feeling is that we should not worry about changing the current .clang-format
you pulled from variant for now. We can entertain adopting a different code style in the future, but this should be discussed more widely at Mapbox. The important thing now is to get the structure in place.
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.
Just checked to see if upgrading to clang++ 4.0.1
formats the code differently than clang 4.0.0
given the same .clang-format
. It does not 🎉 . So, we should plan to upgrade clang++ to the newest from mason (mapbox/mason#452) in another PR. Ticketed this at #58
.travis.yml
Outdated
# Clang format build | ||
- os: linux | ||
env: BUILDTYPE=debug | ||
node_js: 4 |
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.
This looks good. I feel like an improvement would be to strip way even more details to focus this job exclusively on formatting. It could do language: generic
and override install:
to just run the setup.sh
and not the make
step - then this would run even faster and would not need the custom env
.
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.
Looks good to merge pending contributing.md
One failure on travis unrelated to this PR that happened on OS X:
Looks like travis-ci/travis-ci#7636, which appears unsolved, except that some users have switched to wget. No action that we need to take in node-cpp-skel, but mentioning here what I learned nevertheless. |
Per #37:
cc @springmeyer @daniel-j-h