blob: 2e7927a4dc3cc03c5023702c7e25d156a6e75c2e [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 Hsieh9f766232016-09-27 15:39:28 -07001664def project_name_and_pattern(name, pattern):
1665 return [name, '(^|.*/)' + pattern + '/.*: warning:']
1666
1667
1668def simple_project_pattern(pattern):
1669 return project_name_and_pattern(pattern, pattern)
1670
1671
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001672# A list of [project_name, file_path_pattern].
1673# project_name should not contain comma, to be used in CSV output.
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001674project_list = [
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001675 simple_project_pattern('art'),
1676 simple_project_pattern('bionic'),
1677 simple_project_pattern('bootable'),
1678 simple_project_pattern('build'),
1679 simple_project_pattern('cts'),
1680 simple_project_pattern('dalvik'),
1681 simple_project_pattern('developers'),
1682 simple_project_pattern('development'),
1683 simple_project_pattern('device'),
1684 simple_project_pattern('doc'),
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07001685 # match external/google* before external/
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001686 project_name_and_pattern('external/google', 'external/google.*'),
1687 project_name_and_pattern('external/non-google', 'external'),
1688 simple_project_pattern('frameworks/av/camera'),
1689 simple_project_pattern('frameworks/av/cmds'),
1690 simple_project_pattern('frameworks/av/drm'),
1691 simple_project_pattern('frameworks/av/include'),
1692 simple_project_pattern('frameworks/av/media'),
1693 simple_project_pattern('frameworks/av/radio'),
1694 simple_project_pattern('frameworks/av/services'),
1695 project_name_and_pattern('frameworks/av/Other', 'frameworks/av'),
1696 simple_project_pattern('frameworks/base'),
1697 simple_project_pattern('frameworks/compile'),
1698 simple_project_pattern('frameworks/minikin'),
1699 simple_project_pattern('frameworks/native'),
1700 simple_project_pattern('frameworks/opt'),
1701 simple_project_pattern('frameworks/rs'),
1702 simple_project_pattern('frameworks/webview'),
1703 simple_project_pattern('frameworks/wilhelm'),
1704 project_name_and_pattern('frameworks/Other', 'frameworks'),
1705 simple_project_pattern('hardware/akm'),
1706 simple_project_pattern('hardware/broadcom'),
1707 simple_project_pattern('hardware/google'),
1708 simple_project_pattern('hardware/intel'),
1709 simple_project_pattern('hardware/interfaces'),
1710 simple_project_pattern('hardware/libhardware'),
1711 simple_project_pattern('hardware/libhardware_legacy'),
1712 simple_project_pattern('hardware/qcom'),
1713 simple_project_pattern('hardware/ril'),
1714 project_name_and_pattern('hardware/Other', 'hardware'),
1715 simple_project_pattern('kernel'),
1716 simple_project_pattern('libcore'),
1717 simple_project_pattern('libnativehelper'),
1718 simple_project_pattern('ndk'),
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001719 # match vendor/unbungled_google/packages before other packages
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001720 simple_project_pattern('unbundled_google'),
1721 simple_project_pattern('packages'),
1722 simple_project_pattern('pdk'),
1723 simple_project_pattern('prebuilts'),
1724 simple_project_pattern('system/bt'),
1725 simple_project_pattern('system/connectivity'),
1726 simple_project_pattern('system/core'),
1727 simple_project_pattern('system/extras'),
1728 simple_project_pattern('system/gatekeeper'),
1729 simple_project_pattern('system/keymaster'),
1730 simple_project_pattern('system/libhwbinder'),
1731 simple_project_pattern('system/media'),
1732 simple_project_pattern('system/netd'),
1733 simple_project_pattern('system/security'),
1734 simple_project_pattern('system/sepolicy'),
1735 simple_project_pattern('system/tools'),
1736 simple_project_pattern('system/vold'),
1737 project_name_and_pattern('system/Other', 'system'),
1738 simple_project_pattern('toolchain'),
1739 simple_project_pattern('test'),
1740 simple_project_pattern('tools'),
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07001741 # match vendor/google* before vendor/
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001742 project_name_and_pattern('vendor/google', 'vendor/google.*'),
1743 project_name_and_pattern('vendor/non-google', 'vendor'),
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07001744 # keep out/obj and other patterns at the end.
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001745 ['out/obj',
1746 '.*/(gen|obj[^/]*)/(include|EXECUTABLES|SHARED_LIBRARIES|'
1747 'STATIC_LIBRARIES|NATIVE_TESTS)/.*: warning:'],
1748 ['other', '.*'] # all other unrecognized patterns
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001749]
1750
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001751project_patterns = []
1752project_names = []
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001753warning_messages = []
1754warning_records = []
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001755
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001756
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001757def initialize_arrays():
1758 """Complete global arrays before they are used."""
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001759 global project_names, project_patterns
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001760 project_names = [p[0] for p in project_list]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001761 project_patterns = [re.compile(p[1]) for p in project_list]
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001762 for w in warn_patterns:
1763 w['members'] = []
1764 if 'option' not in w:
1765 w['option'] = ''
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001766 # Each warning pattern has a 'projects' dictionary, that
1767 # maps a project name to number of warnings in that project.
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001768 w['projects'] = {}
1769
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001770
1771initialize_arrays()
1772
1773
1774platform_version = 'unknown'
1775target_product = 'unknown'
1776target_variant = 'unknown'
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001777
1778
1779##### Data and functions to dump html file. ##################################
1780
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001781html_head_scripts = """\
1782 <script type="text/javascript">
1783 function expand(id) {
1784 var e = document.getElementById(id);
1785 var f = document.getElementById(id + "_mark");
1786 if (e.style.display == 'block') {
1787 e.style.display = 'none';
1788 f.innerHTML = '&#x2295';
1789 }
1790 else {
1791 e.style.display = 'block';
1792 f.innerHTML = '&#x2296';
1793 }
1794 };
1795 function expandCollapse(show) {
1796 for (var id = 1; ; id++) {
1797 var e = document.getElementById(id + "");
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07001798 var f = document.getElementById(id + "_mark");
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001799 if (!e || !f) break;
1800 e.style.display = (show ? 'block' : 'none');
1801 f.innerHTML = (show ? '&#x2296' : '&#x2295');
1802 }
1803 };
1804 </script>
1805 <style type="text/css">
1806 th,td{border-collapse:collapse; border:1px solid black;}
1807 .button{color:blue;font-size:110%;font-weight:bolder;}
1808 .bt{color:black;background-color:transparent;border:none;outline:none;
1809 font-size:140%;font-weight:bolder;}
1810 .c0{background-color:#e0e0e0;}
1811 .c1{background-color:#d0d0d0;}
1812 .t1{border-collapse:collapse; width:100%; border:1px solid black;}
1813 </style>
1814 <script src="https://www.gstatic.com/charts/loader.js"></script>
1815"""
Marco Nelissen594375d2009-07-14 09:04:04 -07001816
Marco Nelissen594375d2009-07-14 09:04:04 -07001817
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001818def html_big(param):
1819 return '<font size="+2">' + param + '</font>'
Marco Nelissen594375d2009-07-14 09:04:04 -07001820
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07001821
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001822def dump_html_prologue(title):
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001823 print '<html>\n<head>'
1824 print '<title>' + title + '</title>'
1825 print html_head_scripts
1826 emit_stats_by_project()
1827 print '</head>\n<body>'
1828 print html_big(title)
1829 print '<p>'
Marco Nelissen594375d2009-07-14 09:04:04 -07001830
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001831
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001832def dump_html_epilogue():
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001833 print '</body>\n</head>\n</html>'
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001834
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001835
1836def sort_warnings():
1837 for i in warn_patterns:
1838 i['members'] = sorted(set(i['members']))
1839
1840
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001841def emit_stats_by_project():
1842 """Dump a google chart table of warnings per project and severity."""
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001843 # warnings[p][s] is number of warnings in project p of severity s.
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001844 warnings = {p: {s: 0 for s in Severity.range} for p in project_names}
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001845 for i in warn_patterns:
1846 s = i['severity']
1847 for p in i['projects']:
1848 warnings[p][s] += i['projects'][p]
1849
1850 # total_by_project[p] is number of warnings in project p.
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001851 total_by_project = {p: sum(warnings[p][s] for s in Severity.range)
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001852 for p in project_names}
1853
1854 # total_by_severity[s] is number of warnings of severity s.
1855 total_by_severity = {s: sum(warnings[p][s] for p in project_names)
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001856 for s in Severity.range}
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001857
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001858 # emit table header
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001859 stats_header = ['Project']
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001860 for s in Severity.range:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001861 if total_by_severity[s]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001862 stats_header.append("<span style='background-color:{}'>{}</span>".
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001863 format(Severity.colors[s],
1864 Severity.column_headers[s]))
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001865 stats_header.append('TOTAL')
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001866
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001867 # emit a row of warning counts per project, skip no-warning projects
1868 total_all_projects = 0
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001869 stats_rows = []
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001870 for p in project_names:
1871 if total_by_project[p]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001872 one_row = [p]
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001873 for s in Severity.range:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001874 if total_by_severity[s]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001875 one_row.append(warnings[p][s])
1876 one_row.append(total_by_project[p])
1877 stats_rows.append(one_row)
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001878 total_all_projects += total_by_project[p]
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001879
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001880 # emit a row of warning counts per severity
1881 total_all_severities = 0
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001882 one_row = ['<b>TOTAL</b>']
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001883 for s in Severity.range:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001884 if total_by_severity[s]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001885 one_row.append(total_by_severity[s])
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001886 total_all_severities += total_by_severity[s]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001887 one_row.append(total_all_projects)
1888 stats_rows.append(one_row)
1889 print '<script>'
1890 emit_const_string_array('StatsHeader', stats_header)
1891 emit_const_object_array('StatsRows', stats_rows)
1892 print draw_table_javascript
1893 print '</script>'
Marco Nelissen594375d2009-07-14 09:04:04 -07001894
1895
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001896def dump_stats():
1897 """Dump some stats about total number of warnings and such."""
1898 known = 0
1899 skipped = 0
1900 unknown = 0
1901 sort_warnings()
1902 for i in warn_patterns:
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001903 if i['severity'] == Severity.UNKNOWN:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001904 unknown += len(i['members'])
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001905 elif i['severity'] == Severity.SKIP:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001906 skipped += len(i['members'])
Ian Rogersf3829732016-05-10 12:06:01 -07001907 else:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001908 known += len(i['members'])
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001909 print 'Number of classified warnings: <b>' + str(known) + '</b><br>'
1910 print 'Number of skipped warnings: <b>' + str(skipped) + '</b><br>'
1911 print 'Number of unclassified warnings: <b>' + str(unknown) + '</b><br>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001912 total = unknown + known + skipped
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001913 extra_msg = ''
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001914 if total < 1000:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001915 extra_msg = ' (low count may indicate incremental build)'
1916 print 'Total number of warnings: <b>' + str(total) + '</b>' + extra_msg
Marco Nelissen594375d2009-07-14 09:04:04 -07001917
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07001918
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001919# New base table of warnings, [severity, warn_id, project, warning_message]
1920# Need buttons to show warnings in different grouping options.
1921# (1) Current, group by severity, id for each warning pattern
1922# sort by severity, warn_id, warning_message
1923# (2) Current --byproject, group by severity,
1924# id for each warning pattern + project name
1925# sort by severity, warn_id, project, warning_message
1926# (3) New, group by project + severity,
1927# id for each warning pattern
1928# sort by project, severity, warn_id, warning_message
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001929def emit_buttons():
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001930 print ('<button class="button" onclick="expandCollapse(1);">'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001931 'Expand all warnings</button>\n'
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001932 '<button class="button" onclick="expandCollapse(0);">'
1933 'Collapse all warnings</button>\n'
1934 '<button class="button" onclick="groupBySeverity();">'
1935 'Group warnings by severity</button>\n'
1936 '<button class="button" onclick="groupByProject();">'
1937 'Group warnings by project</button><br>')
Marco Nelissen594375d2009-07-14 09:04:04 -07001938
1939
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001940def all_patterns(category):
1941 patterns = ''
1942 for i in category['patterns']:
1943 patterns += i
1944 patterns += ' / '
1945 return patterns
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001946
1947
1948def dump_fixed():
1949 """Show which warnings no longer occur."""
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001950 anchor = 'fixed_warnings'
1951 mark = anchor + '_mark'
1952 print ('\n<br><p style="background-color:lightblue"><b>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001953 '<button id="' + mark + '" '
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001954 'class="bt" onclick="expand(\'' + anchor + '\');">'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001955 '&#x2295</button> Fixed warnings. '
1956 'No more occurrences. Please consider turning these into '
1957 'errors if possible, before they are reintroduced in to the build'
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001958 ':</b></p>')
1959 print '<blockquote>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001960 fixed_patterns = []
1961 for i in warn_patterns:
1962 if not i['members']:
1963 fixed_patterns.append(i['description'] + ' (' +
1964 all_patterns(i) + ')')
1965 if i['option']:
1966 fixed_patterns.append(' ' + i['option'])
1967 fixed_patterns.sort()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001968 print '<div id="' + anchor + '" style="display:none;"><table>'
1969 cur_row_class = 0
1970 for text in fixed_patterns:
1971 cur_row_class = 1 - cur_row_class
1972 # remove last '\n'
1973 t = text[:-1] if text[-1] == '\n' else text
1974 print '<tr><td class="c' + str(cur_row_class) + '">' + t + '</td></tr>'
1975 print '</table></div>'
1976 print '</blockquote>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001977
1978
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001979def find_project_index(line):
1980 for p in range(len(project_patterns)):
1981 if project_patterns[p].match(line):
1982 return p
1983 return -1
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001984
1985
1986def classify_warning(line):
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001987 for i in range(len(warn_patterns)):
1988 w = warn_patterns[i]
1989 for cpat in w['compiled_patterns']:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001990 if cpat.match(line):
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001991 w['members'].append(line)
1992 p = find_project_index(line)
1993 index = len(warning_messages)
1994 warning_messages.append(line)
1995 warning_records.append([i, p, index])
1996 pname = '???' if p < 0 else project_names[p]
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001997 # Count warnings by project.
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001998 if pname in w['projects']:
1999 w['projects'][pname] += 1
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002000 else:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002001 w['projects'][pname] = 1
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002002 return
2003 else:
2004 # If we end up here, there was a problem parsing the log
2005 # probably caused by 'make -j' mixing the output from
2006 # 2 or more concurrent compiles
2007 pass
Marco Nelissen594375d2009-07-14 09:04:04 -07002008
2009
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002010def compile_patterns():
2011 """Precompiling every pattern speeds up parsing by about 30x."""
2012 for i in warn_patterns:
2013 i['compiled_patterns'] = []
2014 for pat in i['patterns']:
2015 i['compiled_patterns'].append(re.compile(pat))
2016
2017
2018def parse_input_file():
2019 """Parse input file, match warning lines."""
2020 global platform_version
2021 global target_product
2022 global target_variant
2023 infile = open(args.buildlog, 'r')
2024 line_counter = 0
2025
2026 warning_pattern = re.compile('.* warning:.*')
2027 compile_patterns()
2028
2029 # read the log file and classify all the warnings
2030 warning_lines = set()
2031 for line in infile:
2032 # replace fancy quotes with plain ol' quotes
2033 line = line.replace('‘', "'")
2034 line = line.replace('’', "'")
2035 if warning_pattern.match(line):
2036 if line not in warning_lines:
2037 classify_warning(line)
2038 warning_lines.add(line)
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002039 elif line_counter < 50:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002040 # save a little bit of time by only doing this for the first few lines
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002041 line_counter += 1
2042 m = re.search('(?<=^PLATFORM_VERSION=).*', line)
2043 if m is not None:
2044 platform_version = m.group(0)
2045 m = re.search('(?<=^TARGET_PRODUCT=).*', line)
2046 if m is not None:
2047 target_product = m.group(0)
2048 m = re.search('(?<=^TARGET_BUILD_VARIANT=).*', line)
2049 if m is not None:
2050 target_variant = m.group(0)
2051
2052
2053# Return s with escaped quotation characters.
2054def escape_string(s):
2055 return s.replace('"', '\\"')
2056
2057
2058# Return s without trailing '\n' and escape the quotation characters.
2059def strip_escape_string(s):
2060 if not s:
2061 return s
2062 s = s[:-1] if s[-1] == '\n' else s
2063 return escape_string(s)
2064
2065
2066def emit_warning_array(name):
2067 print 'var warning_{} = ['.format(name)
2068 for i in range(len(warn_patterns)):
2069 print '{},'.format(warn_patterns[i][name])
2070 print '];'
2071
2072
2073def emit_warning_arrays():
2074 emit_warning_array('severity')
2075 print 'var warning_description = ['
2076 for i in range(len(warn_patterns)):
2077 if warn_patterns[i]['members']:
2078 print '"{}",'.format(escape_string(warn_patterns[i]['description']))
2079 else:
2080 print '"",' # no such warning
2081 print '];'
2082
2083scripts_for_warning_groups = """
2084 function compareMessages(x1, x2) { // of the same warning type
2085 return (WarningMessages[x1[2]] <= WarningMessages[x2[2]]) ? -1 : 1;
2086 }
2087 function byMessageCount(x1, x2) {
2088 return x2[2] - x1[2]; // reversed order
2089 }
2090 function bySeverityMessageCount(x1, x2) {
2091 // orer by severity first
2092 if (x1[1] != x2[1])
2093 return x1[1] - x2[1];
2094 return byMessageCount(x1, x2);
2095 }
2096 const ParseLinePattern = /^([^ :]+):(\\d+):(.+)/;
2097 function addURL(line) {
2098 if (FlagURL == "") return line;
2099 if (FlagSeparator == "") {
2100 return line.replace(ParseLinePattern,
2101 "<a href='" + FlagURL + "/$1'>$1</a>:$2:$3");
2102 }
2103 return line.replace(ParseLinePattern,
2104 "<a href='" + FlagURL + "/$1" + FlagSeparator + "$2'>$1:$2</a>:$3");
2105 }
2106 function createArrayOfDictionaries(n) {
2107 var result = [];
2108 for (var i=0; i<n; i++) result.push({});
2109 return result;
2110 }
2111 function groupWarningsBySeverity() {
2112 // groups is an array of dictionaries,
2113 // each dictionary maps from warning type to array of warning messages.
2114 var groups = createArrayOfDictionaries(SeverityColors.length);
2115 for (var i=0; i<Warnings.length; i++) {
2116 var w = Warnings[i][0];
2117 var s = WarnPatternsSeverity[w];
2118 var k = w.toString();
2119 if (!(k in groups[s]))
2120 groups[s][k] = [];
2121 groups[s][k].push(Warnings[i]);
2122 }
2123 return groups;
2124 }
2125 function groupWarningsByProject() {
2126 var groups = createArrayOfDictionaries(ProjectNames.length);
2127 for (var i=0; i<Warnings.length; i++) {
2128 var w = Warnings[i][0];
2129 var p = Warnings[i][1];
2130 var k = w.toString();
2131 if (!(k in groups[p]))
2132 groups[p][k] = [];
2133 groups[p][k].push(Warnings[i]);
2134 }
2135 return groups;
2136 }
2137 var GlobalAnchor = 0;
2138 function createWarningSection(header, color, group) {
2139 var result = "";
2140 var groupKeys = [];
2141 var totalMessages = 0;
2142 for (var k in group) {
2143 totalMessages += group[k].length;
2144 groupKeys.push([k, WarnPatternsSeverity[parseInt(k)], group[k].length]);
2145 }
2146 groupKeys.sort(bySeverityMessageCount);
2147 for (var idx=0; idx<groupKeys.length; idx++) {
2148 var k = groupKeys[idx][0];
2149 var messages = group[k];
2150 var w = parseInt(k);
2151 var wcolor = SeverityColors[WarnPatternsSeverity[w]];
2152 var description = WarnPatternsDescription[w];
2153 if (description.length == 0)
2154 description = "???";
2155 GlobalAnchor += 1;
2156 result += "<table class='t1'><tr bgcolor='" + wcolor + "'><td>" +
2157 "<button class='bt' id='" + GlobalAnchor + "_mark" +
2158 "' onclick='expand(\\"" + GlobalAnchor + "\\");'>" +
2159 "&#x2295</button> " +
2160 description + " (" + messages.length + ")</td></tr></table>";
2161 result += "<div id='" + GlobalAnchor +
2162 "' style='display:none;'><table class='t1'>";
2163 var c = 0;
2164 messages.sort(compareMessages);
2165 for (var i=0; i<messages.length; i++) {
2166 result += "<tr><td class='c" + c + "'>" +
2167 addURL(WarningMessages[messages[i][2]]) + "</td></tr>";
2168 c = 1 - c;
2169 }
2170 result += "</table></div>";
2171 }
2172 if (result.length > 0) {
2173 return "<br><span style='background-color:" + color + "'><b>" +
2174 header + ": " + totalMessages +
2175 "</b></span><blockquote><table class='t1'>" +
2176 result + "</table></blockquote>";
2177
2178 }
2179 return ""; // empty section
2180 }
2181 function generateSectionsBySeverity() {
2182 var result = "";
2183 var groups = groupWarningsBySeverity();
2184 for (s=0; s<SeverityColors.length; s++) {
2185 result += createWarningSection(SeverityHeaders[s], SeverityColors[s], groups[s]);
2186 }
2187 return result;
2188 }
2189 function generateSectionsByProject() {
2190 var result = "";
2191 var groups = groupWarningsByProject();
2192 for (i=0; i<groups.length; i++) {
2193 result += createWarningSection(ProjectNames[i], 'lightgrey', groups[i]);
2194 }
2195 return result;
2196 }
2197 function groupWarnings(generator) {
2198 GlobalAnchor = 0;
2199 var e = document.getElementById("warning_groups");
2200 e.innerHTML = generator();
2201 }
2202 function groupBySeverity() {
2203 groupWarnings(generateSectionsBySeverity);
2204 }
2205 function groupByProject() {
2206 groupWarnings(generateSectionsByProject);
2207 }
2208"""
2209
2210
2211# Emit a JavaScript const string
2212def emit_const_string(name, value):
2213 print 'const ' + name + ' = "' + escape_string(value) + '";'
2214
2215
2216# Emit a JavaScript const integer array.
2217def emit_const_int_array(name, array):
2218 print 'const ' + name + ' = ['
2219 for n in array:
2220 print str(n) + ','
2221 print '];'
2222
2223
2224# Emit a JavaScript const string array.
2225def emit_const_string_array(name, array):
2226 print 'const ' + name + ' = ['
2227 for s in array:
2228 print '"' + strip_escape_string(s) + '",'
2229 print '];'
2230
2231
2232# Emit a JavaScript const object array.
2233def emit_const_object_array(name, array):
2234 print 'const ' + name + ' = ['
2235 for x in array:
2236 print str(x) + ','
2237 print '];'
2238
2239
2240def emit_js_data():
2241 """Dump dynamic HTML page's static JavaScript data."""
2242 emit_const_string('FlagURL', args.url if args.url else '')
2243 emit_const_string('FlagSeparator', args.separator if args.separator else '')
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002244 emit_const_string_array('SeverityColors', Severity.colors)
2245 emit_const_string_array('SeverityHeaders', Severity.headers)
2246 emit_const_string_array('SeverityColumnHeaders', Severity.column_headers)
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002247 emit_const_string_array('ProjectNames', project_names)
2248 emit_const_int_array('WarnPatternsSeverity',
2249 [w['severity'] for w in warn_patterns])
2250 emit_const_string_array('WarnPatternsDescription',
2251 [w['description'] for w in warn_patterns])
2252 emit_const_string_array('WarnPatternsOption',
2253 [w['option'] for w in warn_patterns])
2254 emit_const_string_array('WarningMessages', warning_messages)
2255 emit_const_object_array('Warnings', warning_records)
2256
2257draw_table_javascript = """
2258google.charts.load('current', {'packages':['table']});
2259google.charts.setOnLoadCallback(drawTable);
2260function drawTable() {
2261 var data = new google.visualization.DataTable();
2262 data.addColumn('string', StatsHeader[0]);
2263 for (var i=1; i<StatsHeader.length; i++) {
2264 data.addColumn('number', StatsHeader[i]);
2265 }
2266 data.addRows(StatsRows);
2267 for (var i=0; i<StatsRows.length; i++) {
2268 for (var j=0; j<StatsHeader.length; j++) {
2269 data.setProperty(i, j, 'style', 'border:1px solid black;');
2270 }
2271 }
2272 var table = new google.visualization.Table(document.getElementById('stats_table'));
2273 table.draw(data, {allowHtml: true, alternatingRowStyle: true});
2274}
2275"""
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002276
2277
2278def dump_html():
2279 """Dump the html output to stdout."""
2280 dump_html_prologue('Warnings for ' + platform_version + ' - ' +
2281 target_product + ' - ' + target_variant)
2282 dump_stats()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002283 print '<br><div id="stats_table"></div><br>'
2284 print '\n<script>'
2285 emit_js_data()
2286 print scripts_for_warning_groups
2287 print '</script>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002288 emit_buttons()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002289 # Warning messages are grouped by severities or project names.
2290 print '<br><div id="warning_groups"></div>'
2291 if args.byproject:
2292 print '<script>groupByProject();</script>'
2293 else:
2294 print '<script>groupBySeverity();</script>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002295 dump_fixed()
2296 dump_html_epilogue()
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002297
2298
2299##### Functions to count warnings and dump csv file. #########################
2300
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002301
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002302def description_for_csv(category):
2303 if not category['description']:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002304 return '?'
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002305 return category['description']
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002306
2307
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002308def string_for_csv(s):
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002309 # Only some Java warning desciptions have used quotation marks.
2310 # TODO(chh): if s has double quote character, s should be quoted.
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002311 if ',' in s:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002312 # TODO(chh): replace a double quote with two double quotes in s.
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002313 return '"{}"'.format(s)
2314 return s
2315
2316
2317def count_severity(sev, kind):
2318 """Count warnings of given severity."""
2319 total = 0
2320 for i in warn_patterns:
2321 if i['severity'] == sev and i['members']:
2322 n = len(i['members'])
2323 total += n
2324 warning = string_for_csv(kind + ': ' + description_for_csv(i))
2325 print '{},,{}'.format(n, warning)
2326 # print number of warnings for each project, ordered by project name.
2327 projects = i['projects'].keys()
2328 projects.sort()
2329 for p in projects:
2330 print '{},{},{}'.format(i['projects'][p], p, warning)
2331 print '{},,{}'.format(total, kind + ' warnings')
2332 return total
2333
2334
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002335# dump number of warnings in csv format to stdout
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002336def dump_csv():
2337 """Dump number of warnings in csv format to stdout."""
2338 sort_warnings()
2339 total = 0
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002340 for s in Severity.range:
2341 total += count_severity(s, Severity.column_headers[s])
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002342 print '{},,{}'.format(total, 'All warnings')
2343
2344
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002345##### Main function starts here. #########################
2346
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002347parse_input_file()
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002348if args.gencsv:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002349 dump_csv()
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002350else:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002351 dump_html()