3232 - id: clang-format
3333 args: [--style=file] # to load .clang-format
3434 - id: clang-tidy
35- args: [--config =.clang-tidy] # path/to/.clang-tidy
35+ args: [--checks =.clang-tidy] # path/to/.clang-tidy
3636` ` `
3737
3838The example of using any version of [clang-tools](https://github.com/shenxianpeng/clang-tools-pip).
@@ -45,17 +45,67 @@ repos:
4545 - id: clang-format
4646 args: [--style=file, --version=13]
4747 - id: clang-tidy
48- args: [--config =.clang-tidy, --version=12]
48+ args: [--checks =.clang-tidy, --version=12]
4949` ` `
5050
5151# # Output
5252
53- The output when catching unformatted and error code.
53+ # ## clang-format
5454
55- ```
55+ ` ` ` bash
5656clang-format.............................................................Failed
5757- hook id: clang-format
5858- files were modified by this hook
59+ ` ` `
60+
61+ Here is the diff between the modified file.
62+
63+ ` ` ` diff
64+ --- a/testing/main.c
65+ +++ b/testing/main.c
66+ @@ -1,3 +1,6 @@
67+ #include <stdio.h>
68+ -int main() {for (;;) break; printf("Hello world!\n ");return 0;}
69+ -
70+ +int main() {
71+ + for (;;) break;
72+ + printf("Hello world!\n ");
73+ + return 0;
74+ +}
75+ ` ` `
76+
77+ Pass `--dry-run` to the `args` of `clang-format`(can also pass other arg which clang-format supports)
78+
79+ This just prints instead of changing the format. E.g :
80+
81+ ` ` ` bash
82+ clang-format.............................................................Failed
83+ - hook id: clang-format
84+ - exit code: 255
85+
86+ main.c:2:11: warning: code should be clang-formatted [-Wclang-format-violations]
87+ int main() {for (;;) break; printf("Hello world!\n ");return 0;}
88+ ^
89+ main.c:2:13: warning: code should be clang-formatted [-Wclang-format-violations]
90+ int main() {for (;;) break; printf("Hello world!\n ");return 0;}
91+ ^
92+ main.c:2:21: warning: code should be clang-formatted [-Wclang-format-violations]
93+ int main() {for (;;) break; printf("Hello world!\n ");return 0;}
94+ ^
95+ main.c:2:28: warning: code should be clang-formatted [-Wclang-format-violations]
96+ int main() {for (;;) break; printf("Hello world!\n ");return 0;}
97+ ^
98+ main.c:2:54: warning: code should be clang-formatted [-Wclang-format-violations]
99+ int main() {for (;;) break; printf("Hello world!\n ");return 0;}
100+ ^
101+ main.c:2:63: warning: code should be clang-formatted [-Wclang-format-violations]
102+ int main() {for (;;) break; printf("Hello world!\n ");return 0;}
103+ ^
104+ ` ` `
105+
106+ # ## chang-tidy
107+
108+ ` ` ` bash
59109clang-tidy...............................................................Failed
60110- hook id: clang-tidy
61111- exit code: 1
@@ -74,21 +124,9 @@ Found compiler error(s).
74124 ^~~~~~~~~~
75125` ` `
76126
77- The diff of the modified file.
127+ # # Contributing
78128
79- ```diff
80- --- a/testing/main.c
81- +++ b/testing/main.c
82- @@ -1,3 +1,6 @@
83- #include <stdio.h>
84- -int main() {for (;;) break; printf("Hello world!\n");return 0;}
85- -
86- +int main() {
87- + for (;;) break;
88- + printf("Hello world!\n");
89- + return 0;
90- +}
91- ```
129+ Any contribution is very welcome, including submitting issues, PRs, etc.
92130
93131# # License
94132
0 commit comments