-
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 tidy/format docs #103
Conversation
docs/extended-tour.md
Outdated
@@ -172,6 +173,40 @@ User of your module runs 'npm install' | |||
|
|||
This binary file `../lib/binding/module.node` is what `require()` points to within Node.js. | |||
|
|||
# Clang Tools | |||
|
|||
This skeleton uses two clang llvm tools for automated formatting and static fixes. |
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.
Ideally say clang/llvm
to denote the projects are the same (just different parts: llvm
is the term for the entire project and clang
is the term for the "front-end" sub-projects).
docs/extended-tour.md
Outdated
This skeleton uses two clang llvm tools for automated formatting and static fixes. | ||
|
||
Each of these tools run within their own [Travis jobs](https://github.com/mapbox/node-cpp-skel/blob/master/.travis.yml). You can disable these Travis jobs if you'd like, by commenting them out in `.travis.yml`. This may be necessary if you're porting this skel into an already-existing project that triggers tons of clang-tidy errors, and you'd like to work through them gradually while still actively iterating on other parts of your code. | ||
|
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.
👍
|
||
### [clang-tidy](https://clang.llvm.org/extra/clang-tidy/) | ||
Lint framework that can do very powerful checks, for example bugs that can be deduced via [static analysis](https://github.com/mapbox/cpp/blob/master/glossary.md#static-analysis), unneeded copies, inefficient for-loops, and improved readability. In many cases, it can fix and modernize your code. | ||
|
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.
Awesome description 👏
docs/extended-tour.md
Outdated
make tidy | ||
``` | ||
|
||
- If clang-tidy outputs a failure, it will also output a specific code. Check llvm's clang docs for that exact code to learn more. For example, see ["performance-unnecessary-copy-initialization"](https://clang.llvm.org/extra/clang-tidy/checks/performance-unnecessary-copy-initialization.html). |
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.
If not heard them referred to as code
s but rather checks
. How about:
The
clang-tidy
tool has a large set of checks and when one fails the error message contains the shorthand for the check name. See llvm's docs for details about what failed check is referring to. For example, see ...
docs/extended-tour.md
Outdated
``` | ||
|
||
- If clang-tidy outputs a failure, it will also output a specific code. Check llvm's clang docs for that exact code to learn more. For example, see ["performance-unnecessary-copy-initialization"](https://clang.llvm.org/extra/clang-tidy/checks/performance-unnecessary-copy-initialization.html). | ||
- Set tidy preferences in [`.clang-tidy`](https://github.com/mapbox/node-cpp-skel/blob/master/.clang-tidy). When you run clang-tidy, you'll see output of a number of specific checks that tidy runs. You can add/remove any of these checks via the `.clang-tidy` file, configure these checks, and specify the files you'd like to run these checks against. The skel runs clang-tidy against everything within the `/src` directory. |
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.
cant
-> can't
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.
Whoops, this was meant to refer to the line below that reads you either want to keep as-is or cant control
docs/extended-tour.md
Outdated
- Installed and run via [`/scripts/clang-tidy.sh`](https://github.com/mapbox/node-cpp-skel/blob/master/scripts/clang-tidy.sh) | ||
- `NOLINT`: In the case that clang-tidy throws for code that you either want to keep as-is or cant control, you can [use `NOLINT`](https://github.com/mapbox/node-cpp-skel/blob/87c8d51f2d7d05ac44f3ea7a607f60e73a2af9c8/src/module.cpp#L43-L46) to silent clang-tidy. | ||
- Since clang-tidy must compile the code to do its checks, skel [generates](https://github.com/mapbox/node-cpp-skel/blob/master/scripts/generate_compile_commands.py) a JSON file that tells clang-tidy which files to run against and what compile command to run. This file newly generated file, `/build/compile_command.json`, is created when running `make tidy`. See [clang's JSON compilation format docs](https://clang.llvm.org/docs/JSONCompilationDatabase.html) for more info. | ||
|
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 is great! One chunk of text reads oddly however This file newly generated file
. Should it read: This newly generated file
?
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.
Great PR. I made minor comments inline. I think this is ready to merge anytime you do @GretaCB.
🙌 |
Per #70, add more info and context about how the skel uses clang-tidy and clang-format.
cc @mapbox/core-tech