-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathexample.json
More file actions
177 lines (177 loc) · 3.55 KB
/
example.json
File metadata and controls
177 lines (177 loc) · 3.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
{
"roots": [
"../dojo/src",
"../dojo/include",
"../dojo2D/src",
"../dojo2D/include",
"src"
],
"excludes": [
"lodepng",
"atomicops",
"Pipe.h",
"android_native_app_glue.h",
"AndroidPlatform\\."
],
"includes": [
".cpp$",
".h$"
],
"incremental": false,
"tests": [
{
"fail": [
"[^A-Za-z0-9_]+new\\s+"
],
"allow": [
"ref new\\s+"
],
"error": "Don't use new, use a owning pointer or a container instead"
},
{
"classOnly": true,
"fail": [
"^\\s+[A-Z_][A-Za-z0-9_]*\\([A-Za-z_][A-Za-z0-9_]*[\\*&]?\\s*[A-Za-z_][A-Za-z0-9_]*\\)\\s*[{;]"
],
"error": "Missing `explicit` keyword on possible conversion constructor"
},
{
"fail": [
"[^A-Za-z0-9_]+malloc\\s*\\(.*\\)\\s*;"
],
"error": "Don't use malloc(), try to use containers instead"
},
{
"fail": [
"[^A-Za-z0-9_]+delete\\s+"
],
"error": "Don't use delete, use a owning pointer or a container instead"
},
{
"fail": [
"[^A-Za-z0-9_]+long[^A-Za-z0-9_]+"
],
"allow": [
"long double",
"[^A-Za-z0-9_]+long long[^A-Za-z0-9_]+"
],
"error": "Use of inconsistent-length type long: use int64_t or int instead"
},
{
"fail": [
"[^A-Za-z0-9_]+long long[^A-Za-z0-9_]+"
],
"error": "Replace long long with int64_t"
},
{
"fail": [
"const_cast<.*>\\(.*\\)"
],
"error": "Don't use const_cast, really :("
},
{
"fail": [
"dynamic_cast<.*>\\(.*\\)"
],
"error": "Dynamic_cast? RTTI is off!"
},
{
"fail": [
"std::stack"
],
"error": "Stack is non-contiguous and usually slower than a vector"
},
{
"fail": [
"std::list"
],
"error": "Don't use std::list, there is rarely any reason at all to do it"
},
{
"fail": [
"\\(.*Unique<[^>]*>&[^&]"
],
"error": "Pass unique pointers by value, force the caller to move explicitly"
},
{
"fail": [
"(^|\\s)+volatile\\s+"
],
"error": "Probably volatile doesn't mean what you think it means, use std::atomic<>"
},
{
"classOnly": true,
"fail": [
"(^|\\s)+inline\\s+"
],
"error": "Inline doesn't do anything on modern compilers, just explicitly include the code in the header if desired"
},
{
"headerOnly": true,
"fail": [
"\\(.*std::string[^&,*]+[A-Za-z_][A-Za-z0-9_]*.*\\)"
],
"allow": [
"const\\s*&"
],
"error": "Passing strings via copy"
},
{
"fail": [
"for\\s*\\(\\s*[a-zA-Z_]+[a-zA-Z0-9_]*\\s+[a-zA-Z_]+[a-zA-Z0-9_]*\\s*:\\s*[a-zA-Z_]+[a-zA-Z0-9_]*"
],
"allow": [
"range"
],
"error": "Don't use plain for(T : foo), always use for(T&)! The first form can incur in lots of costly copies if the element type is non-primitive"
},
{
"fail": [
"auto_ptr"
],
"error": "Never use auto_ptr, upgrade to unique_ptr"
},
{
"fail": [
"const\\s+char\\s+\\*"
],
"error": "Don't use const char*, use std::string instead"
},
{
"fail": [
"[^A-Za-z0-9_]+register\\s+"
],
"error": "Don't use the register keyword, compilers are able to optimally allocate registers"
},
{
"fail": [
"[^A-Za-z0-9_]+NULL[^A-Za-z0-9_]+"
],
"error": "Don't use NULL, use nullptr"
},
{
"fail": [
"[^A-Za-z0-9_]+push_back\\s*\\("
],
"error": "Don't use push_back, always prefer emplace_back"
},
{
"fail": [
"[^A-Za-z0-9_]+goto[^A-Za-z0-9_]+"
],
"error": "Don't use goto dude"
},
{
"fail": [
"#pragma once"
],
"include_paths": [
".*\\.h$"
],
"expected_fails": {
"exactly": 1
},
"error": "Pragma once should exist exactly once in each file"
}
]
}