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