Skip to content
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

Implement clang-tidy #64

Merged
merged 15 commits into from
Aug 25, 2017
Merged

Implement clang-tidy #64

merged 15 commits into from
Aug 25, 2017

Conversation

springmeyer
Copy link
Contributor

This addresses #63 (see that ticket for context).

This PR builds in:

  • clang-tidy checks. If clang-tidy detects errors travis will fail
  • The -fix command is passed so some fixes are automatically done
  • Other warnings need to be noticed and fixed manually

Other notes:

  • Uses a custom python script to convert the Makefile output into compile_commands.json
  • Uses clang-tidy from mason, version controlled in the setup.sh script - refs Upgrade to latest llvm + mason #58

/cc @GretaCB for review

/cc @mapbox/directions @mapbox/gl-core - thank you for the examples of clang-tidy usage in OSRM and MBGL - I learned from them in order to apply here ✊

Dane Springmeyer added 3 commits August 17, 2017 15:33
- This enables most things
- Originally generated from -dump-config
- I figure downstream consumers will need to walk
  some things back by disabling, but that it is
  nevertheless ideal to start out with most checks enabled
@@ -0,0 +1,28 @@
---
Checks: '*'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using * here is very aggressive. But it does not reveal any more than a few problems inside node-cpp-skel and they are easily fixed. So I think starting with this is ideal. Downstream users of node-cpp-skel will be able to change this to disable some checks (based on https://clang.llvm.org/extra/clang-tidy/) but opt-ing into all of them seems wisest to me to help keep code robust from the start.

@@ -0,0 +1,28 @@
---
Checks: '*'
WarningsAsErrors: '*'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this. However I can't seem to get run-clang-tidy.py to return a non-zero error code. So this basically has no impact on the return code, just an minor impact on the stdout from clang-tidy.

# First run the clang-tidy target
# This target does not currently return non-zero when problems
# are fixed, but rather it fixes automatically. Changed files
# will be detected by the format target and will trigger an error
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working around the lack of non-zero error code on error mentioned at https://github.com/mapbox/node-cpp-skel/pull/64/files#r133848127 here by running make tidy first and depending on make format to throw if it sees any changes. It would be ideal to error immediately in make tidy but I can't figure out how to get that working...

@springmeyer
Copy link
Contributor Author

🎉 travis properly caught the clang-tidy changes to source files and errored: https://travis-ci.org/mapbox/node-cpp-skel/builds/265773011. Digging in the logs for the make tidy target show why. Going to now create a separate PR that will address the fixes needed.

Dane Springmeyer added 3 commits August 17, 2017 16:07
a. hello_async.cpp:225:5 use auto when initializing with a template cast to avoid duplicating the type name [modernize-use-auto]
b. hello_async.cpp:321:2: error: namespace 'object_async' not terminated with a closing comment [google-readability-namespace-comments]
@springmeyer springmeyer mentioned this pull request Aug 18, 2017
@springmeyer springmeyer added this to the 1.0.0 milestone Aug 25, 2017
@springmeyer
Copy link
Contributor Author

Fixed landed. Will merge this once travis is green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant