notskm / vscode-clang-tidy

MIT License
48 stars 26 forks source link

clang-tidy.checks example #40

Open chetrf opened 4 years ago

chetrf commented 4 years ago

Could you give an example of how to add or suppress clang-tidy checks in settings.json? The specific check I would like to add is implicit-function-declaration and I would like to suppress errors with not finding headers. I am already using cpptools. Thanks.

jfrascon commented 4 years ago

Example of my configuration: "clang-tidy.checks": [ "bugprone-", "cert-", "clang-analyzer-", "cppcoreguidelines-", "-cppcoreguidelines-pro-type-vararg", <== when you see a - sign at the first character it means, don't use this flag "-cppcoreguidelines-pro-bounds-array-to-pointer-decay", "llvm-", "-llvm-include-order", "misc-", "modernize-", "-modernize-use-trailing-return-type", "-modernize-concat-nested-namespaces", "performance-", "readability-*" ],

Regarding the error 'not finding headers', try to use a file compile_commands.json in the buildPath variable. The file compile_commands.json is created by cmake using the option -DCMAKE_EXPORT_COMPILE_COMMANDS=ON

"clang-tidy.buildPath": "/path/to /the/file_compile_commands.json" (note: the path to the folder containing the file, not the path including the file ;) )

notskm commented 3 years ago

@chetrf Has your question been answered? Is it safe to close this issue now?

PacoUK commented 3 years ago

@notskm It did to me, Could you guys put it on the documentation, this will be great to know.