32
32
- id: clang-format
33
33
args: [--style=file] # to load .clang-format
34
34
- id: clang-tidy
35
- args: [--config =.clang-tidy] # path/to/.clang-tidy
35
+ args: [--checks =.clang-tidy] # path/to/.clang-tidy
36
36
` ` `
37
37
38
38
The example of using any version of [clang-tools](https://github.com/shenxianpeng/clang-tools-pip).
@@ -45,17 +45,67 @@ repos:
45
45
- id: clang-format
46
46
args: [--style=file, --version=13]
47
47
- id: clang-tidy
48
- args: [--config =.clang-tidy, --version=12]
48
+ args: [--checks =.clang-tidy, --version=12]
49
49
` ` `
50
50
51
51
# # Output
52
52
53
- The output when catching unformatted and error code.
53
+ # ## clang-format
54
54
55
- ```
55
+ ` ` ` bash
56
56
clang-format.............................................................Failed
57
57
- hook id: clang-format
58
58
- 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
59
109
clang-tidy...............................................................Failed
60
110
- hook id: clang-tidy
61
111
- exit code: 1
@@ -74,21 +124,9 @@ Found compiler error(s).
74
124
^~~~~~~~~~
75
125
` ` `
76
126
77
- The diff of the modified file.
127
+ # # Contributing
78
128
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.
92
130
93
131
# # License
94
132
0 commit comments