blob: c819d7fa6dc75cb1eda3b85a6fd97b8ec528b5ac [file] [log] [blame]
Marco Nelissen594375d2009-07-14 09:04:04 -07001#!/usr/bin/env python
Marco Nelissen8e201962010-03-10 16:16:02 -08002# This file uses the following encoding: utf-8
Marco Nelissen594375d2009-07-14 09:04:04 -07003
Ian Rogersf3829732016-05-10 12:06:01 -07004import argparse
Marco Nelissen594375d2009-07-14 09:04:04 -07005import sys
6import re
7
Ian Rogersf3829732016-05-10 12:06:01 -07008parser = argparse.ArgumentParser(description='Convert a build log into HTML')
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07009parser.add_argument('--gencsv',
10 help='Generate a CSV file with number of various warnings',
11 action="store_true",
12 default=False)
Ian Rogersf3829732016-05-10 12:06:01 -070013parser.add_argument('--url',
14 help='Root URL of an Android source code tree prefixed '
15 'before files in warnings')
16parser.add_argument('--separator',
17 help='Separator between the end of a URL and the line '
18 'number argument. e.g. #')
19parser.add_argument(dest='buildlog', metavar='build.log',
20 help='Path to build.log file')
21args = parser.parse_args()
Marco Nelissen594375d2009-07-14 09:04:04 -070022
23# if you add another level, don't forget to give it a color below
24class severity:
25 UNKNOWN=0
26 SKIP=100
27 FIXMENOW=1
28 HIGH=2
29 MEDIUM=3
30 LOW=4
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -070031 TIDY=5
32 HARMLESS=6
Marco Nelissen594375d2009-07-14 09:04:04 -070033
34def colorforseverity(sev):
35 if sev == severity.FIXMENOW:
36 return 'fuchsia'
37 if sev == severity.HIGH:
38 return 'red'
39 if sev == severity.MEDIUM:
40 return 'orange'
41 if sev == severity.LOW:
42 return 'yellow'
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -070043 if sev == severity.TIDY:
44 return 'peachpuff'
Marco Nelissen594375d2009-07-14 09:04:04 -070045 if sev == severity.HARMLESS:
46 return 'limegreen'
47 if sev == severity.UNKNOWN:
Chih-Hung Hsieha9be47e2016-03-21 14:11:03 -070048 return 'lightblue'
Marco Nelissen594375d2009-07-14 09:04:04 -070049 return 'grey'
50
Chih-Hung Hsieha9be47e2016-03-21 14:11:03 -070051def headerforseverity(sev):
52 if sev == severity.FIXMENOW:
53 return 'Critical warnings, fix me now'
54 if sev == severity.HIGH:
55 return 'High severity warnings'
56 if sev == severity.MEDIUM:
57 return 'Medium severity warnings'
58 if sev == severity.LOW:
59 return 'Low severity warnings'
60 if sev == severity.HARMLESS:
61 return 'Harmless warnings'
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -070062 if sev == severity.TIDY:
63 return 'Clang-Tidy warnings'
Chih-Hung Hsieha9be47e2016-03-21 14:11:03 -070064 if sev == severity.UNKNOWN:
65 return 'Unknown warnings'
66 return 'Unhandled warnings'
67
Marco Nelissen594375d2009-07-14 09:04:04 -070068warnpatterns = [
69 { 'category':'make', 'severity':severity.MEDIUM, 'members':[], 'option':'',
70 'description':'make: overriding commands/ignoring old commands',
71 'patterns':[r".*: warning: overriding commands for target .+",
72 r".*: warning: ignoring old commands for target .+"] },
73 { 'category':'C/C++', 'severity':severity.HIGH, 'members':[], 'option':'-Wimplicit-function-declaration',
74 'description':'Implicit function declaration',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -070075 'patterns':[r".*: warning: implicit declaration of function .+",
76 r".*: warning: implicitly declaring library function" ] },
Marco Nelissen594375d2009-07-14 09:04:04 -070077 { 'category':'C/C++', 'severity':severity.SKIP, 'members':[], 'option':'',
78 'description':'',
79 'patterns':[r".*: warning: conflicting types for '.+'"] },
80 { 'category':'C/C++', 'severity':severity.HIGH, 'members':[], 'option':'-Wtype-limits',
81 'description':'Expression always evaluates to true or false',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -070082 'patterns':[r".*: warning: comparison is always .+ due to limited range of data type",
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -070083 r".*: warning: comparison of unsigned .*expression .+ is always true",
84 r".*: warning: comparison of unsigned .*expression .+ is always false"] },
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -070085 { 'category':'C/C++', 'severity':severity.HIGH, 'members':[], 'option':'',
86 'description':'Potential leak of memory, bad free, use after free',
87 'patterns':[r".*: warning: Potential leak of memory",
88 r".*: warning: Potential memory leak",
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -070089 r".*: warning: Memory allocated by alloca\(\) should not be deallocated",
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -070090 r".*: warning: Memory allocated by .+ should be deallocated by .+ not .+",
91 r".*: warning: 'delete' applied to a pointer that was allocated",
92 r".*: warning: Use of memory after it is freed",
93 r".*: warning: Argument to .+ is the address of .+ variable",
94 r".*: warning: Argument to free\(\) is offset by .+ of memory allocated by",
95 r".*: warning: Attempt to .+ released memory"] },
96 { 'category':'C/C++', 'severity':severity.HIGH, 'members':[], 'option':'',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -070097 'description':'Use transient memory for control value',
98 'patterns':[r".*: warning: .+Using such transient memory for the control value is .*dangerous."] },
99 { 'category':'C/C++', 'severity':severity.HIGH, 'members':[], 'option':'',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700100 'description':'Return address of stack memory',
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700101 'patterns':[r".*: warning: Address of stack memory .+ returned to caller",
102 r".*: warning: Address of stack memory .+ will be a dangling reference"] },
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700103 { 'category':'C/C++', 'severity':severity.HIGH, 'members':[], 'option':'',
104 'description':'Problem with vfork',
105 'patterns':[r".*: warning: This .+ is prohibited after a successful vfork",
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700106 r".*: warning: Call to function '.+' is insecure "] },
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700107 { 'category':'C/C++', 'severity':severity.HIGH, 'members':[], 'option':'infinite-recursion',
108 'description':'Infinite recursion',
109 'patterns':[r".*: warning: all paths through this function will call itself"] },
110 { 'category':'C/C++', 'severity':severity.HIGH, 'members':[], 'option':'',
111 'description':'Potential buffer overflow',
112 'patterns':[r".*: warning: Size argument is greater than .+ the destination buffer",
113 r".*: warning: Potential buffer overflow.",
114 r".*: warning: String copy function overflows destination buffer"] },
Marco Nelissen594375d2009-07-14 09:04:04 -0700115 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
116 'description':'Incompatible pointer types',
117 'patterns':[r".*: warning: assignment from incompatible pointer type",
Marco Nelissen8e201962010-03-10 16:16:02 -0800118 r".*: warning: return from incompatible pointer type",
Marco Nelissen594375d2009-07-14 09:04:04 -0700119 r".*: warning: passing argument [0-9]+ of '.*' from incompatible pointer type",
120 r".*: warning: initialization from incompatible pointer type"] },
121 { 'category':'C/C++', 'severity':severity.HIGH, 'members':[], 'option':'-fno-builtin',
122 'description':'Incompatible declaration of built in function',
123 'patterns':[r".*: warning: incompatible implicit declaration of built-in function .+"] },
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700124 { 'category':'C/C++', 'severity':severity.HIGH, 'members':[], 'option':'',
125 'description':'Null passed as non-null argument',
Chih-Hung Hsiehc21ddbd2016-07-20 10:08:51 -0700126 'patterns':[r".*: warning: Null passed to a callee that requires a non-null"] },
Marco Nelissen594375d2009-07-14 09:04:04 -0700127 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wunused-parameter',
128 'description':'Unused parameter',
129 'patterns':[r".*: warning: unused parameter '.*'"] },
130 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wunused',
131 'description':'Unused function, variable or label',
Marco Nelissen8e201962010-03-10 16:16:02 -0800132 'patterns':[r".*: warning: '.+' defined but not used",
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700133 r".*: warning: unused function '.+'",
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -0700134 r".*: warning: private field '.+' is not used",
Marco Nelissen8e201962010-03-10 16:16:02 -0800135 r".*: warning: unused variable '.+'"] },
Marco Nelissen594375d2009-07-14 09:04:04 -0700136 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wunused-value',
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -0700137 'description':'Statement with no effect or result unused',
138 'patterns':[r".*: warning: statement with no effect",
139 r".*: warning: expression result unused"] },
140 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wunused-result',
141 'description':'Ignoreing return value of function',
142 'patterns':[r".*: warning: ignoring return value of function .+Wunused-result"] },
Marco Nelissen594375d2009-07-14 09:04:04 -0700143 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wmissing-field-initializers',
144 'description':'Missing initializer',
145 'patterns':[r".*: warning: missing initializer"] },
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700146 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wdelete-non-virtual-dtor',
147 'description':'Need virtual destructor',
148 'patterns':[r".*: warning: delete called .* has virtual functions but non-virtual destructor"] },
Marco Nelissen594375d2009-07-14 09:04:04 -0700149 { 'category':'cont.', 'severity':severity.SKIP, 'members':[], 'option':'',
150 'description':'',
151 'patterns':[r".*: warning: \(near initialization for '.+'\)"] },
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700152 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wdate-time',
153 'description':'Expansion of data or time macro',
154 'patterns':[r".*: warning: expansion of date or time macro is not reproducible"] },
Marco Nelissen594375d2009-07-14 09:04:04 -0700155 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wformat',
156 'description':'Format string does not match arguments',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700157 'patterns':[r".*: warning: format '.+' expects type '.+', but argument [0-9]+ has type '.+'",
158 r".*: warning: more '%' conversions than data arguments",
159 r".*: warning: data argument not used by format string",
160 r".*: warning: incomplete format specifier",
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700161 r".*: warning: unknown conversion type .* in format",
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700162 r".*: warning: format .+ expects .+ but argument .+Wformat=",
163 r".*: warning: field precision should have .+ but argument has .+Wformat",
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700164 r".*: warning: format specifies type .+ but the argument has .*type .+Wformat"] },
Marco Nelissen594375d2009-07-14 09:04:04 -0700165 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wformat-extra-args',
166 'description':'Too many arguments for format string',
167 'patterns':[r".*: warning: too many arguments for format"] },
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700168 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wformat-invalid-specifier',
169 'description':'Invalid format specifier',
170 'patterns':[r".*: warning: invalid .+ specifier '.+'.+format-invalid-specifier"] },
Marco Nelissen594375d2009-07-14 09:04:04 -0700171 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wsign-compare',
172 'description':'Comparison between signed and unsigned',
173 'patterns':[r".*: warning: comparison between signed and unsigned",
174 r".*: warning: comparison of promoted \~unsigned with unsigned",
175 r".*: warning: signed and unsigned type in conditional expression"] },
Marco Nelissen8e201962010-03-10 16:16:02 -0800176 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
177 'description':'Comparison between enum and non-enum',
178 'patterns':[r".*: warning: enumeral and non-enumeral type in conditional expression"] },
Marco Nelissen594375d2009-07-14 09:04:04 -0700179 { 'category':'libpng', 'severity':severity.MEDIUM, 'members':[], 'option':'',
180 'description':'libpng: zero area',
181 'patterns':[r".*libpng warning: Ignoring attempt to set cHRM RGB triangle with zero area"] },
182 { 'category':'aapt', 'severity':severity.MEDIUM, 'members':[], 'option':'',
183 'description':'aapt: no comment for public symbol',
184 'patterns':[r".*: warning: No comment for public symbol .+"] },
185 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wmissing-braces',
186 'description':'Missing braces around initializer',
187 'patterns':[r".*: warning: missing braces around initializer.*"] },
188 { 'category':'C/C++', 'severity':severity.HARMLESS, 'members':[], 'option':'',
189 'description':'No newline at end of file',
190 'patterns':[r".*: warning: no newline at end of file"] },
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700191 { 'category':'C/C++', 'severity':severity.HARMLESS, 'members':[], 'option':'',
192 'description':'Missing space after macro name',
193 'patterns':[r".*: warning: missing whitespace after the macro name"] },
194 { 'category':'C/C++', 'severity':severity.LOW, 'members':[], 'option':'-Wcast-align',
195 'description':'Cast increases required alignment',
196 'patterns':[r".*: warning: cast from .* to .* increases required alignment .*"] },
Marco Nelissen594375d2009-07-14 09:04:04 -0700197 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wcast-qual',
198 'description':'Qualifier discarded',
199 'patterns':[r".*: warning: passing argument [0-9]+ of '.+' discards qualifiers from pointer target type",
200 r".*: warning: assignment discards qualifiers from pointer target type",
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700201 r".*: warning: passing .+ to parameter of type .+ discards qualifiers",
202 r".*: warning: assigning to .+ from .+ discards qualifiers",
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700203 r".*: warning: initializing .+ discards qualifiers .+types-discards-qualifiers",
Marco Nelissen594375d2009-07-14 09:04:04 -0700204 r".*: warning: return discards qualifiers from pointer target type"] },
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700205 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wunknown-attributes',
206 'description':'Unknown attribute',
207 'patterns':[r".*: warning: unknown attribute '.+'"] },
208 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wignored-attributes',
Marco Nelissen594375d2009-07-14 09:04:04 -0700209 'description':'Attribute ignored',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700210 'patterns':[r".*: warning: '_*packed_*' attribute ignored",
211 r".*: warning: attribute declaration must precede definition .+ignored-attributes"] },
212 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wvisibility',
213 'description':'Visibility problem',
214 'patterns':[r".*: warning: declaration of '.+' will not be visible outside of this function"] },
Marco Nelissen594375d2009-07-14 09:04:04 -0700215 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wattributes',
216 'description':'Visibility mismatch',
217 'patterns':[r".*: warning: '.+' declared with greater visibility than the type of its field '.+'"] },
218 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
219 'description':'Shift count greater than width of type',
220 'patterns':[r".*: warning: (left|right) shift count >= width of type"] },
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700221 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wextern-initializer',
Marco Nelissen594375d2009-07-14 09:04:04 -0700222 'description':'extern <foo> is initialized',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700223 'patterns':[r".*: warning: '.+' initialized and declared 'extern'",
224 r".*: warning: 'extern' variable has an initializer"] },
Marco Nelissen594375d2009-07-14 09:04:04 -0700225 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wold-style-declaration',
226 'description':'Old style declaration',
227 'patterns':[r".*: warning: 'static' is not at beginning of declaration"] },
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700228 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wreturn-type',
229 'description':'Missing return value',
230 'patterns':[r".*: warning: control reaches end of non-void function"] },
231 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wimplicit-int',
232 'description':'Implicit int type',
233 'patterns':[r".*: warning: type specifier missing, defaults to 'int'"] },
234 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wmain-return-type',
235 'description':'Main function should return int',
236 'patterns':[r".*: warning: return type of 'main' is not 'int'"] },
Marco Nelissen594375d2009-07-14 09:04:04 -0700237 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wuninitialized',
238 'description':'Variable may be used uninitialized',
239 'patterns':[r".*: warning: '.+' may be used uninitialized in this function"] },
240 { 'category':'C/C++', 'severity':severity.HIGH, 'members':[], 'option':'-Wuninitialized',
241 'description':'Variable is used uninitialized',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700242 'patterns':[r".*: warning: '.+' is used uninitialized in this function",
243 r".*: warning: variable '.+' is uninitialized when used here"] },
Marco Nelissen594375d2009-07-14 09:04:04 -0700244 { 'category':'ld', 'severity':severity.MEDIUM, 'members':[], 'option':'-fshort-enums',
245 'description':'ld: possible enum size mismatch',
246 'patterns':[r".*: warning: .* uses variable-size enums yet the output is to use 32-bit enums; use of enum values across objects may fail"] },
247 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wpointer-sign',
248 'description':'Pointer targets differ in signedness',
249 'patterns':[r".*: warning: pointer targets in initialization differ in signedness",
250 r".*: warning: pointer targets in assignment differ in signedness",
251 r".*: warning: pointer targets in return differ in signedness",
252 r".*: warning: pointer targets in passing argument [0-9]+ of '.+' differ in signedness"] },
253 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wstrict-overflow',
254 'description':'Assuming overflow does not occur',
255 'patterns':[r".*: warning: assuming signed overflow does not occur when assuming that .* is always (true|false)"] },
256 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wempty-body',
257 'description':'Suggest adding braces around empty body',
258 'patterns':[r".*: warning: suggest braces around empty body in an 'if' statement",
259 r".*: warning: empty body in an if-statement",
260 r".*: warning: suggest braces around empty body in an 'else' statement",
261 r".*: warning: empty body in an else-statement"] },
262 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wparentheses',
263 'description':'Suggest adding parentheses',
264 'patterns':[r".*: warning: suggest explicit braces to avoid ambiguous 'else'",
265 r".*: warning: suggest parentheses around arithmetic in operand of '.+'",
266 r".*: warning: suggest parentheses around comparison in operand of '.+'",
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700267 r".*: warning: logical not is only applied to the left hand side of this comparison",
268 r".*: warning: using the result of an assignment as a condition without parentheses",
269 r".*: warning: .+ has lower precedence than .+ be evaluated first .+Wparentheses",
Marco Nelissen594375d2009-07-14 09:04:04 -0700270 r".*: warning: suggest parentheses around '.+?' .+ '.+?'",
271 r".*: warning: suggest parentheses around assignment used as truth value"] },
272 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
273 'description':'Static variable used in non-static inline function',
274 'patterns':[r".*: warning: '.+' is static but used in inline function '.+' which is not static"] },
275 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wimplicit int',
276 'description':'No type or storage class (will default to int)',
277 'patterns':[r".*: warning: data definition has no type or storage class"] },
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700278 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
279 'description':'Null pointer',
280 'patterns':[r".*: warning: Dereference of null pointer",
281 r".*: warning: Called .+ pointer is null",
282 r".*: warning: Forming reference to null pointer",
283 r".*: warning: Returning null reference",
284 r".*: warning: Null pointer passed as an argument to a 'nonnull' parameter",
285 r".*: warning: .+ results in a null pointer dereference",
286 r".*: warning: Access to .+ results in a dereference of a null pointer",
287 r".*: warning: Null pointer argument in"] },
Marco Nelissen594375d2009-07-14 09:04:04 -0700288 { 'category':'cont.', 'severity':severity.SKIP, 'members':[], 'option':'',
289 'description':'',
290 'patterns':[r".*: warning: type defaults to 'int' in declaration of '.+'"] },
291 { 'category':'cont.', 'severity':severity.SKIP, 'members':[], 'option':'',
292 'description':'',
293 'patterns':[r".*: warning: parameter names \(without types\) in function declaration"] },
294 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wstrict-aliasing',
295 'description':'Dereferencing <foo> breaks strict aliasing rules',
296 'patterns':[r".*: warning: dereferencing .* break strict-aliasing rules"] },
297 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wpointer-to-int-cast',
298 'description':'Cast from pointer to integer of different size',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700299 'patterns':[r".*: warning: cast from pointer to integer of different size",
300 r".*: warning: initialization makes pointer from integer without a cast"] } ,
Marco Nelissen594375d2009-07-14 09:04:04 -0700301 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wint-to-pointer-cast',
302 'description':'Cast to pointer from integer of different size',
303 'patterns':[r".*: warning: cast to pointer from integer of different size"] },
304 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
305 'description':'Symbol redefined',
306 'patterns':[r".*: warning: "".+"" redefined"] },
307 { 'category':'cont.', 'severity':severity.SKIP, 'members':[], 'option':'',
308 'description':'',
309 'patterns':[r".*: warning: this is the location of the previous definition"] },
310 { 'category':'ld', 'severity':severity.MEDIUM, 'members':[], 'option':'',
311 'description':'ld: type and size of dynamic symbol are not defined',
312 'patterns':[r".*: warning: type and size of dynamic symbol `.+' are not defined"] },
313 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
314 'description':'Pointer from integer without cast',
315 'patterns':[r".*: warning: assignment makes pointer from integer without a cast"] },
316 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
317 'description':'Pointer from integer without cast',
318 'patterns':[r".*: warning: passing argument [0-9]+ of '.+' makes pointer from integer without a cast"] },
319 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
320 'description':'Integer from pointer without cast',
321 'patterns':[r".*: warning: assignment makes integer from pointer without a cast"] },
322 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
323 'description':'Integer from pointer without cast',
324 'patterns':[r".*: warning: passing argument [0-9]+ of '.+' makes integer from pointer without a cast"] },
325 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
326 'description':'Integer from pointer without cast',
327 'patterns':[r".*: warning: return makes integer from pointer without a cast"] },
328 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wunknown-pragmas',
329 'description':'Ignoring pragma',
330 'patterns':[r".*: warning: ignoring #pragma .+"] },
331 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wclobbered',
332 'description':'Variable might be clobbered by longjmp or vfork',
333 'patterns':[r".*: warning: variable '.+' might be clobbered by 'longjmp' or 'vfork'"] },
334 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wclobbered',
335 'description':'Argument might be clobbered by longjmp or vfork',
336 'patterns':[r".*: warning: argument '.+' might be clobbered by 'longjmp' or 'vfork'"] },
337 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wredundant-decls',
338 'description':'Redundant declaration',
339 'patterns':[r".*: warning: redundant redeclaration of '.+'"] },
340 { 'category':'cont.', 'severity':severity.SKIP, 'members':[], 'option':'',
341 'description':'',
342 'patterns':[r".*: warning: previous declaration of '.+' was here"] },
343 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wswitch-enum',
344 'description':'Enum value not handled in switch',
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700345 'patterns':[r".*: warning: .*enumeration value.* not handled in switch.+Wswitch"] },
Marco Nelissen594375d2009-07-14 09:04:04 -0700346 { 'category':'java', 'severity':severity.MEDIUM, 'members':[], 'option':'-encoding',
347 'description':'Java: Non-ascii characters used, but ascii encoding specified',
348 'patterns':[r".*: warning: unmappable character for encoding ascii"] },
349 { 'category':'java', 'severity':severity.MEDIUM, 'members':[], 'option':'',
350 'description':'Java: Non-varargs call of varargs method with inexact argument type for last parameter',
351 'patterns':[r".*: warning: non-varargs call of varargs method with inexact argument type for last parameter"] },
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700352 { 'category':'java', 'severity':severity.MEDIUM, 'members':[], 'option':'',
353 'description':'Java: Unchecked method invocation',
354 'patterns':[r".*: warning: \[unchecked\] unchecked method invocation: .+ in class .+"] },
355 { 'category':'java', 'severity':severity.MEDIUM, 'members':[], 'option':'',
356 'description':'Java: Unchecked conversion',
357 'patterns':[r".*: warning: \[unchecked\] unchecked conversion"] },
Ian Rogers32bb9bd2016-05-09 23:19:42 -0700358
Ian Rogers6e520032016-05-13 08:59:00 -0700359 # Warnings from Error Prone.
360 {'category': 'java',
361 'severity': severity.MEDIUM,
362 'members': [],
363 'option': '',
364 'description': 'Java: Use of deprecated member',
365 'patterns': [r'.*: warning: \[deprecation\] .+']},
366 {'category': 'java',
367 'severity': severity.MEDIUM,
368 'members': [],
369 'option': '',
370 'description': 'Java: Unchecked conversion',
371 'patterns': [r'.*: warning: \[unchecked\] .+']},
Ian Rogers32bb9bd2016-05-09 23:19:42 -0700372
Ian Rogers6e520032016-05-13 08:59:00 -0700373 # Warnings from Error Prone (auto generated list).
374 {'category': 'java',
375 'severity': severity.LOW,
376 'members': [],
377 'option': '',
378 'description':
379 'Java: Deprecated item is not annotated with @Deprecated',
380 'patterns': [r".*: warning: \[DepAnn\] .+"]},
381 {'category': 'java',
382 'severity': severity.LOW,
383 'members': [],
384 'option': '',
385 'description':
386 'Java: Fallthrough warning suppression has no effect if warning is suppressed',
387 'patterns': [r".*: warning: \[FallthroughSuppression\] .+"]},
388 {'category': 'java',
389 'severity': severity.LOW,
390 'members': [],
391 'option': '',
392 'description':
393 'Java: Prefer \'L\' to \'l\' for the suffix to long literals',
394 'patterns': [r".*: warning: \[LongLiteralLowerCaseSuffix\] .+"]},
395 {'category': 'java',
396 'severity': severity.LOW,
397 'members': [],
398 'option': '',
399 'description':
400 'Java: @Binds is a more efficient and declaritive mechanism for delegating a binding.',
401 'patterns': [r".*: warning: \[UseBinds\] .+"]},
402 {'category': 'java',
403 'severity': severity.MEDIUM,
404 'members': [],
405 'option': '',
406 'description':
407 'Java: Assertions may be disabled at runtime and do not guarantee that execution will halt here; consider throwing an exception instead',
408 'patterns': [r".*: warning: \[AssertFalse\] .+"]},
409 {'category': 'java',
410 'severity': severity.MEDIUM,
411 'members': [],
412 'option': '',
413 'description':
414 'Java: Classes that implement Annotation must override equals and hashCode. Consider using AutoAnnotation instead of implementing Annotation by hand.',
415 'patterns': [r".*: warning: \[BadAnnotationImplementation\] .+"]},
416 {'category': 'java',
417 'severity': severity.MEDIUM,
418 'members': [],
419 'option': '',
420 'description':
421 'Java: BigDecimal(double) and BigDecimal.valueOf(double) may lose precision, prefer BigDecimal(String) or BigDecimal(long)',
422 'patterns': [r".*: warning: \[BigDecimalLiteralDouble\] .+"]},
423 {'category': 'java',
424 'severity': severity.MEDIUM,
425 'members': [],
426 'option': '',
427 'description':
428 'Java: Mockito cannot mock final classes',
429 'patterns': [r".*: warning: \[CannotMockFinalClass\] .+"]},
430 {'category': 'java',
431 'severity': severity.MEDIUM,
432 'members': [],
433 'option': '',
434 'description':
435 'Java: This code, which counts elements using a loop, can be replaced by a simpler library method',
436 'patterns': [r".*: warning: \[ElementsCountedInLoop\] .+"]},
437 {'category': 'java',
438 'severity': severity.MEDIUM,
439 'members': [],
440 'option': '',
441 'description':
442 'Java: Empty top-level type declaration',
443 'patterns': [r".*: warning: \[EmptyTopLevelDeclaration\] .+"]},
444 {'category': 'java',
445 'severity': severity.MEDIUM,
446 'members': [],
447 'option': '',
448 'description':
449 'Java: Classes that override equals should also override hashCode.',
450 'patterns': [r".*: warning: \[EqualsHashCode\] .+"]},
451 {'category': 'java',
452 'severity': severity.MEDIUM,
453 'members': [],
454 'option': '',
455 'description':
456 'Java: An equality test between objects with incompatible types always returns false',
457 'patterns': [r".*: warning: \[EqualsIncompatibleType\] .+"]},
458 {'category': 'java',
459 'severity': severity.MEDIUM,
460 'members': [],
461 'option': '',
462 'description':
463 'Java: If you return or throw from a finally, then values returned or thrown from the try-catch block will be ignored. Consider using try-with-resources instead.',
464 'patterns': [r".*: warning: \[Finally\] .+"]},
465 {'category': 'java',
466 'severity': severity.MEDIUM,
467 'members': [],
468 'option': '',
469 'description':
470 'Java: This annotation has incompatible modifiers as specified by its @IncompatibleModifiers annotation',
471 'patterns': [r".*: warning: \[IncompatibleModifiers\] .+"]},
472 {'category': 'java',
473 'severity': severity.MEDIUM,
474 'members': [],
475 'option': '',
476 'description':
477 'Java: Class should not implement both `Iterable` and `Iterator`',
478 'patterns': [r".*: warning: \[IterableAndIterator\] .+"]},
479 {'category': 'java',
480 'severity': severity.MEDIUM,
481 'members': [],
482 'option': '',
483 'description':
484 'Java: Floating-point comparison without error tolerance',
485 'patterns': [r".*: warning: \[JUnit3FloatingPointComparisonWithoutDelta\] .+"]},
486 {'category': 'java',
487 'severity': severity.MEDIUM,
488 'members': [],
489 'option': '',
490 'description':
491 'Java: Test class inherits from JUnit 3\'s TestCase but has JUnit 4 @Test annotations.',
492 'patterns': [r".*: warning: \[JUnitAmbiguousTestClass\] .+"]},
493 {'category': 'java',
494 'severity': severity.MEDIUM,
495 'members': [],
496 'option': '',
497 'description':
498 'Java: Enum switch statement is missing cases',
499 'patterns': [r".*: warning: \[MissingCasesInEnumSwitch\] .+"]},
500 {'category': 'java',
501 'severity': severity.MEDIUM,
502 'members': [],
503 'option': '',
504 'description':
505 'Java: Not calling fail() when expecting an exception masks bugs',
506 'patterns': [r".*: warning: \[MissingFail\] .+"]},
507 {'category': 'java',
508 'severity': severity.MEDIUM,
509 'members': [],
510 'option': '',
511 'description':
512 'Java: method overrides method in supertype; expected @Override',
513 'patterns': [r".*: warning: \[MissingOverride\] .+"]},
514 {'category': 'java',
515 'severity': severity.MEDIUM,
516 'members': [],
517 'option': '',
518 'description':
519 'Java: Source files should not contain multiple top-level class declarations',
520 'patterns': [r".*: warning: \[MultipleTopLevelClasses\] .+"]},
521 {'category': 'java',
522 'severity': severity.MEDIUM,
523 'members': [],
524 'option': '',
525 'description':
526 'Java: This update of a volatile variable is non-atomic',
527 'patterns': [r".*: warning: \[NonAtomicVolatileUpdate\] .+"]},
528 {'category': 'java',
529 'severity': severity.MEDIUM,
530 'members': [],
531 'option': '',
532 'description':
533 'Java: Static import of member uses non-canonical name',
534 'patterns': [r".*: warning: \[NonCanonicalStaticMemberImport\] .+"]},
535 {'category': 'java',
536 'severity': severity.MEDIUM,
537 'members': [],
538 'option': '',
539 'description':
540 'Java: equals method doesn\'t override Object.equals',
541 'patterns': [r".*: warning: \[NonOverridingEquals\] .+"]},
542 {'category': 'java',
543 'severity': severity.MEDIUM,
544 'members': [],
545 'option': '',
546 'description':
547 'Java: Constructors should not be annotated with @Nullable since they cannot return null',
548 'patterns': [r".*: warning: \[NullableConstructor\] .+"]},
549 {'category': 'java',
550 'severity': severity.MEDIUM,
551 'members': [],
552 'option': '',
553 'description':
554 'Java: @Nullable should not be used for primitive types since they cannot be null',
555 'patterns': [r".*: warning: \[NullablePrimitive\] .+"]},
556 {'category': 'java',
557 'severity': severity.MEDIUM,
558 'members': [],
559 'option': '',
560 'description':
561 'Java: void-returning methods should not be annotated with @Nullable, since they cannot return null',
562 'patterns': [r".*: warning: \[NullableVoid\] .+"]},
563 {'category': 'java',
564 'severity': severity.MEDIUM,
565 'members': [],
566 'option': '',
567 'description':
568 'Java: Package names should match the directory they are declared in',
569 'patterns': [r".*: warning: \[PackageLocation\] .+"]},
570 {'category': 'java',
571 'severity': severity.MEDIUM,
572 'members': [],
573 'option': '',
574 'description':
575 'Java: Second argument to Preconditions.* is a call to String.format(), which can be unwrapped',
576 'patterns': [r".*: warning: \[PreconditionsErrorMessageEagerEvaluation\] .+"]},
577 {'category': 'java',
578 'severity': severity.MEDIUM,
579 'members': [],
580 'option': '',
581 'description':
582 'Java: Preconditions only accepts the %s placeholder in error message strings',
583 'patterns': [r".*: warning: \[PreconditionsInvalidPlaceholder\] .+"]},
584 {'category': 'java',
585 'severity': severity.MEDIUM,
586 'members': [],
587 'option': '',
588 'description':
589 'Java: Passing a primitive array to a varargs method is usually wrong',
590 'patterns': [r".*: warning: \[PrimitiveArrayPassedToVarargsMethod\] .+"]},
591 {'category': 'java',
592 'severity': severity.MEDIUM,
593 'members': [],
594 'option': '',
595 'description':
596 'Java: Protobuf fields cannot be null, so this check is redundant',
597 'patterns': [r".*: warning: \[ProtoFieldPreconditionsCheckNotNull\] .+"]},
598 {'category': 'java',
599 'severity': severity.MEDIUM,
600 'members': [],
601 'option': '',
602 'description':
603 'Java: This annotation is missing required modifiers as specified by its @RequiredModifiers annotation',
604 'patterns': [r".*: warning: \[RequiredModifiers\] .+"]},
605 {'category': 'java',
606 'severity': severity.MEDIUM,
607 'members': [],
608 'option': '',
609 'description':
610 'Java: A static variable or method should not be accessed from an object instance',
611 'patterns': [r".*: warning: \[StaticAccessedFromInstance\] .+"]},
612 {'category': 'java',
613 'severity': severity.MEDIUM,
614 'members': [],
615 'option': '',
616 'description':
617 'Java: String comparison using reference equality instead of value equality',
618 'patterns': [r".*: warning: \[StringEquality\] .+"]},
619 {'category': 'java',
620 'severity': severity.MEDIUM,
621 'members': [],
622 'option': '',
623 'description':
624 'Java: Declaring a type parameter that is only used in the return type is a misuse of generics: operations on the type parameter are unchecked, it hides unsafe casts at invocations of the method, and it interacts badly with method overload resolution.',
625 'patterns': [r".*: warning: \[TypeParameterUnusedInFormals\] .+"]},
626 {'category': 'java',
627 'severity': severity.MEDIUM,
628 'members': [],
629 'option': '',
630 'description':
631 'Java: Using static imports for types is unnecessary',
632 'patterns': [r".*: warning: \[UnnecessaryStaticImport\] .+"]},
633 {'category': 'java',
634 'severity': severity.MEDIUM,
635 'members': [],
636 'option': '',
637 'description':
638 'Java: Unsynchronized method overrides a synchronized method.',
639 'patterns': [r".*: warning: \[UnsynchronizedOverridesSynchronized\] .+"]},
640 {'category': 'java',
641 'severity': severity.MEDIUM,
642 'members': [],
643 'option': '',
644 'description':
645 'Java: Non-constant variable missing @Var annotation',
646 'patterns': [r".*: warning: \[Var\] .+"]},
647 {'category': 'java',
648 'severity': severity.MEDIUM,
649 'members': [],
650 'option': '',
651 'description':
652 'Java: Because of spurious wakeups, Object.wait() and Condition.await() must always be called in a loop',
653 'patterns': [r".*: warning: \[WaitNotInLoop\] .+"]},
654 {'category': 'java',
655 'severity': severity.MEDIUM,
656 'members': [],
657 'option': '',
658 'description':
659 'Java: Subclasses of Fragment must be instantiable via Class#newInstance(): the class must be public, static and have a public nullary constructor',
660 'patterns': [r".*: warning: \[FragmentNotInstantiable\] .+"]},
661 {'category': 'java',
662 'severity': severity.MEDIUM,
663 'members': [],
664 'option': '',
665 'description':
666 'Java: Hardcoded reference to /sdcard',
667 'patterns': [r".*: warning: \[HardCodedSdCardPath\] .+"]},
668 {'category': 'java',
669 'severity': severity.MEDIUM,
670 'members': [],
671 'option': '',
672 'description':
673 'Java: Incompatible type as argument to Object-accepting Java collections method',
674 'patterns': [r".*: warning: \[CollectionIncompatibleType\] .+"]},
675 {'category': 'java',
676 'severity': severity.MEDIUM,
677 'members': [],
678 'option': '',
679 'description':
680 'Java: @AssistedInject and @Inject should not be used on different constructors in the same class.',
681 'patterns': [r".*: warning: \[AssistedInjectAndInjectOnConstructors\] .+"]},
682 {'category': 'java',
683 'severity': severity.MEDIUM,
684 'members': [],
685 'option': '',
686 'description':
687 'Java: Although Guice allows injecting final fields, doing so is not recommended because the injected value may not be visible to other threads.',
688 'patterns': [r".*: warning: \[GuiceInjectOnFinalField\] .+"]},
689 {'category': 'java',
690 'severity': severity.MEDIUM,
691 'members': [],
692 'option': '',
693 'description':
694 'Java: This method is not annotated with @Inject, but it overrides a method that is annotated with @com.google.inject.Inject. Guice will inject this method, and it is recommended to annotate it explicitly.',
695 'patterns': [r".*: warning: \[OverridesGuiceInjectableMethod\] .+"]},
696 {'category': 'java',
697 'severity': severity.MEDIUM,
698 'members': [],
699 'option': '',
700 'description':
701 'Java: Double-checked locking on non-volatile fields is unsafe',
702 'patterns': [r".*: warning: \[DoubleCheckedLocking\] .+"]},
703 {'category': 'java',
704 'severity': severity.MEDIUM,
705 'members': [],
706 'option': '',
707 'description':
708 'Java: Writes to static fields should not be guarded by instance locks',
709 'patterns': [r".*: warning: \[StaticGuardedByInstance\] .+"]},
710 {'category': 'java',
711 'severity': severity.MEDIUM,
712 'members': [],
713 'option': '',
714 'description':
715 'Java: Synchronizing on non-final fields is not safe: if the field is ever updated, different threads may end up locking on different objects.',
716 'patterns': [r".*: warning: \[SynchronizeOnNonFinalField\] .+"]},
717 {'category': 'java',
718 'severity': severity.HIGH,
719 'members': [],
720 'option': '',
721 'description':
722 'Java: Reference equality used to compare arrays',
723 'patterns': [r".*: warning: \[ArrayEquals\] .+"]},
724 {'category': 'java',
725 'severity': severity.HIGH,
726 'members': [],
727 'option': '',
728 'description':
729 'Java: hashcode method on array does not hash array contents',
730 'patterns': [r".*: warning: \[ArrayHashCode\] .+"]},
731 {'category': 'java',
732 'severity': severity.HIGH,
733 'members': [],
734 'option': '',
735 'description':
736 'Java: Calling toString on an array does not provide useful information',
737 'patterns': [r".*: warning: \[ArrayToString.*\] .+"]},
738 {'category': 'java',
739 'severity': severity.HIGH,
740 'members': [],
741 'option': '',
742 'description':
743 'Java: Arrays.asList does not autobox primitive arrays, as one might expect.',
744 'patterns': [r".*: warning: \[ArraysAsListPrimitiveArray\] .+"]},
745 {'category': 'java',
746 'severity': severity.HIGH,
747 'members': [],
748 'option': '',
749 'description':
750 'Java: AsyncCallable should not return a null Future, only a Future whose result is null.',
751 'patterns': [r".*: warning: \[AsyncCallableReturnsNull\] .+"]},
752 {'category': 'java',
753 'severity': severity.HIGH,
754 'members': [],
755 'option': '',
756 'description':
757 'Java: AsyncFunction should not return a null Future, only a Future whose result is null.',
758 'patterns': [r".*: warning: \[AsyncFunctionReturnsNull\] .+"]},
759 {'category': 'java',
760 'severity': severity.HIGH,
761 'members': [],
762 'option': '',
763 'description':
764 'Java: Possible sign flip from narrowing conversion',
765 'patterns': [r".*: warning: \[BadComparable\] .+"]},
766 {'category': 'java',
767 'severity': severity.HIGH,
768 'members': [],
769 'option': '',
770 'description':
771 'Java: Shift by an amount that is out of range',
772 'patterns': [r".*: warning: \[BadShiftAmount\] .+"]},
773 {'category': 'java',
774 'severity': severity.HIGH,
775 'members': [],
776 'option': '',
777 'description':
778 'Java: valueOf provides better time and space performance',
779 'patterns': [r".*: warning: \[BoxedPrimitiveConstructor\] .+"]},
780 {'category': 'java',
781 'severity': severity.HIGH,
782 'members': [],
783 'option': '',
784 'description':
785 'Java: The called constructor accepts a parameter with the same name and type as one of its caller\'s parameters, but its caller doesn\'t pass that parameter to it. It\'s likely that it was intended to.',
786 'patterns': [r".*: warning: \[ChainingConstructorIgnoresParameter\] .+"]},
787 {'category': 'java',
788 'severity': severity.HIGH,
789 'members': [],
790 'option': '',
791 'description':
792 'Java: Ignored return value of method that is annotated with @CheckReturnValue',
793 'patterns': [r".*: warning: \[CheckReturnValue\] .+"]},
794 {'category': 'java',
795 'severity': severity.HIGH,
796 'members': [],
797 'option': '',
798 'description':
799 'Java: Inner class is non-static but does not reference enclosing class',
800 'patterns': [r".*: warning: \[ClassCanBeStatic\] .+"]},
801 {'category': 'java',
802 'severity': severity.HIGH,
803 'members': [],
804 'option': '',
805 'description':
806 'Java: The source file name should match the name of the top-level class it contains',
807 'patterns': [r".*: warning: \[ClassName\] .+"]},
808 {'category': 'java',
809 'severity': severity.HIGH,
810 'members': [],
811 'option': '',
812 'description':
813 'Java: This comparison method violates the contract',
814 'patterns': [r".*: warning: \[ComparisonContractViolated\] .+"]},
815 {'category': 'java',
816 'severity': severity.HIGH,
817 'members': [],
818 'option': '',
819 'description':
820 'Java: Comparison to value that is out of range for the compared type',
821 'patterns': [r".*: warning: \[ComparisonOutOfRange\] .+"]},
822 {'category': 'java',
823 'severity': severity.HIGH,
824 'members': [],
825 'option': '',
826 'description':
827 'Java: Non-compile-time constant expression passed to parameter with @CompileTimeConstant type annotation.',
828 'patterns': [r".*: warning: \[CompileTimeConstant\] .+"]},
829 {'category': 'java',
830 'severity': severity.HIGH,
831 'members': [],
832 'option': '',
833 'description':
834 'Java: Exception created but not thrown',
835 'patterns': [r".*: warning: \[DeadException\] .+"]},
836 {'category': 'java',
837 'severity': severity.HIGH,
838 'members': [],
839 'option': '',
840 'description':
841 'Java: Division by integer literal zero',
842 'patterns': [r".*: warning: \[DivZero\] .+"]},
843 {'category': 'java',
844 'severity': severity.HIGH,
845 'members': [],
846 'option': '',
847 'description':
848 'Java: Empty statement after if',
849 'patterns': [r".*: warning: \[EmptyIf\] .+"]},
850 {'category': 'java',
851 'severity': severity.HIGH,
852 'members': [],
853 'option': '',
854 'description':
855 'Java: == NaN always returns false; use the isNaN methods instead',
856 'patterns': [r".*: warning: \[EqualsNaN\] .+"]},
857 {'category': 'java',
858 'severity': severity.HIGH,
859 'members': [],
860 'option': '',
861 'description':
862 'Java: Method annotated @ForOverride must be protected or package-private and only invoked from declaring class',
863 'patterns': [r".*: warning: \[ForOverride\] .+"]},
864 {'category': 'java',
865 'severity': severity.HIGH,
866 'members': [],
867 'option': '',
868 'description':
869 'Java: Futures.getChecked requires a checked exception type with a standard constructor.',
870 'patterns': [r".*: warning: \[FuturesGetCheckedIllegalExceptionType\] .+"]},
871 {'category': 'java',
872 'severity': severity.HIGH,
873 'members': [],
874 'option': '',
875 'description':
876 'Java: Calling getClass() on an object of type Class returns the Class object for java.lang.Class; you probably meant to operate on the object directly',
877 'patterns': [r".*: warning: \[GetClassOnClass\] .+"]},
878 {'category': 'java',
879 'severity': severity.HIGH,
880 'members': [],
881 'option': '',
882 'description':
883 'Java: An object is tested for equality to itself using Guava Libraries',
884 'patterns': [r".*: warning: \[GuavaSelfEquals\] .+"]},
885 {'category': 'java',
886 'severity': severity.HIGH,
887 'members': [],
888 'option': '',
889 'description':
890 'Java: contains() is a legacy method that is equivalent to containsValue()',
891 'patterns': [r".*: warning: \[HashtableContains\] .+"]},
892 {'category': 'java',
893 'severity': severity.HIGH,
894 'members': [],
895 'option': '',
896 'description':
897 'Java: Cipher.getInstance() is invoked using either the default settings or ECB mode',
898 'patterns': [r".*: warning: \[InsecureCipherMode\] .+"]},
899 {'category': 'java',
900 'severity': severity.HIGH,
901 'members': [],
902 'option': '',
903 'description':
904 'Java: Invalid syntax used for a regular expression',
905 'patterns': [r".*: warning: \[InvalidPatternSyntax\] .+"]},
906 {'category': 'java',
907 'severity': severity.HIGH,
908 'members': [],
909 'option': '',
910 'description':
911 'Java: The argument to Class#isInstance(Object) should not be a Class',
912 'patterns': [r".*: warning: \[IsInstanceOfClass\] .+"]},
913 {'category': 'java',
914 'severity': severity.HIGH,
915 'members': [],
916 'option': '',
917 'description':
918 'Java: jMock tests must have a @RunWith(JMock.class) annotation, or the Mockery field must have a @Rule JUnit annotation',
919 'patterns': [r".*: warning: \[JMockTestWithoutRunWithOrRuleAnnotation\] .+"]},
920 {'category': 'java',
921 'severity': severity.HIGH,
922 'members': [],
923 'option': '',
924 'description':
925 'Java: Test method will not be run; please prefix name with "test"',
926 'patterns': [r".*: warning: \[JUnit3TestNotRun\] .+"]},
927 {'category': 'java',
928 'severity': severity.HIGH,
929 'members': [],
930 'option': '',
931 'description':
932 'Java: setUp() method will not be run; Please add a @Before annotation',
933 'patterns': [r".*: warning: \[JUnit4SetUpNotRun\] .+"]},
934 {'category': 'java',
935 'severity': severity.HIGH,
936 'members': [],
937 'option': '',
938 'description':
939 'Java: tearDown() method will not be run; Please add an @After annotation',
940 'patterns': [r".*: warning: \[JUnit4TearDownNotRun\] .+"]},
941 {'category': 'java',
942 'severity': severity.HIGH,
943 'members': [],
944 'option': '',
945 'description':
946 'Java: Test method will not be run; please add @Test annotation',
947 'patterns': [r".*: warning: \[JUnit4TestNotRun\] .+"]},
948 {'category': 'java',
949 'severity': severity.HIGH,
950 'members': [],
951 'option': '',
952 'description':
953 'Java: Printf-like format string does not match its arguments',
954 'patterns': [r".*: warning: \[MalformedFormatString\] .+"]},
955 {'category': 'java',
956 'severity': severity.HIGH,
957 'members': [],
958 'option': '',
959 'description':
960 'Java: Use of "YYYY" (week year) in a date pattern without "ww" (week in year). You probably meant to use "yyyy" (year) instead.',
961 'patterns': [r".*: warning: \[MisusedWeekYear\] .+"]},
962 {'category': 'java',
963 'severity': severity.HIGH,
964 'members': [],
965 'option': '',
966 'description':
967 'Java: A bug in Mockito will cause this test to fail at runtime with a ClassCastException',
968 'patterns': [r".*: warning: \[MockitoCast\] .+"]},
969 {'category': 'java',
970 'severity': severity.HIGH,
971 'members': [],
972 'option': '',
973 'description':
974 'Java: Missing method call for verify(mock) here',
975 'patterns': [r".*: warning: \[MockitoUsage\] .+"]},
976 {'category': 'java',
977 'severity': severity.HIGH,
978 'members': [],
979 'option': '',
980 'description':
981 'Java: Modifying a collection with itself',
982 'patterns': [r".*: warning: \[ModifyingCollectionWithItself\] .+"]},
983 {'category': 'java',
984 'severity': severity.HIGH,
985 'members': [],
986 'option': '',
987 'description':
988 'Java: Compound assignments to bytes, shorts, chars, and floats hide dangerous casts',
989 'patterns': [r".*: warning: \[NarrowingCompoundAssignment\] .+"]},
990 {'category': 'java',
991 'severity': severity.HIGH,
992 'members': [],
993 'option': '',
994 'description':
995 'Java: @NoAllocation was specified on this method, but something was found that would trigger an allocation',
996 'patterns': [r".*: warning: \[NoAllocation\] .+"]},
997 {'category': 'java',
998 'severity': severity.HIGH,
999 'members': [],
1000 'option': '',
1001 'description':
1002 'Java: Static import of type uses non-canonical name',
1003 'patterns': [r".*: warning: \[NonCanonicalStaticImport\] .+"]},
1004 {'category': 'java',
1005 'severity': severity.HIGH,
1006 'members': [],
1007 'option': '',
1008 'description':
1009 'Java: @CompileTimeConstant parameters should be final',
1010 'patterns': [r".*: warning: \[NonFinalCompileTimeConstant\] .+"]},
1011 {'category': 'java',
1012 'severity': severity.HIGH,
1013 'members': [],
1014 'option': '',
1015 'description':
1016 'Java: Calling getAnnotation on an annotation that is not retained at runtime.',
1017 'patterns': [r".*: warning: \[NonRuntimeAnnotation\] .+"]},
1018 {'category': 'java',
1019 'severity': severity.HIGH,
1020 'members': [],
1021 'option': '',
1022 'description':
1023 'Java: Numeric comparison using reference equality instead of value equality',
1024 'patterns': [r".*: warning: \[NumericEquality\] .+"]},
1025 {'category': 'java',
1026 'severity': severity.HIGH,
1027 'members': [],
1028 'option': '',
1029 'description':
1030 'Java: Comparison using reference equality instead of value equality',
1031 'patterns': [r".*: warning: \[OptionalEquality\] .+"]},
1032 {'category': 'java',
1033 'severity': severity.HIGH,
1034 'members': [],
1035 'option': '',
1036 'description':
1037 'Java: Varargs doesn\'t agree for overridden method',
1038 'patterns': [r".*: warning: \[Overrides\] .+"]},
1039 {'category': 'java',
1040 'severity': severity.HIGH,
1041 'members': [],
1042 'option': '',
1043 'description':
1044 'Java: Literal passed as first argument to Preconditions.checkNotNull() can never be null',
1045 'patterns': [r".*: warning: \[PreconditionsCheckNotNull\] .+"]},
1046 {'category': 'java',
1047 'severity': severity.HIGH,
1048 'members': [],
1049 'option': '',
1050 'description':
1051 'Java: First argument to `Preconditions.checkNotNull()` is a primitive rather than an object reference',
1052 'patterns': [r".*: warning: \[PreconditionsCheckNotNullPrimitive\] .+"]},
1053 {'category': 'java',
1054 'severity': severity.HIGH,
1055 'members': [],
1056 'option': '',
1057 'description':
1058 'Java: Protobuf fields cannot be null',
1059 'patterns': [r".*: warning: \[ProtoFieldNullComparison\] .+"]},
1060 {'category': 'java',
1061 'severity': severity.HIGH,
1062 'members': [],
1063 'option': '',
1064 'description':
1065 'Java: Comparing protobuf fields of type String using reference equality',
1066 'patterns': [r".*: warning: \[ProtoStringFieldReferenceEquality\] .+"]},
1067 {'category': 'java',
1068 'severity': severity.HIGH,
1069 'members': [],
1070 'option': '',
1071 'description':
1072 'Java: Check for non-whitelisted callers to RestrictedApiChecker.',
1073 'patterns': [r".*: warning: \[RestrictedApiChecker\] .+"]},
1074 {'category': 'java',
1075 'severity': severity.HIGH,
1076 'members': [],
1077 'option': '',
1078 'description':
1079 'Java: Return value of this method must be used',
1080 'patterns': [r".*: warning: \[ReturnValueIgnored\] .+"]},
1081 {'category': 'java',
1082 'severity': severity.HIGH,
1083 'members': [],
1084 'option': '',
1085 'description':
1086 'Java: Variable assigned to itself',
1087 'patterns': [r".*: warning: \[SelfAssignment\] .+"]},
1088 {'category': 'java',
1089 'severity': severity.HIGH,
1090 'members': [],
1091 'option': '',
1092 'description':
1093 'Java: An object is compared to itself',
1094 'patterns': [r".*: warning: \[SelfComparision\] .+"]},
1095 {'category': 'java',
1096 'severity': severity.HIGH,
1097 'members': [],
1098 'option': '',
1099 'description':
1100 'Java: Variable compared to itself',
1101 'patterns': [r".*: warning: \[SelfEquality\] .+"]},
1102 {'category': 'java',
1103 'severity': severity.HIGH,
1104 'members': [],
1105 'option': '',
1106 'description':
1107 'Java: An object is tested for equality to itself',
1108 'patterns': [r".*: warning: \[SelfEquals\] .+"]},
1109 {'category': 'java',
1110 'severity': severity.HIGH,
1111 'members': [],
1112 'option': '',
1113 'description':
1114 'Java: Comparison of a size >= 0 is always true, did you intend to check for non-emptiness?',
1115 'patterns': [r".*: warning: \[SizeGreaterThanOrEqualsZero\] .+"]},
1116 {'category': 'java',
1117 'severity': severity.HIGH,
1118 'members': [],
1119 'option': '',
1120 'description':
1121 'Java: Calling toString on a Stream does not provide useful information',
1122 'patterns': [r".*: warning: \[StreamToString\] .+"]},
1123 {'category': 'java',
1124 'severity': severity.HIGH,
1125 'members': [],
1126 'option': '',
1127 'description':
1128 'Java: StringBuilder does not have a char constructor; this invokes the int constructor.',
1129 'patterns': [r".*: warning: \[StringBuilderInitWithChar\] .+"]},
1130 {'category': 'java',
1131 'severity': severity.HIGH,
1132 'members': [],
1133 'option': '',
1134 'description':
1135 'Java: Suppressing "deprecated" is probably a typo for "deprecation"',
1136 'patterns': [r".*: warning: \[SuppressWarningsDeprecated\] .+"]},
1137 {'category': 'java',
1138 'severity': severity.HIGH,
1139 'members': [],
1140 'option': '',
1141 'description':
1142 'Java: throwIfUnchecked(knownCheckedException) is a no-op.',
1143 'patterns': [r".*: warning: \[ThrowIfUncheckedKnownChecked\] .+"]},
1144 {'category': 'java',
1145 'severity': severity.HIGH,
1146 'members': [],
1147 'option': '',
1148 'description':
1149 'Java: Catching Throwable/Error masks failures from fail() or assert*() in the try block',
1150 'patterns': [r".*: warning: \[TryFailThrowable\] .+"]},
1151 {'category': 'java',
1152 'severity': severity.HIGH,
1153 'members': [],
1154 'option': '',
1155 'description':
1156 'Java: Type parameter used as type qualifier',
1157 'patterns': [r".*: warning: \[TypeParameterQualifier\] .+"]},
1158 {'category': 'java',
1159 'severity': severity.HIGH,
1160 'members': [],
1161 'option': '',
1162 'description':
1163 'Java: Non-generic methods should not be invoked with type arguments',
1164 'patterns': [r".*: warning: \[UnnecessaryTypeArgument\] .+"]},
1165 {'category': 'java',
1166 'severity': severity.HIGH,
1167 'members': [],
1168 'option': '',
1169 'description':
1170 'Java: Instance created but never used',
1171 'patterns': [r".*: warning: \[UnusedAnonymousClass\] .+"]},
1172 {'category': 'java',
1173 'severity': severity.HIGH,
1174 'members': [],
1175 'option': '',
1176 'description':
1177 'Java: Use of wildcard imports is forbidden',
1178 'patterns': [r".*: warning: \[WildcardImport\] .+"]},
1179 {'category': 'java',
1180 'severity': severity.HIGH,
1181 'members': [],
1182 'option': '',
1183 'description':
1184 'Java: Method parameter has wrong package',
1185 'patterns': [r".*: warning: \[ParameterPackage\] .+"]},
1186 {'category': 'java',
1187 'severity': severity.HIGH,
1188 'members': [],
1189 'option': '',
1190 'description':
1191 'Java: Certain resources in `android.R.string` have names that do not match their content',
1192 'patterns': [r".*: warning: \[MislabeledAndroidString\] .+"]},
1193 {'category': 'java',
1194 'severity': severity.HIGH,
1195 'members': [],
1196 'option': '',
1197 'description':
1198 'Java: Return value of android.graphics.Rect.intersect() must be checked',
1199 'patterns': [r".*: warning: \[RectIntersectReturnValueIgnored\] .+"]},
1200 {'category': 'java',
1201 'severity': severity.HIGH,
1202 'members': [],
1203 'option': '',
1204 'description':
1205 'Java: Invalid printf-style format string',
1206 'patterns': [r".*: warning: \[FormatString\] .+"]},
1207 {'category': 'java',
1208 'severity': severity.HIGH,
1209 'members': [],
1210 'option': '',
1211 'description':
1212 'Java: @AssistedInject and @Inject cannot be used on the same constructor.',
1213 'patterns': [r".*: warning: \[AssistedInjectAndInjectOnSameConstructor\] .+"]},
1214 {'category': 'java',
1215 'severity': severity.HIGH,
1216 'members': [],
1217 'option': '',
1218 'description':
1219 'Java: Injected constructors cannot be optional nor have binding annotations',
1220 'patterns': [r".*: warning: \[InjectedConstructorAnnotations\] .+"]},
1221 {'category': 'java',
1222 'severity': severity.HIGH,
1223 'members': [],
1224 'option': '',
1225 'description':
1226 'Java: The target of a scoping annotation must be set to METHOD and/or TYPE.',
1227 'patterns': [r".*: warning: \[InjectInvalidTargetingOnScopingAnnotation\] .+"]},
1228 {'category': 'java',
1229 'severity': severity.HIGH,
1230 'members': [],
1231 'option': '',
1232 'description':
1233 'Java: Abstract methods are not injectable with javax.inject.Inject.',
1234 'patterns': [r".*: warning: \[JavaxInjectOnAbstractMethod\] .+"]},
1235 {'category': 'java',
1236 'severity': severity.HIGH,
1237 'members': [],
1238 'option': '',
1239 'description':
1240 'Java: @javax.inject.Inject cannot be put on a final field.',
1241 'patterns': [r".*: warning: \[JavaxInjectOnFinalField\] .+"]},
1242 {'category': 'java',
1243 'severity': severity.HIGH,
1244 'members': [],
1245 'option': '',
1246 'description':
1247 'Java: A class may not have more than one injectable constructor.',
1248 'patterns': [r".*: warning: \[MoreThanOneInjectableConstructor\] .+"]},
1249 {'category': 'java',
1250 'severity': severity.HIGH,
1251 'members': [],
1252 'option': '',
1253 'description':
1254 'Java: Using more than one qualifier annotation on the same element is not allowed.',
1255 'patterns': [r".*: warning: \[InjectMoreThanOneQualifier\] .+"]},
1256 {'category': 'java',
1257 'severity': severity.HIGH,
1258 'members': [],
1259 'option': '',
1260 'description':
1261 'Java: A class can be annotated with at most one scope annotation',
1262 'patterns': [r".*: warning: \[InjectMoreThanOneScopeAnnotationOnClass\] .+"]},
1263 {'category': 'java',
1264 'severity': severity.HIGH,
1265 'members': [],
1266 'option': '',
1267 'description':
1268 'Java: Annotations cannot be both Qualifiers/BindingAnnotations and Scopes',
1269 'patterns': [r".*: warning: \[OverlappingQualifierAndScopeAnnotation\] .+"]},
1270 {'category': 'java',
1271 'severity': severity.HIGH,
1272 'members': [],
1273 'option': '',
1274 'description':
1275 'Java: Scope annotation on an interface or abstact class is not allowed',
1276 'patterns': [r".*: warning: \[InjectScopeAnnotationOnInterfaceOrAbstractClass\] .+"]},
1277 {'category': 'java',
1278 'severity': severity.HIGH,
1279 'members': [],
1280 'option': '',
1281 'description':
1282 'Java: Scoping and qualifier annotations must have runtime retention.',
1283 'patterns': [r".*: warning: \[InjectScopeOrQualifierAnnotationRetention\] .+"]},
1284 {'category': 'java',
1285 'severity': severity.HIGH,
1286 'members': [],
1287 'option': '',
1288 'description':
1289 'Java: Dagger @Provides methods may not return null unless annotated with @Nullable',
1290 'patterns': [r".*: warning: \[DaggerProvidesNull\] .+"]},
1291 {'category': 'java',
1292 'severity': severity.HIGH,
1293 'members': [],
1294 'option': '',
1295 'description':
1296 'Java: Scope annotation on implementation class of AssistedInject factory is not allowed',
1297 'patterns': [r".*: warning: \[GuiceAssistedInjectScoping\] .+"]},
1298 {'category': 'java',
1299 'severity': severity.HIGH,
1300 'members': [],
1301 'option': '',
1302 'description':
1303 'Java: A constructor cannot have two @Assisted parameters of the same type unless they are disambiguated with named @Assisted annotations. ',
1304 'patterns': [r".*: warning: \[GuiceAssistedParameters\] .+"]},
1305 {'category': 'java',
1306 'severity': severity.HIGH,
1307 'members': [],
1308 'option': '',
1309 'description':
1310 'Java: This method is not annotated with @Inject, but it overrides a method that is annotated with @javax.inject.Inject.',
1311 'patterns': [r".*: warning: \[OverridesJavaxInjectableMethod\] .+"]},
1312 {'category': 'java',
1313 'severity': severity.HIGH,
1314 'members': [],
1315 'option': '',
1316 'description':
1317 'Java: Checks for unguarded accesses to fields and methods with @GuardedBy annotations',
1318 'patterns': [r".*: warning: \[GuardedByChecker\] .+"]},
1319 {'category': 'java',
1320 'severity': severity.HIGH,
1321 'members': [],
1322 'option': '',
1323 'description':
1324 'Java: Invalid @GuardedBy expression',
1325 'patterns': [r".*: warning: \[GuardedByValidator\] .+"]},
1326 {'category': 'java',
1327 'severity': severity.HIGH,
1328 'members': [],
1329 'option': '',
1330 'description':
1331 'Java: Type declaration annotated with @Immutable is not immutable',
1332 'patterns': [r".*: warning: \[Immutable\] .+"]},
1333 {'category': 'java',
1334 'severity': severity.HIGH,
1335 'members': [],
1336 'option': '',
1337 'description':
1338 'Java: This method does not acquire the locks specified by its @LockMethod annotation',
1339 'patterns': [r".*: warning: \[LockMethodChecker\] .+"]},
1340 {'category': 'java',
1341 'severity': severity.HIGH,
1342 'members': [],
1343 'option': '',
1344 'description':
1345 'Java: This method does not acquire the locks specified by its @UnlockMethod annotation',
1346 'patterns': [r".*: warning: \[UnlockMethod\] .+"]},
Ian Rogers32bb9bd2016-05-09 23:19:42 -07001347
Ian Rogers6e520032016-05-13 08:59:00 -07001348 {'category': 'java',
1349 'severity': severity.UNKNOWN,
1350 'members': [],
1351 'option': '',
1352 'description': 'Java: Unclassified/unrecognized warnings',
1353 'patterns': [r".*: warning: \[.+\] .+"]},
Ian Rogers32bb9bd2016-05-09 23:19:42 -07001354
Marco Nelissen594375d2009-07-14 09:04:04 -07001355 { 'category':'aapt', 'severity':severity.MEDIUM, 'members':[], 'option':'',
Marco Nelissen8e201962010-03-10 16:16:02 -08001356 'description':'aapt: No default translation',
1357 'patterns':[r".*: warning: string '.+' has no default translation in .*"] },
1358 { 'category':'aapt', 'severity':severity.MEDIUM, 'members':[], 'option':'',
1359 'description':'aapt: Missing default or required localization',
1360 'patterns':[r".*: warning: \*\*\*\* string '.+' has no default or required localization for '.+' in .+"] },
1361 { 'category':'aapt', 'severity':severity.MEDIUM, 'members':[], 'option':'',
Marco Nelissen594375d2009-07-14 09:04:04 -07001362 'description':'aapt: String marked untranslatable, but translation exists',
1363 'patterns':[r".*: warning: string '.+' in .* marked untranslatable but exists in locale '??_??'"] },
1364 { 'category':'aapt', 'severity':severity.MEDIUM, 'members':[], 'option':'',
1365 'description':'aapt: empty span in string',
1366 'patterns':[r".*: warning: empty '.+' span found in text '.+"] },
1367 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
1368 'description':'Taking address of temporary',
1369 'patterns':[r".*: warning: taking address of temporary"] },
1370 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
1371 'description':'Possible broken line continuation',
1372 'patterns':[r".*: warning: backslash and newline separated by space"] },
Chih-Hung Hsiehc21ddbd2016-07-20 10:08:51 -07001373 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wundefined-var-template',
1374 'description':'Undefined variable template',
1375 'patterns':[r".*: warning: instantiation of variable .* no definition is available"] },
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001376 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wundefined-inline',
1377 'description':'Inline function is not defined',
1378 'patterns':[r".*: warning: inline function '.*' is not defined"] },
Marco Nelissen594375d2009-07-14 09:04:04 -07001379 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Warray-bounds',
1380 'description':'Array subscript out of bounds',
Marco Nelissen8e201962010-03-10 16:16:02 -08001381 'patterns':[r".*: warning: array subscript is above array bounds",
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001382 r".*: warning: Array subscript is undefined",
Marco Nelissen8e201962010-03-10 16:16:02 -08001383 r".*: warning: array subscript is below array bounds"] },
Marco Nelissen594375d2009-07-14 09:04:04 -07001384 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001385 'description':'Excess elements in initializer',
1386 'patterns':[r".*: warning: excess elements in .+ initializer"] },
1387 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
Marco Nelissen594375d2009-07-14 09:04:04 -07001388 'description':'Decimal constant is unsigned only in ISO C90',
1389 'patterns':[r".*: warning: this decimal constant is unsigned only in ISO C90"] },
1390 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wmain',
1391 'description':'main is usually a function',
1392 'patterns':[r".*: warning: 'main' is usually a function"] },
1393 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
1394 'description':'Typedef ignored',
1395 'patterns':[r".*: warning: 'typedef' was ignored in this declaration"] },
1396 { 'category':'C/C++', 'severity':severity.HIGH, 'members':[], 'option':'-Waddress',
1397 'description':'Address always evaluates to true',
1398 'patterns':[r".*: warning: the address of '.+' will always evaluate as 'true'"] },
1399 { 'category':'C/C++', 'severity':severity.FIXMENOW, 'members':[], 'option':'',
1400 'description':'Freeing a non-heap object',
1401 'patterns':[r".*: warning: attempt to free a non-heap object '.+'"] },
1402 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wchar-subscripts',
1403 'description':'Array subscript has type char',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001404 'patterns':[r".*: warning: array subscript .+ type 'char'.+Wchar-subscripts"] },
Marco Nelissen594375d2009-07-14 09:04:04 -07001405 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
1406 'description':'Constant too large for type',
1407 'patterns':[r".*: warning: integer constant is too large for '.+' type"] },
1408 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Woverflow',
1409 'description':'Constant too large for type, truncated',
1410 'patterns':[r".*: warning: large integer implicitly truncated to unsigned type"] },
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001411 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Winteger-overflow',
1412 'description':'Overflow in expression',
1413 'patterns':[r".*: warning: overflow in expression; .*Winteger-overflow"] },
Marco Nelissen594375d2009-07-14 09:04:04 -07001414 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Woverflow',
1415 'description':'Overflow in implicit constant conversion',
1416 'patterns':[r".*: warning: overflow in implicit constant conversion"] },
1417 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
1418 'description':'Declaration does not declare anything',
1419 'patterns':[r".*: warning: declaration 'class .+' does not declare anything"] },
1420 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wreorder',
1421 'description':'Initialization order will be different',
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001422 'patterns':[r".*: warning: '.+' will be initialized after",
1423 r".*: warning: field .+ will be initialized after .+Wreorder"] },
Marco Nelissen594375d2009-07-14 09:04:04 -07001424 { 'category':'cont.', 'severity':severity.SKIP, 'members':[], 'option':'',
1425 'description':'',
1426 'patterns':[r".*: warning: '.+'"] },
1427 { 'category':'cont.', 'severity':severity.SKIP, 'members':[], 'option':'',
1428 'description':'',
Marco Nelissen8e201962010-03-10 16:16:02 -08001429 'patterns':[r".*: warning: base '.+'"] },
1430 { 'category':'cont.', 'severity':severity.SKIP, 'members':[], 'option':'',
1431 'description':'',
Marco Nelissen594375d2009-07-14 09:04:04 -07001432 'patterns':[r".*: warning: when initialized here"] },
1433 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wmissing-parameter-type',
1434 'description':'Parameter type not specified',
1435 'patterns':[r".*: warning: type of '.+' defaults to 'int'"] },
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001436 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wmissing-declarations',
1437 'description':'Missing declarations',
1438 'patterns':[r".*: warning: declaration does not declare anything"] },
1439 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wmissing-noreturn',
1440 'description':'Missing noreturn',
1441 'patterns':[r".*: warning: function '.*' could be declared with attribute 'noreturn'"] },
Marco Nelissen594375d2009-07-14 09:04:04 -07001442 { 'category':'gcc', 'severity':severity.MEDIUM, 'members':[], 'option':'',
1443 'description':'Invalid option for C file',
1444 'patterns':[r".*: warning: command line option "".+"" is valid for C\+\+\/ObjC\+\+ but not for C"] },
1445 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
1446 'description':'User warning',
1447 'patterns':[r".*: warning: #warning "".+"""] },
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001448 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wvexing-parse',
1449 'description':'Vexing parsing problem',
1450 'patterns':[r".*: warning: empty parentheses interpreted as a function declaration"] },
Marco Nelissen594375d2009-07-14 09:04:04 -07001451 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wextra',
1452 'description':'Dereferencing void*',
1453 'patterns':[r".*: warning: dereferencing 'void \*' pointer"] },
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001454 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
1455 'description':'Comparison of pointer and integer',
1456 'patterns':[r".*: warning: ordered comparison of pointer with integer zero",
1457 r".*: warning: .*comparison between pointer and integer"] },
1458 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
1459 'description':'Use of error-prone unary operator',
1460 'patterns':[r".*: warning: use of unary operator that may be intended as compound assignment"] },
Marco Nelissen594375d2009-07-14 09:04:04 -07001461 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wwrite-strings',
1462 'description':'Conversion of string constant to non-const char*',
1463 'patterns':[r".*: warning: deprecated conversion from string constant to '.+'"] },
1464 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wstrict-prototypes',
1465 'description':'Function declaration isn''t a prototype',
1466 'patterns':[r".*: warning: function declaration isn't a prototype"] },
1467 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wignored-qualifiers',
1468 'description':'Type qualifiers ignored on function return value',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001469 'patterns':[r".*: warning: type qualifiers ignored on function return type",
1470 r".*: warning: .+ type qualifier .+ has no effect .+Wignored-qualifiers"] },
Marco Nelissen594375d2009-07-14 09:04:04 -07001471 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
1472 'description':'<foo> declared inside parameter list, scope limited to this definition',
1473 'patterns':[r".*: warning: '.+' declared inside parameter list"] },
1474 { 'category':'cont.', 'severity':severity.SKIP, 'members':[], 'option':'',
1475 'description':'',
1476 'patterns':[r".*: warning: its scope is only this definition or declaration, which is probably not what you want"] },
1477 { 'category':'C/C++', 'severity':severity.LOW, 'members':[], 'option':'-Wcomment',
1478 'description':'Line continuation inside comment',
1479 'patterns':[r".*: warning: multi-line comment"] },
Marco Nelissen8e201962010-03-10 16:16:02 -08001480 { 'category':'C/C++', 'severity':severity.LOW, 'members':[], 'option':'-Wcomment',
1481 'description':'Comment inside comment',
1482 'patterns':[r".*: warning: "".+"" within comment"] },
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001483 { 'category':'C/C++', 'severity':severity.LOW, 'members':[], 'option':'',
1484 'description':'Value stored is never read',
1485 'patterns':[r".*: warning: Value stored to .+ is never read"] },
1486 { 'category':'C/C++', 'severity':severity.LOW, 'members':[], 'option':'-Wdeprecated-declarations',
1487 'description':'Deprecated declarations',
1488 'patterns':[r".*: warning: .+ is deprecated.+deprecated-declarations"] },
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001489 { 'category':'C/C++', 'severity':severity.LOW, 'members':[], 'option':'-Wdeprecated-register',
1490 'description':'Deprecated register',
1491 'patterns':[r".*: warning: 'register' storage class specifier is deprecated"] },
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001492 { 'category':'C/C++', 'severity':severity.LOW, 'members':[], 'option':'-Wpointer-sign',
1493 'description':'Converts between pointers to integer types with different sign',
1494 'patterns':[r".*: warning: .+ converts between pointers to integer types with different sign"] },
Marco Nelissen594375d2009-07-14 09:04:04 -07001495 { 'category':'C/C++', 'severity':severity.HARMLESS, 'members':[], 'option':'',
1496 'description':'Extra tokens after #endif',
1497 'patterns':[r".*: warning: extra tokens at end of #endif directive"] },
1498 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wenum-compare',
1499 'description':'Comparison between different enums',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001500 'patterns':[r".*: warning: comparison between '.+' and '.+'.+Wenum-compare"] },
Marco Nelissen594375d2009-07-14 09:04:04 -07001501 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wconversion',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001502 'description':'Conversion may change value',
1503 'patterns':[r".*: warning: converting negative value '.+' to '.+'",
1504 r".*: warning: conversion to '.+' .+ may alter its value"] },
1505 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wconversion-null',
1506 'description':'Converting to non-pointer type from NULL',
1507 'patterns':[r".*: warning: converting to non-pointer type '.+' from NULL"] },
1508 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wnull-conversion',
1509 'description':'Converting NULL to non-pointer type',
1510 'patterns':[r".*: warning: implicit conversion of NULL constant to '.+'"] },
1511 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wnon-literal-null-conversion',
1512 'description':'Zero used as null pointer',
1513 'patterns':[r".*: warning: expression .* zero treated as a null pointer constant"] },
Chih-Hung Hsiehc21ddbd2016-07-20 10:08:51 -07001514 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001515 'description':'Implicit conversion changes value',
Chih-Hung Hsiehc21ddbd2016-07-20 10:08:51 -07001516 'patterns':[r".*: warning: implicit conversion .* changes value from .* to .*-conversion"] },
Marco Nelissen594375d2009-07-14 09:04:04 -07001517 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
1518 'description':'Passing NULL as non-pointer argument',
Marco Nelissen5236fbd2009-07-31 08:30:34 -07001519 'patterns':[r".*: warning: passing NULL to non-pointer argument [0-9]+ of '.+'"] },
Marco Nelissen594375d2009-07-14 09:04:04 -07001520 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wctor-dtor-privacy',
1521 'description':'Class seems unusable because of private ctor/dtor' ,
1522 'patterns':[r".*: warning: all member functions in class '.+' are private"] },
1523 # skip this next one, because it only points out some RefBase-based classes where having a private destructor is perfectly fine
1524 { 'category':'C/C++', 'severity':severity.SKIP, 'members':[], 'option':'-Wctor-dtor-privacy',
1525 'description':'Class seems unusable because of private ctor/dtor' ,
1526 'patterns':[r".*: warning: 'class .+' only defines a private destructor and has no friends"] },
1527 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wctor-dtor-privacy',
1528 'description':'Class seems unusable because of private ctor/dtor' ,
1529 'patterns':[r".*: warning: 'class .+' only defines private constructors and has no friends"] },
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001530 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wgnu-static-float-init',
1531 'description':'In-class initializer for static const float/double' ,
1532 'patterns':[r".*: warning: in-class initializer for static data member of .+const (float|double)"] },
Marco Nelissen594375d2009-07-14 09:04:04 -07001533 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wpointer-arith',
1534 'description':'void* used in arithmetic' ,
1535 'patterns':[r".*: warning: pointer of type 'void \*' used in (arithmetic|subtraction)",
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001536 r".*: warning: arithmetic on .+ to void is a GNU extension.*Wpointer-arith",
Marco Nelissen594375d2009-07-14 09:04:04 -07001537 r".*: warning: wrong type argument to increment"] },
1538 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wsign-promo',
1539 'description':'Overload resolution chose to promote from unsigned or enum to signed type' ,
1540 'patterns':[r".*: warning: passing '.+' chooses 'int' over '.* int'"] },
1541 { 'category':'cont.', 'severity':severity.SKIP, 'members':[], 'option':'',
1542 'description':'',
1543 'patterns':[r".*: warning: in call to '.+'"] },
Marco Nelissen5236fbd2009-07-31 08:30:34 -07001544 { 'category':'C/C++', 'severity':severity.HIGH, 'members':[], 'option':'-Wextra',
1545 'description':'Base should be explicitly initialized in copy constructor',
1546 'patterns':[r".*: warning: base class '.+' should be explicitly initialized in the copy constructor"] },
1547 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
1548 'description':'Converting from <type> to <other type>',
1549 'patterns':[r".*: warning: converting to '.+' from '.+'"] },
Marco Nelissen8e201962010-03-10 16:16:02 -08001550 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001551 'description':'VLA has zero or negative size',
1552 'patterns':[r".*: warning: Declared variable-length array \(VLA\) has .+ size"] },
1553 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
Marco Nelissen8e201962010-03-10 16:16:02 -08001554 'description':'Return value from void function',
1555 'patterns':[r".*: warning: 'return' with a value, in function returning void"] },
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001556 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'multichar',
1557 'description':'Multi-character character constant',
1558 'patterns':[r".*: warning: multi-character character constant"] },
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001559 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'writable-strings',
1560 'description':'Conversion from string literal to char*',
1561 'patterns':[r".*: warning: .+ does not allow conversion from string literal to 'char \*'"] },
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001562 { 'category':'C/C++', 'severity':severity.LOW, 'members':[], 'option':'-Wextra-semi',
1563 'description':'Extra \';\'',
1564 'patterns':[r".*: warning: extra ';' .+extra-semi"] },
Marco Nelissen8e201962010-03-10 16:16:02 -08001565 { 'category':'C/C++', 'severity':severity.LOW, 'members':[], 'option':'',
1566 'description':'Useless specifier',
1567 'patterns':[r".*: warning: useless storage class specifier in empty declaration"] },
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001568 { 'category':'C/C++', 'severity':severity.LOW, 'members':[], 'option':'-Wduplicate-decl-specifier',
1569 'description':'Duplicate declaration specifier',
1570 'patterns':[r".*: warning: duplicate '.+' declaration specifier"] },
Marco Nelissen8e201962010-03-10 16:16:02 -08001571 { 'category':'logtags', 'severity':severity.LOW, 'members':[], 'option':'',
1572 'description':'Duplicate logtag',
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001573 'patterns':[r".*: warning: tag \".+\" \(.+\) duplicated in .+"] },
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001574 { 'category':'logtags', 'severity':severity.LOW, 'members':[], 'option':'typedef-redefinition',
1575 'description':'Typedef redefinition',
1576 'patterns':[r".*: warning: redefinition of typedef '.+' is a C11 feature"] },
1577 { 'category':'logtags', 'severity':severity.LOW, 'members':[], 'option':'gnu-designator',
1578 'description':'GNU old-style field designator',
1579 'patterns':[r".*: warning: use of GNU old-style field designator extension"] },
1580 { 'category':'logtags', 'severity':severity.LOW, 'members':[], 'option':'missing-field-initializers',
1581 'description':'Missing field initializers',
1582 'patterns':[r".*: warning: missing field '.+' initializer"] },
1583 { 'category':'logtags', 'severity':severity.LOW, 'members':[], 'option':'missing-braces',
1584 'description':'Missing braces',
1585 'patterns':[r".*: warning: suggest braces around initialization of",
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001586 r".*: warning: too many braces around scalar initializer .+Wmany-braces-around-scalar-init",
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001587 r".*: warning: braces around scalar initializer"] },
1588 { 'category':'logtags', 'severity':severity.LOW, 'members':[], 'option':'sign-compare',
1589 'description':'Comparison of integers of different signs',
1590 'patterns':[r".*: warning: comparison of integers of different signs.+sign-compare"] },
1591 { 'category':'logtags', 'severity':severity.LOW, 'members':[], 'option':'dangling-else',
1592 'description':'Add braces to avoid dangling else',
1593 'patterns':[r".*: warning: add explicit braces to avoid dangling else"] },
1594 { 'category':'logtags', 'severity':severity.LOW, 'members':[], 'option':'initializer-overrides',
1595 'description':'Initializer overrides prior initialization',
1596 'patterns':[r".*: warning: initializer overrides prior initialization of this subobject"] },
1597 { 'category':'logtags', 'severity':severity.LOW, 'members':[], 'option':'self-assign',
1598 'description':'Assigning value to self',
1599 'patterns':[r".*: warning: explicitly assigning value of .+ to itself"] },
1600 { 'category':'logtags', 'severity':severity.LOW, 'members':[], 'option':'gnu-variable-sized-type-not-at-end',
1601 'description':'GNU extension, variable sized type not at end',
1602 'patterns':[r".*: warning: field '.+' with variable sized type '.+' not at the end of a struct or class"] },
1603 { 'category':'logtags', 'severity':severity.LOW, 'members':[], 'option':'tautological-constant-out-of-range-compare',
1604 'description':'Comparison of constant is always false/true',
1605 'patterns':[r".*: comparison of .+ is always .+Wtautological-constant-out-of-range-compare"] },
1606 { 'category':'logtags', 'severity':severity.LOW, 'members':[], 'option':'overloaded-virtual',
1607 'description':'Hides overloaded virtual function',
1608 'patterns':[r".*: '.+' hides overloaded virtual function"] },
1609 { 'category':'logtags', 'severity':severity.LOW, 'members':[], 'option':'incompatible-pointer-types',
1610 'description':'Incompatible pointer types',
1611 'patterns':[r".*: warning: incompatible pointer types .+Wincompatible-pointer-types"] },
1612 { 'category':'logtags', 'severity':severity.LOW, 'members':[], 'option':'asm-operand-widths',
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001613 'description':'ASM value size does not match register size',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001614 'patterns':[r".*: warning: value size does not match register size specified by the constraint and modifier"] },
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001615 { 'category':'C/C++', 'severity':severity.LOW, 'members':[], 'option':'tautological-compare',
1616 'description':'Comparison of self is always false',
1617 'patterns':[r".*: self-comparison always evaluates to false"] },
1618 { 'category':'C/C++', 'severity':severity.LOW, 'members':[], 'option':'constant-logical-operand',
1619 'description':'Logical op with constant operand',
1620 'patterns':[r".*: use of logical '.+' with constant operand"] },
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001621 { 'category':'C/C++', 'severity':severity.LOW, 'members':[], 'option':'literal-suffix',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001622 'description':'Needs a space between literal and string macro',
1623 'patterns':[r".*: warning: invalid suffix on literal.+ requires a space .+Wliteral-suffix"] },
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001624 { 'category':'C/C++', 'severity':severity.LOW, 'members':[], 'option':'#warnings',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001625 'description':'Warnings from #warning',
1626 'patterns':[r".*: warning: .+-W#warnings"] },
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001627 { 'category':'C/C++', 'severity':severity.LOW, 'members':[], 'option':'absolute-value',
1628 'description':'Using float/int absolute value function with int/float argument',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001629 'patterns':[r".*: warning: using .+ absolute value function .+ when argument is .+ type .+Wabsolute-value",
1630 r".*: warning: absolute value function '.+' given .+ which may cause truncation .+Wabsolute-value"] },
1631 { 'category':'C/C++', 'severity':severity.LOW, 'members':[], 'option':'-Wc++11-extensions',
1632 'description':'Using C++11 extensions',
1633 'patterns':[r".*: warning: 'auto' type specifier is a C\+\+11 extension"] },
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001634 { 'category':'C/C++', 'severity':severity.LOW, 'members':[], 'option':'',
1635 'description':'Refers to implicitly defined namespace',
1636 'patterns':[r".*: warning: using directive refers to implicitly-defined namespace .+"] },
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001637 { 'category':'C/C++', 'severity':severity.LOW, 'members':[], 'option':'-Winvalid-pp-token',
1638 'description':'Invalid pp token',
1639 'patterns':[r".*: warning: missing .+Winvalid-pp-token"] },
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001640
Marco Nelissen8e201962010-03-10 16:16:02 -08001641 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
1642 'description':'Operator new returns NULL',
1643 'patterns':[r".*: warning: 'operator new' must not return NULL unless it is declared 'throw\(\)' .+"] },
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001644 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wnull-arithmetic',
Marco Nelissen8e201962010-03-10 16:16:02 -08001645 'description':'NULL used in arithmetic',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001646 'patterns':[r".*: warning: NULL used in arithmetic",
1647 r".*: warning: comparison between NULL and non-pointer"] },
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001648 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'header-guard',
1649 'description':'Misspelled header guard',
1650 'patterns':[r".*: warning: '.+' is used as a header guard .+ followed by .+ different macro"] },
1651 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'empty-body',
1652 'description':'Empty loop body',
1653 'patterns':[r".*: warning: .+ loop has empty body"] },
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001654 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'enum-conversion',
1655 'description':'Implicit conversion from enumeration type',
1656 'patterns':[r".*: warning: implicit conversion from enumeration type '.+'"] },
1657 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'switch',
1658 'description':'case value not in enumerated type',
1659 'patterns':[r".*: warning: case value not in enumerated type '.+'"] },
1660 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
1661 'description':'Undefined result',
1662 'patterns':[r".*: warning: The result of .+ is undefined",
1663 r".*: warning: 'this' pointer cannot be null in well-defined C\+\+ code;",
1664 r".*: warning: shifting a negative signed value is undefined"] },
1665 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
1666 'description':'Division by zero',
1667 'patterns':[r".*: warning: Division by zero"] },
Marco Nelissen8e201962010-03-10 16:16:02 -08001668 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
1669 'description':'Use of deprecated method',
1670 'patterns':[r".*: warning: '.+' is deprecated .+"] },
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001671 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
1672 'description':'Use of garbage or uninitialized value',
1673 'patterns':[r".*: warning: .+ is a garbage value",
1674 r".*: warning: Function call argument is an uninitialized value",
1675 r".*: warning: Undefined or garbage value returned to caller",
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001676 r".*: warning: Called .+ pointer is.+uninitialized",
1677 r".*: warning: Called .+ pointer is.+uninitalized", # match a typo in compiler message
1678 r".*: warning: Use of zero-allocated memory",
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001679 r".*: warning: Dereference of undefined pointer value",
1680 r".*: warning: Passed-by-value .+ contains uninitialized data",
1681 r".*: warning: Branch condition evaluates to a garbage value",
1682 r".*: warning: The .+ of .+ is an uninitialized value.",
1683 r".*: warning: .+ is used uninitialized whenever .+sometimes-uninitialized",
1684 r".*: warning: Assigned value is garbage or undefined"] },
1685 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
1686 'description':'Result of malloc type incompatible with sizeof operand type',
1687 'patterns':[r".*: warning: Result of '.+' is converted to .+ incompatible with sizeof operand type"] },
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001688 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wsizeof-array-argument',
1689 'description':'Sizeof on array argument',
1690 'patterns':[r".*: warning: sizeof on array function parameter will return"] },
1691 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wsizeof-pointer-memacces',
1692 'description':'Bad argument size of memory access functions',
1693 'patterns':[r".*: warning: .+\[-Wsizeof-pointer-memaccess\]"] },
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001694 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
1695 'description':'Return value not checked',
1696 'patterns':[r".*: warning: The return value from .+ is not checked"] },
1697 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
1698 'description':'Possible heap pollution',
1699 'patterns':[r".*: warning: .*Possible heap pollution from .+ type .+"] },
1700 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
1701 'description':'Allocation size of 0 byte',
1702 'patterns':[r".*: warning: Call to .+ has an allocation size of 0 byte"] },
1703 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
1704 'description':'Result of malloc type incompatible with sizeof operand type',
1705 'patterns':[r".*: warning: Result of '.+' is converted to .+ incompatible with sizeof operand type"] },
1706
1707 { 'category':'C/C++', 'severity':severity.HARMLESS, 'members':[], 'option':'',
1708 'description':'Discarded qualifier from pointer target type',
1709 'patterns':[r".*: warning: .+ discards '.+' qualifier from pointer target type"] },
1710 { 'category':'C/C++', 'severity':severity.HARMLESS, 'members':[], 'option':'',
1711 'description':'Use snprintf instead of sprintf',
1712 'patterns':[r".*: warning: .*sprintf is often misused; please use snprintf"] },
1713 { 'category':'C/C++', 'severity':severity.HARMLESS, 'members':[], 'option':'',
1714 'description':'Unsupported optimizaton flag',
1715 'patterns':[r".*: warning: optimization flag '.+' is not supported"] },
1716 { 'category':'C/C++', 'severity':severity.HARMLESS, 'members':[], 'option':'',
1717 'description':'Extra or missing parentheses',
1718 'patterns':[r".*: warning: equality comparison with extraneous parentheses",
1719 r".*: warning: .+ within .+Wlogical-op-parentheses"] },
1720 { 'category':'C/C++', 'severity':severity.HARMLESS, 'members':[], 'option':'mismatched-tags',
1721 'description':'Mismatched class vs struct tags',
1722 'patterns':[r".*: warning: '.+' defined as a .+ here but previously declared as a .+mismatched-tags",
1723 r".*: warning: .+ was previously declared as a .+mismatched-tags"] },
Marco Nelissen594375d2009-07-14 09:04:04 -07001724
1725 # these next ones are to deal with formatting problems resulting from the log being mixed up by 'make -j'
1726 { 'category':'C/C++', 'severity':severity.SKIP, 'members':[], 'option':'',
1727 'description':'',
1728 'patterns':[r".*: warning: ,$"] },
1729 { 'category':'C/C++', 'severity':severity.SKIP, 'members':[], 'option':'',
1730 'description':'',
1731 'patterns':[r".*: warning: $"] },
1732 { 'category':'C/C++', 'severity':severity.SKIP, 'members':[], 'option':'',
1733 'description':'',
1734 'patterns':[r".*: warning: In file included from .+,"] },
1735
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001736 # warnings from clang-tidy
1737 { 'category':'C/C++', 'severity':severity.TIDY, 'members':[], 'option':'',
1738 'description':'clang-tidy readability',
1739 'patterns':[r".*: .+\[readability-.+\]$"] },
1740 { 'category':'C/C++', 'severity':severity.TIDY, 'members':[], 'option':'',
1741 'description':'clang-tidy c++ core guidelines',
1742 'patterns':[r".*: .+\[cppcoreguidelines-.+\]$"] },
1743 { 'category':'C/C++', 'severity':severity.TIDY, 'members':[], 'option':'',
Chih-Hung Hsiehc21ddbd2016-07-20 10:08:51 -07001744 'description':'clang-tidy google-default-arguments',
1745 'patterns':[r".*: .+\[google-default-arguments\]$"] },
1746 { 'category':'C/C++', 'severity':severity.TIDY, 'members':[], 'option':'',
1747 'description':'clang-tidy google-runtime-int',
1748 'patterns':[r".*: .+\[google-runtime-int\]$"] },
1749 { 'category':'C/C++', 'severity':severity.TIDY, 'members':[], 'option':'',
1750 'description':'clang-tidy google-runtime-operator',
1751 'patterns':[r".*: .+\[google-runtime-operator\]$"] },
1752 { 'category':'C/C++', 'severity':severity.TIDY, 'members':[], 'option':'',
1753 'description':'clang-tidy google-runtime-references',
1754 'patterns':[r".*: .+\[google-runtime-references\]$"] },
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001755 { 'category':'C/C++', 'severity':severity.TIDY, 'members':[], 'option':'',
1756 'description':'clang-tidy google-build',
1757 'patterns':[r".*: .+\[google-build-.+\]$"] },
1758 { 'category':'C/C++', 'severity':severity.TIDY, 'members':[], 'option':'',
1759 'description':'clang-tidy google-explicit',
1760 'patterns':[r".*: .+\[google-explicit-.+\]$"] },
1761 { 'category':'C/C++', 'severity':severity.TIDY, 'members':[], 'option':'',
Chih-Hung Hsiehd742e902016-03-31 16:14:55 -07001762 'description':'clang-tidy google-readability',
1763 'patterns':[r".*: .+\[google-readability-.+\]$"] },
1764 { 'category':'C/C++', 'severity':severity.TIDY, 'members':[], 'option':'',
1765 'description':'clang-tidy google-global',
1766 'patterns':[r".*: .+\[google-global-.+\]$"] },
1767 { 'category':'C/C++', 'severity':severity.TIDY, 'members':[], 'option':'',
Chih-Hung Hsiehc21ddbd2016-07-20 10:08:51 -07001768 'description':'clang-tidy google- other',
1769 'patterns':[r".*: .+\[google-.+\]$"] },
1770 { 'category':'C/C++', 'severity':severity.TIDY, 'members':[], 'option':'',
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001771 'description':'clang-tidy modernize',
1772 'patterns':[r".*: .+\[modernize-.+\]$"] },
1773 { 'category':'C/C++', 'severity':severity.TIDY, 'members':[], 'option':'',
1774 'description':'clang-tidy misc',
1775 'patterns':[r".*: .+\[misc-.+\]$"] },
1776 { 'category':'C/C++', 'severity':severity.TIDY, 'members':[], 'option':'',
Chih-Hung Hsiehc8682932016-07-26 14:27:03 -07001777 'description':'clang-tidy performance-faster-string-find',
1778 'patterns':[r".*: .+\[performance-faster-string-find\]$"] },
1779 { 'category':'C/C++', 'severity':severity.TIDY, 'members':[], 'option':'',
1780 'description':'clang-tidy performance-for-range-copy',
1781 'patterns':[r".*: .+\[performance-for-range-copy\]$"] },
1782 { 'category':'C/C++', 'severity':severity.TIDY, 'members':[], 'option':'',
1783 'description':'clang-tidy performance-implicit-cast-in-loop',
1784 'patterns':[r".*: .+\[performance-implicit-cast-in-loop\]$"] },
1785 { 'category':'C/C++', 'severity':severity.TIDY, 'members':[], 'option':'',
1786 'description':'clang-tidy performance-unnecessary-copy-initialization',
1787 'patterns':[r".*: .+\[performance-unnecessary-copy-initialization\]$"] },
1788 { 'category':'C/C++', 'severity':severity.TIDY, 'members':[], 'option':'',
1789 'description':'clang-tidy performance-unnecessary-value-param',
1790 'patterns':[r".*: .+\[performance-unnecessary-value-param\]$"] },
1791 { 'category':'C/C++', 'severity':severity.TIDY, 'members':[], 'option':'',
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001792 'description':'clang-tidy CERT',
1793 'patterns':[r".*: .+\[cert-.+\]$"] },
1794 { 'category':'C/C++', 'severity':severity.TIDY, 'members':[], 'option':'',
1795 'description':'clang-tidy llvm',
1796 'patterns':[r".*: .+\[llvm-.+\]$"] },
1797 { 'category':'C/C++', 'severity':severity.TIDY, 'members':[], 'option':'',
1798 'description':'clang-tidy clang-diagnostic',
1799 'patterns':[r".*: .+\[clang-diagnostic-.+\]$"] },
1800 { 'category':'C/C++', 'severity':severity.TIDY, 'members':[], 'option':'',
1801 'description':'clang-tidy clang-analyzer',
1802 'patterns':[r".*: .+\[clang-analyzer-.+\]$",
1803 r".*: Call Path : .+$"] },
1804
Marco Nelissen594375d2009-07-14 09:04:04 -07001805 # catch-all for warnings this script doesn't know about yet
1806 { 'category':'C/C++', 'severity':severity.UNKNOWN, 'members':[], 'option':'',
1807 'description':'Unclassified/unrecognized warnings',
1808 'patterns':[r".*: warning: .+"] },
1809]
1810
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001811# A list of [project_name, file_path_pattern].
1812# project_name should not contain comma, to be used in CSV output.
1813projectlist = [
1814 ['art', r"(^|.*/)art/.*: warning:"],
1815 ['bionic', r"(^|.*/)bionic/.*: warning:"],
1816 ['bootable', r"(^|.*/)bootable/.*: warning:"],
1817 ['build', r"(^|.*/)build/.*: warning:"],
1818 ['cts', r"(^|.*/)cts/.*: warning:"],
1819 ['dalvik', r"(^|.*/)dalvik/.*: warning:"],
1820 ['developers', r"(^|.*/)developers/.*: warning:"],
1821 ['development', r"(^|.*/)development/.*: warning:"],
1822 ['device', r"(^|.*/)device/.*: warning:"],
1823 ['doc', r"(^|.*/)doc/.*: warning:"],
1824 ['external', r"(^|.*/)external/.*: warning:"],
1825 ['frameworks', r"(^|.*/)frameworks/.*: warning:"],
1826 ['hardware', r"(^|.*/)hardware/.*: warning:"],
1827 ['kernel', r"(^|.*/)kernel/.*: warning:"],
1828 ['libcore', r"(^|.*/)libcore/.*: warning:"],
1829 ['libnativehelper', r"(^|.*/)libnativehelper/.*: warning:"],
1830 ['ndk', r"(^|.*/)ndk/.*: warning:"],
1831 ['packages', r"(^|.*/)packages/.*: warning:"],
1832 ['pdk', r"(^|.*/)pdk/.*: warning:"],
1833 ['prebuilts', r"(^|.*/)prebuilts/.*: warning:"],
1834 ['system', r"(^|.*/)system/.*: warning:"],
1835 ['toolchain', r"(^|.*/)toolchain/.*: warning:"],
1836 ['test', r"(^|.*/)test/.*: warning:"],
1837 ['tools', r"(^|.*/)tools/.*: warning:"],
1838 ['vendor', r"(^|.*/)vendor/.*: warning:"],
1839 ['out/obj', r".*/(gen|obj[^/]*)/(include|EXECUTABLES|SHARED_LIBRARIES|STATIC_LIBRARIES)/.*: warning:"],
1840 ['other', r".*: warning:"],
1841]
1842
1843projectpatterns = []
1844for p in projectlist:
1845 projectpatterns.append({'description':p[0], 'members':[], 'pattern':re.compile(p[1])})
1846
1847# Each warning pattern has a dictionary that maps
1848# a project name to number of warnings in that project.
1849for w in warnpatterns:
1850 w['projects'] = {}
1851
1852platformversion = 'unknown'
1853targetproduct = 'unknown'
1854targetvariant = 'unknown'
1855
1856
1857##### Data and functions to dump html file. ##################################
1858
Marco Nelissen594375d2009-07-14 09:04:04 -07001859anchor = 0
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07001860cur_row_class = 0
1861
1862html_script_style = """\
1863 <script type="text/javascript">
1864 function expand(id) {
1865 var e = document.getElementById(id);
1866 var f = document.getElementById(id + "_mark");
1867 if (e.style.display == 'block') {
1868 e.style.display = 'none';
1869 f.innerHTML = '&#x2295';
1870 }
1871 else {
1872 e.style.display = 'block';
1873 f.innerHTML = '&#x2296';
1874 }
1875 };
1876 function expand_collapse(show) {
1877 for (var id = 1; ; id++) {
1878 var e = document.getElementById(id + "");
1879 var f = document.getElementById(id + "_mark");
1880 if (!e || !f) break;
1881 e.style.display = (show ? 'block' : 'none');
1882 f.innerHTML = (show ? '&#x2296' : '&#x2295');
1883 }
1884 };
1885 </script>
1886 <style type="text/css">
1887 table,th,td{border-collapse:collapse; width:100%;}
1888 .button{color:blue;font-size:110%;font-weight:bolder;}
1889 .bt{color:black;background-color:transparent;border:none;outline:none;
1890 font-size:140%;font-weight:bolder;}
1891 .c0{background-color:#e0e0e0;}
1892 .c1{background-color:#d0d0d0;}
1893 </style>\n"""
1894
Marco Nelissen594375d2009-07-14 09:04:04 -07001895
1896def output(text):
1897 print text,
1898
1899def htmlbig(param):
1900 return '<font size="+2">' + param + '</font>'
1901
1902def dumphtmlprologue(title):
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07001903 output('<html>\n<head>\n')
1904 output('<title>' + title + '</title>\n')
1905 output(html_script_style)
1906 output('</head>\n<body>\n')
Marco Nelissen594375d2009-07-14 09:04:04 -07001907 output(htmlbig(title))
1908 output('<p>\n')
1909
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07001910def dumphtmlepilogue():
1911 output('</body>\n</head>\n</html>\n')
1912
Marco Nelissen594375d2009-07-14 09:04:04 -07001913def tablerow(text):
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07001914 global cur_row_class
1915 output('<tr><td class="c' + str(cur_row_class) + '">')
1916 cur_row_class = 1 - cur_row_class
1917 output(text)
1918 output('</td></tr>')
Marco Nelissen594375d2009-07-14 09:04:04 -07001919
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001920def sortwarnings():
1921 for i in warnpatterns:
1922 i['members'] = sorted(set(i['members']))
1923
Marco Nelissen594375d2009-07-14 09:04:04 -07001924# dump some stats about total number of warnings and such
1925def dumpstats():
1926 known = 0
1927 unknown = 0
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001928 sortwarnings()
Marco Nelissen594375d2009-07-14 09:04:04 -07001929 for i in warnpatterns:
1930 if i['severity'] == severity.UNKNOWN:
1931 unknown += len(i['members'])
1932 elif i['severity'] != severity.SKIP:
1933 known += len(i['members'])
Chih-Hung Hsieha9be47e2016-03-21 14:11:03 -07001934 output('\nNumber of classified warnings: <b>' + str(known) + '</b><br>' )
1935 output('\nNumber of unclassified warnings: <b>' + str(unknown) + '</b><br>')
Marco Nelissen594375d2009-07-14 09:04:04 -07001936 total = unknown + known
Chih-Hung Hsieha9be47e2016-03-21 14:11:03 -07001937 output('\nTotal number of warnings: <b>' + str(total) + '</b>')
Marco Nelissen594375d2009-07-14 09:04:04 -07001938 if total < 1000:
1939 output('(low count may indicate incremental build)')
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07001940 output('<br><br>\n')
1941 output('<button class="button" onclick="expand_collapse(1);">' +
1942 'Expand all warnings</button> ' +
1943 '<button class="button" onclick="expand_collapse(0);">' +
1944 'Collapse all warnings</button>')
1945 output('<br>\n')
Chih-Hung Hsieha9be47e2016-03-21 14:11:03 -07001946
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07001947# dump everything for a given severity
1948def dumpseverity(sev):
1949 global anchor
1950 output('\n<br><span style="background-color:' + colorforseverity(sev) + '"><b>' +
1951 headerforseverity(sev) + ':</b></span>\n')
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001952 output('<blockquote>\n')
Chih-Hung Hsieha9be47e2016-03-21 14:11:03 -07001953 for i in warnpatterns:
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07001954 if i['severity'] == sev and len(i['members']) > 0:
1955 output('\n<table frame="box">\n')
1956 anchor += 1
1957 i['anchor'] = str(anchor)
1958 mark = str(anchor) + '_mark'
1959 output('<tr bgcolor="' + colorforseverity(sev) + '">' +
1960 '<td><button class="bt" id="' + mark +
1961 '" onclick="expand(\'' + str(anchor) + '\');">' +
1962 '&#x2295</button> ' + descriptionfor(i) +
1963 ' (' + str(len(i['members'])) + ')</td></tr>\n')
1964 output('</table>\n')
1965 dumpcategory(i)
1966 output('</blockquote>\n')
Marco Nelissen594375d2009-07-14 09:04:04 -07001967
1968def allpatterns(cat):
1969 pats = ''
1970 for i in cat['patterns']:
1971 pats += i
1972 pats += ' / '
1973 return pats
1974
1975def descriptionfor(cat):
1976 if cat['description'] != '':
1977 return cat['description']
1978 return allpatterns(cat)
1979
1980
1981# show which warnings no longer occur
1982def dumpfixed():
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07001983 global anchor
1984 anchor += 1
1985 mark = str(anchor) + '_mark'
1986 output('\n<br><p style="background-color:lightblue"><b>' +
1987 '<button id="' + mark + '" ' +
1988 'class="bt" onclick="expand(' + str(anchor) + ');">' +
1989 '&#x2295</button> Fixed warnings. ' +
1990 'No more occurences. Please consider turning these into ' +
1991 'errors if possible, before they are reintroduced in to the build' +
1992 ':</b></p>\n')
1993 output('<blockquote>\n')
1994 fixed_patterns = []
Marco Nelissen594375d2009-07-14 09:04:04 -07001995 for i in warnpatterns:
1996 if len(i['members']) == 0 and i['severity'] != severity.SKIP:
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07001997 fixed_patterns.append(i['description'] + ' (' +
1998 allpatterns(i) + ') ' + i['option'])
1999 fixed_patterns.sort()
2000 output('<div id="' + str(anchor) + '" style="display:none;"><table>\n')
2001 for i in fixed_patterns:
2002 tablerow(i)
2003 output('</table></div>\n')
2004 output('</blockquote>\n')
Marco Nelissen594375d2009-07-14 09:04:04 -07002005
Ian Rogersf3829732016-05-10 12:06:01 -07002006def warningwithurl(line):
2007 if not args.url:
2008 return line
2009 m = re.search( r'^([^ :]+):(\d+):(.+)', line, re.M|re.I)
2010 if not m:
2011 return line
2012 filepath = m.group(1)
2013 linenumber = m.group(2)
2014 warning = m.group(3)
2015 if args.separator:
2016 return '<a href="' + args.url + '/' + filepath + args.separator + linenumber + '">' + filepath + ':' + linenumber + '</a>:' + warning
2017 else:
2018 return '<a href="' + args.url + '/' + filepath + '">' + filepath + '</a>:' + linenumber + ':' + warning
Marco Nelissen594375d2009-07-14 09:04:04 -07002019
2020# dump a category, provided it is not marked as 'SKIP' and has more than 0 occurrences
2021def dumpcategory(cat):
2022 if cat['severity'] != severity.SKIP and len(cat['members']) != 0:
2023 header = [descriptionfor(cat),str(len(cat['members'])) + ' occurences:']
2024 if cat['option'] != '':
2025 header[1:1] = [' (related option: ' + cat['option'] +')']
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07002026
2027 output('<div id="' + cat['anchor'] + '" style="display:none;">')
2028 output('<table>\n')
Marco Nelissen594375d2009-07-14 09:04:04 -07002029 for i in cat['members']:
Ian Rogersf3829732016-05-10 12:06:01 -07002030 tablerow(warningwithurl(i))
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07002031 output('</table></div>\n')
Marco Nelissen594375d2009-07-14 09:04:04 -07002032
2033
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002034def findproject(line):
2035 for p in projectpatterns:
2036 if p['pattern'].match(line):
2037 return p['description']
2038 return '???'
2039
Marco Nelissen594375d2009-07-14 09:04:04 -07002040def classifywarning(line):
2041 for i in warnpatterns:
Marco Nelissen2bdc7ec2009-09-29 10:19:29 -07002042 for cpat in i['compiledpatterns']:
2043 if cpat.match(line):
Marco Nelissen594375d2009-07-14 09:04:04 -07002044 i['members'].append(line)
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002045 pname = findproject(line)
2046 if pname in i['projects']:
2047 i['projects'][pname] += 1
2048 else:
2049 i['projects'][pname] = 1
Marco Nelissen594375d2009-07-14 09:04:04 -07002050 return
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002051 else:
2052 # If we end up here, there was a problem parsing the log
2053 # probably caused by 'make -j' mixing the output from
2054 # 2 or more concurrent compiles
2055 pass
Marco Nelissen594375d2009-07-14 09:04:04 -07002056
Marco Nelissen2bdc7ec2009-09-29 10:19:29 -07002057# precompiling every pattern speeds up parsing by about 30x
2058def compilepatterns():
2059 for i in warnpatterns:
2060 i['compiledpatterns'] = []
2061 for pat in i['patterns']:
2062 i['compiledpatterns'].append(re.compile(pat))
Marco Nelissen594375d2009-07-14 09:04:04 -07002063
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002064def parseinputfile():
2065 global platformversion
2066 global targetproduct
2067 global targetvariant
2068 infile = open(args.buildlog, 'r')
2069 linecounter = 0
Marco Nelissen594375d2009-07-14 09:04:04 -07002070
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002071 warningpattern = re.compile('.* warning:.*')
2072 compilepatterns()
Marco Nelissen594375d2009-07-14 09:04:04 -07002073
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002074 # read the log file and classify all the warnings
2075 warninglines = set()
2076 for line in infile:
2077 # replace fancy quotes with plain ol' quotes
2078 line = line.replace("‘", "'");
2079 line = line.replace("’", "'");
2080 if warningpattern.match(line):
2081 if line not in warninglines:
2082 classifywarning(line)
2083 warninglines.add(line)
2084 else:
2085 # save a little bit of time by only doing this for the first few lines
2086 if linecounter < 50:
2087 linecounter +=1
2088 m = re.search('(?<=^PLATFORM_VERSION=).*', line)
2089 if m != None:
2090 platformversion = m.group(0)
2091 m = re.search('(?<=^TARGET_PRODUCT=).*', line)
2092 if m != None:
2093 targetproduct = m.group(0)
2094 m = re.search('(?<=^TARGET_BUILD_VARIANT=).*', line)
2095 if m != None:
2096 targetvariant = m.group(0)
Marco Nelissen594375d2009-07-14 09:04:04 -07002097
2098
2099# dump the html output to stdout
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002100def dumphtml():
2101 dumphtmlprologue('Warnings for ' + platformversion + ' - ' + targetproduct + ' - ' + targetvariant)
2102 dumpstats()
2103 # sort table based on number of members once dumpstats has deduplicated the
2104 # members.
2105 warnpatterns.sort(reverse=True, key=lambda i: len(i['members']))
2106 dumpseverity(severity.FIXMENOW)
2107 dumpseverity(severity.HIGH)
2108 dumpseverity(severity.MEDIUM)
2109 dumpseverity(severity.LOW)
2110 dumpseverity(severity.TIDY)
2111 dumpseverity(severity.HARMLESS)
2112 dumpseverity(severity.UNKNOWN)
2113 dumpfixed()
2114 dumphtmlepilogue()
2115
2116
2117##### Functions to count warnings and dump csv file. #########################
2118
2119def descriptionforcsv(cat):
2120 if cat['description'] == '':
2121 return '?'
2122 return cat['description']
2123
2124def stringforcsv(s):
2125 if ',' in s:
2126 return '"{}"'.format(s)
2127 return s
2128
2129def countseverity(sev, kind):
2130 sum = 0
2131 for i in warnpatterns:
2132 if i['severity'] == sev and len(i['members']) > 0:
2133 n = len(i['members'])
2134 sum += n
2135 warning = stringforcsv(kind + ': ' + descriptionforcsv(i))
2136 print '{},,{}'.format(n, warning)
2137 # print number of warnings for each project, ordered by project name.
2138 projects = i['projects'].keys()
2139 projects.sort()
2140 for p in projects:
2141 print '{},{},{}'.format(i['projects'][p], p, warning)
2142 print '{},,{}'.format(sum, kind + ' warnings')
2143 return sum
2144
2145# dump number of warnings in csv format to stdout
2146def dumpcsv():
2147 sortwarnings()
2148 total = 0
2149 total += countseverity(severity.FIXMENOW, 'FixNow')
2150 total += countseverity(severity.HIGH, 'High')
2151 total += countseverity(severity.MEDIUM, 'Medium')
2152 total += countseverity(severity.LOW, 'Low')
2153 total += countseverity(severity.TIDY, 'Tidy')
2154 total += countseverity(severity.HARMLESS, 'Harmless')
2155 total += countseverity(severity.UNKNOWN, 'Unknown')
2156 print '{},,{}'.format(total, 'All warnings')
2157
2158
2159parseinputfile()
2160if args.gencsv:
2161 dumpcsv()
2162else:
2163 dumphtml()