blob: dc6aacd1aed094f37e41ba90a16a7c908338b404 [file] [log] [blame]
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001#!/usr/bin/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
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07004"""Grep warnings messages and output HTML tables or warning counts in CSV.
5
6Default is to output warnings in HTML tables grouped by warning severity.
7Use option --byproject to output tables grouped by source file projects.
8Use option --gencsv to output warning counts in CSV format.
9"""
10
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -070011# List of important data structures and functions in this script.
12#
13# To parse and keep warning message in the input file:
14# severity: classification of message severity
15# severity.range [0, 1, ... last_severity_level]
16# severity.colors for header background
17# severity.column_headers for the warning count table
18# severity.headers for warning message tables
19# warn_patterns:
20# warn_patterns[w]['category'] tool that issued the warning, not used now
21# warn_patterns[w]['description'] table heading
22# warn_patterns[w]['members'] matched warnings from input
23# warn_patterns[w]['option'] compiler flag to control the warning
24# warn_patterns[w]['patterns'] regular expressions to match warnings
25# warn_patterns[w]['projects'][p] number of warnings of pattern w in p
26# warn_patterns[w]['severity'] severity level
27# project_list[p][0] project name
28# project_list[p][1] regular expression to match a project path
29# project_patterns[p] re.compile(project_list[p][1])
30# project_names[p] project_list[p][0]
31# warning_messages array of each warning message, without source url
32# warning_records array of [idx to warn_patterns,
33# idx to project_names,
34# idx to warning_messages]
35# platform_version
36# target_product
37# target_variant
38# compile_patterns, parse_input_file
39#
40# To emit html page of warning messages:
41# flags: --byproject, --url, --separator
42# Old stuff for static html components:
43# html_script_style: static html scripts and styles
44# htmlbig:
45# dump_stats, dump_html_prologue, dump_html_epilogue:
46# emit_buttons:
47# dump_fixed
48# sort_warnings:
49# emit_stats_by_project:
50# all_patterns,
51# findproject, classify_warning
52# dump_html
53#
54# New dynamic HTML page's static JavaScript data:
55# Some data are copied from Python to JavaScript, to generate HTML elements.
56# FlagURL args.url
57# FlagSeparator args.separator
58# SeverityColors: severity.colors
59# SeverityHeaders: severity.headers
60# SeverityColumnHeaders: severity.column_headers
61# ProjectNames: project_names, or project_list[*][0]
62# WarnPatternsSeverity: warn_patterns[*]['severity']
63# WarnPatternsDescription: warn_patterns[*]['description']
64# WarnPatternsOption: warn_patterns[*]['option']
65# WarningMessages: warning_messages
66# Warnings: warning_records
67# StatsHeader: warning count table header row
68# StatsRows: array of warning count table rows
69#
70# New dynamic HTML page's dynamic JavaScript data:
71#
72# New dynamic HTML related function to emit data:
73# escape_string, strip_escape_string, emit_warning_arrays
74# emit_js_data():
75#
76# To emit csv files of warning message counts:
77# flag --gencsv
78# description_for_csv, string_for_csv:
79# count_severity(sev, kind):
80# dump_csv():
81
Ian Rogersf3829732016-05-10 12:06:01 -070082import argparse
Marco Nelissen594375d2009-07-14 09:04:04 -070083import re
84
Ian Rogersf3829732016-05-10 12:06:01 -070085parser = argparse.ArgumentParser(description='Convert a build log into HTML')
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -070086parser.add_argument('--gencsv',
87 help='Generate a CSV file with number of various warnings',
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -070088 action='store_true',
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -070089 default=False)
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -070090parser.add_argument('--byproject',
91 help='Separate warnings in HTML output by project names',
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -070092 action='store_true',
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -070093 default=False)
Ian Rogersf3829732016-05-10 12:06:01 -070094parser.add_argument('--url',
95 help='Root URL of an Android source code tree prefixed '
96 'before files in warnings')
97parser.add_argument('--separator',
98 help='Separator between the end of a URL and the line '
99 'number argument. e.g. #')
100parser.add_argument(dest='buildlog', metavar='build.log',
101 help='Path to build.log file')
102args = parser.parse_args()
Marco Nelissen594375d2009-07-14 09:04:04 -0700103
Marco Nelissen594375d2009-07-14 09:04:04 -0700104
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700105class Severity(object):
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700106 """Severity levels and attributes."""
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -0700107 # numbered by dump order
108 FIXMENOW = 0
109 HIGH = 1
110 MEDIUM = 2
111 LOW = 3
112 TIDY = 4
113 HARMLESS = 5
114 UNKNOWN = 6
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700115 SKIP = 7
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -0700116 range = range(8)
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700117 attributes = [
118 # pylint:disable=bad-whitespace
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700119 ['fuchsia', 'FixNow', 'Critical warnings, fix me now'],
120 ['red', 'High', 'High severity warnings'],
121 ['orange', 'Medium', 'Medium severity warnings'],
122 ['yellow', 'Low', 'Low severity warnings'],
123 ['peachpuff', 'Tidy', 'Clang-Tidy warnings'],
124 ['limegreen', 'Harmless', 'Harmless warnings'],
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -0700125 ['lightblue', 'Unknown', 'Unknown warnings'],
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700126 ['grey', 'Unhandled', 'Unhandled warnings']
127 ]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -0700128 colors = [a[0] for a in attributes]
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700129 column_headers = [a[1] for a in attributes]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -0700130 headers = [a[2] for a in attributes]
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700131
132warn_patterns = [
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700133 # pylint:disable=line-too-long,g-inconsistent-quotes
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700134 {'category': 'make', 'severity': Severity.MEDIUM,
135 'description': 'make: overriding commands/ignoring old commands',
136 'patterns': [r".*: warning: overriding commands for target .+",
137 r".*: warning: ignoring old commands for target .+"]},
138 {'category': 'make', 'severity': Severity.HIGH,
139 'description': 'make: LOCAL_CLANG is false',
140 'patterns': [r".*: warning: LOCAL_CLANG is set to false"]},
141 {'category': 'make', 'severity': Severity.HIGH,
142 'description': 'SDK App using platform shared library',
143 'patterns': [r".*: warning: .+ \(.*app:sdk.*\) should not link to .+ \(native:platform\)"]},
144 {'category': 'make', 'severity': Severity.HIGH,
145 'description': 'System module linking to a vendor module',
146 'patterns': [r".*: warning: .+ \(.+\) should not link to .+ \(partition:.+\)"]},
147 {'category': 'make', 'severity': Severity.MEDIUM,
148 'description': 'Invalid SDK/NDK linking',
149 'patterns': [r".*: warning: .+ \(.+\) should not link to .+ \(.+\)"]},
150 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wimplicit-function-declaration',
151 'description': 'Implicit function declaration',
152 'patterns': [r".*: warning: implicit declaration of function .+",
153 r".*: warning: implicitly declaring library function"]},
154 {'category': 'C/C++', 'severity': Severity.SKIP,
155 'description': 'skip, conflicting types for ...',
156 'patterns': [r".*: warning: conflicting types for '.+'"]},
157 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wtype-limits',
158 'description': 'Expression always evaluates to true or false',
159 'patterns': [r".*: warning: comparison is always .+ due to limited range of data type",
160 r".*: warning: comparison of unsigned .*expression .+ is always true",
161 r".*: warning: comparison of unsigned .*expression .+ is always false"]},
162 {'category': 'C/C++', 'severity': Severity.HIGH,
163 'description': 'Potential leak of memory, bad free, use after free',
164 'patterns': [r".*: warning: Potential leak of memory",
165 r".*: warning: Potential memory leak",
166 r".*: warning: Memory allocated by alloca\(\) should not be deallocated",
167 r".*: warning: Memory allocated by .+ should be deallocated by .+ not .+",
168 r".*: warning: 'delete' applied to a pointer that was allocated",
169 r".*: warning: Use of memory after it is freed",
170 r".*: warning: Argument to .+ is the address of .+ variable",
171 r".*: warning: Argument to free\(\) is offset by .+ of memory allocated by",
172 r".*: warning: Attempt to .+ released memory"]},
173 {'category': 'C/C++', 'severity': Severity.HIGH,
174 'description': 'Use transient memory for control value',
175 'patterns': [r".*: warning: .+Using such transient memory for the control value is .*dangerous."]},
176 {'category': 'C/C++', 'severity': Severity.HIGH,
177 'description': 'Return address of stack memory',
178 'patterns': [r".*: warning: Address of stack memory .+ returned to caller",
179 r".*: warning: Address of stack memory .+ will be a dangling reference"]},
180 {'category': 'C/C++', 'severity': Severity.HIGH,
181 'description': 'Problem with vfork',
182 'patterns': [r".*: warning: This .+ is prohibited after a successful vfork",
183 r".*: warning: Call to function '.+' is insecure "]},
184 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': 'infinite-recursion',
185 'description': 'Infinite recursion',
186 'patterns': [r".*: warning: all paths through this function will call itself"]},
187 {'category': 'C/C++', 'severity': Severity.HIGH,
188 'description': 'Potential buffer overflow',
189 'patterns': [r".*: warning: Size argument is greater than .+ the destination buffer",
190 r".*: warning: Potential buffer overflow.",
191 r".*: warning: String copy function overflows destination buffer"]},
192 {'category': 'C/C++', 'severity': Severity.MEDIUM,
193 'description': 'Incompatible pointer types',
194 'patterns': [r".*: warning: assignment from incompatible pointer type",
195 r".*: warning: return from incompatible pointer type",
196 r".*: warning: passing argument [0-9]+ of '.*' from incompatible pointer type",
197 r".*: warning: initialization from incompatible pointer type"]},
198 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-fno-builtin',
199 'description': 'Incompatible declaration of built in function',
200 'patterns': [r".*: warning: incompatible implicit declaration of built-in function .+"]},
201 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wincompatible-library-redeclaration',
202 'description': 'Incompatible redeclaration of library function',
203 'patterns': [r".*: warning: incompatible redeclaration of library function .+"]},
204 {'category': 'C/C++', 'severity': Severity.HIGH,
205 'description': 'Null passed as non-null argument',
206 'patterns': [r".*: warning: Null passed to a callee that requires a non-null"]},
207 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused-parameter',
208 'description': 'Unused parameter',
209 'patterns': [r".*: warning: unused parameter '.*'"]},
210 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused',
211 'description': 'Unused function, variable or label',
212 'patterns': [r".*: warning: '.+' defined but not used",
213 r".*: warning: unused function '.+'",
214 r".*: warning: private field '.+' is not used",
215 r".*: warning: unused variable '.+'"]},
216 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused-value',
217 'description': 'Statement with no effect or result unused',
218 'patterns': [r".*: warning: statement with no effect",
219 r".*: warning: expression result unused"]},
220 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused-result',
221 'description': 'Ignoreing return value of function',
222 'patterns': [r".*: warning: ignoring return value of function .+Wunused-result"]},
223 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-field-initializers',
224 'description': 'Missing initializer',
225 'patterns': [r".*: warning: missing initializer"]},
226 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wdelete-non-virtual-dtor',
227 'description': 'Need virtual destructor',
228 'patterns': [r".*: warning: delete called .* has virtual functions but non-virtual destructor"]},
229 {'category': 'cont.', 'severity': Severity.SKIP,
230 'description': 'skip, near initialization for ...',
231 'patterns': [r".*: warning: \(near initialization for '.+'\)"]},
232 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wdate-time',
233 'description': 'Expansion of data or time macro',
234 'patterns': [r".*: warning: expansion of date or time macro is not reproducible"]},
235 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wformat',
236 'description': 'Format string does not match arguments',
237 'patterns': [r".*: warning: format '.+' expects type '.+', but argument [0-9]+ has type '.+'",
238 r".*: warning: more '%' conversions than data arguments",
239 r".*: warning: data argument not used by format string",
240 r".*: warning: incomplete format specifier",
241 r".*: warning: unknown conversion type .* in format",
242 r".*: warning: format .+ expects .+ but argument .+Wformat=",
243 r".*: warning: field precision should have .+ but argument has .+Wformat",
244 r".*: warning: format specifies type .+ but the argument has .*type .+Wformat"]},
245 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wformat-extra-args',
246 'description': 'Too many arguments for format string',
247 'patterns': [r".*: warning: too many arguments for format"]},
248 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wformat-invalid-specifier',
249 'description': 'Invalid format specifier',
250 'patterns': [r".*: warning: invalid .+ specifier '.+'.+format-invalid-specifier"]},
251 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsign-compare',
252 'description': 'Comparison between signed and unsigned',
253 'patterns': [r".*: warning: comparison between signed and unsigned",
254 r".*: warning: comparison of promoted \~unsigned with unsigned",
255 r".*: warning: signed and unsigned type in conditional expression"]},
256 {'category': 'C/C++', 'severity': Severity.MEDIUM,
257 'description': 'Comparison between enum and non-enum',
258 'patterns': [r".*: warning: enumeral and non-enumeral type in conditional expression"]},
259 {'category': 'libpng', 'severity': Severity.MEDIUM,
260 'description': 'libpng: zero area',
261 'patterns': [r".*libpng warning: Ignoring attempt to set cHRM RGB triangle with zero area"]},
262 {'category': 'aapt', 'severity': Severity.MEDIUM,
263 'description': 'aapt: no comment for public symbol',
264 'patterns': [r".*: warning: No comment for public symbol .+"]},
265 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-braces',
266 'description': 'Missing braces around initializer',
267 'patterns': [r".*: warning: missing braces around initializer.*"]},
268 {'category': 'C/C++', 'severity': Severity.HARMLESS,
269 'description': 'No newline at end of file',
270 'patterns': [r".*: warning: no newline at end of file"]},
271 {'category': 'C/C++', 'severity': Severity.HARMLESS,
272 'description': 'Missing space after macro name',
273 'patterns': [r".*: warning: missing whitespace after the macro name"]},
274 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wcast-align',
275 'description': 'Cast increases required alignment',
276 'patterns': [r".*: warning: cast from .* to .* increases required alignment .*"]},
277 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wcast-qual',
278 'description': 'Qualifier discarded',
279 'patterns': [r".*: warning: passing argument [0-9]+ of '.+' discards qualifiers from pointer target type",
280 r".*: warning: assignment discards qualifiers from pointer target type",
281 r".*: warning: passing .+ to parameter of type .+ discards qualifiers",
282 r".*: warning: assigning to .+ from .+ discards qualifiers",
283 r".*: warning: initializing .+ discards qualifiers .+types-discards-qualifiers",
284 r".*: warning: return discards qualifiers from pointer target type"]},
285 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunknown-attributes',
286 'description': 'Unknown attribute',
287 'patterns': [r".*: warning: unknown attribute '.+'"]},
288 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wignored-attributes',
289 'description': 'Attribute ignored',
290 'patterns': [r".*: warning: '_*packed_*' attribute ignored",
291 r".*: warning: attribute declaration must precede definition .+ignored-attributes"]},
292 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wvisibility',
293 'description': 'Visibility problem',
294 'patterns': [r".*: warning: declaration of '.+' will not be visible outside of this function"]},
295 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wattributes',
296 'description': 'Visibility mismatch',
297 'patterns': [r".*: warning: '.+' declared with greater visibility than the type of its field '.+'"]},
298 {'category': 'C/C++', 'severity': Severity.MEDIUM,
299 'description': 'Shift count greater than width of type',
300 'patterns': [r".*: warning: (left|right) shift count >= width of type"]},
301 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wextern-initializer',
302 'description': 'extern <foo> is initialized',
303 'patterns': [r".*: warning: '.+' initialized and declared 'extern'",
304 r".*: warning: 'extern' variable has an initializer"]},
305 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wold-style-declaration',
306 'description': 'Old style declaration',
307 'patterns': [r".*: warning: 'static' is not at beginning of declaration"]},
308 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wreturn-type',
309 'description': 'Missing return value',
310 'patterns': [r".*: warning: control reaches end of non-void function"]},
311 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wimplicit-int',
312 'description': 'Implicit int type',
313 'patterns': [r".*: warning: type specifier missing, defaults to 'int'",
314 r".*: warning: type defaults to 'int' in declaration of '.+'"]},
315 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmain-return-type',
316 'description': 'Main function should return int',
317 'patterns': [r".*: warning: return type of 'main' is not 'int'"]},
318 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wuninitialized',
319 'description': 'Variable may be used uninitialized',
320 'patterns': [r".*: warning: '.+' may be used uninitialized in this function"]},
321 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wuninitialized',
322 'description': 'Variable is used uninitialized',
323 'patterns': [r".*: warning: '.+' is used uninitialized in this function",
324 r".*: warning: variable '.+' is uninitialized when used here"]},
325 {'category': 'ld', 'severity': Severity.MEDIUM, 'option': '-fshort-enums',
326 'description': 'ld: possible enum size mismatch',
327 'patterns': [r".*: warning: .* uses variable-size enums yet the output is to use 32-bit enums; use of enum values across objects may fail"]},
328 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wpointer-sign',
329 'description': 'Pointer targets differ in signedness',
330 'patterns': [r".*: warning: pointer targets in initialization differ in signedness",
331 r".*: warning: pointer targets in assignment differ in signedness",
332 r".*: warning: pointer targets in return differ in signedness",
333 r".*: warning: pointer targets in passing argument [0-9]+ of '.+' differ in signedness"]},
334 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wstrict-overflow',
335 'description': 'Assuming overflow does not occur',
336 'patterns': [r".*: warning: assuming signed overflow does not occur when assuming that .* is always (true|false)"]},
337 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wempty-body',
338 'description': 'Suggest adding braces around empty body',
339 'patterns': [r".*: warning: suggest braces around empty body in an 'if' statement",
340 r".*: warning: empty body in an if-statement",
341 r".*: warning: suggest braces around empty body in an 'else' statement",
342 r".*: warning: empty body in an else-statement"]},
343 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wparentheses',
344 'description': 'Suggest adding parentheses',
345 'patterns': [r".*: warning: suggest explicit braces to avoid ambiguous 'else'",
346 r".*: warning: suggest parentheses around arithmetic in operand of '.+'",
347 r".*: warning: suggest parentheses around comparison in operand of '.+'",
348 r".*: warning: logical not is only applied to the left hand side of this comparison",
349 r".*: warning: using the result of an assignment as a condition without parentheses",
350 r".*: warning: .+ has lower precedence than .+ be evaluated first .+Wparentheses",
351 r".*: warning: suggest parentheses around '.+?' .+ '.+?'",
352 r".*: warning: suggest parentheses around assignment used as truth value"]},
353 {'category': 'C/C++', 'severity': Severity.MEDIUM,
354 'description': 'Static variable used in non-static inline function',
355 'patterns': [r".*: warning: '.+' is static but used in inline function '.+' which is not static"]},
356 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wimplicit int',
357 'description': 'No type or storage class (will default to int)',
358 'patterns': [r".*: warning: data definition has no type or storage class"]},
359 {'category': 'C/C++', 'severity': Severity.MEDIUM,
360 'description': 'Null pointer',
361 'patterns': [r".*: warning: Dereference of null pointer",
362 r".*: warning: Called .+ pointer is null",
363 r".*: warning: Forming reference to null pointer",
364 r".*: warning: Returning null reference",
365 r".*: warning: Null pointer passed as an argument to a 'nonnull' parameter",
366 r".*: warning: .+ results in a null pointer dereference",
367 r".*: warning: Access to .+ results in a dereference of a null pointer",
368 r".*: warning: Null pointer argument in"]},
369 {'category': 'cont.', 'severity': Severity.SKIP,
370 'description': 'skip, parameter name (without types) in function declaration',
371 'patterns': [r".*: warning: parameter names \(without types\) in function declaration"]},
372 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wstrict-aliasing',
373 'description': 'Dereferencing <foo> breaks strict aliasing rules',
374 'patterns': [r".*: warning: dereferencing .* break strict-aliasing rules"]},
375 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wpointer-to-int-cast',
376 'description': 'Cast from pointer to integer of different size',
377 'patterns': [r".*: warning: cast from pointer to integer of different size",
378 r".*: warning: initialization makes pointer from integer without a cast"]},
379 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wint-to-pointer-cast',
380 'description': 'Cast to pointer from integer of different size',
381 'patterns': [r".*: warning: cast to pointer from integer of different size"]},
382 {'category': 'C/C++', 'severity': Severity.MEDIUM,
383 'description': 'Symbol redefined',
384 'patterns': [r".*: warning: "".+"" redefined"]},
385 {'category': 'cont.', 'severity': Severity.SKIP,
386 'description': 'skip, ... location of the previous definition',
387 'patterns': [r".*: warning: this is the location of the previous definition"]},
388 {'category': 'ld', 'severity': Severity.MEDIUM,
389 'description': 'ld: type and size of dynamic symbol are not defined',
390 'patterns': [r".*: warning: type and size of dynamic symbol `.+' are not defined"]},
391 {'category': 'C/C++', 'severity': Severity.MEDIUM,
392 'description': 'Pointer from integer without cast',
393 'patterns': [r".*: warning: assignment makes pointer from integer without a cast"]},
394 {'category': 'C/C++', 'severity': Severity.MEDIUM,
395 'description': 'Pointer from integer without cast',
396 'patterns': [r".*: warning: passing argument [0-9]+ of '.+' makes pointer from integer without a cast"]},
397 {'category': 'C/C++', 'severity': Severity.MEDIUM,
398 'description': 'Integer from pointer without cast',
399 'patterns': [r".*: warning: assignment makes integer from pointer without a cast"]},
400 {'category': 'C/C++', 'severity': Severity.MEDIUM,
401 'description': 'Integer from pointer without cast',
402 'patterns': [r".*: warning: passing argument [0-9]+ of '.+' makes integer from pointer without a cast"]},
403 {'category': 'C/C++', 'severity': Severity.MEDIUM,
404 'description': 'Integer from pointer without cast',
405 'patterns': [r".*: warning: return makes integer from pointer without a cast"]},
406 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunknown-pragmas',
407 'description': 'Ignoring pragma',
408 'patterns': [r".*: warning: ignoring #pragma .+"]},
409 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-W#pragma-messages',
410 'description': 'Pragma warning messages',
411 'patterns': [r".*: warning: .+W#pragma-messages"]},
412 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wclobbered',
413 'description': 'Variable might be clobbered by longjmp or vfork',
414 'patterns': [r".*: warning: variable '.+' might be clobbered by 'longjmp' or 'vfork'"]},
415 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wclobbered',
416 'description': 'Argument might be clobbered by longjmp or vfork',
417 'patterns': [r".*: warning: argument '.+' might be clobbered by 'longjmp' or 'vfork'"]},
418 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wredundant-decls',
419 'description': 'Redundant declaration',
420 'patterns': [r".*: warning: redundant redeclaration of '.+'"]},
421 {'category': 'cont.', 'severity': Severity.SKIP,
422 'description': 'skip, previous declaration ... was here',
423 'patterns': [r".*: warning: previous declaration of '.+' was here"]},
424 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wswitch-enum',
425 'description': 'Enum value not handled in switch',
426 'patterns': [r".*: warning: .*enumeration value.* not handled in switch.+Wswitch"]},
427 {'category': 'java', 'severity': Severity.MEDIUM, 'option': '-encoding',
428 'description': 'Java: Non-ascii characters used, but ascii encoding specified',
429 'patterns': [r".*: warning: unmappable character for encoding ascii"]},
430 {'category': 'java', 'severity': Severity.MEDIUM,
431 'description': 'Java: Non-varargs call of varargs method with inexact argument type for last parameter',
432 'patterns': [r".*: warning: non-varargs call of varargs method with inexact argument type for last parameter"]},
433 {'category': 'java', 'severity': Severity.MEDIUM,
434 'description': 'Java: Unchecked method invocation',
435 'patterns': [r".*: warning: \[unchecked\] unchecked method invocation: .+ in class .+"]},
436 {'category': 'java', 'severity': Severity.MEDIUM,
437 'description': 'Java: Unchecked conversion',
438 'patterns': [r".*: warning: \[unchecked\] unchecked conversion"]},
439 {'category': 'java', 'severity': Severity.MEDIUM,
440 'description': '_ used as an identifier',
441 'patterns': [r".*: warning: '_' used as an identifier"]},
Ian Rogers32bb9bd2016-05-09 23:19:42 -0700442
Ian Rogers6e520032016-05-13 08:59:00 -0700443 # Warnings from Error Prone.
444 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700445 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700446 'description': 'Java: Use of deprecated member',
447 'patterns': [r'.*: warning: \[deprecation\] .+']},
448 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700449 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700450 'description': 'Java: Unchecked conversion',
451 'patterns': [r'.*: warning: \[unchecked\] .+']},
Ian Rogers32bb9bd2016-05-09 23:19:42 -0700452
Ian Rogers6e520032016-05-13 08:59:00 -0700453 # Warnings from Error Prone (auto generated list).
454 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700455 'severity': Severity.LOW,
Ian Rogers6e520032016-05-13 08:59:00 -0700456 'description':
457 'Java: Deprecated item is not annotated with @Deprecated',
458 'patterns': [r".*: warning: \[DepAnn\] .+"]},
459 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700460 'severity': Severity.LOW,
Ian Rogers6e520032016-05-13 08:59:00 -0700461 'description':
462 'Java: Fallthrough warning suppression has no effect if warning is suppressed',
463 'patterns': [r".*: warning: \[FallthroughSuppression\] .+"]},
464 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700465 'severity': Severity.LOW,
Ian Rogers6e520032016-05-13 08:59:00 -0700466 'description':
467 'Java: Prefer \'L\' to \'l\' for the suffix to long literals',
468 'patterns': [r".*: warning: \[LongLiteralLowerCaseSuffix\] .+"]},
469 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700470 'severity': Severity.LOW,
Ian Rogers6e520032016-05-13 08:59:00 -0700471 'description':
472 'Java: @Binds is a more efficient and declaritive mechanism for delegating a binding.',
473 'patterns': [r".*: warning: \[UseBinds\] .+"]},
474 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700475 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700476 'description':
477 'Java: Assertions may be disabled at runtime and do not guarantee that execution will halt here; consider throwing an exception instead',
478 'patterns': [r".*: warning: \[AssertFalse\] .+"]},
479 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700480 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700481 'description':
482 'Java: Classes that implement Annotation must override equals and hashCode. Consider using AutoAnnotation instead of implementing Annotation by hand.',
483 'patterns': [r".*: warning: \[BadAnnotationImplementation\] .+"]},
484 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700485 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700486 'description':
487 'Java: BigDecimal(double) and BigDecimal.valueOf(double) may lose precision, prefer BigDecimal(String) or BigDecimal(long)',
488 'patterns': [r".*: warning: \[BigDecimalLiteralDouble\] .+"]},
489 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700490 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700491 'description':
492 'Java: Mockito cannot mock final classes',
493 'patterns': [r".*: warning: \[CannotMockFinalClass\] .+"]},
494 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700495 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700496 'description':
497 'Java: This code, which counts elements using a loop, can be replaced by a simpler library method',
498 'patterns': [r".*: warning: \[ElementsCountedInLoop\] .+"]},
499 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700500 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700501 'description':
502 'Java: Empty top-level type declaration',
503 'patterns': [r".*: warning: \[EmptyTopLevelDeclaration\] .+"]},
504 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700505 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700506 'description':
507 'Java: Classes that override equals should also override hashCode.',
508 'patterns': [r".*: warning: \[EqualsHashCode\] .+"]},
509 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700510 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700511 'description':
512 'Java: An equality test between objects with incompatible types always returns false',
513 'patterns': [r".*: warning: \[EqualsIncompatibleType\] .+"]},
514 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700515 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700516 'description':
517 '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.',
518 'patterns': [r".*: warning: \[Finally\] .+"]},
519 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700520 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700521 'description':
522 'Java: This annotation has incompatible modifiers as specified by its @IncompatibleModifiers annotation',
523 'patterns': [r".*: warning: \[IncompatibleModifiers\] .+"]},
524 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700525 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700526 'description':
527 'Java: Class should not implement both `Iterable` and `Iterator`',
528 'patterns': [r".*: warning: \[IterableAndIterator\] .+"]},
529 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700530 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700531 'description':
532 'Java: Floating-point comparison without error tolerance',
533 'patterns': [r".*: warning: \[JUnit3FloatingPointComparisonWithoutDelta\] .+"]},
534 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700535 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700536 'description':
537 'Java: Test class inherits from JUnit 3\'s TestCase but has JUnit 4 @Test annotations.',
538 'patterns': [r".*: warning: \[JUnitAmbiguousTestClass\] .+"]},
539 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700540 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700541 'description':
542 'Java: Enum switch statement is missing cases',
543 'patterns': [r".*: warning: \[MissingCasesInEnumSwitch\] .+"]},
544 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700545 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700546 'description':
547 'Java: Not calling fail() when expecting an exception masks bugs',
548 'patterns': [r".*: warning: \[MissingFail\] .+"]},
549 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700550 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700551 'description':
552 'Java: method overrides method in supertype; expected @Override',
553 'patterns': [r".*: warning: \[MissingOverride\] .+"]},
554 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700555 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700556 'description':
557 'Java: Source files should not contain multiple top-level class declarations',
558 'patterns': [r".*: warning: \[MultipleTopLevelClasses\] .+"]},
559 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700560 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700561 'description':
562 'Java: This update of a volatile variable is non-atomic',
563 'patterns': [r".*: warning: \[NonAtomicVolatileUpdate\] .+"]},
564 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700565 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700566 'description':
567 'Java: Static import of member uses non-canonical name',
568 'patterns': [r".*: warning: \[NonCanonicalStaticMemberImport\] .+"]},
569 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700570 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700571 'description':
572 'Java: equals method doesn\'t override Object.equals',
573 'patterns': [r".*: warning: \[NonOverridingEquals\] .+"]},
574 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700575 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700576 'description':
577 'Java: Constructors should not be annotated with @Nullable since they cannot return null',
578 'patterns': [r".*: warning: \[NullableConstructor\] .+"]},
579 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700580 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700581 'description':
582 'Java: @Nullable should not be used for primitive types since they cannot be null',
583 'patterns': [r".*: warning: \[NullablePrimitive\] .+"]},
584 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700585 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700586 'description':
587 'Java: void-returning methods should not be annotated with @Nullable, since they cannot return null',
588 'patterns': [r".*: warning: \[NullableVoid\] .+"]},
589 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700590 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700591 'description':
592 'Java: Package names should match the directory they are declared in',
593 'patterns': [r".*: warning: \[PackageLocation\] .+"]},
594 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700595 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700596 'description':
597 'Java: Second argument to Preconditions.* is a call to String.format(), which can be unwrapped',
598 'patterns': [r".*: warning: \[PreconditionsErrorMessageEagerEvaluation\] .+"]},
599 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700600 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700601 'description':
602 'Java: Preconditions only accepts the %s placeholder in error message strings',
603 'patterns': [r".*: warning: \[PreconditionsInvalidPlaceholder\] .+"]},
604 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700605 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700606 'description':
607 'Java: Passing a primitive array to a varargs method is usually wrong',
608 'patterns': [r".*: warning: \[PrimitiveArrayPassedToVarargsMethod\] .+"]},
609 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700610 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700611 'description':
612 'Java: Protobuf fields cannot be null, so this check is redundant',
613 'patterns': [r".*: warning: \[ProtoFieldPreconditionsCheckNotNull\] .+"]},
614 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700615 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700616 'description':
617 'Java: This annotation is missing required modifiers as specified by its @RequiredModifiers annotation',
618 'patterns': [r".*: warning: \[RequiredModifiers\] .+"]},
619 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700620 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700621 'description':
622 'Java: A static variable or method should not be accessed from an object instance',
623 'patterns': [r".*: warning: \[StaticAccessedFromInstance\] .+"]},
624 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700625 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700626 'description':
627 'Java: String comparison using reference equality instead of value equality',
628 'patterns': [r".*: warning: \[StringEquality\] .+"]},
629 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700630 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700631 'description':
632 '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.',
633 'patterns': [r".*: warning: \[TypeParameterUnusedInFormals\] .+"]},
634 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700635 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700636 'description':
637 'Java: Using static imports for types is unnecessary',
638 'patterns': [r".*: warning: \[UnnecessaryStaticImport\] .+"]},
639 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700640 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700641 'description':
642 'Java: Unsynchronized method overrides a synchronized method.',
643 'patterns': [r".*: warning: \[UnsynchronizedOverridesSynchronized\] .+"]},
644 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700645 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700646 'description':
647 'Java: Non-constant variable missing @Var annotation',
648 'patterns': [r".*: warning: \[Var\] .+"]},
649 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700650 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700651 'description':
652 'Java: Because of spurious wakeups, Object.wait() and Condition.await() must always be called in a loop',
653 'patterns': [r".*: warning: \[WaitNotInLoop\] .+"]},
654 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700655 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700656 'description':
657 'Java: Subclasses of Fragment must be instantiable via Class#newInstance(): the class must be public, static and have a public nullary constructor',
658 'patterns': [r".*: warning: \[FragmentNotInstantiable\] .+"]},
659 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700660 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700661 'description':
662 'Java: Hardcoded reference to /sdcard',
663 'patterns': [r".*: warning: \[HardCodedSdCardPath\] .+"]},
664 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700665 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700666 'description':
667 'Java: Incompatible type as argument to Object-accepting Java collections method',
668 'patterns': [r".*: warning: \[CollectionIncompatibleType\] .+"]},
669 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700670 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700671 'description':
672 'Java: @AssistedInject and @Inject should not be used on different constructors in the same class.',
673 'patterns': [r".*: warning: \[AssistedInjectAndInjectOnConstructors\] .+"]},
674 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700675 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700676 'description':
677 'Java: Although Guice allows injecting final fields, doing so is not recommended because the injected value may not be visible to other threads.',
678 'patterns': [r".*: warning: \[GuiceInjectOnFinalField\] .+"]},
679 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700680 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700681 'description':
682 '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.',
683 'patterns': [r".*: warning: \[OverridesGuiceInjectableMethod\] .+"]},
684 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700685 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700686 'description':
687 'Java: Double-checked locking on non-volatile fields is unsafe',
688 'patterns': [r".*: warning: \[DoubleCheckedLocking\] .+"]},
689 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700690 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700691 'description':
692 'Java: Writes to static fields should not be guarded by instance locks',
693 'patterns': [r".*: warning: \[StaticGuardedByInstance\] .+"]},
694 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700695 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700696 'description':
697 'Java: Synchronizing on non-final fields is not safe: if the field is ever updated, different threads may end up locking on different objects.',
698 'patterns': [r".*: warning: \[SynchronizeOnNonFinalField\] .+"]},
699 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700700 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700701 'description':
702 'Java: Reference equality used to compare arrays',
703 'patterns': [r".*: warning: \[ArrayEquals\] .+"]},
704 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700705 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700706 'description':
707 'Java: hashcode method on array does not hash array contents',
708 'patterns': [r".*: warning: \[ArrayHashCode\] .+"]},
709 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700710 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700711 'description':
712 'Java: Calling toString on an array does not provide useful information',
713 'patterns': [r".*: warning: \[ArrayToString.*\] .+"]},
714 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700715 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700716 'description':
717 'Java: Arrays.asList does not autobox primitive arrays, as one might expect.',
718 'patterns': [r".*: warning: \[ArraysAsListPrimitiveArray\] .+"]},
719 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700720 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700721 'description':
722 'Java: AsyncCallable should not return a null Future, only a Future whose result is null.',
723 'patterns': [r".*: warning: \[AsyncCallableReturnsNull\] .+"]},
724 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700725 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700726 'description':
727 'Java: AsyncFunction should not return a null Future, only a Future whose result is null.',
728 'patterns': [r".*: warning: \[AsyncFunctionReturnsNull\] .+"]},
729 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700730 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700731 'description':
732 'Java: Possible sign flip from narrowing conversion',
733 'patterns': [r".*: warning: \[BadComparable\] .+"]},
734 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700735 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700736 'description':
737 'Java: Shift by an amount that is out of range',
738 'patterns': [r".*: warning: \[BadShiftAmount\] .+"]},
739 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700740 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700741 'description':
742 'Java: valueOf provides better time and space performance',
743 'patterns': [r".*: warning: \[BoxedPrimitiveConstructor\] .+"]},
744 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700745 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700746 'description':
747 '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.',
748 'patterns': [r".*: warning: \[ChainingConstructorIgnoresParameter\] .+"]},
749 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700750 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700751 'description':
752 'Java: Ignored return value of method that is annotated with @CheckReturnValue',
753 'patterns': [r".*: warning: \[CheckReturnValue\] .+"]},
754 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700755 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700756 'description':
757 'Java: Inner class is non-static but does not reference enclosing class',
758 'patterns': [r".*: warning: \[ClassCanBeStatic\] .+"]},
759 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700760 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700761 'description':
762 'Java: The source file name should match the name of the top-level class it contains',
763 'patterns': [r".*: warning: \[ClassName\] .+"]},
764 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700765 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700766 'description':
767 'Java: This comparison method violates the contract',
768 'patterns': [r".*: warning: \[ComparisonContractViolated\] .+"]},
769 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700770 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700771 'description':
772 'Java: Comparison to value that is out of range for the compared type',
773 'patterns': [r".*: warning: \[ComparisonOutOfRange\] .+"]},
774 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700775 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700776 'description':
777 'Java: Non-compile-time constant expression passed to parameter with @CompileTimeConstant type annotation.',
778 'patterns': [r".*: warning: \[CompileTimeConstant\] .+"]},
779 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700780 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700781 'description':
782 'Java: Exception created but not thrown',
783 'patterns': [r".*: warning: \[DeadException\] .+"]},
784 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700785 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700786 'description':
787 'Java: Division by integer literal zero',
788 'patterns': [r".*: warning: \[DivZero\] .+"]},
789 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700790 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700791 'description':
792 'Java: Empty statement after if',
793 'patterns': [r".*: warning: \[EmptyIf\] .+"]},
794 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700795 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700796 'description':
797 'Java: == NaN always returns false; use the isNaN methods instead',
798 'patterns': [r".*: warning: \[EqualsNaN\] .+"]},
799 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700800 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700801 'description':
802 'Java: Method annotated @ForOverride must be protected or package-private and only invoked from declaring class',
803 'patterns': [r".*: warning: \[ForOverride\] .+"]},
804 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700805 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700806 'description':
807 'Java: Futures.getChecked requires a checked exception type with a standard constructor.',
808 'patterns': [r".*: warning: \[FuturesGetCheckedIllegalExceptionType\] .+"]},
809 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700810 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700811 'description':
812 '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',
813 'patterns': [r".*: warning: \[GetClassOnClass\] .+"]},
814 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700815 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700816 'description':
817 'Java: An object is tested for equality to itself using Guava Libraries',
818 'patterns': [r".*: warning: \[GuavaSelfEquals\] .+"]},
819 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700820 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700821 'description':
822 'Java: contains() is a legacy method that is equivalent to containsValue()',
823 'patterns': [r".*: warning: \[HashtableContains\] .+"]},
824 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700825 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700826 'description':
827 'Java: Cipher.getInstance() is invoked using either the default settings or ECB mode',
828 'patterns': [r".*: warning: \[InsecureCipherMode\] .+"]},
829 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700830 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700831 'description':
832 'Java: Invalid syntax used for a regular expression',
833 'patterns': [r".*: warning: \[InvalidPatternSyntax\] .+"]},
834 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700835 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700836 'description':
837 'Java: The argument to Class#isInstance(Object) should not be a Class',
838 'patterns': [r".*: warning: \[IsInstanceOfClass\] .+"]},
839 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700840 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700841 'description':
842 'Java: jMock tests must have a @RunWith(JMock.class) annotation, or the Mockery field must have a @Rule JUnit annotation',
843 'patterns': [r".*: warning: \[JMockTestWithoutRunWithOrRuleAnnotation\] .+"]},
844 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700845 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700846 'description':
847 'Java: Test method will not be run; please prefix name with "test"',
848 'patterns': [r".*: warning: \[JUnit3TestNotRun\] .+"]},
849 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700850 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700851 'description':
852 'Java: setUp() method will not be run; Please add a @Before annotation',
853 'patterns': [r".*: warning: \[JUnit4SetUpNotRun\] .+"]},
854 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700855 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700856 'description':
857 'Java: tearDown() method will not be run; Please add an @After annotation',
858 'patterns': [r".*: warning: \[JUnit4TearDownNotRun\] .+"]},
859 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700860 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700861 'description':
862 'Java: Test method will not be run; please add @Test annotation',
863 'patterns': [r".*: warning: \[JUnit4TestNotRun\] .+"]},
864 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700865 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700866 'description':
867 'Java: Printf-like format string does not match its arguments',
868 'patterns': [r".*: warning: \[MalformedFormatString\] .+"]},
869 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700870 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700871 'description':
872 'Java: Use of "YYYY" (week year) in a date pattern without "ww" (week in year). You probably meant to use "yyyy" (year) instead.',
873 'patterns': [r".*: warning: \[MisusedWeekYear\] .+"]},
874 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700875 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700876 'description':
877 'Java: A bug in Mockito will cause this test to fail at runtime with a ClassCastException',
878 'patterns': [r".*: warning: \[MockitoCast\] .+"]},
879 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700880 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700881 'description':
882 'Java: Missing method call for verify(mock) here',
883 'patterns': [r".*: warning: \[MockitoUsage\] .+"]},
884 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700885 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700886 'description':
887 'Java: Modifying a collection with itself',
888 'patterns': [r".*: warning: \[ModifyingCollectionWithItself\] .+"]},
889 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700890 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700891 'description':
892 'Java: Compound assignments to bytes, shorts, chars, and floats hide dangerous casts',
893 'patterns': [r".*: warning: \[NarrowingCompoundAssignment\] .+"]},
894 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700895 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700896 'description':
897 'Java: @NoAllocation was specified on this method, but something was found that would trigger an allocation',
898 'patterns': [r".*: warning: \[NoAllocation\] .+"]},
899 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700900 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700901 'description':
902 'Java: Static import of type uses non-canonical name',
903 'patterns': [r".*: warning: \[NonCanonicalStaticImport\] .+"]},
904 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700905 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700906 'description':
907 'Java: @CompileTimeConstant parameters should be final',
908 'patterns': [r".*: warning: \[NonFinalCompileTimeConstant\] .+"]},
909 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700910 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700911 'description':
912 'Java: Calling getAnnotation on an annotation that is not retained at runtime.',
913 'patterns': [r".*: warning: \[NonRuntimeAnnotation\] .+"]},
914 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700915 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700916 'description':
917 'Java: Numeric comparison using reference equality instead of value equality',
918 'patterns': [r".*: warning: \[NumericEquality\] .+"]},
919 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700920 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700921 'description':
922 'Java: Comparison using reference equality instead of value equality',
923 'patterns': [r".*: warning: \[OptionalEquality\] .+"]},
924 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700925 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700926 'description':
927 'Java: Varargs doesn\'t agree for overridden method',
928 'patterns': [r".*: warning: \[Overrides\] .+"]},
929 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700930 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700931 'description':
932 'Java: Literal passed as first argument to Preconditions.checkNotNull() can never be null',
933 'patterns': [r".*: warning: \[PreconditionsCheckNotNull\] .+"]},
934 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700935 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700936 'description':
937 'Java: First argument to `Preconditions.checkNotNull()` is a primitive rather than an object reference',
938 'patterns': [r".*: warning: \[PreconditionsCheckNotNullPrimitive\] .+"]},
939 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700940 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700941 'description':
942 'Java: Protobuf fields cannot be null',
943 'patterns': [r".*: warning: \[ProtoFieldNullComparison\] .+"]},
944 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700945 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700946 'description':
947 'Java: Comparing protobuf fields of type String using reference equality',
948 'patterns': [r".*: warning: \[ProtoStringFieldReferenceEquality\] .+"]},
949 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700950 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700951 'description':
952 'Java: Check for non-whitelisted callers to RestrictedApiChecker.',
953 'patterns': [r".*: warning: \[RestrictedApiChecker\] .+"]},
954 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700955 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700956 'description':
957 'Java: Return value of this method must be used',
958 'patterns': [r".*: warning: \[ReturnValueIgnored\] .+"]},
959 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700960 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700961 'description':
962 'Java: Variable assigned to itself',
963 'patterns': [r".*: warning: \[SelfAssignment\] .+"]},
964 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700965 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700966 'description':
967 'Java: An object is compared to itself',
968 'patterns': [r".*: warning: \[SelfComparision\] .+"]},
969 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700970 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700971 'description':
972 'Java: Variable compared to itself',
973 'patterns': [r".*: warning: \[SelfEquality\] .+"]},
974 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700975 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700976 'description':
977 'Java: An object is tested for equality to itself',
978 'patterns': [r".*: warning: \[SelfEquals\] .+"]},
979 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700980 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700981 'description':
982 'Java: Comparison of a size >= 0 is always true, did you intend to check for non-emptiness?',
983 'patterns': [r".*: warning: \[SizeGreaterThanOrEqualsZero\] .+"]},
984 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700985 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700986 'description':
987 'Java: Calling toString on a Stream does not provide useful information',
988 'patterns': [r".*: warning: \[StreamToString\] .+"]},
989 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700990 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700991 'description':
992 'Java: StringBuilder does not have a char constructor; this invokes the int constructor.',
993 'patterns': [r".*: warning: \[StringBuilderInitWithChar\] .+"]},
994 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700995 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700996 'description':
997 'Java: Suppressing "deprecated" is probably a typo for "deprecation"',
998 'patterns': [r".*: warning: \[SuppressWarningsDeprecated\] .+"]},
999 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001000 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001001 'description':
1002 'Java: throwIfUnchecked(knownCheckedException) is a no-op.',
1003 'patterns': [r".*: warning: \[ThrowIfUncheckedKnownChecked\] .+"]},
1004 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001005 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001006 'description':
1007 'Java: Catching Throwable/Error masks failures from fail() or assert*() in the try block',
1008 'patterns': [r".*: warning: \[TryFailThrowable\] .+"]},
1009 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001010 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001011 'description':
1012 'Java: Type parameter used as type qualifier',
1013 'patterns': [r".*: warning: \[TypeParameterQualifier\] .+"]},
1014 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001015 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001016 'description':
1017 'Java: Non-generic methods should not be invoked with type arguments',
1018 'patterns': [r".*: warning: \[UnnecessaryTypeArgument\] .+"]},
1019 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001020 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001021 'description':
1022 'Java: Instance created but never used',
1023 'patterns': [r".*: warning: \[UnusedAnonymousClass\] .+"]},
1024 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001025 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001026 'description':
1027 'Java: Use of wildcard imports is forbidden',
1028 'patterns': [r".*: warning: \[WildcardImport\] .+"]},
1029 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001030 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001031 'description':
1032 'Java: Method parameter has wrong package',
1033 'patterns': [r".*: warning: \[ParameterPackage\] .+"]},
1034 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001035 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001036 'description':
1037 'Java: Certain resources in `android.R.string` have names that do not match their content',
1038 'patterns': [r".*: warning: \[MislabeledAndroidString\] .+"]},
1039 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001040 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001041 'description':
1042 'Java: Return value of android.graphics.Rect.intersect() must be checked',
1043 'patterns': [r".*: warning: \[RectIntersectReturnValueIgnored\] .+"]},
1044 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001045 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001046 'description':
1047 'Java: Invalid printf-style format string',
1048 'patterns': [r".*: warning: \[FormatString\] .+"]},
1049 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001050 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001051 'description':
1052 'Java: @AssistedInject and @Inject cannot be used on the same constructor.',
1053 'patterns': [r".*: warning: \[AssistedInjectAndInjectOnSameConstructor\] .+"]},
1054 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001055 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001056 'description':
1057 'Java: Injected constructors cannot be optional nor have binding annotations',
1058 'patterns': [r".*: warning: \[InjectedConstructorAnnotations\] .+"]},
1059 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001060 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001061 'description':
1062 'Java: The target of a scoping annotation must be set to METHOD and/or TYPE.',
1063 'patterns': [r".*: warning: \[InjectInvalidTargetingOnScopingAnnotation\] .+"]},
1064 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001065 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001066 'description':
1067 'Java: Abstract methods are not injectable with javax.inject.Inject.',
1068 'patterns': [r".*: warning: \[JavaxInjectOnAbstractMethod\] .+"]},
1069 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001070 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001071 'description':
1072 'Java: @javax.inject.Inject cannot be put on a final field.',
1073 'patterns': [r".*: warning: \[JavaxInjectOnFinalField\] .+"]},
1074 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001075 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001076 'description':
1077 'Java: A class may not have more than one injectable constructor.',
1078 'patterns': [r".*: warning: \[MoreThanOneInjectableConstructor\] .+"]},
1079 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001080 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001081 'description':
1082 'Java: Using more than one qualifier annotation on the same element is not allowed.',
1083 'patterns': [r".*: warning: \[InjectMoreThanOneQualifier\] .+"]},
1084 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001085 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001086 'description':
1087 'Java: A class can be annotated with at most one scope annotation',
1088 'patterns': [r".*: warning: \[InjectMoreThanOneScopeAnnotationOnClass\] .+"]},
1089 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001090 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001091 'description':
1092 'Java: Annotations cannot be both Qualifiers/BindingAnnotations and Scopes',
1093 'patterns': [r".*: warning: \[OverlappingQualifierAndScopeAnnotation\] .+"]},
1094 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001095 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001096 'description':
1097 'Java: Scope annotation on an interface or abstact class is not allowed',
1098 'patterns': [r".*: warning: \[InjectScopeAnnotationOnInterfaceOrAbstractClass\] .+"]},
1099 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001100 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001101 'description':
1102 'Java: Scoping and qualifier annotations must have runtime retention.',
1103 'patterns': [r".*: warning: \[InjectScopeOrQualifierAnnotationRetention\] .+"]},
1104 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001105 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001106 'description':
1107 'Java: Dagger @Provides methods may not return null unless annotated with @Nullable',
1108 'patterns': [r".*: warning: \[DaggerProvidesNull\] .+"]},
1109 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001110 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001111 'description':
1112 'Java: Scope annotation on implementation class of AssistedInject factory is not allowed',
1113 'patterns': [r".*: warning: \[GuiceAssistedInjectScoping\] .+"]},
1114 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001115 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001116 'description':
1117 'Java: A constructor cannot have two @Assisted parameters of the same type unless they are disambiguated with named @Assisted annotations. ',
1118 'patterns': [r".*: warning: \[GuiceAssistedParameters\] .+"]},
1119 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001120 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001121 'description':
1122 'Java: This method is not annotated with @Inject, but it overrides a method that is annotated with @javax.inject.Inject.',
1123 'patterns': [r".*: warning: \[OverridesJavaxInjectableMethod\] .+"]},
1124 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001125 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001126 'description':
1127 'Java: Checks for unguarded accesses to fields and methods with @GuardedBy annotations',
1128 'patterns': [r".*: warning: \[GuardedByChecker\] .+"]},
1129 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001130 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001131 'description':
1132 'Java: Invalid @GuardedBy expression',
1133 'patterns': [r".*: warning: \[GuardedByValidator\] .+"]},
1134 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001135 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001136 'description':
1137 'Java: Type declaration annotated with @Immutable is not immutable',
1138 'patterns': [r".*: warning: \[Immutable\] .+"]},
1139 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001140 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001141 'description':
1142 'Java: This method does not acquire the locks specified by its @LockMethod annotation',
1143 'patterns': [r".*: warning: \[LockMethodChecker\] .+"]},
1144 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001145 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001146 'description':
1147 'Java: This method does not acquire the locks specified by its @UnlockMethod annotation',
1148 'patterns': [r".*: warning: \[UnlockMethod\] .+"]},
Ian Rogers32bb9bd2016-05-09 23:19:42 -07001149
Ian Rogers6e520032016-05-13 08:59:00 -07001150 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001151 'severity': Severity.UNKNOWN,
Ian Rogers6e520032016-05-13 08:59:00 -07001152 'description': 'Java: Unclassified/unrecognized warnings',
1153 'patterns': [r".*: warning: \[.+\] .+"]},
Ian Rogers32bb9bd2016-05-09 23:19:42 -07001154
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001155 {'category': 'aapt', 'severity': Severity.MEDIUM,
1156 'description': 'aapt: No default translation',
1157 'patterns': [r".*: warning: string '.+' has no default translation in .*"]},
1158 {'category': 'aapt', 'severity': Severity.MEDIUM,
1159 'description': 'aapt: Missing default or required localization',
1160 'patterns': [r".*: warning: \*\*\*\* string '.+' has no default or required localization for '.+' in .+"]},
1161 {'category': 'aapt', 'severity': Severity.MEDIUM,
1162 'description': 'aapt: String marked untranslatable, but translation exists',
1163 'patterns': [r".*: warning: string '.+' in .* marked untranslatable but exists in locale '??_??'"]},
1164 {'category': 'aapt', 'severity': Severity.MEDIUM,
1165 'description': 'aapt: empty span in string',
1166 'patterns': [r".*: warning: empty '.+' span found in text '.+"]},
1167 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1168 'description': 'Taking address of temporary',
1169 'patterns': [r".*: warning: taking address of temporary"]},
1170 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1171 'description': 'Possible broken line continuation',
1172 'patterns': [r".*: warning: backslash and newline separated by space"]},
1173 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wundefined-var-template',
1174 'description': 'Undefined variable template',
1175 'patterns': [r".*: warning: instantiation of variable .* no definition is available"]},
1176 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wundefined-inline',
1177 'description': 'Inline function is not defined',
1178 'patterns': [r".*: warning: inline function '.*' is not defined"]},
1179 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Warray-bounds',
1180 'description': 'Array subscript out of bounds',
1181 'patterns': [r".*: warning: array subscript is above array bounds",
1182 r".*: warning: Array subscript is undefined",
1183 r".*: warning: array subscript is below array bounds"]},
1184 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1185 'description': 'Excess elements in initializer',
1186 'patterns': [r".*: warning: excess elements in .+ initializer"]},
1187 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1188 'description': 'Decimal constant is unsigned only in ISO C90',
1189 'patterns': [r".*: warning: this decimal constant is unsigned only in ISO C90"]},
1190 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmain',
1191 'description': 'main is usually a function',
1192 'patterns': [r".*: warning: 'main' is usually a function"]},
1193 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1194 'description': 'Typedef ignored',
1195 'patterns': [r".*: warning: 'typedef' was ignored in this declaration"]},
1196 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Waddress',
1197 'description': 'Address always evaluates to true',
1198 'patterns': [r".*: warning: the address of '.+' will always evaluate as 'true'"]},
1199 {'category': 'C/C++', 'severity': Severity.FIXMENOW,
1200 'description': 'Freeing a non-heap object',
1201 'patterns': [r".*: warning: attempt to free a non-heap object '.+'"]},
1202 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wchar-subscripts',
1203 'description': 'Array subscript has type char',
1204 'patterns': [r".*: warning: array subscript .+ type 'char'.+Wchar-subscripts"]},
1205 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1206 'description': 'Constant too large for type',
1207 'patterns': [r".*: warning: integer constant is too large for '.+' type"]},
1208 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Woverflow',
1209 'description': 'Constant too large for type, truncated',
1210 'patterns': [r".*: warning: large integer implicitly truncated to unsigned type"]},
1211 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Winteger-overflow',
1212 'description': 'Overflow in expression',
1213 'patterns': [r".*: warning: overflow in expression; .*Winteger-overflow"]},
1214 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Woverflow',
1215 'description': 'Overflow in implicit constant conversion',
1216 'patterns': [r".*: warning: overflow in implicit constant conversion"]},
1217 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1218 'description': 'Declaration does not declare anything',
1219 'patterns': [r".*: warning: declaration 'class .+' does not declare anything"]},
1220 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wreorder',
1221 'description': 'Initialization order will be different',
1222 'patterns': [r".*: warning: '.+' will be initialized after",
1223 r".*: warning: field .+ will be initialized after .+Wreorder"]},
1224 {'category': 'cont.', 'severity': Severity.SKIP,
1225 'description': 'skip, ....',
1226 'patterns': [r".*: warning: '.+'"]},
1227 {'category': 'cont.', 'severity': Severity.SKIP,
1228 'description': 'skip, base ...',
1229 'patterns': [r".*: warning: base '.+'"]},
1230 {'category': 'cont.', 'severity': Severity.SKIP,
1231 'description': 'skip, when initialized here',
1232 'patterns': [r".*: warning: when initialized here"]},
1233 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-parameter-type',
1234 'description': 'Parameter type not specified',
1235 'patterns': [r".*: warning: type of '.+' defaults to 'int'"]},
1236 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-declarations',
1237 'description': 'Missing declarations',
1238 'patterns': [r".*: warning: declaration does not declare anything"]},
1239 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-noreturn',
1240 'description': 'Missing noreturn',
1241 'patterns': [r".*: warning: function '.*' could be declared with attribute 'noreturn'"]},
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001242 # pylint:disable=anomalous-backslash-in-string
1243 # TODO(chh): fix the backslash pylint warning.
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001244 {'category': 'gcc', 'severity': Severity.MEDIUM,
1245 'description': 'Invalid option for C file',
1246 'patterns': [r".*: warning: command line option "".+"" is valid for C\+\+\/ObjC\+\+ but not for C"]},
1247 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1248 'description': 'User warning',
1249 'patterns': [r".*: warning: #warning "".+"""]},
1250 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wvexing-parse',
1251 'description': 'Vexing parsing problem',
1252 'patterns': [r".*: warning: empty parentheses interpreted as a function declaration"]},
1253 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wextra',
1254 'description': 'Dereferencing void*',
1255 'patterns': [r".*: warning: dereferencing 'void \*' pointer"]},
1256 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1257 'description': 'Comparison of pointer and integer',
1258 'patterns': [r".*: warning: ordered comparison of pointer with integer zero",
1259 r".*: warning: .*comparison between pointer and integer"]},
1260 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1261 'description': 'Use of error-prone unary operator',
1262 'patterns': [r".*: warning: use of unary operator that may be intended as compound assignment"]},
1263 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wwrite-strings',
1264 'description': 'Conversion of string constant to non-const char*',
1265 'patterns': [r".*: warning: deprecated conversion from string constant to '.+'"]},
1266 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wstrict-prototypes',
1267 'description': 'Function declaration isn''t a prototype',
1268 'patterns': [r".*: warning: function declaration isn't a prototype"]},
1269 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wignored-qualifiers',
1270 'description': 'Type qualifiers ignored on function return value',
1271 'patterns': [r".*: warning: type qualifiers ignored on function return type",
1272 r".*: warning: .+ type qualifier .+ has no effect .+Wignored-qualifiers"]},
1273 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1274 'description': '<foo> declared inside parameter list, scope limited to this definition',
1275 'patterns': [r".*: warning: '.+' declared inside parameter list"]},
1276 {'category': 'cont.', 'severity': Severity.SKIP,
1277 'description': 'skip, its scope is only this ...',
1278 'patterns': [r".*: warning: its scope is only this definition or declaration, which is probably not what you want"]},
1279 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wcomment',
1280 'description': 'Line continuation inside comment',
1281 'patterns': [r".*: warning: multi-line comment"]},
1282 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wcomment',
1283 'description': 'Comment inside comment',
1284 'patterns': [r".*: warning: "".+"" within comment"]},
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001285 # Warning "value stored is never read" could be from clang-tidy or clang static analyzer.
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001286 {'category': 'C/C++', 'severity': Severity.TIDY,
1287 'description': 'clang-tidy Value stored is never read',
1288 'patterns': [r".*: warning: Value stored to .+ is never read.*clang-analyzer-deadcode.DeadStores"]},
1289 {'category': 'C/C++', 'severity': Severity.LOW,
1290 'description': 'Value stored is never read',
1291 'patterns': [r".*: warning: Value stored to .+ is never read"]},
1292 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wdeprecated-declarations',
1293 'description': 'Deprecated declarations',
1294 'patterns': [r".*: warning: .+ is deprecated.+deprecated-declarations"]},
1295 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wdeprecated-register',
1296 'description': 'Deprecated register',
1297 'patterns': [r".*: warning: 'register' storage class specifier is deprecated"]},
1298 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wpointer-sign',
1299 'description': 'Converts between pointers to integer types with different sign',
1300 'patterns': [r".*: warning: .+ converts between pointers to integer types with different sign"]},
1301 {'category': 'C/C++', 'severity': Severity.HARMLESS,
1302 'description': 'Extra tokens after #endif',
1303 'patterns': [r".*: warning: extra tokens at end of #endif directive"]},
1304 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wenum-compare',
1305 'description': 'Comparison between different enums',
1306 'patterns': [r".*: warning: comparison between '.+' and '.+'.+Wenum-compare"]},
1307 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wconversion',
1308 'description': 'Conversion may change value',
1309 'patterns': [r".*: warning: converting negative value '.+' to '.+'",
1310 r".*: warning: conversion to '.+' .+ may (alter|change)"]},
1311 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wconversion-null',
1312 'description': 'Converting to non-pointer type from NULL',
1313 'patterns': [r".*: warning: converting to non-pointer type '.+' from NULL"]},
1314 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wnull-conversion',
1315 'description': 'Converting NULL to non-pointer type',
1316 'patterns': [r".*: warning: implicit conversion of NULL constant to '.+'"]},
1317 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wnon-literal-null-conversion',
1318 'description': 'Zero used as null pointer',
1319 'patterns': [r".*: warning: expression .* zero treated as a null pointer constant"]},
1320 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1321 'description': 'Implicit conversion changes value',
1322 'patterns': [r".*: warning: implicit conversion .* changes value from .* to .*-conversion"]},
1323 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1324 'description': 'Passing NULL as non-pointer argument',
1325 'patterns': [r".*: warning: passing NULL to non-pointer argument [0-9]+ of '.+'"]},
1326 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wctor-dtor-privacy',
1327 'description': 'Class seems unusable because of private ctor/dtor',
1328 'patterns': [r".*: warning: all member functions in class '.+' are private"]},
Marco Nelissen594375d2009-07-14 09:04:04 -07001329 # skip this next one, because it only points out some RefBase-based classes where having a private destructor is perfectly fine
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001330 {'category': 'C/C++', 'severity': Severity.SKIP, 'option': '-Wctor-dtor-privacy',
1331 'description': 'Class seems unusable because of private ctor/dtor',
1332 'patterns': [r".*: warning: 'class .+' only defines a private destructor and has no friends"]},
1333 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wctor-dtor-privacy',
1334 'description': 'Class seems unusable because of private ctor/dtor',
1335 'patterns': [r".*: warning: 'class .+' only defines private constructors and has no friends"]},
1336 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wgnu-static-float-init',
1337 'description': 'In-class initializer for static const float/double',
1338 'patterns': [r".*: warning: in-class initializer for static data member of .+const (float|double)"]},
1339 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wpointer-arith',
1340 'description': 'void* used in arithmetic',
1341 'patterns': [r".*: warning: pointer of type 'void \*' used in (arithmetic|subtraction)",
1342 r".*: warning: arithmetic on .+ to void is a GNU extension.*Wpointer-arith",
1343 r".*: warning: wrong type argument to increment"]},
1344 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsign-promo',
1345 'description': 'Overload resolution chose to promote from unsigned or enum to signed type',
1346 'patterns': [r".*: warning: passing '.+' chooses '.+' over '.+'.*Wsign-promo"]},
1347 {'category': 'cont.', 'severity': Severity.SKIP,
1348 'description': 'skip, in call to ...',
1349 'patterns': [r".*: warning: in call to '.+'"]},
1350 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wextra',
1351 'description': 'Base should be explicitly initialized in copy constructor',
1352 'patterns': [r".*: warning: base class '.+' should be explicitly initialized in the copy constructor"]},
1353 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1354 'description': 'VLA has zero or negative size',
1355 'patterns': [r".*: warning: Declared variable-length array \(VLA\) has .+ size"]},
1356 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1357 'description': 'Return value from void function',
1358 'patterns': [r".*: warning: 'return' with a value, in function returning void"]},
1359 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'multichar',
1360 'description': 'Multi-character character constant',
1361 'patterns': [r".*: warning: multi-character character constant"]},
1362 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'writable-strings',
1363 'description': 'Conversion from string literal to char*',
1364 'patterns': [r".*: warning: .+ does not allow conversion from string literal to 'char \*'"]},
1365 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wextra-semi',
1366 'description': 'Extra \';\'',
1367 'patterns': [r".*: warning: extra ';' .+extra-semi"]},
1368 {'category': 'C/C++', 'severity': Severity.LOW,
1369 'description': 'Useless specifier',
1370 'patterns': [r".*: warning: useless storage class specifier in empty declaration"]},
1371 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wduplicate-decl-specifier',
1372 'description': 'Duplicate declaration specifier',
1373 'patterns': [r".*: warning: duplicate '.+' declaration specifier"]},
1374 {'category': 'logtags', 'severity': Severity.LOW,
1375 'description': 'Duplicate logtag',
1376 'patterns': [r".*: warning: tag \".+\" \(.+\) duplicated in .+"]},
1377 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'typedef-redefinition',
1378 'description': 'Typedef redefinition',
1379 'patterns': [r".*: warning: redefinition of typedef '.+' is a C11 feature"]},
1380 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'gnu-designator',
1381 'description': 'GNU old-style field designator',
1382 'patterns': [r".*: warning: use of GNU old-style field designator extension"]},
1383 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'missing-field-initializers',
1384 'description': 'Missing field initializers',
1385 'patterns': [r".*: warning: missing field '.+' initializer"]},
1386 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'missing-braces',
1387 'description': 'Missing braces',
1388 'patterns': [r".*: warning: suggest braces around initialization of",
1389 r".*: warning: too many braces around scalar initializer .+Wmany-braces-around-scalar-init",
1390 r".*: warning: braces around scalar initializer"]},
1391 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'sign-compare',
1392 'description': 'Comparison of integers of different signs',
1393 'patterns': [r".*: warning: comparison of integers of different signs.+sign-compare"]},
1394 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'dangling-else',
1395 'description': 'Add braces to avoid dangling else',
1396 'patterns': [r".*: warning: add explicit braces to avoid dangling else"]},
1397 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'initializer-overrides',
1398 'description': 'Initializer overrides prior initialization',
1399 'patterns': [r".*: warning: initializer overrides prior initialization of this subobject"]},
1400 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'self-assign',
1401 'description': 'Assigning value to self',
1402 'patterns': [r".*: warning: explicitly assigning value of .+ to itself"]},
1403 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'gnu-variable-sized-type-not-at-end',
1404 'description': 'GNU extension, variable sized type not at end',
1405 'patterns': [r".*: warning: field '.+' with variable sized type '.+' not at the end of a struct or class"]},
1406 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'tautological-constant-out-of-range-compare',
1407 'description': 'Comparison of constant is always false/true',
1408 'patterns': [r".*: comparison of .+ is always .+Wtautological-constant-out-of-range-compare"]},
1409 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'overloaded-virtual',
1410 'description': 'Hides overloaded virtual function',
1411 'patterns': [r".*: '.+' hides overloaded virtual function"]},
1412 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'incompatible-pointer-types',
1413 'description': 'Incompatible pointer types',
1414 'patterns': [r".*: warning: incompatible pointer types .+Wincompatible-pointer-types"]},
1415 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'asm-operand-widths',
1416 'description': 'ASM value size does not match register size',
1417 'patterns': [r".*: warning: value size does not match register size specified by the constraint and modifier"]},
1418 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'tautological-compare',
1419 'description': 'Comparison of self is always false',
1420 'patterns': [r".*: self-comparison always evaluates to false"]},
1421 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'constant-logical-operand',
1422 'description': 'Logical op with constant operand',
1423 'patterns': [r".*: use of logical '.+' with constant operand"]},
1424 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'literal-suffix',
1425 'description': 'Needs a space between literal and string macro',
1426 'patterns': [r".*: warning: invalid suffix on literal.+ requires a space .+Wliteral-suffix"]},
1427 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '#warnings',
1428 'description': 'Warnings from #warning',
1429 'patterns': [r".*: warning: .+-W#warnings"]},
1430 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'absolute-value',
1431 'description': 'Using float/int absolute value function with int/float argument',
1432 'patterns': [r".*: warning: using .+ absolute value function .+ when argument is .+ type .+Wabsolute-value",
1433 r".*: warning: absolute value function '.+' given .+ which may cause truncation .+Wabsolute-value"]},
1434 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wc++11-extensions',
1435 'description': 'Using C++11 extensions',
1436 'patterns': [r".*: warning: 'auto' type specifier is a C\+\+11 extension"]},
1437 {'category': 'C/C++', 'severity': Severity.LOW,
1438 'description': 'Refers to implicitly defined namespace',
1439 'patterns': [r".*: warning: using directive refers to implicitly-defined namespace .+"]},
1440 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Winvalid-pp-token',
1441 'description': 'Invalid pp token',
1442 'patterns': [r".*: warning: missing .+Winvalid-pp-token"]},
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001443
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001444 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1445 'description': 'Operator new returns NULL',
1446 'patterns': [r".*: warning: 'operator new' must not return NULL unless it is declared 'throw\(\)' .+"]},
1447 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wnull-arithmetic',
1448 'description': 'NULL used in arithmetic',
1449 'patterns': [r".*: warning: NULL used in arithmetic",
1450 r".*: warning: comparison between NULL and non-pointer"]},
1451 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'header-guard',
1452 'description': 'Misspelled header guard',
1453 'patterns': [r".*: warning: '.+' is used as a header guard .+ followed by .+ different macro"]},
1454 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'empty-body',
1455 'description': 'Empty loop body',
1456 'patterns': [r".*: warning: .+ loop has empty body"]},
1457 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'enum-conversion',
1458 'description': 'Implicit conversion from enumeration type',
1459 'patterns': [r".*: warning: implicit conversion from enumeration type '.+'"]},
1460 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'switch',
1461 'description': 'case value not in enumerated type',
1462 'patterns': [r".*: warning: case value not in enumerated type '.+'"]},
1463 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1464 'description': 'Undefined result',
1465 'patterns': [r".*: warning: The result of .+ is undefined",
1466 r".*: warning: passing an object that .+ has undefined behavior \[-Wvarargs\]",
1467 r".*: warning: 'this' pointer cannot be null in well-defined C\+\+ code;",
1468 r".*: warning: shifting a negative signed value is undefined"]},
1469 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1470 'description': 'Division by zero',
1471 'patterns': [r".*: warning: Division by zero"]},
1472 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1473 'description': 'Use of deprecated method',
1474 'patterns': [r".*: warning: '.+' is deprecated .+"]},
1475 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1476 'description': 'Use of garbage or uninitialized value',
1477 'patterns': [r".*: warning: .+ is a garbage value",
1478 r".*: warning: Function call argument is an uninitialized value",
1479 r".*: warning: Undefined or garbage value returned to caller",
1480 r".*: warning: Called .+ pointer is.+uninitialized",
1481 r".*: warning: Called .+ pointer is.+uninitalized", # match a typo in compiler message
1482 r".*: warning: Use of zero-allocated memory",
1483 r".*: warning: Dereference of undefined pointer value",
1484 r".*: warning: Passed-by-value .+ contains uninitialized data",
1485 r".*: warning: Branch condition evaluates to a garbage value",
1486 r".*: warning: The .+ of .+ is an uninitialized value.",
1487 r".*: warning: .+ is used uninitialized whenever .+sometimes-uninitialized",
1488 r".*: warning: Assigned value is garbage or undefined"]},
1489 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1490 'description': 'Result of malloc type incompatible with sizeof operand type',
1491 'patterns': [r".*: warning: Result of '.+' is converted to .+ incompatible with sizeof operand type"]},
1492 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsizeof-array-argument',
1493 'description': 'Sizeof on array argument',
1494 'patterns': [r".*: warning: sizeof on array function parameter will return"]},
1495 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsizeof-pointer-memacces',
1496 'description': 'Bad argument size of memory access functions',
1497 'patterns': [r".*: warning: .+\[-Wsizeof-pointer-memaccess\]"]},
1498 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1499 'description': 'Return value not checked',
1500 'patterns': [r".*: warning: The return value from .+ is not checked"]},
1501 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1502 'description': 'Possible heap pollution',
1503 'patterns': [r".*: warning: .*Possible heap pollution from .+ type .+"]},
1504 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1505 'description': 'Allocation size of 0 byte',
1506 'patterns': [r".*: warning: Call to .+ has an allocation size of 0 byte"]},
1507 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1508 'description': 'Result of malloc type incompatible with sizeof operand type',
1509 'patterns': [r".*: warning: Result of '.+' is converted to .+ incompatible with sizeof operand type"]},
1510 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wfor-loop-analysis',
1511 'description': 'Variable used in loop condition not modified in loop body',
1512 'patterns': [r".*: warning: variable '.+' used in loop condition.*Wfor-loop-analysis"]},
1513 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1514 'description': 'Closing a previously closed file',
1515 'patterns': [r".*: warning: Closing a previously closed file"]},
1516 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunnamed-type-template-args',
1517 'description': 'Unnamed template type argument',
1518 'patterns': [r".*: warning: template argument.+Wunnamed-type-template-args"]},
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001519
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001520 {'category': 'C/C++', 'severity': Severity.HARMLESS,
1521 'description': 'Discarded qualifier from pointer target type',
1522 'patterns': [r".*: warning: .+ discards '.+' qualifier from pointer target type"]},
1523 {'category': 'C/C++', 'severity': Severity.HARMLESS,
1524 'description': 'Use snprintf instead of sprintf',
1525 'patterns': [r".*: warning: .*sprintf is often misused; please use snprintf"]},
1526 {'category': 'C/C++', 'severity': Severity.HARMLESS,
1527 'description': 'Unsupported optimizaton flag',
1528 'patterns': [r".*: warning: optimization flag '.+' is not supported"]},
1529 {'category': 'C/C++', 'severity': Severity.HARMLESS,
1530 'description': 'Extra or missing parentheses',
1531 'patterns': [r".*: warning: equality comparison with extraneous parentheses",
1532 r".*: warning: .+ within .+Wlogical-op-parentheses"]},
1533 {'category': 'C/C++', 'severity': Severity.HARMLESS, 'option': 'mismatched-tags',
1534 'description': 'Mismatched class vs struct tags',
1535 'patterns': [r".*: warning: '.+' defined as a .+ here but previously declared as a .+mismatched-tags",
1536 r".*: warning: .+ was previously declared as a .+mismatched-tags"]},
Marco Nelissen594375d2009-07-14 09:04:04 -07001537
1538 # these next ones are to deal with formatting problems resulting from the log being mixed up by 'make -j'
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001539 {'category': 'C/C++', 'severity': Severity.SKIP,
1540 'description': 'skip, ,',
1541 'patterns': [r".*: warning: ,$"]},
1542 {'category': 'C/C++', 'severity': Severity.SKIP,
1543 'description': 'skip,',
1544 'patterns': [r".*: warning: $"]},
1545 {'category': 'C/C++', 'severity': Severity.SKIP,
1546 'description': 'skip, In file included from ...',
1547 'patterns': [r".*: warning: In file included from .+,"]},
Marco Nelissen594375d2009-07-14 09:04:04 -07001548
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001549 # warnings from clang-tidy
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001550 {'category': 'C/C++', 'severity': Severity.TIDY,
1551 'description': 'clang-tidy readability',
1552 'patterns': [r".*: .+\[readability-.+\]$"]},
1553 {'category': 'C/C++', 'severity': Severity.TIDY,
1554 'description': 'clang-tidy c++ core guidelines',
1555 'patterns': [r".*: .+\[cppcoreguidelines-.+\]$"]},
1556 {'category': 'C/C++', 'severity': Severity.TIDY,
1557 'description': 'clang-tidy google-default-arguments',
1558 'patterns': [r".*: .+\[google-default-arguments\]$"]},
1559 {'category': 'C/C++', 'severity': Severity.TIDY,
1560 'description': 'clang-tidy google-runtime-int',
1561 'patterns': [r".*: .+\[google-runtime-int\]$"]},
1562 {'category': 'C/C++', 'severity': Severity.TIDY,
1563 'description': 'clang-tidy google-runtime-operator',
1564 'patterns': [r".*: .+\[google-runtime-operator\]$"]},
1565 {'category': 'C/C++', 'severity': Severity.TIDY,
1566 'description': 'clang-tidy google-runtime-references',
1567 'patterns': [r".*: .+\[google-runtime-references\]$"]},
1568 {'category': 'C/C++', 'severity': Severity.TIDY,
1569 'description': 'clang-tidy google-build',
1570 'patterns': [r".*: .+\[google-build-.+\]$"]},
1571 {'category': 'C/C++', 'severity': Severity.TIDY,
1572 'description': 'clang-tidy google-explicit',
1573 'patterns': [r".*: .+\[google-explicit-.+\]$"]},
1574 {'category': 'C/C++', 'severity': Severity.TIDY,
1575 'description': 'clang-tidy google-readability',
1576 'patterns': [r".*: .+\[google-readability-.+\]$"]},
1577 {'category': 'C/C++', 'severity': Severity.TIDY,
1578 'description': 'clang-tidy google-global',
1579 'patterns': [r".*: .+\[google-global-.+\]$"]},
1580 {'category': 'C/C++', 'severity': Severity.TIDY,
1581 'description': 'clang-tidy google- other',
1582 'patterns': [r".*: .+\[google-.+\]$"]},
1583 {'category': 'C/C++', 'severity': Severity.TIDY,
1584 'description': 'clang-tidy modernize',
1585 'patterns': [r".*: .+\[modernize-.+\]$"]},
1586 {'category': 'C/C++', 'severity': Severity.TIDY,
1587 'description': 'clang-tidy misc',
1588 'patterns': [r".*: .+\[misc-.+\]$"]},
1589 {'category': 'C/C++', 'severity': Severity.TIDY,
1590 'description': 'clang-tidy performance-faster-string-find',
1591 'patterns': [r".*: .+\[performance-faster-string-find\]$"]},
1592 {'category': 'C/C++', 'severity': Severity.TIDY,
1593 'description': 'clang-tidy performance-for-range-copy',
1594 'patterns': [r".*: .+\[performance-for-range-copy\]$"]},
1595 {'category': 'C/C++', 'severity': Severity.TIDY,
1596 'description': 'clang-tidy performance-implicit-cast-in-loop',
1597 'patterns': [r".*: .+\[performance-implicit-cast-in-loop\]$"]},
1598 {'category': 'C/C++', 'severity': Severity.TIDY,
1599 'description': 'clang-tidy performance-unnecessary-copy-initialization',
1600 'patterns': [r".*: .+\[performance-unnecessary-copy-initialization\]$"]},
1601 {'category': 'C/C++', 'severity': Severity.TIDY,
1602 'description': 'clang-tidy performance-unnecessary-value-param',
1603 'patterns': [r".*: .+\[performance-unnecessary-value-param\]$"]},
1604 {'category': 'C/C++', 'severity': Severity.TIDY,
1605 'description': 'clang-analyzer Unreachable code',
1606 'patterns': [r".*: warning: This statement is never executed.*UnreachableCode"]},
1607 {'category': 'C/C++', 'severity': Severity.TIDY,
1608 'description': 'clang-analyzer Size of malloc may overflow',
1609 'patterns': [r".*: warning: .* size of .* may overflow .*MallocOverflow"]},
1610 {'category': 'C/C++', 'severity': Severity.TIDY,
1611 'description': 'clang-analyzer Stream pointer might be NULL',
1612 'patterns': [r".*: warning: Stream pointer might be NULL .*unix.Stream"]},
1613 {'category': 'C/C++', 'severity': Severity.TIDY,
1614 'description': 'clang-analyzer Opened file never closed',
1615 'patterns': [r".*: warning: Opened File never closed.*unix.Stream"]},
1616 {'category': 'C/C++', 'severity': Severity.TIDY,
1617 'description': 'clang-analyzer sozeof() on a pointer type',
1618 'patterns': [r".*: warning: .*calls sizeof.* on a pointer type.*SizeofPtr"]},
1619 {'category': 'C/C++', 'severity': Severity.TIDY,
1620 'description': 'clang-analyzer Pointer arithmetic on non-array variables',
1621 'patterns': [r".*: warning: Pointer arithmetic on non-array variables .*PointerArithm"]},
1622 {'category': 'C/C++', 'severity': Severity.TIDY,
1623 'description': 'clang-analyzer Subtraction of pointers of different memory chunks',
1624 'patterns': [r".*: warning: Subtraction of two pointers .*PointerSub"]},
1625 {'category': 'C/C++', 'severity': Severity.TIDY,
1626 'description': 'clang-analyzer Access out-of-bound array element',
1627 'patterns': [r".*: warning: Access out-of-bound array element .*ArrayBound"]},
1628 {'category': 'C/C++', 'severity': Severity.TIDY,
1629 'description': 'clang-analyzer Out of bound memory access',
1630 'patterns': [r".*: warning: Out of bound memory access .*ArrayBoundV2"]},
1631 {'category': 'C/C++', 'severity': Severity.TIDY,
1632 'description': 'clang-analyzer Possible lock order reversal',
1633 'patterns': [r".*: warning: .* Possible lock order reversal.*PthreadLock"]},
1634 {'category': 'C/C++', 'severity': Severity.TIDY,
1635 'description': 'clang-analyzer Argument is a pointer to uninitialized value',
1636 'patterns': [r".*: warning: .* argument is a pointer to uninitialized value .*CallAndMessage"]},
1637 {'category': 'C/C++', 'severity': Severity.TIDY,
1638 'description': 'clang-analyzer cast to struct',
1639 'patterns': [r".*: warning: Casting a non-structure type to a structure type .*CastToStruct"]},
1640 {'category': 'C/C++', 'severity': Severity.TIDY,
1641 'description': 'clang-analyzer call path problems',
1642 'patterns': [r".*: warning: Call Path : .+"]},
1643 {'category': 'C/C++', 'severity': Severity.TIDY,
1644 'description': 'clang-analyzer other',
1645 'patterns': [r".*: .+\[clang-analyzer-.+\]$",
1646 r".*: Call Path : .+$"]},
1647 {'category': 'C/C++', 'severity': Severity.TIDY,
1648 'description': 'clang-tidy CERT',
1649 'patterns': [r".*: .+\[cert-.+\]$"]},
1650 {'category': 'C/C++', 'severity': Severity.TIDY,
1651 'description': 'clang-tidy llvm',
1652 'patterns': [r".*: .+\[llvm-.+\]$"]},
1653 {'category': 'C/C++', 'severity': Severity.TIDY,
1654 'description': 'clang-diagnostic',
1655 'patterns': [r".*: .+\[clang-diagnostic-.+\]$"]},
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001656
Marco Nelissen594375d2009-07-14 09:04:04 -07001657 # catch-all for warnings this script doesn't know about yet
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001658 {'category': 'C/C++', 'severity': Severity.UNKNOWN,
1659 'description': 'Unclassified/unrecognized warnings',
1660 'patterns': [r".*: warning: .+"]},
Marco Nelissen594375d2009-07-14 09:04:04 -07001661]
1662
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001663
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001664# A list of [project_name, file_path_pattern].
1665# project_name should not contain comma, to be used in CSV output.
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001666project_list = [
1667 # pylint:disable=bad-whitespace,g-inconsistent-quotes,line-too-long
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07001668 ['art', r"(^|.*/)art/.*: warning:"],
1669 ['bionic', r"(^|.*/)bionic/.*: warning:"],
1670 ['bootable', r"(^|.*/)bootable/.*: warning:"],
1671 ['build', r"(^|.*/)build/.*: warning:"],
1672 ['cts', r"(^|.*/)cts/.*: warning:"],
1673 ['dalvik', r"(^|.*/)dalvik/.*: warning:"],
1674 ['developers', r"(^|.*/)developers/.*: warning:"],
1675 ['development', r"(^|.*/)development/.*: warning:"],
1676 ['device', r"(^|.*/)device/.*: warning:"],
1677 ['doc', r"(^|.*/)doc/.*: warning:"],
1678 # match external/google* before external/
1679 ['external/google', r"(^|.*/)external/google.*: warning:"],
1680 ['external/non-google', r"(^|.*/)external/.*: warning:"],
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001681 ['frameworks/av/camera',r"(^|.*/)frameworks/av/camera/.*: warning:"],
1682 ['frameworks/av/cmds', r"(^|.*/)frameworks/av/cmds/.*: warning:"],
1683 ['frameworks/av/drm', r"(^|.*/)frameworks/av/drm/.*: warning:"],
1684 ['frameworks/av/include',r"(^|.*/)frameworks/av/include/.*: warning:"],
1685 ['frameworks/av/media', r"(^|.*/)frameworks/av/media/.*: warning:"],
1686 ['frameworks/av/radio', r"(^|.*/)frameworks/av/radio/.*: warning:"],
1687 ['frameworks/av/services', r"(^|.*/)frameworks/av/services/.*: warning:"],
1688 ['frameworks/av/Other', r"(^|.*/)frameworks/av/.*: warning:"],
1689 ['frameworks/base', r"(^|.*/)frameworks/base/.*: warning:"],
1690 ['frameworks/compile', r"(^|.*/)frameworks/compile/.*: warning:"],
1691 ['frameworks/minikin', r"(^|.*/)frameworks/minikin/.*: warning:"],
1692 ['frameworks/native', r"(^|.*/)frameworks/native/.*: warning:"],
1693 ['frameworks/opt', r"(^|.*/)frameworks/opt/.*: warning:"],
1694 ['frameworks/rs', r"(^|.*/)frameworks/rs/.*: warning:"],
1695 ['frameworks/webview', r"(^|.*/)frameworks/webview/.*: warning:"],
1696 ['frameworks/wilhelm', r"(^|.*/)frameworks/wilhelm/.*: warning:"],
1697 ['frameworks/Other', r"(^|.*/)frameworks/.*: warning:"],
1698 ['hardware/akm', r"(^|.*/)hardware/akm/.*: warning:"],
1699 ['hardware/broadcom', r"(^|.*/)hardware/broadcom/.*: warning:"],
1700 ['hardware/google', r"(^|.*/)hardware/google/.*: warning:"],
1701 ['hardware/intel', r"(^|.*/)hardware/intel/.*: warning:"],
1702 ['hardware/interfaces', r"(^|.*/)hardware/interfaces/.*: warning:"],
1703 ['hardware/libhardware',r"(^|.*/)hardware/libhardware/.*: warning:"],
1704 ['hardware/libhardware_legacy',r"(^|.*/)hardware/libhardware_legacy/.*: warning:"],
1705 ['hardware/qcom', r"(^|.*/)hardware/qcom/.*: warning:"],
1706 ['hardware/ril', r"(^|.*/)hardware/ril/.*: warning:"],
1707 ['hardware/Other', r"(^|.*/)hardware/.*: warning:"],
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07001708 ['kernel', r"(^|.*/)kernel/.*: warning:"],
1709 ['libcore', r"(^|.*/)libcore/.*: warning:"],
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001710 ['libnativehelper', r"(^|.*/)libnativehelper/.*: warning:"],
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07001711 ['ndk', r"(^|.*/)ndk/.*: warning:"],
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001712 # match vendor/unbungled_google/packages before other packages
1713 ['unbundled_google', r"(^|.*/)unbundled_google/.*: warning:"],
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07001714 ['packages', r"(^|.*/)packages/.*: warning:"],
1715 ['pdk', r"(^|.*/)pdk/.*: warning:"],
1716 ['prebuilts', r"(^|.*/)prebuilts/.*: warning:"],
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001717 ['system/bt', r"(^|.*/)system/bt/.*: warning:"],
1718 ['system/connectivity', r"(^|.*/)system/connectivity/.*: warning:"],
1719 ['system/core', r"(^|.*/)system/core/.*: warning:"],
1720 ['system/extras', r"(^|.*/)system/extras/.*: warning:"],
1721 ['system/gatekeeper', r"(^|.*/)system/gatekeeper/.*: warning:"],
1722 ['system/keymaster', r"(^|.*/)system/keymaster/.*: warning:"],
1723 ['system/libhwbinder', r"(^|.*/)system/libhwbinder/.*: warning:"],
1724 ['system/media', r"(^|.*/)system/media/.*: warning:"],
1725 ['system/netd', r"(^|.*/)system/netd/.*: warning:"],
1726 ['system/security', r"(^|.*/)system/security/.*: warning:"],
1727 ['system/sepolicy', r"(^|.*/)system/sepolicy/.*: warning:"],
1728 ['system/tools', r"(^|.*/)system/tools/.*: warning:"],
1729 ['system/vold', r"(^|.*/)system/vold/.*: warning:"],
1730 ['system/Other', r"(^|.*/)system/.*: warning:"],
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07001731 ['toolchain', r"(^|.*/)toolchain/.*: warning:"],
1732 ['test', r"(^|.*/)test/.*: warning:"],
1733 ['tools', r"(^|.*/)tools/.*: warning:"],
1734 # match vendor/google* before vendor/
1735 ['vendor/google', r"(^|.*/)vendor/google.*: warning:"],
1736 ['vendor/non-google', r"(^|.*/)vendor/.*: warning:"],
1737 # keep out/obj and other patterns at the end.
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001738 ['out/obj', r".*/(gen|obj[^/]*)/(include|EXECUTABLES|SHARED_LIBRARIES|STATIC_LIBRARIES|NATIVE_TESTS)/.*: warning:"],
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07001739 ['other', r".*: warning:"],
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001740]
1741
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001742project_patterns = []
1743project_names = []
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001744warning_messages = []
1745warning_records = []
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001746
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001747
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001748def initialize_arrays():
1749 """Complete global arrays before they are used."""
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001750 global project_names, project_patterns
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001751 project_names = [p[0] for p in project_list]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001752 project_patterns = [re.compile(p[1]) for p in project_list]
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001753 for w in warn_patterns:
1754 w['members'] = []
1755 if 'option' not in w:
1756 w['option'] = ''
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001757 # Each warning pattern has a 'projects' dictionary, that
1758 # maps a project name to number of warnings in that project.
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001759 w['projects'] = {}
1760
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001761
1762initialize_arrays()
1763
1764
1765platform_version = 'unknown'
1766target_product = 'unknown'
1767target_variant = 'unknown'
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001768
1769
1770##### Data and functions to dump html file. ##################################
1771
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001772html_head_scripts = """\
1773 <script type="text/javascript">
1774 function expand(id) {
1775 var e = document.getElementById(id);
1776 var f = document.getElementById(id + "_mark");
1777 if (e.style.display == 'block') {
1778 e.style.display = 'none';
1779 f.innerHTML = '&#x2295';
1780 }
1781 else {
1782 e.style.display = 'block';
1783 f.innerHTML = '&#x2296';
1784 }
1785 };
1786 function expandCollapse(show) {
1787 for (var id = 1; ; id++) {
1788 var e = document.getElementById(id + "");
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07001789 var f = document.getElementById(id + "_mark");
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001790 if (!e || !f) break;
1791 e.style.display = (show ? 'block' : 'none');
1792 f.innerHTML = (show ? '&#x2296' : '&#x2295');
1793 }
1794 };
1795 </script>
1796 <style type="text/css">
1797 th,td{border-collapse:collapse; border:1px solid black;}
1798 .button{color:blue;font-size:110%;font-weight:bolder;}
1799 .bt{color:black;background-color:transparent;border:none;outline:none;
1800 font-size:140%;font-weight:bolder;}
1801 .c0{background-color:#e0e0e0;}
1802 .c1{background-color:#d0d0d0;}
1803 .t1{border-collapse:collapse; width:100%; border:1px solid black;}
1804 </style>
1805 <script src="https://www.gstatic.com/charts/loader.js"></script>
1806"""
Marco Nelissen594375d2009-07-14 09:04:04 -07001807
Marco Nelissen594375d2009-07-14 09:04:04 -07001808
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001809def html_big(param):
1810 return '<font size="+2">' + param + '</font>'
Marco Nelissen594375d2009-07-14 09:04:04 -07001811
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07001812
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001813def dump_html_prologue(title):
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001814 print '<html>\n<head>'
1815 print '<title>' + title + '</title>'
1816 print html_head_scripts
1817 emit_stats_by_project()
1818 print '</head>\n<body>'
1819 print html_big(title)
1820 print '<p>'
Marco Nelissen594375d2009-07-14 09:04:04 -07001821
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001822
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001823def dump_html_epilogue():
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001824 print '</body>\n</head>\n</html>'
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001825
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001826
1827def sort_warnings():
1828 for i in warn_patterns:
1829 i['members'] = sorted(set(i['members']))
1830
1831
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001832def emit_stats_by_project():
1833 """Dump a google chart table of warnings per project and severity."""
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001834 # warnings[p][s] is number of warnings in project p of severity s.
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001835 warnings = {p: {s: 0 for s in Severity.range} for p in project_names}
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001836 for i in warn_patterns:
1837 s = i['severity']
1838 for p in i['projects']:
1839 warnings[p][s] += i['projects'][p]
1840
1841 # total_by_project[p] is number of warnings in project p.
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001842 total_by_project = {p: sum(warnings[p][s] for s in Severity.range)
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001843 for p in project_names}
1844
1845 # total_by_severity[s] is number of warnings of severity s.
1846 total_by_severity = {s: sum(warnings[p][s] for p in project_names)
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001847 for s in Severity.range}
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001848
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001849 # emit table header
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001850 stats_header = ['Project']
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001851 for s in Severity.range:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001852 if total_by_severity[s]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001853 stats_header.append("<span style='background-color:{}'>{}</span>".
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001854 format(Severity.colors[s],
1855 Severity.column_headers[s]))
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001856 stats_header.append('TOTAL')
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001857
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001858 # emit a row of warning counts per project, skip no-warning projects
1859 total_all_projects = 0
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001860 stats_rows = []
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001861 for p in project_names:
1862 if total_by_project[p]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001863 one_row = [p]
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001864 for s in Severity.range:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001865 if total_by_severity[s]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001866 one_row.append(warnings[p][s])
1867 one_row.append(total_by_project[p])
1868 stats_rows.append(one_row)
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001869 total_all_projects += total_by_project[p]
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001870
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001871 # emit a row of warning counts per severity
1872 total_all_severities = 0
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001873 one_row = ['<b>TOTAL</b>']
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001874 for s in Severity.range:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001875 if total_by_severity[s]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001876 one_row.append(total_by_severity[s])
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001877 total_all_severities += total_by_severity[s]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001878 one_row.append(total_all_projects)
1879 stats_rows.append(one_row)
1880 print '<script>'
1881 emit_const_string_array('StatsHeader', stats_header)
1882 emit_const_object_array('StatsRows', stats_rows)
1883 print draw_table_javascript
1884 print '</script>'
Marco Nelissen594375d2009-07-14 09:04:04 -07001885
1886
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001887def dump_stats():
1888 """Dump some stats about total number of warnings and such."""
1889 known = 0
1890 skipped = 0
1891 unknown = 0
1892 sort_warnings()
1893 for i in warn_patterns:
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001894 if i['severity'] == Severity.UNKNOWN:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001895 unknown += len(i['members'])
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001896 elif i['severity'] == Severity.SKIP:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001897 skipped += len(i['members'])
Ian Rogersf3829732016-05-10 12:06:01 -07001898 else:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001899 known += len(i['members'])
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001900 print 'Number of classified warnings: <b>' + str(known) + '</b><br>'
1901 print 'Number of skipped warnings: <b>' + str(skipped) + '</b><br>'
1902 print 'Number of unclassified warnings: <b>' + str(unknown) + '</b><br>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001903 total = unknown + known + skipped
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001904 extra_msg = ''
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001905 if total < 1000:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001906 extra_msg = ' (low count may indicate incremental build)'
1907 print 'Total number of warnings: <b>' + str(total) + '</b>' + extra_msg
Marco Nelissen594375d2009-07-14 09:04:04 -07001908
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07001909
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001910# New base table of warnings, [severity, warn_id, project, warning_message]
1911# Need buttons to show warnings in different grouping options.
1912# (1) Current, group by severity, id for each warning pattern
1913# sort by severity, warn_id, warning_message
1914# (2) Current --byproject, group by severity,
1915# id for each warning pattern + project name
1916# sort by severity, warn_id, project, warning_message
1917# (3) New, group by project + severity,
1918# id for each warning pattern
1919# sort by project, severity, warn_id, warning_message
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001920def emit_buttons():
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001921 print ('<button class="button" onclick="expandCollapse(1);">'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001922 'Expand all warnings</button>\n'
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001923 '<button class="button" onclick="expandCollapse(0);">'
1924 'Collapse all warnings</button>\n'
1925 '<button class="button" onclick="groupBySeverity();">'
1926 'Group warnings by severity</button>\n'
1927 '<button class="button" onclick="groupByProject();">'
1928 'Group warnings by project</button><br>')
Marco Nelissen594375d2009-07-14 09:04:04 -07001929
1930
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001931def all_patterns(category):
1932 patterns = ''
1933 for i in category['patterns']:
1934 patterns += i
1935 patterns += ' / '
1936 return patterns
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001937
1938
1939def dump_fixed():
1940 """Show which warnings no longer occur."""
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001941 anchor = 'fixed_warnings'
1942 mark = anchor + '_mark'
1943 print ('\n<br><p style="background-color:lightblue"><b>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001944 '<button id="' + mark + '" '
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001945 'class="bt" onclick="expand(\'' + anchor + '\');">'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001946 '&#x2295</button> Fixed warnings. '
1947 'No more occurrences. Please consider turning these into '
1948 'errors if possible, before they are reintroduced in to the build'
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001949 ':</b></p>')
1950 print '<blockquote>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001951 fixed_patterns = []
1952 for i in warn_patterns:
1953 if not i['members']:
1954 fixed_patterns.append(i['description'] + ' (' +
1955 all_patterns(i) + ')')
1956 if i['option']:
1957 fixed_patterns.append(' ' + i['option'])
1958 fixed_patterns.sort()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001959 print '<div id="' + anchor + '" style="display:none;"><table>'
1960 cur_row_class = 0
1961 for text in fixed_patterns:
1962 cur_row_class = 1 - cur_row_class
1963 # remove last '\n'
1964 t = text[:-1] if text[-1] == '\n' else text
1965 print '<tr><td class="c' + str(cur_row_class) + '">' + t + '</td></tr>'
1966 print '</table></div>'
1967 print '</blockquote>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001968
1969
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001970def find_project_index(line):
1971 for p in range(len(project_patterns)):
1972 if project_patterns[p].match(line):
1973 return p
1974 return -1
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001975
1976
1977def classify_warning(line):
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001978 for i in range(len(warn_patterns)):
1979 w = warn_patterns[i]
1980 for cpat in w['compiled_patterns']:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001981 if cpat.match(line):
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001982 w['members'].append(line)
1983 p = find_project_index(line)
1984 index = len(warning_messages)
1985 warning_messages.append(line)
1986 warning_records.append([i, p, index])
1987 pname = '???' if p < 0 else project_names[p]
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001988 # Count warnings by project.
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001989 if pname in w['projects']:
1990 w['projects'][pname] += 1
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001991 else:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001992 w['projects'][pname] = 1
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001993 return
1994 else:
1995 # If we end up here, there was a problem parsing the log
1996 # probably caused by 'make -j' mixing the output from
1997 # 2 or more concurrent compiles
1998 pass
Marco Nelissen594375d2009-07-14 09:04:04 -07001999
2000
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002001def compile_patterns():
2002 """Precompiling every pattern speeds up parsing by about 30x."""
2003 for i in warn_patterns:
2004 i['compiled_patterns'] = []
2005 for pat in i['patterns']:
2006 i['compiled_patterns'].append(re.compile(pat))
2007
2008
2009def parse_input_file():
2010 """Parse input file, match warning lines."""
2011 global platform_version
2012 global target_product
2013 global target_variant
2014 infile = open(args.buildlog, 'r')
2015 line_counter = 0
2016
2017 warning_pattern = re.compile('.* warning:.*')
2018 compile_patterns()
2019
2020 # read the log file and classify all the warnings
2021 warning_lines = set()
2022 for line in infile:
2023 # replace fancy quotes with plain ol' quotes
2024 line = line.replace('‘', "'")
2025 line = line.replace('’', "'")
2026 if warning_pattern.match(line):
2027 if line not in warning_lines:
2028 classify_warning(line)
2029 warning_lines.add(line)
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002030 elif line_counter < 50:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002031 # save a little bit of time by only doing this for the first few lines
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002032 line_counter += 1
2033 m = re.search('(?<=^PLATFORM_VERSION=).*', line)
2034 if m is not None:
2035 platform_version = m.group(0)
2036 m = re.search('(?<=^TARGET_PRODUCT=).*', line)
2037 if m is not None:
2038 target_product = m.group(0)
2039 m = re.search('(?<=^TARGET_BUILD_VARIANT=).*', line)
2040 if m is not None:
2041 target_variant = m.group(0)
2042
2043
2044# Return s with escaped quotation characters.
2045def escape_string(s):
2046 return s.replace('"', '\\"')
2047
2048
2049# Return s without trailing '\n' and escape the quotation characters.
2050def strip_escape_string(s):
2051 if not s:
2052 return s
2053 s = s[:-1] if s[-1] == '\n' else s
2054 return escape_string(s)
2055
2056
2057def emit_warning_array(name):
2058 print 'var warning_{} = ['.format(name)
2059 for i in range(len(warn_patterns)):
2060 print '{},'.format(warn_patterns[i][name])
2061 print '];'
2062
2063
2064def emit_warning_arrays():
2065 emit_warning_array('severity')
2066 print 'var warning_description = ['
2067 for i in range(len(warn_patterns)):
2068 if warn_patterns[i]['members']:
2069 print '"{}",'.format(escape_string(warn_patterns[i]['description']))
2070 else:
2071 print '"",' # no such warning
2072 print '];'
2073
2074scripts_for_warning_groups = """
2075 function compareMessages(x1, x2) { // of the same warning type
2076 return (WarningMessages[x1[2]] <= WarningMessages[x2[2]]) ? -1 : 1;
2077 }
2078 function byMessageCount(x1, x2) {
2079 return x2[2] - x1[2]; // reversed order
2080 }
2081 function bySeverityMessageCount(x1, x2) {
2082 // orer by severity first
2083 if (x1[1] != x2[1])
2084 return x1[1] - x2[1];
2085 return byMessageCount(x1, x2);
2086 }
2087 const ParseLinePattern = /^([^ :]+):(\\d+):(.+)/;
2088 function addURL(line) {
2089 if (FlagURL == "") return line;
2090 if (FlagSeparator == "") {
2091 return line.replace(ParseLinePattern,
2092 "<a href='" + FlagURL + "/$1'>$1</a>:$2:$3");
2093 }
2094 return line.replace(ParseLinePattern,
2095 "<a href='" + FlagURL + "/$1" + FlagSeparator + "$2'>$1:$2</a>:$3");
2096 }
2097 function createArrayOfDictionaries(n) {
2098 var result = [];
2099 for (var i=0; i<n; i++) result.push({});
2100 return result;
2101 }
2102 function groupWarningsBySeverity() {
2103 // groups is an array of dictionaries,
2104 // each dictionary maps from warning type to array of warning messages.
2105 var groups = createArrayOfDictionaries(SeverityColors.length);
2106 for (var i=0; i<Warnings.length; i++) {
2107 var w = Warnings[i][0];
2108 var s = WarnPatternsSeverity[w];
2109 var k = w.toString();
2110 if (!(k in groups[s]))
2111 groups[s][k] = [];
2112 groups[s][k].push(Warnings[i]);
2113 }
2114 return groups;
2115 }
2116 function groupWarningsByProject() {
2117 var groups = createArrayOfDictionaries(ProjectNames.length);
2118 for (var i=0; i<Warnings.length; i++) {
2119 var w = Warnings[i][0];
2120 var p = Warnings[i][1];
2121 var k = w.toString();
2122 if (!(k in groups[p]))
2123 groups[p][k] = [];
2124 groups[p][k].push(Warnings[i]);
2125 }
2126 return groups;
2127 }
2128 var GlobalAnchor = 0;
2129 function createWarningSection(header, color, group) {
2130 var result = "";
2131 var groupKeys = [];
2132 var totalMessages = 0;
2133 for (var k in group) {
2134 totalMessages += group[k].length;
2135 groupKeys.push([k, WarnPatternsSeverity[parseInt(k)], group[k].length]);
2136 }
2137 groupKeys.sort(bySeverityMessageCount);
2138 for (var idx=0; idx<groupKeys.length; idx++) {
2139 var k = groupKeys[idx][0];
2140 var messages = group[k];
2141 var w = parseInt(k);
2142 var wcolor = SeverityColors[WarnPatternsSeverity[w]];
2143 var description = WarnPatternsDescription[w];
2144 if (description.length == 0)
2145 description = "???";
2146 GlobalAnchor += 1;
2147 result += "<table class='t1'><tr bgcolor='" + wcolor + "'><td>" +
2148 "<button class='bt' id='" + GlobalAnchor + "_mark" +
2149 "' onclick='expand(\\"" + GlobalAnchor + "\\");'>" +
2150 "&#x2295</button> " +
2151 description + " (" + messages.length + ")</td></tr></table>";
2152 result += "<div id='" + GlobalAnchor +
2153 "' style='display:none;'><table class='t1'>";
2154 var c = 0;
2155 messages.sort(compareMessages);
2156 for (var i=0; i<messages.length; i++) {
2157 result += "<tr><td class='c" + c + "'>" +
2158 addURL(WarningMessages[messages[i][2]]) + "</td></tr>";
2159 c = 1 - c;
2160 }
2161 result += "</table></div>";
2162 }
2163 if (result.length > 0) {
2164 return "<br><span style='background-color:" + color + "'><b>" +
2165 header + ": " + totalMessages +
2166 "</b></span><blockquote><table class='t1'>" +
2167 result + "</table></blockquote>";
2168
2169 }
2170 return ""; // empty section
2171 }
2172 function generateSectionsBySeverity() {
2173 var result = "";
2174 var groups = groupWarningsBySeverity();
2175 for (s=0; s<SeverityColors.length; s++) {
2176 result += createWarningSection(SeverityHeaders[s], SeverityColors[s], groups[s]);
2177 }
2178 return result;
2179 }
2180 function generateSectionsByProject() {
2181 var result = "";
2182 var groups = groupWarningsByProject();
2183 for (i=0; i<groups.length; i++) {
2184 result += createWarningSection(ProjectNames[i], 'lightgrey', groups[i]);
2185 }
2186 return result;
2187 }
2188 function groupWarnings(generator) {
2189 GlobalAnchor = 0;
2190 var e = document.getElementById("warning_groups");
2191 e.innerHTML = generator();
2192 }
2193 function groupBySeverity() {
2194 groupWarnings(generateSectionsBySeverity);
2195 }
2196 function groupByProject() {
2197 groupWarnings(generateSectionsByProject);
2198 }
2199"""
2200
2201
2202# Emit a JavaScript const string
2203def emit_const_string(name, value):
2204 print 'const ' + name + ' = "' + escape_string(value) + '";'
2205
2206
2207# Emit a JavaScript const integer array.
2208def emit_const_int_array(name, array):
2209 print 'const ' + name + ' = ['
2210 for n in array:
2211 print str(n) + ','
2212 print '];'
2213
2214
2215# Emit a JavaScript const string array.
2216def emit_const_string_array(name, array):
2217 print 'const ' + name + ' = ['
2218 for s in array:
2219 print '"' + strip_escape_string(s) + '",'
2220 print '];'
2221
2222
2223# Emit a JavaScript const object array.
2224def emit_const_object_array(name, array):
2225 print 'const ' + name + ' = ['
2226 for x in array:
2227 print str(x) + ','
2228 print '];'
2229
2230
2231def emit_js_data():
2232 """Dump dynamic HTML page's static JavaScript data."""
2233 emit_const_string('FlagURL', args.url if args.url else '')
2234 emit_const_string('FlagSeparator', args.separator if args.separator else '')
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002235 emit_const_string_array('SeverityColors', Severity.colors)
2236 emit_const_string_array('SeverityHeaders', Severity.headers)
2237 emit_const_string_array('SeverityColumnHeaders', Severity.column_headers)
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002238 emit_const_string_array('ProjectNames', project_names)
2239 emit_const_int_array('WarnPatternsSeverity',
2240 [w['severity'] for w in warn_patterns])
2241 emit_const_string_array('WarnPatternsDescription',
2242 [w['description'] for w in warn_patterns])
2243 emit_const_string_array('WarnPatternsOption',
2244 [w['option'] for w in warn_patterns])
2245 emit_const_string_array('WarningMessages', warning_messages)
2246 emit_const_object_array('Warnings', warning_records)
2247
2248draw_table_javascript = """
2249google.charts.load('current', {'packages':['table']});
2250google.charts.setOnLoadCallback(drawTable);
2251function drawTable() {
2252 var data = new google.visualization.DataTable();
2253 data.addColumn('string', StatsHeader[0]);
2254 for (var i=1; i<StatsHeader.length; i++) {
2255 data.addColumn('number', StatsHeader[i]);
2256 }
2257 data.addRows(StatsRows);
2258 for (var i=0; i<StatsRows.length; i++) {
2259 for (var j=0; j<StatsHeader.length; j++) {
2260 data.setProperty(i, j, 'style', 'border:1px solid black;');
2261 }
2262 }
2263 var table = new google.visualization.Table(document.getElementById('stats_table'));
2264 table.draw(data, {allowHtml: true, alternatingRowStyle: true});
2265}
2266"""
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002267
2268
2269def dump_html():
2270 """Dump the html output to stdout."""
2271 dump_html_prologue('Warnings for ' + platform_version + ' - ' +
2272 target_product + ' - ' + target_variant)
2273 dump_stats()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002274 print '<br><div id="stats_table"></div><br>'
2275 print '\n<script>'
2276 emit_js_data()
2277 print scripts_for_warning_groups
2278 print '</script>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002279 emit_buttons()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002280 # Warning messages are grouped by severities or project names.
2281 print '<br><div id="warning_groups"></div>'
2282 if args.byproject:
2283 print '<script>groupByProject();</script>'
2284 else:
2285 print '<script>groupBySeverity();</script>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002286 dump_fixed()
2287 dump_html_epilogue()
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002288
2289
2290##### Functions to count warnings and dump csv file. #########################
2291
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002292
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002293def description_for_csv(category):
2294 if not category['description']:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002295 return '?'
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002296 return category['description']
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002297
2298
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002299def string_for_csv(s):
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002300 # Only some Java warning desciptions have used quotation marks.
2301 # TODO(chh): if s has double quote character, s should be quoted.
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002302 if ',' in s:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002303 # TODO(chh): replace a double quote with two double quotes in s.
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002304 return '"{}"'.format(s)
2305 return s
2306
2307
2308def count_severity(sev, kind):
2309 """Count warnings of given severity."""
2310 total = 0
2311 for i in warn_patterns:
2312 if i['severity'] == sev and i['members']:
2313 n = len(i['members'])
2314 total += n
2315 warning = string_for_csv(kind + ': ' + description_for_csv(i))
2316 print '{},,{}'.format(n, warning)
2317 # print number of warnings for each project, ordered by project name.
2318 projects = i['projects'].keys()
2319 projects.sort()
2320 for p in projects:
2321 print '{},{},{}'.format(i['projects'][p], p, warning)
2322 print '{},,{}'.format(total, kind + ' warnings')
2323 return total
2324
2325
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002326# dump number of warnings in csv format to stdout
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002327def dump_csv():
2328 """Dump number of warnings in csv format to stdout."""
2329 sort_warnings()
2330 total = 0
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002331 for s in Severity.range:
2332 total += count_severity(s, Severity.column_headers[s])
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002333 print '{},,{}'.format(total, 'All warnings')
2334
2335
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002336##### Main function starts here. #########################
2337
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002338parse_input_file()
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002339if args.gencsv:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002340 dump_csv()
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002341else:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002342 dump_html()