@@ -17,8 +17,21 @@ repos:
1717 hooks :
1818 - id : clang-format
1919 args : [--style=Google]
20- # - id: clang-tidy ## Work in progress
21- # args: [--config-file=file]
20+ - id : clang-tidy
21+ args : [--checks='boost-*,bugprone-*,performance-*,readability-*,portability-*,modernize-*,clang-analyzer-*,cppcoreguidelines-*']
22+ ` ` `
23+
24+ Use specific version. for example ` clang-format` is version 13, `clang-tidy` is version 12.
25+
26+ ` ` ` yaml
27+ repos:
28+ - repo: https://github.com/shenxianpeng/cpp-linter-hooks
29+ rev: v0.1.0 # Use the ref you want to point at
30+ hooks:
31+ - id: clang-format
32+ args: [--style=Google, --version=13]
33+ - id: clang-tidy
34+ args: [--checks='boost-*,bugprone-*,performance-*,readability-*,portability-*,modernize-*,clang-analyzer-*,cppcoreguidelines-*', --version=12]
2235` ` `
2336
2437# # Support hooks
@@ -30,6 +43,31 @@ Prevent committing unformatted C/C++ code.
3043* Set coding style: LLVM, GNU, Google, Chromium, Microsoft, Mozilla, WebKit with `args: [--style=LLVM]`
3144* Load coding style configuration file `.clang-format` with `args: [--style=file]`
3245
46+ output
47+
48+ ```
49+ clang-format.............................................................Failed
50+ - hook id: clang-format
51+ - files were modified by this hook
52+ ```
53+ modified file
54+ ```diff
55+ --- a/testing/main.c
56+ +++ b/testing/main.c
57+ @@ -1,3 +1,6 @@
58+ #include <stdio.h>
59+ -int main() {for (;;) break; printf("Hello world!\n");return 0;}
60+ -
61+ +int main() {
62+ + for (;;) break;
63+ + printf("Hello world!\n");
64+ + return 0;
65+ +}
66+ ```
67+
3368### ` clang-tidy `
3469
3570Prevent committing typical programming errors, like style violations, interface misuse, or bugs that can be deduced.
71+
72+ * Set checks like ` args: [--checks='boost-*,bugprone-*,performance-*,readability-*,portability-*,modernize-*,clang-analyzer-*,cppcoreguidelines-*'] `
73+ * Or set specify the path of .clang-tidy like ` args: [--checks=path/to/.clang-tidy] `
0 commit comments