blob: 355d12019af02fea8ea64e53ce95700dbbd074f2 [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]
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -070035# android_root
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -070036# platform_version
37# target_product
38# target_variant
39# compile_patterns, parse_input_file
40#
41# To emit html page of warning messages:
42# flags: --byproject, --url, --separator
43# Old stuff for static html components:
44# html_script_style: static html scripts and styles
45# htmlbig:
46# dump_stats, dump_html_prologue, dump_html_epilogue:
47# emit_buttons:
48# dump_fixed
49# sort_warnings:
50# emit_stats_by_project:
51# all_patterns,
52# findproject, classify_warning
53# dump_html
54#
55# New dynamic HTML page's static JavaScript data:
56# Some data are copied from Python to JavaScript, to generate HTML elements.
57# FlagURL args.url
58# FlagSeparator args.separator
59# SeverityColors: severity.colors
60# SeverityHeaders: severity.headers
61# SeverityColumnHeaders: severity.column_headers
62# ProjectNames: project_names, or project_list[*][0]
63# WarnPatternsSeverity: warn_patterns[*]['severity']
64# WarnPatternsDescription: warn_patterns[*]['description']
65# WarnPatternsOption: warn_patterns[*]['option']
66# WarningMessages: warning_messages
67# Warnings: warning_records
68# StatsHeader: warning count table header row
69# StatsRows: array of warning count table rows
70#
71# New dynamic HTML page's dynamic JavaScript data:
72#
73# New dynamic HTML related function to emit data:
74# escape_string, strip_escape_string, emit_warning_arrays
75# emit_js_data():
76#
77# To emit csv files of warning message counts:
78# flag --gencsv
79# description_for_csv, string_for_csv:
80# count_severity(sev, kind):
81# dump_csv():
82
Ian Rogersf3829732016-05-10 12:06:01 -070083import argparse
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -070084import multiprocessing
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -070085import os
Marco Nelissen594375d2009-07-14 09:04:04 -070086import re
87
Ian Rogersf3829732016-05-10 12:06:01 -070088parser = argparse.ArgumentParser(description='Convert a build log into HTML')
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -070089parser.add_argument('--gencsv',
90 help='Generate a CSV file with number of various warnings',
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -070091 action='store_true',
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -070092 default=False)
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -070093parser.add_argument('--byproject',
94 help='Separate warnings in HTML output by project names',
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -070095 action='store_true',
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -070096 default=False)
Ian Rogersf3829732016-05-10 12:06:01 -070097parser.add_argument('--url',
98 help='Root URL of an Android source code tree prefixed '
99 'before files in warnings')
100parser.add_argument('--separator',
101 help='Separator between the end of a URL and the line '
102 'number argument. e.g. #')
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -0700103parser.add_argument('--processes',
104 type=int,
105 default=multiprocessing.cpu_count(),
106 help='Number of parallel processes to process warnings')
Ian Rogersf3829732016-05-10 12:06:01 -0700107parser.add_argument(dest='buildlog', metavar='build.log',
108 help='Path to build.log file')
109args = parser.parse_args()
Marco Nelissen594375d2009-07-14 09:04:04 -0700110
Marco Nelissen594375d2009-07-14 09:04:04 -0700111
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700112class Severity(object):
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700113 """Severity levels and attributes."""
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -0700114 # numbered by dump order
115 FIXMENOW = 0
116 HIGH = 1
117 MEDIUM = 2
118 LOW = 3
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -0700119 ANALYZER = 4
120 TIDY = 5
121 HARMLESS = 6
122 UNKNOWN = 7
123 SKIP = 8
124 range = range(SKIP + 1)
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700125 attributes = [
126 # pylint:disable=bad-whitespace
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700127 ['fuchsia', 'FixNow', 'Critical warnings, fix me now'],
128 ['red', 'High', 'High severity warnings'],
129 ['orange', 'Medium', 'Medium severity warnings'],
130 ['yellow', 'Low', 'Low severity warnings'],
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -0700131 ['hotpink', 'Analyzer', 'Clang-Analyzer warnings'],
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700132 ['peachpuff', 'Tidy', 'Clang-Tidy warnings'],
133 ['limegreen', 'Harmless', 'Harmless warnings'],
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -0700134 ['lightblue', 'Unknown', 'Unknown warnings'],
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700135 ['grey', 'Unhandled', 'Unhandled warnings']
136 ]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -0700137 colors = [a[0] for a in attributes]
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700138 column_headers = [a[1] for a in attributes]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -0700139 headers = [a[2] for a in attributes]
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700140
141warn_patterns = [
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700142 # pylint:disable=line-too-long,g-inconsistent-quotes
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -0700143 {'category': 'C/C++', 'severity': Severity.ANALYZER,
144 'description': 'clang-analyzer Security warning',
145 'patterns': [r".*: warning: .+\[clang-analyzer-security.*\]"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700146 {'category': 'make', 'severity': Severity.MEDIUM,
147 'description': 'make: overriding commands/ignoring old commands',
148 'patterns': [r".*: warning: overriding commands for target .+",
149 r".*: warning: ignoring old commands for target .+"]},
150 {'category': 'make', 'severity': Severity.HIGH,
151 'description': 'make: LOCAL_CLANG is false',
152 'patterns': [r".*: warning: LOCAL_CLANG is set to false"]},
153 {'category': 'make', 'severity': Severity.HIGH,
154 'description': 'SDK App using platform shared library',
155 'patterns': [r".*: warning: .+ \(.*app:sdk.*\) should not link to .+ \(native:platform\)"]},
156 {'category': 'make', 'severity': Severity.HIGH,
157 'description': 'System module linking to a vendor module',
158 'patterns': [r".*: warning: .+ \(.+\) should not link to .+ \(partition:.+\)"]},
159 {'category': 'make', 'severity': Severity.MEDIUM,
160 'description': 'Invalid SDK/NDK linking',
161 'patterns': [r".*: warning: .+ \(.+\) should not link to .+ \(.+\)"]},
162 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wimplicit-function-declaration',
163 'description': 'Implicit function declaration',
164 'patterns': [r".*: warning: implicit declaration of function .+",
165 r".*: warning: implicitly declaring library function"]},
166 {'category': 'C/C++', 'severity': Severity.SKIP,
167 'description': 'skip, conflicting types for ...',
168 'patterns': [r".*: warning: conflicting types for '.+'"]},
169 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wtype-limits',
170 'description': 'Expression always evaluates to true or false',
171 'patterns': [r".*: warning: comparison is always .+ due to limited range of data type",
172 r".*: warning: comparison of unsigned .*expression .+ is always true",
173 r".*: warning: comparison of unsigned .*expression .+ is always false"]},
174 {'category': 'C/C++', 'severity': Severity.HIGH,
175 'description': 'Potential leak of memory, bad free, use after free',
176 'patterns': [r".*: warning: Potential leak of memory",
177 r".*: warning: Potential memory leak",
178 r".*: warning: Memory allocated by alloca\(\) should not be deallocated",
179 r".*: warning: Memory allocated by .+ should be deallocated by .+ not .+",
180 r".*: warning: 'delete' applied to a pointer that was allocated",
181 r".*: warning: Use of memory after it is freed",
182 r".*: warning: Argument to .+ is the address of .+ variable",
183 r".*: warning: Argument to free\(\) is offset by .+ of memory allocated by",
184 r".*: warning: Attempt to .+ released memory"]},
185 {'category': 'C/C++', 'severity': Severity.HIGH,
186 'description': 'Use transient memory for control value',
187 'patterns': [r".*: warning: .+Using such transient memory for the control value is .*dangerous."]},
188 {'category': 'C/C++', 'severity': Severity.HIGH,
189 'description': 'Return address of stack memory',
190 'patterns': [r".*: warning: Address of stack memory .+ returned to caller",
191 r".*: warning: Address of stack memory .+ will be a dangling reference"]},
192 {'category': 'C/C++', 'severity': Severity.HIGH,
193 'description': 'Problem with vfork',
194 'patterns': [r".*: warning: This .+ is prohibited after a successful vfork",
195 r".*: warning: Call to function '.+' is insecure "]},
196 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': 'infinite-recursion',
197 'description': 'Infinite recursion',
198 'patterns': [r".*: warning: all paths through this function will call itself"]},
199 {'category': 'C/C++', 'severity': Severity.HIGH,
200 'description': 'Potential buffer overflow',
201 'patterns': [r".*: warning: Size argument is greater than .+ the destination buffer",
202 r".*: warning: Potential buffer overflow.",
203 r".*: warning: String copy function overflows destination buffer"]},
204 {'category': 'C/C++', 'severity': Severity.MEDIUM,
205 'description': 'Incompatible pointer types',
206 'patterns': [r".*: warning: assignment from incompatible pointer type",
207 r".*: warning: return from incompatible pointer type",
208 r".*: warning: passing argument [0-9]+ of '.*' from incompatible pointer type",
209 r".*: warning: initialization from incompatible pointer type"]},
210 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-fno-builtin',
211 'description': 'Incompatible declaration of built in function',
212 'patterns': [r".*: warning: incompatible implicit declaration of built-in function .+"]},
213 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wincompatible-library-redeclaration',
214 'description': 'Incompatible redeclaration of library function',
215 'patterns': [r".*: warning: incompatible redeclaration of library function .+"]},
216 {'category': 'C/C++', 'severity': Severity.HIGH,
217 'description': 'Null passed as non-null argument',
218 'patterns': [r".*: warning: Null passed to a callee that requires a non-null"]},
219 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused-parameter',
220 'description': 'Unused parameter',
221 'patterns': [r".*: warning: unused parameter '.*'"]},
222 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused',
223 'description': 'Unused function, variable or label',
224 'patterns': [r".*: warning: '.+' defined but not used",
225 r".*: warning: unused function '.+'",
226 r".*: warning: private field '.+' is not used",
227 r".*: warning: unused variable '.+'"]},
228 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused-value',
229 'description': 'Statement with no effect or result unused',
230 'patterns': [r".*: warning: statement with no effect",
231 r".*: warning: expression result unused"]},
232 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused-result',
233 'description': 'Ignoreing return value of function',
234 'patterns': [r".*: warning: ignoring return value of function .+Wunused-result"]},
235 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-field-initializers',
236 'description': 'Missing initializer',
237 'patterns': [r".*: warning: missing initializer"]},
238 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wdelete-non-virtual-dtor',
239 'description': 'Need virtual destructor',
240 'patterns': [r".*: warning: delete called .* has virtual functions but non-virtual destructor"]},
241 {'category': 'cont.', 'severity': Severity.SKIP,
242 'description': 'skip, near initialization for ...',
243 'patterns': [r".*: warning: \(near initialization for '.+'\)"]},
244 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wdate-time',
245 'description': 'Expansion of data or time macro',
246 'patterns': [r".*: warning: expansion of date or time macro is not reproducible"]},
247 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wformat',
248 'description': 'Format string does not match arguments',
249 'patterns': [r".*: warning: format '.+' expects type '.+', but argument [0-9]+ has type '.+'",
250 r".*: warning: more '%' conversions than data arguments",
251 r".*: warning: data argument not used by format string",
252 r".*: warning: incomplete format specifier",
253 r".*: warning: unknown conversion type .* in format",
254 r".*: warning: format .+ expects .+ but argument .+Wformat=",
255 r".*: warning: field precision should have .+ but argument has .+Wformat",
256 r".*: warning: format specifies type .+ but the argument has .*type .+Wformat"]},
257 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wformat-extra-args',
258 'description': 'Too many arguments for format string',
259 'patterns': [r".*: warning: too many arguments for format"]},
260 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wformat-invalid-specifier',
261 'description': 'Invalid format specifier',
262 'patterns': [r".*: warning: invalid .+ specifier '.+'.+format-invalid-specifier"]},
263 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsign-compare',
264 'description': 'Comparison between signed and unsigned',
265 'patterns': [r".*: warning: comparison between signed and unsigned",
266 r".*: warning: comparison of promoted \~unsigned with unsigned",
267 r".*: warning: signed and unsigned type in conditional expression"]},
268 {'category': 'C/C++', 'severity': Severity.MEDIUM,
269 'description': 'Comparison between enum and non-enum',
270 'patterns': [r".*: warning: enumeral and non-enumeral type in conditional expression"]},
271 {'category': 'libpng', 'severity': Severity.MEDIUM,
272 'description': 'libpng: zero area',
273 'patterns': [r".*libpng warning: Ignoring attempt to set cHRM RGB triangle with zero area"]},
274 {'category': 'aapt', 'severity': Severity.MEDIUM,
275 'description': 'aapt: no comment for public symbol',
276 'patterns': [r".*: warning: No comment for public symbol .+"]},
277 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-braces',
278 'description': 'Missing braces around initializer',
279 'patterns': [r".*: warning: missing braces around initializer.*"]},
280 {'category': 'C/C++', 'severity': Severity.HARMLESS,
281 'description': 'No newline at end of file',
282 'patterns': [r".*: warning: no newline at end of file"]},
283 {'category': 'C/C++', 'severity': Severity.HARMLESS,
284 'description': 'Missing space after macro name',
285 'patterns': [r".*: warning: missing whitespace after the macro name"]},
286 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wcast-align',
287 'description': 'Cast increases required alignment',
288 'patterns': [r".*: warning: cast from .* to .* increases required alignment .*"]},
289 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wcast-qual',
290 'description': 'Qualifier discarded',
291 'patterns': [r".*: warning: passing argument [0-9]+ of '.+' discards qualifiers from pointer target type",
292 r".*: warning: assignment discards qualifiers from pointer target type",
293 r".*: warning: passing .+ to parameter of type .+ discards qualifiers",
294 r".*: warning: assigning to .+ from .+ discards qualifiers",
295 r".*: warning: initializing .+ discards qualifiers .+types-discards-qualifiers",
296 r".*: warning: return discards qualifiers from pointer target type"]},
297 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunknown-attributes',
298 'description': 'Unknown attribute',
299 'patterns': [r".*: warning: unknown attribute '.+'"]},
300 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wignored-attributes',
301 'description': 'Attribute ignored',
302 'patterns': [r".*: warning: '_*packed_*' attribute ignored",
303 r".*: warning: attribute declaration must precede definition .+ignored-attributes"]},
304 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wvisibility',
305 'description': 'Visibility problem',
306 'patterns': [r".*: warning: declaration of '.+' will not be visible outside of this function"]},
307 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wattributes',
308 'description': 'Visibility mismatch',
309 'patterns': [r".*: warning: '.+' declared with greater visibility than the type of its field '.+'"]},
310 {'category': 'C/C++', 'severity': Severity.MEDIUM,
311 'description': 'Shift count greater than width of type',
312 'patterns': [r".*: warning: (left|right) shift count >= width of type"]},
313 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wextern-initializer',
314 'description': 'extern <foo> is initialized',
315 'patterns': [r".*: warning: '.+' initialized and declared 'extern'",
316 r".*: warning: 'extern' variable has an initializer"]},
317 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wold-style-declaration',
318 'description': 'Old style declaration',
319 'patterns': [r".*: warning: 'static' is not at beginning of declaration"]},
320 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wreturn-type',
321 'description': 'Missing return value',
322 'patterns': [r".*: warning: control reaches end of non-void function"]},
323 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wimplicit-int',
324 'description': 'Implicit int type',
325 'patterns': [r".*: warning: type specifier missing, defaults to 'int'",
326 r".*: warning: type defaults to 'int' in declaration of '.+'"]},
327 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmain-return-type',
328 'description': 'Main function should return int',
329 'patterns': [r".*: warning: return type of 'main' is not 'int'"]},
330 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wuninitialized',
331 'description': 'Variable may be used uninitialized',
332 'patterns': [r".*: warning: '.+' may be used uninitialized in this function"]},
333 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wuninitialized',
334 'description': 'Variable is used uninitialized',
335 'patterns': [r".*: warning: '.+' is used uninitialized in this function",
336 r".*: warning: variable '.+' is uninitialized when used here"]},
337 {'category': 'ld', 'severity': Severity.MEDIUM, 'option': '-fshort-enums',
338 'description': 'ld: possible enum size mismatch',
339 'patterns': [r".*: warning: .* uses variable-size enums yet the output is to use 32-bit enums; use of enum values across objects may fail"]},
340 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wpointer-sign',
341 'description': 'Pointer targets differ in signedness',
342 'patterns': [r".*: warning: pointer targets in initialization differ in signedness",
343 r".*: warning: pointer targets in assignment differ in signedness",
344 r".*: warning: pointer targets in return differ in signedness",
345 r".*: warning: pointer targets in passing argument [0-9]+ of '.+' differ in signedness"]},
346 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wstrict-overflow',
347 'description': 'Assuming overflow does not occur',
348 'patterns': [r".*: warning: assuming signed overflow does not occur when assuming that .* is always (true|false)"]},
349 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wempty-body',
350 'description': 'Suggest adding braces around empty body',
351 'patterns': [r".*: warning: suggest braces around empty body in an 'if' statement",
352 r".*: warning: empty body in an if-statement",
353 r".*: warning: suggest braces around empty body in an 'else' statement",
354 r".*: warning: empty body in an else-statement"]},
355 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wparentheses',
356 'description': 'Suggest adding parentheses',
357 'patterns': [r".*: warning: suggest explicit braces to avoid ambiguous 'else'",
358 r".*: warning: suggest parentheses around arithmetic in operand of '.+'",
359 r".*: warning: suggest parentheses around comparison in operand of '.+'",
360 r".*: warning: logical not is only applied to the left hand side of this comparison",
361 r".*: warning: using the result of an assignment as a condition without parentheses",
362 r".*: warning: .+ has lower precedence than .+ be evaluated first .+Wparentheses",
363 r".*: warning: suggest parentheses around '.+?' .+ '.+?'",
364 r".*: warning: suggest parentheses around assignment used as truth value"]},
365 {'category': 'C/C++', 'severity': Severity.MEDIUM,
366 'description': 'Static variable used in non-static inline function',
367 'patterns': [r".*: warning: '.+' is static but used in inline function '.+' which is not static"]},
368 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wimplicit int',
369 'description': 'No type or storage class (will default to int)',
370 'patterns': [r".*: warning: data definition has no type or storage class"]},
371 {'category': 'C/C++', 'severity': Severity.MEDIUM,
372 'description': 'Null pointer',
373 'patterns': [r".*: warning: Dereference of null pointer",
374 r".*: warning: Called .+ pointer is null",
375 r".*: warning: Forming reference to null pointer",
376 r".*: warning: Returning null reference",
377 r".*: warning: Null pointer passed as an argument to a 'nonnull' parameter",
378 r".*: warning: .+ results in a null pointer dereference",
379 r".*: warning: Access to .+ results in a dereference of a null pointer",
380 r".*: warning: Null pointer argument in"]},
381 {'category': 'cont.', 'severity': Severity.SKIP,
382 'description': 'skip, parameter name (without types) in function declaration',
383 'patterns': [r".*: warning: parameter names \(without types\) in function declaration"]},
384 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wstrict-aliasing',
385 'description': 'Dereferencing <foo> breaks strict aliasing rules',
386 'patterns': [r".*: warning: dereferencing .* break strict-aliasing rules"]},
387 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wpointer-to-int-cast',
388 'description': 'Cast from pointer to integer of different size',
389 'patterns': [r".*: warning: cast from pointer to integer of different size",
390 r".*: warning: initialization makes pointer from integer without a cast"]},
391 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wint-to-pointer-cast',
392 'description': 'Cast to pointer from integer of different size',
393 'patterns': [r".*: warning: cast to pointer from integer of different size"]},
394 {'category': 'C/C++', 'severity': Severity.MEDIUM,
395 'description': 'Symbol redefined',
396 'patterns': [r".*: warning: "".+"" redefined"]},
397 {'category': 'cont.', 'severity': Severity.SKIP,
398 'description': 'skip, ... location of the previous definition',
399 'patterns': [r".*: warning: this is the location of the previous definition"]},
400 {'category': 'ld', 'severity': Severity.MEDIUM,
401 'description': 'ld: type and size of dynamic symbol are not defined',
402 'patterns': [r".*: warning: type and size of dynamic symbol `.+' are not defined"]},
403 {'category': 'C/C++', 'severity': Severity.MEDIUM,
404 'description': 'Pointer from integer without cast',
405 'patterns': [r".*: warning: assignment makes pointer from integer without a cast"]},
406 {'category': 'C/C++', 'severity': Severity.MEDIUM,
407 'description': 'Pointer from integer without cast',
408 'patterns': [r".*: warning: passing argument [0-9]+ of '.+' makes pointer from integer without a cast"]},
409 {'category': 'C/C++', 'severity': Severity.MEDIUM,
410 'description': 'Integer from pointer without cast',
411 'patterns': [r".*: warning: assignment makes integer from pointer without a cast"]},
412 {'category': 'C/C++', 'severity': Severity.MEDIUM,
413 'description': 'Integer from pointer without cast',
414 'patterns': [r".*: warning: passing argument [0-9]+ of '.+' makes integer from pointer without a cast"]},
415 {'category': 'C/C++', 'severity': Severity.MEDIUM,
416 'description': 'Integer from pointer without cast',
417 'patterns': [r".*: warning: return makes integer from pointer without a cast"]},
418 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunknown-pragmas',
419 'description': 'Ignoring pragma',
420 'patterns': [r".*: warning: ignoring #pragma .+"]},
421 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-W#pragma-messages',
422 'description': 'Pragma warning messages',
423 'patterns': [r".*: warning: .+W#pragma-messages"]},
424 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wclobbered',
425 'description': 'Variable might be clobbered by longjmp or vfork',
426 'patterns': [r".*: warning: variable '.+' might be clobbered by 'longjmp' or 'vfork'"]},
427 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wclobbered',
428 'description': 'Argument might be clobbered by longjmp or vfork',
429 'patterns': [r".*: warning: argument '.+' might be clobbered by 'longjmp' or 'vfork'"]},
430 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wredundant-decls',
431 'description': 'Redundant declaration',
432 'patterns': [r".*: warning: redundant redeclaration of '.+'"]},
433 {'category': 'cont.', 'severity': Severity.SKIP,
434 'description': 'skip, previous declaration ... was here',
435 'patterns': [r".*: warning: previous declaration of '.+' was here"]},
436 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wswitch-enum',
437 'description': 'Enum value not handled in switch',
438 'patterns': [r".*: warning: .*enumeration value.* not handled in switch.+Wswitch"]},
439 {'category': 'java', 'severity': Severity.MEDIUM, 'option': '-encoding',
440 'description': 'Java: Non-ascii characters used, but ascii encoding specified',
441 'patterns': [r".*: warning: unmappable character for encoding ascii"]},
442 {'category': 'java', 'severity': Severity.MEDIUM,
443 'description': 'Java: Non-varargs call of varargs method with inexact argument type for last parameter',
444 'patterns': [r".*: warning: non-varargs call of varargs method with inexact argument type for last parameter"]},
445 {'category': 'java', 'severity': Severity.MEDIUM,
446 'description': 'Java: Unchecked method invocation',
447 'patterns': [r".*: warning: \[unchecked\] unchecked method invocation: .+ in class .+"]},
448 {'category': 'java', 'severity': Severity.MEDIUM,
449 'description': 'Java: Unchecked conversion',
450 'patterns': [r".*: warning: \[unchecked\] unchecked conversion"]},
451 {'category': 'java', 'severity': Severity.MEDIUM,
452 'description': '_ used as an identifier',
453 'patterns': [r".*: warning: '_' used as an identifier"]},
Ian Rogers32bb9bd2016-05-09 23:19:42 -0700454
Ian Rogers6e520032016-05-13 08:59:00 -0700455 # Warnings from Error Prone.
456 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700457 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700458 'description': 'Java: Use of deprecated member',
459 'patterns': [r'.*: warning: \[deprecation\] .+']},
460 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700461 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700462 'description': 'Java: Unchecked conversion',
463 'patterns': [r'.*: warning: \[unchecked\] .+']},
Ian Rogers32bb9bd2016-05-09 23:19:42 -0700464
Ian Rogers6e520032016-05-13 08:59:00 -0700465 # Warnings from Error Prone (auto generated list).
466 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700467 'severity': Severity.LOW,
Ian Rogers6e520032016-05-13 08:59:00 -0700468 'description':
469 'Java: Deprecated item is not annotated with @Deprecated',
470 'patterns': [r".*: warning: \[DepAnn\] .+"]},
471 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700472 'severity': Severity.LOW,
Ian Rogers6e520032016-05-13 08:59:00 -0700473 'description':
474 'Java: Fallthrough warning suppression has no effect if warning is suppressed',
475 'patterns': [r".*: warning: \[FallthroughSuppression\] .+"]},
476 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700477 'severity': Severity.LOW,
Ian Rogers6e520032016-05-13 08:59:00 -0700478 'description':
479 'Java: Prefer \'L\' to \'l\' for the suffix to long literals',
480 'patterns': [r".*: warning: \[LongLiteralLowerCaseSuffix\] .+"]},
481 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700482 'severity': Severity.LOW,
Ian Rogers6e520032016-05-13 08:59:00 -0700483 'description':
484 'Java: @Binds is a more efficient and declaritive mechanism for delegating a binding.',
485 'patterns': [r".*: warning: \[UseBinds\] .+"]},
486 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700487 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700488 'description':
489 'Java: Assertions may be disabled at runtime and do not guarantee that execution will halt here; consider throwing an exception instead',
490 'patterns': [r".*: warning: \[AssertFalse\] .+"]},
491 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700492 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700493 'description':
494 'Java: Classes that implement Annotation must override equals and hashCode. Consider using AutoAnnotation instead of implementing Annotation by hand.',
495 'patterns': [r".*: warning: \[BadAnnotationImplementation\] .+"]},
496 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700497 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700498 'description':
499 'Java: BigDecimal(double) and BigDecimal.valueOf(double) may lose precision, prefer BigDecimal(String) or BigDecimal(long)',
500 'patterns': [r".*: warning: \[BigDecimalLiteralDouble\] .+"]},
501 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700502 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700503 'description':
504 'Java: Mockito cannot mock final classes',
505 'patterns': [r".*: warning: \[CannotMockFinalClass\] .+"]},
506 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700507 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700508 'description':
509 'Java: This code, which counts elements using a loop, can be replaced by a simpler library method',
510 'patterns': [r".*: warning: \[ElementsCountedInLoop\] .+"]},
511 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700512 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700513 'description':
514 'Java: Empty top-level type declaration',
515 'patterns': [r".*: warning: \[EmptyTopLevelDeclaration\] .+"]},
516 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700517 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700518 'description':
519 'Java: Classes that override equals should also override hashCode.',
520 'patterns': [r".*: warning: \[EqualsHashCode\] .+"]},
521 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700522 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700523 'description':
524 'Java: An equality test between objects with incompatible types always returns false',
525 'patterns': [r".*: warning: \[EqualsIncompatibleType\] .+"]},
526 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700527 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700528 'description':
529 '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.',
530 'patterns': [r".*: warning: \[Finally\] .+"]},
531 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700532 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700533 'description':
534 'Java: This annotation has incompatible modifiers as specified by its @IncompatibleModifiers annotation',
535 'patterns': [r".*: warning: \[IncompatibleModifiers\] .+"]},
536 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700537 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700538 'description':
539 'Java: Class should not implement both `Iterable` and `Iterator`',
540 'patterns': [r".*: warning: \[IterableAndIterator\] .+"]},
541 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700542 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700543 'description':
544 'Java: Floating-point comparison without error tolerance',
545 'patterns': [r".*: warning: \[JUnit3FloatingPointComparisonWithoutDelta\] .+"]},
546 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700547 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700548 'description':
549 'Java: Test class inherits from JUnit 3\'s TestCase but has JUnit 4 @Test annotations.',
550 'patterns': [r".*: warning: \[JUnitAmbiguousTestClass\] .+"]},
551 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700552 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700553 'description':
554 'Java: Enum switch statement is missing cases',
555 'patterns': [r".*: warning: \[MissingCasesInEnumSwitch\] .+"]},
556 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700557 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700558 'description':
559 'Java: Not calling fail() when expecting an exception masks bugs',
560 'patterns': [r".*: warning: \[MissingFail\] .+"]},
561 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700562 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700563 'description':
564 'Java: method overrides method in supertype; expected @Override',
565 'patterns': [r".*: warning: \[MissingOverride\] .+"]},
566 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700567 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700568 'description':
569 'Java: Source files should not contain multiple top-level class declarations',
570 'patterns': [r".*: warning: \[MultipleTopLevelClasses\] .+"]},
571 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700572 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700573 'description':
574 'Java: This update of a volatile variable is non-atomic',
575 'patterns': [r".*: warning: \[NonAtomicVolatileUpdate\] .+"]},
576 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700577 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700578 'description':
579 'Java: Static import of member uses non-canonical name',
580 'patterns': [r".*: warning: \[NonCanonicalStaticMemberImport\] .+"]},
581 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700582 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700583 'description':
584 'Java: equals method doesn\'t override Object.equals',
585 'patterns': [r".*: warning: \[NonOverridingEquals\] .+"]},
586 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700587 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700588 'description':
589 'Java: Constructors should not be annotated with @Nullable since they cannot return null',
590 'patterns': [r".*: warning: \[NullableConstructor\] .+"]},
591 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700592 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700593 'description':
594 'Java: @Nullable should not be used for primitive types since they cannot be null',
595 'patterns': [r".*: warning: \[NullablePrimitive\] .+"]},
596 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700597 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700598 'description':
599 'Java: void-returning methods should not be annotated with @Nullable, since they cannot return null',
600 'patterns': [r".*: warning: \[NullableVoid\] .+"]},
601 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700602 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700603 'description':
604 'Java: Package names should match the directory they are declared in',
605 'patterns': [r".*: warning: \[PackageLocation\] .+"]},
606 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700607 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700608 'description':
609 'Java: Second argument to Preconditions.* is a call to String.format(), which can be unwrapped',
610 'patterns': [r".*: warning: \[PreconditionsErrorMessageEagerEvaluation\] .+"]},
611 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700612 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700613 'description':
614 'Java: Preconditions only accepts the %s placeholder in error message strings',
615 'patterns': [r".*: warning: \[PreconditionsInvalidPlaceholder\] .+"]},
616 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700617 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700618 'description':
619 'Java: Passing a primitive array to a varargs method is usually wrong',
620 'patterns': [r".*: warning: \[PrimitiveArrayPassedToVarargsMethod\] .+"]},
621 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700622 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700623 'description':
624 'Java: Protobuf fields cannot be null, so this check is redundant',
625 'patterns': [r".*: warning: \[ProtoFieldPreconditionsCheckNotNull\] .+"]},
626 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700627 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700628 'description':
629 'Java: This annotation is missing required modifiers as specified by its @RequiredModifiers annotation',
630 'patterns': [r".*: warning: \[RequiredModifiers\] .+"]},
631 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700632 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700633 'description':
634 'Java: A static variable or method should not be accessed from an object instance',
635 'patterns': [r".*: warning: \[StaticAccessedFromInstance\] .+"]},
636 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700637 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700638 'description':
639 'Java: String comparison using reference equality instead of value equality',
640 'patterns': [r".*: warning: \[StringEquality\] .+"]},
641 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700642 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700643 'description':
644 '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.',
645 'patterns': [r".*: warning: \[TypeParameterUnusedInFormals\] .+"]},
646 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700647 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700648 'description':
649 'Java: Using static imports for types is unnecessary',
650 'patterns': [r".*: warning: \[UnnecessaryStaticImport\] .+"]},
651 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700652 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700653 'description':
654 'Java: Unsynchronized method overrides a synchronized method.',
655 'patterns': [r".*: warning: \[UnsynchronizedOverridesSynchronized\] .+"]},
656 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700657 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700658 'description':
659 'Java: Non-constant variable missing @Var annotation',
660 'patterns': [r".*: warning: \[Var\] .+"]},
661 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700662 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700663 'description':
664 'Java: Because of spurious wakeups, Object.wait() and Condition.await() must always be called in a loop',
665 'patterns': [r".*: warning: \[WaitNotInLoop\] .+"]},
666 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700667 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700668 'description':
669 'Java: Subclasses of Fragment must be instantiable via Class#newInstance(): the class must be public, static and have a public nullary constructor',
670 'patterns': [r".*: warning: \[FragmentNotInstantiable\] .+"]},
671 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700672 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700673 'description':
674 'Java: Hardcoded reference to /sdcard',
675 'patterns': [r".*: warning: \[HardCodedSdCardPath\] .+"]},
676 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700677 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700678 'description':
679 'Java: Incompatible type as argument to Object-accepting Java collections method',
680 'patterns': [r".*: warning: \[CollectionIncompatibleType\] .+"]},
681 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700682 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700683 'description':
684 'Java: @AssistedInject and @Inject should not be used on different constructors in the same class.',
685 'patterns': [r".*: warning: \[AssistedInjectAndInjectOnConstructors\] .+"]},
686 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700687 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700688 'description':
689 'Java: Although Guice allows injecting final fields, doing so is not recommended because the injected value may not be visible to other threads.',
690 'patterns': [r".*: warning: \[GuiceInjectOnFinalField\] .+"]},
691 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700692 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700693 'description':
694 'Java: This method is not annotated with @Inject, but it overrides a method that is annotated with @com.google.inject.Inject. Guice will inject this method, and it is recommended to annotate it explicitly.',
695 'patterns': [r".*: warning: \[OverridesGuiceInjectableMethod\] .+"]},
696 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700697 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700698 'description':
699 'Java: Double-checked locking on non-volatile fields is unsafe',
700 'patterns': [r".*: warning: \[DoubleCheckedLocking\] .+"]},
701 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700702 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700703 'description':
704 'Java: Writes to static fields should not be guarded by instance locks',
705 'patterns': [r".*: warning: \[StaticGuardedByInstance\] .+"]},
706 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700707 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700708 'description':
709 'Java: Synchronizing on non-final fields is not safe: if the field is ever updated, different threads may end up locking on different objects.',
710 'patterns': [r".*: warning: \[SynchronizeOnNonFinalField\] .+"]},
711 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700712 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700713 'description':
714 'Java: Reference equality used to compare arrays',
715 'patterns': [r".*: warning: \[ArrayEquals\] .+"]},
716 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700717 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700718 'description':
719 'Java: hashcode method on array does not hash array contents',
720 'patterns': [r".*: warning: \[ArrayHashCode\] .+"]},
721 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700722 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700723 'description':
724 'Java: Calling toString on an array does not provide useful information',
725 'patterns': [r".*: warning: \[ArrayToString.*\] .+"]},
726 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700727 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700728 'description':
729 'Java: Arrays.asList does not autobox primitive arrays, as one might expect.',
730 'patterns': [r".*: warning: \[ArraysAsListPrimitiveArray\] .+"]},
731 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700732 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700733 'description':
734 'Java: AsyncCallable should not return a null Future, only a Future whose result is null.',
735 'patterns': [r".*: warning: \[AsyncCallableReturnsNull\] .+"]},
736 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700737 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700738 'description':
739 'Java: AsyncFunction should not return a null Future, only a Future whose result is null.',
740 'patterns': [r".*: warning: \[AsyncFunctionReturnsNull\] .+"]},
741 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700742 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700743 'description':
744 'Java: Possible sign flip from narrowing conversion',
745 'patterns': [r".*: warning: \[BadComparable\] .+"]},
746 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700747 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700748 'description':
749 'Java: Shift by an amount that is out of range',
750 'patterns': [r".*: warning: \[BadShiftAmount\] .+"]},
751 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700752 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700753 'description':
754 'Java: valueOf provides better time and space performance',
755 'patterns': [r".*: warning: \[BoxedPrimitiveConstructor\] .+"]},
756 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700757 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700758 'description':
759 '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.',
760 'patterns': [r".*: warning: \[ChainingConstructorIgnoresParameter\] .+"]},
761 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700762 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700763 'description':
764 'Java: Ignored return value of method that is annotated with @CheckReturnValue',
765 'patterns': [r".*: warning: \[CheckReturnValue\] .+"]},
766 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700767 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700768 'description':
769 'Java: Inner class is non-static but does not reference enclosing class',
770 'patterns': [r".*: warning: \[ClassCanBeStatic\] .+"]},
771 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700772 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700773 'description':
774 'Java: The source file name should match the name of the top-level class it contains',
775 'patterns': [r".*: warning: \[ClassName\] .+"]},
776 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700777 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700778 'description':
779 'Java: This comparison method violates the contract',
780 'patterns': [r".*: warning: \[ComparisonContractViolated\] .+"]},
781 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700782 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700783 'description':
784 'Java: Comparison to value that is out of range for the compared type',
785 'patterns': [r".*: warning: \[ComparisonOutOfRange\] .+"]},
786 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700787 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700788 'description':
789 'Java: Non-compile-time constant expression passed to parameter with @CompileTimeConstant type annotation.',
790 'patterns': [r".*: warning: \[CompileTimeConstant\] .+"]},
791 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700792 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700793 'description':
794 'Java: Exception created but not thrown',
795 'patterns': [r".*: warning: \[DeadException\] .+"]},
796 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700797 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700798 'description':
799 'Java: Division by integer literal zero',
800 'patterns': [r".*: warning: \[DivZero\] .+"]},
801 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700802 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700803 'description':
804 'Java: Empty statement after if',
805 'patterns': [r".*: warning: \[EmptyIf\] .+"]},
806 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700807 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700808 'description':
809 'Java: == NaN always returns false; use the isNaN methods instead',
810 'patterns': [r".*: warning: \[EqualsNaN\] .+"]},
811 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700812 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700813 'description':
814 'Java: Method annotated @ForOverride must be protected or package-private and only invoked from declaring class',
815 'patterns': [r".*: warning: \[ForOverride\] .+"]},
816 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700817 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700818 'description':
819 'Java: Futures.getChecked requires a checked exception type with a standard constructor.',
820 'patterns': [r".*: warning: \[FuturesGetCheckedIllegalExceptionType\] .+"]},
821 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700822 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700823 'description':
824 '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',
825 'patterns': [r".*: warning: \[GetClassOnClass\] .+"]},
826 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700827 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700828 'description':
829 'Java: An object is tested for equality to itself using Guava Libraries',
830 'patterns': [r".*: warning: \[GuavaSelfEquals\] .+"]},
831 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700832 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700833 'description':
834 'Java: contains() is a legacy method that is equivalent to containsValue()',
835 'patterns': [r".*: warning: \[HashtableContains\] .+"]},
836 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700837 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700838 'description':
839 'Java: Cipher.getInstance() is invoked using either the default settings or ECB mode',
840 'patterns': [r".*: warning: \[InsecureCipherMode\] .+"]},
841 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700842 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700843 'description':
844 'Java: Invalid syntax used for a regular expression',
845 'patterns': [r".*: warning: \[InvalidPatternSyntax\] .+"]},
846 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700847 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700848 'description':
849 'Java: The argument to Class#isInstance(Object) should not be a Class',
850 'patterns': [r".*: warning: \[IsInstanceOfClass\] .+"]},
851 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700852 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700853 'description':
854 'Java: jMock tests must have a @RunWith(JMock.class) annotation, or the Mockery field must have a @Rule JUnit annotation',
855 'patterns': [r".*: warning: \[JMockTestWithoutRunWithOrRuleAnnotation\] .+"]},
856 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700857 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700858 'description':
859 'Java: Test method will not be run; please prefix name with "test"',
860 'patterns': [r".*: warning: \[JUnit3TestNotRun\] .+"]},
861 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700862 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700863 'description':
864 'Java: setUp() method will not be run; Please add a @Before annotation',
865 'patterns': [r".*: warning: \[JUnit4SetUpNotRun\] .+"]},
866 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700867 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700868 'description':
869 'Java: tearDown() method will not be run; Please add an @After annotation',
870 'patterns': [r".*: warning: \[JUnit4TearDownNotRun\] .+"]},
871 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700872 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700873 'description':
874 'Java: Test method will not be run; please add @Test annotation',
875 'patterns': [r".*: warning: \[JUnit4TestNotRun\] .+"]},
876 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700877 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700878 'description':
879 'Java: Printf-like format string does not match its arguments',
880 'patterns': [r".*: warning: \[MalformedFormatString\] .+"]},
881 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700882 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700883 'description':
884 'Java: Use of "YYYY" (week year) in a date pattern without "ww" (week in year). You probably meant to use "yyyy" (year) instead.',
885 'patterns': [r".*: warning: \[MisusedWeekYear\] .+"]},
886 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700887 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700888 'description':
889 'Java: A bug in Mockito will cause this test to fail at runtime with a ClassCastException',
890 'patterns': [r".*: warning: \[MockitoCast\] .+"]},
891 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700892 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700893 'description':
894 'Java: Missing method call for verify(mock) here',
895 'patterns': [r".*: warning: \[MockitoUsage\] .+"]},
896 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700897 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700898 'description':
899 'Java: Modifying a collection with itself',
900 'patterns': [r".*: warning: \[ModifyingCollectionWithItself\] .+"]},
901 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700902 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700903 'description':
904 'Java: Compound assignments to bytes, shorts, chars, and floats hide dangerous casts',
905 'patterns': [r".*: warning: \[NarrowingCompoundAssignment\] .+"]},
906 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700907 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700908 'description':
909 'Java: @NoAllocation was specified on this method, but something was found that would trigger an allocation',
910 'patterns': [r".*: warning: \[NoAllocation\] .+"]},
911 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700912 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700913 'description':
914 'Java: Static import of type uses non-canonical name',
915 'patterns': [r".*: warning: \[NonCanonicalStaticImport\] .+"]},
916 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700917 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700918 'description':
919 'Java: @CompileTimeConstant parameters should be final',
920 'patterns': [r".*: warning: \[NonFinalCompileTimeConstant\] .+"]},
921 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700922 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700923 'description':
924 'Java: Calling getAnnotation on an annotation that is not retained at runtime.',
925 'patterns': [r".*: warning: \[NonRuntimeAnnotation\] .+"]},
926 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700927 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700928 'description':
929 'Java: Numeric comparison using reference equality instead of value equality',
930 'patterns': [r".*: warning: \[NumericEquality\] .+"]},
931 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700932 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700933 'description':
934 'Java: Comparison using reference equality instead of value equality',
935 'patterns': [r".*: warning: \[OptionalEquality\] .+"]},
936 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700937 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700938 'description':
939 'Java: Varargs doesn\'t agree for overridden method',
940 'patterns': [r".*: warning: \[Overrides\] .+"]},
941 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700942 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700943 'description':
944 'Java: Literal passed as first argument to Preconditions.checkNotNull() can never be null',
945 'patterns': [r".*: warning: \[PreconditionsCheckNotNull\] .+"]},
946 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700947 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700948 'description':
949 'Java: First argument to `Preconditions.checkNotNull()` is a primitive rather than an object reference',
950 'patterns': [r".*: warning: \[PreconditionsCheckNotNullPrimitive\] .+"]},
951 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700952 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700953 'description':
954 'Java: Protobuf fields cannot be null',
955 'patterns': [r".*: warning: \[ProtoFieldNullComparison\] .+"]},
956 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700957 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700958 'description':
959 'Java: Comparing protobuf fields of type String using reference equality',
960 'patterns': [r".*: warning: \[ProtoStringFieldReferenceEquality\] .+"]},
961 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700962 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700963 'description':
964 'Java: Check for non-whitelisted callers to RestrictedApiChecker.',
965 'patterns': [r".*: warning: \[RestrictedApiChecker\] .+"]},
966 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700967 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700968 'description':
969 'Java: Return value of this method must be used',
970 'patterns': [r".*: warning: \[ReturnValueIgnored\] .+"]},
971 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700972 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700973 'description':
974 'Java: Variable assigned to itself',
975 'patterns': [r".*: warning: \[SelfAssignment\] .+"]},
976 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700977 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700978 'description':
979 'Java: An object is compared to itself',
980 'patterns': [r".*: warning: \[SelfComparision\] .+"]},
981 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700982 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700983 'description':
984 'Java: Variable compared to itself',
985 'patterns': [r".*: warning: \[SelfEquality\] .+"]},
986 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700987 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700988 'description':
989 'Java: An object is tested for equality to itself',
990 'patterns': [r".*: warning: \[SelfEquals\] .+"]},
991 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700992 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700993 'description':
994 'Java: Comparison of a size >= 0 is always true, did you intend to check for non-emptiness?',
995 'patterns': [r".*: warning: \[SizeGreaterThanOrEqualsZero\] .+"]},
996 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700997 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700998 'description':
999 'Java: Calling toString on a Stream does not provide useful information',
1000 'patterns': [r".*: warning: \[StreamToString\] .+"]},
1001 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001002 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001003 'description':
1004 'Java: StringBuilder does not have a char constructor; this invokes the int constructor.',
1005 'patterns': [r".*: warning: \[StringBuilderInitWithChar\] .+"]},
1006 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001007 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001008 'description':
1009 'Java: Suppressing "deprecated" is probably a typo for "deprecation"',
1010 'patterns': [r".*: warning: \[SuppressWarningsDeprecated\] .+"]},
1011 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001012 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001013 'description':
1014 'Java: throwIfUnchecked(knownCheckedException) is a no-op.',
1015 'patterns': [r".*: warning: \[ThrowIfUncheckedKnownChecked\] .+"]},
1016 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001017 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001018 'description':
1019 'Java: Catching Throwable/Error masks failures from fail() or assert*() in the try block',
1020 'patterns': [r".*: warning: \[TryFailThrowable\] .+"]},
1021 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001022 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001023 'description':
1024 'Java: Type parameter used as type qualifier',
1025 'patterns': [r".*: warning: \[TypeParameterQualifier\] .+"]},
1026 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001027 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001028 'description':
1029 'Java: Non-generic methods should not be invoked with type arguments',
1030 'patterns': [r".*: warning: \[UnnecessaryTypeArgument\] .+"]},
1031 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001032 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001033 'description':
1034 'Java: Instance created but never used',
1035 'patterns': [r".*: warning: \[UnusedAnonymousClass\] .+"]},
1036 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001037 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001038 'description':
1039 'Java: Use of wildcard imports is forbidden',
1040 'patterns': [r".*: warning: \[WildcardImport\] .+"]},
1041 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001042 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001043 'description':
1044 'Java: Method parameter has wrong package',
1045 'patterns': [r".*: warning: \[ParameterPackage\] .+"]},
1046 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001047 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001048 'description':
1049 'Java: Certain resources in `android.R.string` have names that do not match their content',
1050 'patterns': [r".*: warning: \[MislabeledAndroidString\] .+"]},
1051 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001052 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001053 'description':
1054 'Java: Return value of android.graphics.Rect.intersect() must be checked',
1055 'patterns': [r".*: warning: \[RectIntersectReturnValueIgnored\] .+"]},
1056 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001057 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001058 'description':
1059 'Java: Invalid printf-style format string',
1060 'patterns': [r".*: warning: \[FormatString\] .+"]},
1061 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001062 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001063 'description':
1064 'Java: @AssistedInject and @Inject cannot be used on the same constructor.',
1065 'patterns': [r".*: warning: \[AssistedInjectAndInjectOnSameConstructor\] .+"]},
1066 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001067 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001068 'description':
1069 'Java: Injected constructors cannot be optional nor have binding annotations',
1070 'patterns': [r".*: warning: \[InjectedConstructorAnnotations\] .+"]},
1071 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001072 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001073 'description':
1074 'Java: The target of a scoping annotation must be set to METHOD and/or TYPE.',
1075 'patterns': [r".*: warning: \[InjectInvalidTargetingOnScopingAnnotation\] .+"]},
1076 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001077 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001078 'description':
1079 'Java: Abstract methods are not injectable with javax.inject.Inject.',
1080 'patterns': [r".*: warning: \[JavaxInjectOnAbstractMethod\] .+"]},
1081 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001082 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001083 'description':
1084 'Java: @javax.inject.Inject cannot be put on a final field.',
1085 'patterns': [r".*: warning: \[JavaxInjectOnFinalField\] .+"]},
1086 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001087 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001088 'description':
1089 'Java: A class may not have more than one injectable constructor.',
1090 'patterns': [r".*: warning: \[MoreThanOneInjectableConstructor\] .+"]},
1091 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001092 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001093 'description':
1094 'Java: Using more than one qualifier annotation on the same element is not allowed.',
1095 'patterns': [r".*: warning: \[InjectMoreThanOneQualifier\] .+"]},
1096 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001097 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001098 'description':
1099 'Java: A class can be annotated with at most one scope annotation',
1100 'patterns': [r".*: warning: \[InjectMoreThanOneScopeAnnotationOnClass\] .+"]},
1101 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001102 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001103 'description':
1104 'Java: Annotations cannot be both Qualifiers/BindingAnnotations and Scopes',
1105 'patterns': [r".*: warning: \[OverlappingQualifierAndScopeAnnotation\] .+"]},
1106 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001107 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001108 'description':
1109 'Java: Scope annotation on an interface or abstact class is not allowed',
1110 'patterns': [r".*: warning: \[InjectScopeAnnotationOnInterfaceOrAbstractClass\] .+"]},
1111 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001112 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001113 'description':
1114 'Java: Scoping and qualifier annotations must have runtime retention.',
1115 'patterns': [r".*: warning: \[InjectScopeOrQualifierAnnotationRetention\] .+"]},
1116 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001117 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001118 'description':
1119 'Java: Dagger @Provides methods may not return null unless annotated with @Nullable',
1120 'patterns': [r".*: warning: \[DaggerProvidesNull\] .+"]},
1121 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001122 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001123 'description':
1124 'Java: Scope annotation on implementation class of AssistedInject factory is not allowed',
1125 'patterns': [r".*: warning: \[GuiceAssistedInjectScoping\] .+"]},
1126 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001127 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001128 'description':
1129 'Java: A constructor cannot have two @Assisted parameters of the same type unless they are disambiguated with named @Assisted annotations. ',
1130 'patterns': [r".*: warning: \[GuiceAssistedParameters\] .+"]},
1131 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001132 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001133 'description':
1134 'Java: This method is not annotated with @Inject, but it overrides a method that is annotated with @javax.inject.Inject.',
1135 'patterns': [r".*: warning: \[OverridesJavaxInjectableMethod\] .+"]},
1136 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001137 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001138 'description':
1139 'Java: Checks for unguarded accesses to fields and methods with @GuardedBy annotations',
1140 'patterns': [r".*: warning: \[GuardedByChecker\] .+"]},
1141 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001142 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001143 'description':
1144 'Java: Invalid @GuardedBy expression',
1145 'patterns': [r".*: warning: \[GuardedByValidator\] .+"]},
1146 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001147 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001148 'description':
1149 'Java: Type declaration annotated with @Immutable is not immutable',
1150 'patterns': [r".*: warning: \[Immutable\] .+"]},
1151 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001152 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001153 'description':
1154 'Java: This method does not acquire the locks specified by its @LockMethod annotation',
1155 'patterns': [r".*: warning: \[LockMethodChecker\] .+"]},
1156 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001157 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001158 'description':
1159 'Java: This method does not acquire the locks specified by its @UnlockMethod annotation',
1160 'patterns': [r".*: warning: \[UnlockMethod\] .+"]},
Ian Rogers32bb9bd2016-05-09 23:19:42 -07001161
Ian Rogers6e520032016-05-13 08:59:00 -07001162 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001163 'severity': Severity.UNKNOWN,
Ian Rogers6e520032016-05-13 08:59:00 -07001164 'description': 'Java: Unclassified/unrecognized warnings',
1165 'patterns': [r".*: warning: \[.+\] .+"]},
Ian Rogers32bb9bd2016-05-09 23:19:42 -07001166
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001167 {'category': 'aapt', 'severity': Severity.MEDIUM,
1168 'description': 'aapt: No default translation',
1169 'patterns': [r".*: warning: string '.+' has no default translation in .*"]},
1170 {'category': 'aapt', 'severity': Severity.MEDIUM,
1171 'description': 'aapt: Missing default or required localization',
1172 'patterns': [r".*: warning: \*\*\*\* string '.+' has no default or required localization for '.+' in .+"]},
1173 {'category': 'aapt', 'severity': Severity.MEDIUM,
1174 'description': 'aapt: String marked untranslatable, but translation exists',
1175 'patterns': [r".*: warning: string '.+' in .* marked untranslatable but exists in locale '??_??'"]},
1176 {'category': 'aapt', 'severity': Severity.MEDIUM,
1177 'description': 'aapt: empty span in string',
1178 'patterns': [r".*: warning: empty '.+' span found in text '.+"]},
1179 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1180 'description': 'Taking address of temporary',
1181 'patterns': [r".*: warning: taking address of temporary"]},
1182 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1183 'description': 'Possible broken line continuation',
1184 'patterns': [r".*: warning: backslash and newline separated by space"]},
1185 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wundefined-var-template',
1186 'description': 'Undefined variable template',
1187 'patterns': [r".*: warning: instantiation of variable .* no definition is available"]},
1188 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wundefined-inline',
1189 'description': 'Inline function is not defined',
1190 'patterns': [r".*: warning: inline function '.*' is not defined"]},
1191 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Warray-bounds',
1192 'description': 'Array subscript out of bounds',
1193 'patterns': [r".*: warning: array subscript is above array bounds",
1194 r".*: warning: Array subscript is undefined",
1195 r".*: warning: array subscript is below array bounds"]},
1196 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1197 'description': 'Excess elements in initializer',
1198 'patterns': [r".*: warning: excess elements in .+ initializer"]},
1199 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1200 'description': 'Decimal constant is unsigned only in ISO C90',
1201 'patterns': [r".*: warning: this decimal constant is unsigned only in ISO C90"]},
1202 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmain',
1203 'description': 'main is usually a function',
1204 'patterns': [r".*: warning: 'main' is usually a function"]},
1205 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1206 'description': 'Typedef ignored',
1207 'patterns': [r".*: warning: 'typedef' was ignored in this declaration"]},
1208 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Waddress',
1209 'description': 'Address always evaluates to true',
1210 'patterns': [r".*: warning: the address of '.+' will always evaluate as 'true'"]},
1211 {'category': 'C/C++', 'severity': Severity.FIXMENOW,
1212 'description': 'Freeing a non-heap object',
1213 'patterns': [r".*: warning: attempt to free a non-heap object '.+'"]},
1214 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wchar-subscripts',
1215 'description': 'Array subscript has type char',
1216 'patterns': [r".*: warning: array subscript .+ type 'char'.+Wchar-subscripts"]},
1217 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1218 'description': 'Constant too large for type',
1219 'patterns': [r".*: warning: integer constant is too large for '.+' type"]},
1220 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Woverflow',
1221 'description': 'Constant too large for type, truncated',
1222 'patterns': [r".*: warning: large integer implicitly truncated to unsigned type"]},
1223 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Winteger-overflow',
1224 'description': 'Overflow in expression',
1225 'patterns': [r".*: warning: overflow in expression; .*Winteger-overflow"]},
1226 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Woverflow',
1227 'description': 'Overflow in implicit constant conversion',
1228 'patterns': [r".*: warning: overflow in implicit constant conversion"]},
1229 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1230 'description': 'Declaration does not declare anything',
1231 'patterns': [r".*: warning: declaration 'class .+' does not declare anything"]},
1232 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wreorder',
1233 'description': 'Initialization order will be different',
1234 'patterns': [r".*: warning: '.+' will be initialized after",
1235 r".*: warning: field .+ will be initialized after .+Wreorder"]},
1236 {'category': 'cont.', 'severity': Severity.SKIP,
1237 'description': 'skip, ....',
1238 'patterns': [r".*: warning: '.+'"]},
1239 {'category': 'cont.', 'severity': Severity.SKIP,
1240 'description': 'skip, base ...',
1241 'patterns': [r".*: warning: base '.+'"]},
1242 {'category': 'cont.', 'severity': Severity.SKIP,
1243 'description': 'skip, when initialized here',
1244 'patterns': [r".*: warning: when initialized here"]},
1245 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-parameter-type',
1246 'description': 'Parameter type not specified',
1247 'patterns': [r".*: warning: type of '.+' defaults to 'int'"]},
1248 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-declarations',
1249 'description': 'Missing declarations',
1250 'patterns': [r".*: warning: declaration does not declare anything"]},
1251 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-noreturn',
1252 'description': 'Missing noreturn',
1253 'patterns': [r".*: warning: function '.*' could be declared with attribute 'noreturn'"]},
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001254 # pylint:disable=anomalous-backslash-in-string
1255 # TODO(chh): fix the backslash pylint warning.
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001256 {'category': 'gcc', 'severity': Severity.MEDIUM,
1257 'description': 'Invalid option for C file',
1258 'patterns': [r".*: warning: command line option "".+"" is valid for C\+\+\/ObjC\+\+ but not for C"]},
1259 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1260 'description': 'User warning',
1261 'patterns': [r".*: warning: #warning "".+"""]},
1262 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wvexing-parse',
1263 'description': 'Vexing parsing problem',
1264 'patterns': [r".*: warning: empty parentheses interpreted as a function declaration"]},
1265 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wextra',
1266 'description': 'Dereferencing void*',
1267 'patterns': [r".*: warning: dereferencing 'void \*' pointer"]},
1268 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1269 'description': 'Comparison of pointer and integer',
1270 'patterns': [r".*: warning: ordered comparison of pointer with integer zero",
1271 r".*: warning: .*comparison between pointer and integer"]},
1272 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1273 'description': 'Use of error-prone unary operator',
1274 'patterns': [r".*: warning: use of unary operator that may be intended as compound assignment"]},
1275 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wwrite-strings',
1276 'description': 'Conversion of string constant to non-const char*',
1277 'patterns': [r".*: warning: deprecated conversion from string constant to '.+'"]},
1278 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wstrict-prototypes',
1279 'description': 'Function declaration isn''t a prototype',
1280 'patterns': [r".*: warning: function declaration isn't a prototype"]},
1281 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wignored-qualifiers',
1282 'description': 'Type qualifiers ignored on function return value',
1283 'patterns': [r".*: warning: type qualifiers ignored on function return type",
1284 r".*: warning: .+ type qualifier .+ has no effect .+Wignored-qualifiers"]},
1285 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1286 'description': '<foo> declared inside parameter list, scope limited to this definition',
1287 'patterns': [r".*: warning: '.+' declared inside parameter list"]},
1288 {'category': 'cont.', 'severity': Severity.SKIP,
1289 'description': 'skip, its scope is only this ...',
1290 'patterns': [r".*: warning: its scope is only this definition or declaration, which is probably not what you want"]},
1291 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wcomment',
1292 'description': 'Line continuation inside comment',
1293 'patterns': [r".*: warning: multi-line comment"]},
1294 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wcomment',
1295 'description': 'Comment inside comment',
1296 'patterns': [r".*: warning: "".+"" within comment"]},
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001297 # Warning "value stored is never read" could be from clang-tidy or clang static analyzer.
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001298 {'category': 'C/C++', 'severity': Severity.ANALYZER,
1299 'description': 'clang-analyzer Value stored is never read',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001300 'patterns': [r".*: warning: Value stored to .+ is never read.*clang-analyzer-deadcode.DeadStores"]},
1301 {'category': 'C/C++', 'severity': Severity.LOW,
1302 'description': 'Value stored is never read',
1303 'patterns': [r".*: warning: Value stored to .+ is never read"]},
1304 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wdeprecated-declarations',
1305 'description': 'Deprecated declarations',
1306 'patterns': [r".*: warning: .+ is deprecated.+deprecated-declarations"]},
1307 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wdeprecated-register',
1308 'description': 'Deprecated register',
1309 'patterns': [r".*: warning: 'register' storage class specifier is deprecated"]},
1310 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wpointer-sign',
1311 'description': 'Converts between pointers to integer types with different sign',
1312 'patterns': [r".*: warning: .+ converts between pointers to integer types with different sign"]},
1313 {'category': 'C/C++', 'severity': Severity.HARMLESS,
1314 'description': 'Extra tokens after #endif',
1315 'patterns': [r".*: warning: extra tokens at end of #endif directive"]},
1316 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wenum-compare',
1317 'description': 'Comparison between different enums',
1318 'patterns': [r".*: warning: comparison between '.+' and '.+'.+Wenum-compare"]},
1319 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wconversion',
1320 'description': 'Conversion may change value',
1321 'patterns': [r".*: warning: converting negative value '.+' to '.+'",
1322 r".*: warning: conversion to '.+' .+ may (alter|change)"]},
1323 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wconversion-null',
1324 'description': 'Converting to non-pointer type from NULL',
1325 'patterns': [r".*: warning: converting to non-pointer type '.+' from NULL"]},
1326 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wnull-conversion',
1327 'description': 'Converting NULL to non-pointer type',
1328 'patterns': [r".*: warning: implicit conversion of NULL constant to '.+'"]},
1329 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wnon-literal-null-conversion',
1330 'description': 'Zero used as null pointer',
1331 'patterns': [r".*: warning: expression .* zero treated as a null pointer constant"]},
1332 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1333 'description': 'Implicit conversion changes value',
1334 'patterns': [r".*: warning: implicit conversion .* changes value from .* to .*-conversion"]},
1335 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1336 'description': 'Passing NULL as non-pointer argument',
1337 'patterns': [r".*: warning: passing NULL to non-pointer argument [0-9]+ of '.+'"]},
1338 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wctor-dtor-privacy',
1339 'description': 'Class seems unusable because of private ctor/dtor',
1340 'patterns': [r".*: warning: all member functions in class '.+' are private"]},
Marco Nelissen594375d2009-07-14 09:04:04 -07001341 # 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 -07001342 {'category': 'C/C++', 'severity': Severity.SKIP, 'option': '-Wctor-dtor-privacy',
1343 'description': 'Class seems unusable because of private ctor/dtor',
1344 'patterns': [r".*: warning: 'class .+' only defines a private destructor and has no friends"]},
1345 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wctor-dtor-privacy',
1346 'description': 'Class seems unusable because of private ctor/dtor',
1347 'patterns': [r".*: warning: 'class .+' only defines private constructors and has no friends"]},
1348 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wgnu-static-float-init',
1349 'description': 'In-class initializer for static const float/double',
1350 'patterns': [r".*: warning: in-class initializer for static data member of .+const (float|double)"]},
1351 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wpointer-arith',
1352 'description': 'void* used in arithmetic',
1353 'patterns': [r".*: warning: pointer of type 'void \*' used in (arithmetic|subtraction)",
1354 r".*: warning: arithmetic on .+ to void is a GNU extension.*Wpointer-arith",
1355 r".*: warning: wrong type argument to increment"]},
1356 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsign-promo',
1357 'description': 'Overload resolution chose to promote from unsigned or enum to signed type',
1358 'patterns': [r".*: warning: passing '.+' chooses '.+' over '.+'.*Wsign-promo"]},
1359 {'category': 'cont.', 'severity': Severity.SKIP,
1360 'description': 'skip, in call to ...',
1361 'patterns': [r".*: warning: in call to '.+'"]},
1362 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wextra',
1363 'description': 'Base should be explicitly initialized in copy constructor',
1364 'patterns': [r".*: warning: base class '.+' should be explicitly initialized in the copy constructor"]},
1365 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1366 'description': 'VLA has zero or negative size',
1367 'patterns': [r".*: warning: Declared variable-length array \(VLA\) has .+ size"]},
1368 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1369 'description': 'Return value from void function',
1370 'patterns': [r".*: warning: 'return' with a value, in function returning void"]},
1371 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'multichar',
1372 'description': 'Multi-character character constant',
1373 'patterns': [r".*: warning: multi-character character constant"]},
1374 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'writable-strings',
1375 'description': 'Conversion from string literal to char*',
1376 'patterns': [r".*: warning: .+ does not allow conversion from string literal to 'char \*'"]},
1377 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wextra-semi',
1378 'description': 'Extra \';\'',
1379 'patterns': [r".*: warning: extra ';' .+extra-semi"]},
1380 {'category': 'C/C++', 'severity': Severity.LOW,
1381 'description': 'Useless specifier',
1382 'patterns': [r".*: warning: useless storage class specifier in empty declaration"]},
1383 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wduplicate-decl-specifier',
1384 'description': 'Duplicate declaration specifier',
1385 'patterns': [r".*: warning: duplicate '.+' declaration specifier"]},
1386 {'category': 'logtags', 'severity': Severity.LOW,
1387 'description': 'Duplicate logtag',
1388 'patterns': [r".*: warning: tag \".+\" \(.+\) duplicated in .+"]},
1389 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'typedef-redefinition',
1390 'description': 'Typedef redefinition',
1391 'patterns': [r".*: warning: redefinition of typedef '.+' is a C11 feature"]},
1392 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'gnu-designator',
1393 'description': 'GNU old-style field designator',
1394 'patterns': [r".*: warning: use of GNU old-style field designator extension"]},
1395 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'missing-field-initializers',
1396 'description': 'Missing field initializers',
1397 'patterns': [r".*: warning: missing field '.+' initializer"]},
1398 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'missing-braces',
1399 'description': 'Missing braces',
1400 'patterns': [r".*: warning: suggest braces around initialization of",
1401 r".*: warning: too many braces around scalar initializer .+Wmany-braces-around-scalar-init",
1402 r".*: warning: braces around scalar initializer"]},
1403 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'sign-compare',
1404 'description': 'Comparison of integers of different signs',
1405 'patterns': [r".*: warning: comparison of integers of different signs.+sign-compare"]},
1406 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'dangling-else',
1407 'description': 'Add braces to avoid dangling else',
1408 'patterns': [r".*: warning: add explicit braces to avoid dangling else"]},
1409 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'initializer-overrides',
1410 'description': 'Initializer overrides prior initialization',
1411 'patterns': [r".*: warning: initializer overrides prior initialization of this subobject"]},
1412 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'self-assign',
1413 'description': 'Assigning value to self',
1414 'patterns': [r".*: warning: explicitly assigning value of .+ to itself"]},
1415 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'gnu-variable-sized-type-not-at-end',
1416 'description': 'GNU extension, variable sized type not at end',
1417 'patterns': [r".*: warning: field '.+' with variable sized type '.+' not at the end of a struct or class"]},
1418 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'tautological-constant-out-of-range-compare',
1419 'description': 'Comparison of constant is always false/true',
1420 'patterns': [r".*: comparison of .+ is always .+Wtautological-constant-out-of-range-compare"]},
1421 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'overloaded-virtual',
1422 'description': 'Hides overloaded virtual function',
1423 'patterns': [r".*: '.+' hides overloaded virtual function"]},
1424 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'incompatible-pointer-types',
1425 'description': 'Incompatible pointer types',
1426 'patterns': [r".*: warning: incompatible pointer types .+Wincompatible-pointer-types"]},
1427 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'asm-operand-widths',
1428 'description': 'ASM value size does not match register size',
1429 'patterns': [r".*: warning: value size does not match register size specified by the constraint and modifier"]},
1430 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'tautological-compare',
1431 'description': 'Comparison of self is always false',
1432 'patterns': [r".*: self-comparison always evaluates to false"]},
1433 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'constant-logical-operand',
1434 'description': 'Logical op with constant operand',
1435 'patterns': [r".*: use of logical '.+' with constant operand"]},
1436 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'literal-suffix',
1437 'description': 'Needs a space between literal and string macro',
1438 'patterns': [r".*: warning: invalid suffix on literal.+ requires a space .+Wliteral-suffix"]},
1439 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '#warnings',
1440 'description': 'Warnings from #warning',
1441 'patterns': [r".*: warning: .+-W#warnings"]},
1442 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'absolute-value',
1443 'description': 'Using float/int absolute value function with int/float argument',
1444 'patterns': [r".*: warning: using .+ absolute value function .+ when argument is .+ type .+Wabsolute-value",
1445 r".*: warning: absolute value function '.+' given .+ which may cause truncation .+Wabsolute-value"]},
1446 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wc++11-extensions',
1447 'description': 'Using C++11 extensions',
1448 'patterns': [r".*: warning: 'auto' type specifier is a C\+\+11 extension"]},
1449 {'category': 'C/C++', 'severity': Severity.LOW,
1450 'description': 'Refers to implicitly defined namespace',
1451 'patterns': [r".*: warning: using directive refers to implicitly-defined namespace .+"]},
1452 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Winvalid-pp-token',
1453 'description': 'Invalid pp token',
1454 'patterns': [r".*: warning: missing .+Winvalid-pp-token"]},
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001455
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001456 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1457 'description': 'Operator new returns NULL',
1458 'patterns': [r".*: warning: 'operator new' must not return NULL unless it is declared 'throw\(\)' .+"]},
1459 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wnull-arithmetic',
1460 'description': 'NULL used in arithmetic',
1461 'patterns': [r".*: warning: NULL used in arithmetic",
1462 r".*: warning: comparison between NULL and non-pointer"]},
1463 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'header-guard',
1464 'description': 'Misspelled header guard',
1465 'patterns': [r".*: warning: '.+' is used as a header guard .+ followed by .+ different macro"]},
1466 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'empty-body',
1467 'description': 'Empty loop body',
1468 'patterns': [r".*: warning: .+ loop has empty body"]},
1469 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'enum-conversion',
1470 'description': 'Implicit conversion from enumeration type',
1471 'patterns': [r".*: warning: implicit conversion from enumeration type '.+'"]},
1472 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'switch',
1473 'description': 'case value not in enumerated type',
1474 'patterns': [r".*: warning: case value not in enumerated type '.+'"]},
1475 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1476 'description': 'Undefined result',
1477 'patterns': [r".*: warning: The result of .+ is undefined",
1478 r".*: warning: passing an object that .+ has undefined behavior \[-Wvarargs\]",
1479 r".*: warning: 'this' pointer cannot be null in well-defined C\+\+ code;",
1480 r".*: warning: shifting a negative signed value is undefined"]},
1481 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1482 'description': 'Division by zero',
1483 'patterns': [r".*: warning: Division by zero"]},
1484 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1485 'description': 'Use of deprecated method',
1486 'patterns': [r".*: warning: '.+' is deprecated .+"]},
1487 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1488 'description': 'Use of garbage or uninitialized value',
1489 'patterns': [r".*: warning: .+ is a garbage value",
1490 r".*: warning: Function call argument is an uninitialized value",
1491 r".*: warning: Undefined or garbage value returned to caller",
1492 r".*: warning: Called .+ pointer is.+uninitialized",
1493 r".*: warning: Called .+ pointer is.+uninitalized", # match a typo in compiler message
1494 r".*: warning: Use of zero-allocated memory",
1495 r".*: warning: Dereference of undefined pointer value",
1496 r".*: warning: Passed-by-value .+ contains uninitialized data",
1497 r".*: warning: Branch condition evaluates to a garbage value",
1498 r".*: warning: The .+ of .+ is an uninitialized value.",
1499 r".*: warning: .+ is used uninitialized whenever .+sometimes-uninitialized",
1500 r".*: warning: Assigned value is garbage or undefined"]},
1501 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1502 'description': 'Result of malloc type incompatible with sizeof operand type',
1503 'patterns': [r".*: warning: Result of '.+' is converted to .+ incompatible with sizeof operand type"]},
1504 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsizeof-array-argument',
1505 'description': 'Sizeof on array argument',
1506 'patterns': [r".*: warning: sizeof on array function parameter will return"]},
1507 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsizeof-pointer-memacces',
1508 'description': 'Bad argument size of memory access functions',
1509 'patterns': [r".*: warning: .+\[-Wsizeof-pointer-memaccess\]"]},
1510 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1511 'description': 'Return value not checked',
1512 'patterns': [r".*: warning: The return value from .+ is not checked"]},
1513 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1514 'description': 'Possible heap pollution',
1515 'patterns': [r".*: warning: .*Possible heap pollution from .+ type .+"]},
1516 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1517 'description': 'Allocation size of 0 byte',
1518 'patterns': [r".*: warning: Call to .+ has an allocation size of 0 byte"]},
1519 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1520 'description': 'Result of malloc type incompatible with sizeof operand type',
1521 'patterns': [r".*: warning: Result of '.+' is converted to .+ incompatible with sizeof operand type"]},
1522 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wfor-loop-analysis',
1523 'description': 'Variable used in loop condition not modified in loop body',
1524 'patterns': [r".*: warning: variable '.+' used in loop condition.*Wfor-loop-analysis"]},
1525 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1526 'description': 'Closing a previously closed file',
1527 'patterns': [r".*: warning: Closing a previously closed file"]},
1528 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunnamed-type-template-args',
1529 'description': 'Unnamed template type argument',
1530 'patterns': [r".*: warning: template argument.+Wunnamed-type-template-args"]},
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001531
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001532 {'category': 'C/C++', 'severity': Severity.HARMLESS,
1533 'description': 'Discarded qualifier from pointer target type',
1534 'patterns': [r".*: warning: .+ discards '.+' qualifier from pointer target type"]},
1535 {'category': 'C/C++', 'severity': Severity.HARMLESS,
1536 'description': 'Use snprintf instead of sprintf',
1537 'patterns': [r".*: warning: .*sprintf is often misused; please use snprintf"]},
1538 {'category': 'C/C++', 'severity': Severity.HARMLESS,
1539 'description': 'Unsupported optimizaton flag',
1540 'patterns': [r".*: warning: optimization flag '.+' is not supported"]},
1541 {'category': 'C/C++', 'severity': Severity.HARMLESS,
1542 'description': 'Extra or missing parentheses',
1543 'patterns': [r".*: warning: equality comparison with extraneous parentheses",
1544 r".*: warning: .+ within .+Wlogical-op-parentheses"]},
1545 {'category': 'C/C++', 'severity': Severity.HARMLESS, 'option': 'mismatched-tags',
1546 'description': 'Mismatched class vs struct tags',
1547 'patterns': [r".*: warning: '.+' defined as a .+ here but previously declared as a .+mismatched-tags",
1548 r".*: warning: .+ was previously declared as a .+mismatched-tags"]},
Marco Nelissen594375d2009-07-14 09:04:04 -07001549
1550 # 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 -07001551 {'category': 'C/C++', 'severity': Severity.SKIP,
1552 'description': 'skip, ,',
1553 'patterns': [r".*: warning: ,$"]},
1554 {'category': 'C/C++', 'severity': Severity.SKIP,
1555 'description': 'skip,',
1556 'patterns': [r".*: warning: $"]},
1557 {'category': 'C/C++', 'severity': Severity.SKIP,
1558 'description': 'skip, In file included from ...',
1559 'patterns': [r".*: warning: In file included from .+,"]},
Marco Nelissen594375d2009-07-14 09:04:04 -07001560
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001561 # warnings from clang-tidy
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001562 {'category': 'C/C++', 'severity': Severity.TIDY,
1563 'description': 'clang-tidy readability',
1564 'patterns': [r".*: .+\[readability-.+\]$"]},
1565 {'category': 'C/C++', 'severity': Severity.TIDY,
1566 'description': 'clang-tidy c++ core guidelines',
1567 'patterns': [r".*: .+\[cppcoreguidelines-.+\]$"]},
1568 {'category': 'C/C++', 'severity': Severity.TIDY,
1569 'description': 'clang-tidy google-default-arguments',
1570 'patterns': [r".*: .+\[google-default-arguments\]$"]},
1571 {'category': 'C/C++', 'severity': Severity.TIDY,
1572 'description': 'clang-tidy google-runtime-int',
1573 'patterns': [r".*: .+\[google-runtime-int\]$"]},
1574 {'category': 'C/C++', 'severity': Severity.TIDY,
1575 'description': 'clang-tidy google-runtime-operator',
1576 'patterns': [r".*: .+\[google-runtime-operator\]$"]},
1577 {'category': 'C/C++', 'severity': Severity.TIDY,
1578 'description': 'clang-tidy google-runtime-references',
1579 'patterns': [r".*: .+\[google-runtime-references\]$"]},
1580 {'category': 'C/C++', 'severity': Severity.TIDY,
1581 'description': 'clang-tidy google-build',
1582 'patterns': [r".*: .+\[google-build-.+\]$"]},
1583 {'category': 'C/C++', 'severity': Severity.TIDY,
1584 'description': 'clang-tidy google-explicit',
1585 'patterns': [r".*: .+\[google-explicit-.+\]$"]},
1586 {'category': 'C/C++', 'severity': Severity.TIDY,
1587 'description': 'clang-tidy google-readability',
1588 'patterns': [r".*: .+\[google-readability-.+\]$"]},
1589 {'category': 'C/C++', 'severity': Severity.TIDY,
1590 'description': 'clang-tidy google-global',
1591 'patterns': [r".*: .+\[google-global-.+\]$"]},
1592 {'category': 'C/C++', 'severity': Severity.TIDY,
1593 'description': 'clang-tidy google- other',
1594 'patterns': [r".*: .+\[google-.+\]$"]},
1595 {'category': 'C/C++', 'severity': Severity.TIDY,
1596 'description': 'clang-tidy modernize',
1597 'patterns': [r".*: .+\[modernize-.+\]$"]},
1598 {'category': 'C/C++', 'severity': Severity.TIDY,
1599 'description': 'clang-tidy misc',
1600 'patterns': [r".*: .+\[misc-.+\]$"]},
1601 {'category': 'C/C++', 'severity': Severity.TIDY,
1602 'description': 'clang-tidy performance-faster-string-find',
1603 'patterns': [r".*: .+\[performance-faster-string-find\]$"]},
1604 {'category': 'C/C++', 'severity': Severity.TIDY,
1605 'description': 'clang-tidy performance-for-range-copy',
1606 'patterns': [r".*: .+\[performance-for-range-copy\]$"]},
1607 {'category': 'C/C++', 'severity': Severity.TIDY,
1608 'description': 'clang-tidy performance-implicit-cast-in-loop',
1609 'patterns': [r".*: .+\[performance-implicit-cast-in-loop\]$"]},
1610 {'category': 'C/C++', 'severity': Severity.TIDY,
1611 'description': 'clang-tidy performance-unnecessary-copy-initialization',
1612 'patterns': [r".*: .+\[performance-unnecessary-copy-initialization\]$"]},
1613 {'category': 'C/C++', 'severity': Severity.TIDY,
1614 'description': 'clang-tidy performance-unnecessary-value-param',
1615 'patterns': [r".*: .+\[performance-unnecessary-value-param\]$"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001616 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001617 'description': 'clang-analyzer Unreachable code',
1618 'patterns': [r".*: warning: This statement is never executed.*UnreachableCode"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001619 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001620 'description': 'clang-analyzer Size of malloc may overflow',
1621 'patterns': [r".*: warning: .* size of .* may overflow .*MallocOverflow"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001622 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001623 'description': 'clang-analyzer Stream pointer might be NULL',
1624 'patterns': [r".*: warning: Stream pointer might be NULL .*unix.Stream"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001625 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001626 'description': 'clang-analyzer Opened file never closed',
1627 'patterns': [r".*: warning: Opened File never closed.*unix.Stream"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001628 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001629 'description': 'clang-analyzer sozeof() on a pointer type',
1630 'patterns': [r".*: warning: .*calls sizeof.* on a pointer type.*SizeofPtr"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001631 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001632 'description': 'clang-analyzer Pointer arithmetic on non-array variables',
1633 'patterns': [r".*: warning: Pointer arithmetic on non-array variables .*PointerArithm"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001634 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001635 'description': 'clang-analyzer Subtraction of pointers of different memory chunks',
1636 'patterns': [r".*: warning: Subtraction of two pointers .*PointerSub"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001637 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001638 'description': 'clang-analyzer Access out-of-bound array element',
1639 'patterns': [r".*: warning: Access out-of-bound array element .*ArrayBound"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001640 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001641 'description': 'clang-analyzer Out of bound memory access',
1642 'patterns': [r".*: warning: Out of bound memory access .*ArrayBoundV2"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001643 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001644 'description': 'clang-analyzer Possible lock order reversal',
1645 'patterns': [r".*: warning: .* Possible lock order reversal.*PthreadLock"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001646 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001647 'description': 'clang-analyzer Argument is a pointer to uninitialized value',
1648 'patterns': [r".*: warning: .* argument is a pointer to uninitialized value .*CallAndMessage"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001649 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001650 'description': 'clang-analyzer cast to struct',
1651 'patterns': [r".*: warning: Casting a non-structure type to a structure type .*CastToStruct"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001652 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001653 'description': 'clang-analyzer call path problems',
1654 'patterns': [r".*: warning: Call Path : .+"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001655 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001656 'description': 'clang-analyzer other',
1657 'patterns': [r".*: .+\[clang-analyzer-.+\]$",
1658 r".*: Call Path : .+$"]},
1659 {'category': 'C/C++', 'severity': Severity.TIDY,
1660 'description': 'clang-tidy CERT',
1661 'patterns': [r".*: .+\[cert-.+\]$"]},
1662 {'category': 'C/C++', 'severity': Severity.TIDY,
1663 'description': 'clang-tidy llvm',
1664 'patterns': [r".*: .+\[llvm-.+\]$"]},
1665 {'category': 'C/C++', 'severity': Severity.TIDY,
1666 'description': 'clang-diagnostic',
1667 'patterns': [r".*: .+\[clang-diagnostic-.+\]$"]},
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001668
Marco Nelissen594375d2009-07-14 09:04:04 -07001669 # catch-all for warnings this script doesn't know about yet
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001670 {'category': 'C/C++', 'severity': Severity.UNKNOWN,
1671 'description': 'Unclassified/unrecognized warnings',
1672 'patterns': [r".*: warning: .+"]},
Marco Nelissen594375d2009-07-14 09:04:04 -07001673]
1674
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001675
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001676def project_name_and_pattern(name, pattern):
1677 return [name, '(^|.*/)' + pattern + '/.*: warning:']
1678
1679
1680def simple_project_pattern(pattern):
1681 return project_name_and_pattern(pattern, pattern)
1682
1683
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001684# A list of [project_name, file_path_pattern].
1685# project_name should not contain comma, to be used in CSV output.
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001686project_list = [
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001687 simple_project_pattern('art'),
1688 simple_project_pattern('bionic'),
1689 simple_project_pattern('bootable'),
1690 simple_project_pattern('build'),
1691 simple_project_pattern('cts'),
1692 simple_project_pattern('dalvik'),
1693 simple_project_pattern('developers'),
1694 simple_project_pattern('development'),
1695 simple_project_pattern('device'),
1696 simple_project_pattern('doc'),
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07001697 # match external/google* before external/
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001698 project_name_and_pattern('external/google', 'external/google.*'),
1699 project_name_and_pattern('external/non-google', 'external'),
1700 simple_project_pattern('frameworks/av/camera'),
1701 simple_project_pattern('frameworks/av/cmds'),
1702 simple_project_pattern('frameworks/av/drm'),
1703 simple_project_pattern('frameworks/av/include'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07001704 simple_project_pattern('frameworks/av/media/common_time'),
1705 simple_project_pattern('frameworks/av/media/img_utils'),
1706 simple_project_pattern('frameworks/av/media/libcpustats'),
1707 simple_project_pattern('frameworks/av/media/libeffects'),
1708 simple_project_pattern('frameworks/av/media/libmediaplayerservice'),
1709 simple_project_pattern('frameworks/av/media/libmedia'),
1710 simple_project_pattern('frameworks/av/media/libstagefright'),
1711 simple_project_pattern('frameworks/av/media/mtp'),
1712 simple_project_pattern('frameworks/av/media/ndk'),
1713 simple_project_pattern('frameworks/av/media/utils'),
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07001714 project_name_and_pattern('frameworks/av/media/Other',
1715 'frameworks/av/media'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001716 simple_project_pattern('frameworks/av/radio'),
1717 simple_project_pattern('frameworks/av/services'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07001718 simple_project_pattern('frameworks/av/soundtrigger'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001719 project_name_and_pattern('frameworks/av/Other', 'frameworks/av'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07001720 simple_project_pattern('frameworks/base/cmds'),
1721 simple_project_pattern('frameworks/base/core'),
1722 simple_project_pattern('frameworks/base/drm'),
1723 simple_project_pattern('frameworks/base/media'),
1724 simple_project_pattern('frameworks/base/libs'),
1725 simple_project_pattern('frameworks/base/native'),
1726 simple_project_pattern('frameworks/base/packages'),
1727 simple_project_pattern('frameworks/base/rs'),
1728 simple_project_pattern('frameworks/base/services'),
1729 simple_project_pattern('frameworks/base/tests'),
1730 simple_project_pattern('frameworks/base/tools'),
1731 project_name_and_pattern('frameworks/base/Other', 'frameworks/base'),
Stephen Hinesd0aec892016-10-17 15:39:53 -07001732 simple_project_pattern('frameworks/compile/libbcc'),
1733 simple_project_pattern('frameworks/compile/mclinker'),
1734 simple_project_pattern('frameworks/compile/slang'),
1735 project_name_and_pattern('frameworks/compile/Other', 'frameworks/compile'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001736 simple_project_pattern('frameworks/minikin'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07001737 simple_project_pattern('frameworks/ml'),
1738 simple_project_pattern('frameworks/native/cmds'),
1739 simple_project_pattern('frameworks/native/include'),
1740 simple_project_pattern('frameworks/native/libs'),
1741 simple_project_pattern('frameworks/native/opengl'),
1742 simple_project_pattern('frameworks/native/services'),
1743 simple_project_pattern('frameworks/native/vulkan'),
1744 project_name_and_pattern('frameworks/native/Other', 'frameworks/native'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001745 simple_project_pattern('frameworks/opt'),
1746 simple_project_pattern('frameworks/rs'),
1747 simple_project_pattern('frameworks/webview'),
1748 simple_project_pattern('frameworks/wilhelm'),
1749 project_name_and_pattern('frameworks/Other', 'frameworks'),
1750 simple_project_pattern('hardware/akm'),
1751 simple_project_pattern('hardware/broadcom'),
1752 simple_project_pattern('hardware/google'),
1753 simple_project_pattern('hardware/intel'),
1754 simple_project_pattern('hardware/interfaces'),
1755 simple_project_pattern('hardware/libhardware'),
1756 simple_project_pattern('hardware/libhardware_legacy'),
1757 simple_project_pattern('hardware/qcom'),
1758 simple_project_pattern('hardware/ril'),
1759 project_name_and_pattern('hardware/Other', 'hardware'),
1760 simple_project_pattern('kernel'),
1761 simple_project_pattern('libcore'),
1762 simple_project_pattern('libnativehelper'),
1763 simple_project_pattern('ndk'),
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001764 # match vendor/unbungled_google/packages before other packages
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001765 simple_project_pattern('unbundled_google'),
1766 simple_project_pattern('packages'),
1767 simple_project_pattern('pdk'),
1768 simple_project_pattern('prebuilts'),
1769 simple_project_pattern('system/bt'),
1770 simple_project_pattern('system/connectivity'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07001771 simple_project_pattern('system/core/adb'),
1772 simple_project_pattern('system/core/base'),
1773 simple_project_pattern('system/core/debuggerd'),
1774 simple_project_pattern('system/core/fastboot'),
1775 simple_project_pattern('system/core/fingerprintd'),
1776 simple_project_pattern('system/core/fs_mgr'),
1777 simple_project_pattern('system/core/gatekeeperd'),
1778 simple_project_pattern('system/core/healthd'),
1779 simple_project_pattern('system/core/include'),
1780 simple_project_pattern('system/core/init'),
1781 simple_project_pattern('system/core/libbacktrace'),
1782 simple_project_pattern('system/core/liblog'),
1783 simple_project_pattern('system/core/libpixelflinger'),
1784 simple_project_pattern('system/core/libprocessgroup'),
1785 simple_project_pattern('system/core/libsysutils'),
1786 simple_project_pattern('system/core/logcat'),
1787 simple_project_pattern('system/core/logd'),
1788 simple_project_pattern('system/core/run-as'),
1789 simple_project_pattern('system/core/sdcard'),
1790 simple_project_pattern('system/core/toolbox'),
1791 project_name_and_pattern('system/core/Other', 'system/core'),
1792 simple_project_pattern('system/extras/ANRdaemon'),
1793 simple_project_pattern('system/extras/cpustats'),
1794 simple_project_pattern('system/extras/crypto-perf'),
1795 simple_project_pattern('system/extras/ext4_utils'),
1796 simple_project_pattern('system/extras/f2fs_utils'),
1797 simple_project_pattern('system/extras/iotop'),
1798 simple_project_pattern('system/extras/libfec'),
1799 simple_project_pattern('system/extras/memory_replay'),
1800 simple_project_pattern('system/extras/micro_bench'),
1801 simple_project_pattern('system/extras/mmap-perf'),
1802 simple_project_pattern('system/extras/multinetwork'),
1803 simple_project_pattern('system/extras/perfprofd'),
1804 simple_project_pattern('system/extras/procrank'),
1805 simple_project_pattern('system/extras/runconuid'),
1806 simple_project_pattern('system/extras/showmap'),
1807 simple_project_pattern('system/extras/simpleperf'),
1808 simple_project_pattern('system/extras/su'),
1809 simple_project_pattern('system/extras/tests'),
1810 simple_project_pattern('system/extras/verity'),
1811 project_name_and_pattern('system/extras/Other', 'system/extras'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001812 simple_project_pattern('system/gatekeeper'),
1813 simple_project_pattern('system/keymaster'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07001814 simple_project_pattern('system/libhidl'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001815 simple_project_pattern('system/libhwbinder'),
1816 simple_project_pattern('system/media'),
1817 simple_project_pattern('system/netd'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07001818 simple_project_pattern('system/nvram'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001819 simple_project_pattern('system/security'),
1820 simple_project_pattern('system/sepolicy'),
1821 simple_project_pattern('system/tools'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07001822 simple_project_pattern('system/update_engine'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001823 simple_project_pattern('system/vold'),
1824 project_name_and_pattern('system/Other', 'system'),
1825 simple_project_pattern('toolchain'),
1826 simple_project_pattern('test'),
1827 simple_project_pattern('tools'),
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07001828 # match vendor/google* before vendor/
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001829 project_name_and_pattern('vendor/google', 'vendor/google.*'),
1830 project_name_and_pattern('vendor/non-google', 'vendor'),
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07001831 # keep out/obj and other patterns at the end.
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001832 ['out/obj',
1833 '.*/(gen|obj[^/]*)/(include|EXECUTABLES|SHARED_LIBRARIES|'
1834 'STATIC_LIBRARIES|NATIVE_TESTS)/.*: warning:'],
1835 ['other', '.*'] # all other unrecognized patterns
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001836]
1837
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001838project_patterns = []
1839project_names = []
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001840warning_messages = []
1841warning_records = []
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001842
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001843
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001844def initialize_arrays():
1845 """Complete global arrays before they are used."""
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001846 global project_names, project_patterns
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001847 project_names = [p[0] for p in project_list]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001848 project_patterns = [re.compile(p[1]) for p in project_list]
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001849 for w in warn_patterns:
1850 w['members'] = []
1851 if 'option' not in w:
1852 w['option'] = ''
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001853 # Each warning pattern has a 'projects' dictionary, that
1854 # maps a project name to number of warnings in that project.
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001855 w['projects'] = {}
1856
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001857
1858initialize_arrays()
1859
1860
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -07001861android_root = ''
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001862platform_version = 'unknown'
1863target_product = 'unknown'
1864target_variant = 'unknown'
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001865
1866
1867##### Data and functions to dump html file. ##################################
1868
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001869html_head_scripts = """\
1870 <script type="text/javascript">
1871 function expand(id) {
1872 var e = document.getElementById(id);
1873 var f = document.getElementById(id + "_mark");
1874 if (e.style.display == 'block') {
1875 e.style.display = 'none';
1876 f.innerHTML = '&#x2295';
1877 }
1878 else {
1879 e.style.display = 'block';
1880 f.innerHTML = '&#x2296';
1881 }
1882 };
1883 function expandCollapse(show) {
1884 for (var id = 1; ; id++) {
1885 var e = document.getElementById(id + "");
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07001886 var f = document.getElementById(id + "_mark");
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001887 if (!e || !f) break;
1888 e.style.display = (show ? 'block' : 'none');
1889 f.innerHTML = (show ? '&#x2296' : '&#x2295');
1890 }
1891 };
1892 </script>
1893 <style type="text/css">
1894 th,td{border-collapse:collapse; border:1px solid black;}
1895 .button{color:blue;font-size:110%;font-weight:bolder;}
1896 .bt{color:black;background-color:transparent;border:none;outline:none;
1897 font-size:140%;font-weight:bolder;}
1898 .c0{background-color:#e0e0e0;}
1899 .c1{background-color:#d0d0d0;}
1900 .t1{border-collapse:collapse; width:100%; border:1px solid black;}
1901 </style>
1902 <script src="https://www.gstatic.com/charts/loader.js"></script>
1903"""
Marco Nelissen594375d2009-07-14 09:04:04 -07001904
Marco Nelissen594375d2009-07-14 09:04:04 -07001905
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001906def html_big(param):
1907 return '<font size="+2">' + param + '</font>'
Marco Nelissen594375d2009-07-14 09:04:04 -07001908
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07001909
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001910def dump_html_prologue(title):
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001911 print '<html>\n<head>'
1912 print '<title>' + title + '</title>'
1913 print html_head_scripts
1914 emit_stats_by_project()
1915 print '</head>\n<body>'
1916 print html_big(title)
1917 print '<p>'
Marco Nelissen594375d2009-07-14 09:04:04 -07001918
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001919
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001920def dump_html_epilogue():
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001921 print '</body>\n</head>\n</html>'
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001922
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001923
1924def sort_warnings():
1925 for i in warn_patterns:
1926 i['members'] = sorted(set(i['members']))
1927
1928
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001929def emit_stats_by_project():
1930 """Dump a google chart table of warnings per project and severity."""
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001931 # warnings[p][s] is number of warnings in project p of severity s.
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001932 warnings = {p: {s: 0 for s in Severity.range} for p in project_names}
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001933 for i in warn_patterns:
1934 s = i['severity']
1935 for p in i['projects']:
1936 warnings[p][s] += i['projects'][p]
1937
1938 # total_by_project[p] is number of warnings in project p.
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001939 total_by_project = {p: sum(warnings[p][s] for s in Severity.range)
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001940 for p in project_names}
1941
1942 # total_by_severity[s] is number of warnings of severity s.
1943 total_by_severity = {s: sum(warnings[p][s] for p in project_names)
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001944 for s in Severity.range}
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001945
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001946 # emit table header
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001947 stats_header = ['Project']
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001948 for s in Severity.range:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001949 if total_by_severity[s]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001950 stats_header.append("<span style='background-color:{}'>{}</span>".
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001951 format(Severity.colors[s],
1952 Severity.column_headers[s]))
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001953 stats_header.append('TOTAL')
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001954
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001955 # emit a row of warning counts per project, skip no-warning projects
1956 total_all_projects = 0
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001957 stats_rows = []
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001958 for p in project_names:
1959 if total_by_project[p]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001960 one_row = [p]
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001961 for s in Severity.range:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001962 if total_by_severity[s]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001963 one_row.append(warnings[p][s])
1964 one_row.append(total_by_project[p])
1965 stats_rows.append(one_row)
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001966 total_all_projects += total_by_project[p]
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001967
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001968 # emit a row of warning counts per severity
1969 total_all_severities = 0
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001970 one_row = ['<b>TOTAL</b>']
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001971 for s in Severity.range:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001972 if total_by_severity[s]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001973 one_row.append(total_by_severity[s])
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001974 total_all_severities += total_by_severity[s]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001975 one_row.append(total_all_projects)
1976 stats_rows.append(one_row)
1977 print '<script>'
1978 emit_const_string_array('StatsHeader', stats_header)
1979 emit_const_object_array('StatsRows', stats_rows)
1980 print draw_table_javascript
1981 print '</script>'
Marco Nelissen594375d2009-07-14 09:04:04 -07001982
1983
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001984def dump_stats():
1985 """Dump some stats about total number of warnings and such."""
1986 known = 0
1987 skipped = 0
1988 unknown = 0
1989 sort_warnings()
1990 for i in warn_patterns:
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001991 if i['severity'] == Severity.UNKNOWN:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001992 unknown += len(i['members'])
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001993 elif i['severity'] == Severity.SKIP:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001994 skipped += len(i['members'])
Ian Rogersf3829732016-05-10 12:06:01 -07001995 else:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001996 known += len(i['members'])
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001997 print 'Number of classified warnings: <b>' + str(known) + '</b><br>'
1998 print 'Number of skipped warnings: <b>' + str(skipped) + '</b><br>'
1999 print 'Number of unclassified warnings: <b>' + str(unknown) + '</b><br>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002000 total = unknown + known + skipped
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002001 extra_msg = ''
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002002 if total < 1000:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002003 extra_msg = ' (low count may indicate incremental build)'
2004 print 'Total number of warnings: <b>' + str(total) + '</b>' + extra_msg
Marco Nelissen594375d2009-07-14 09:04:04 -07002005
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07002006
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002007# New base table of warnings, [severity, warn_id, project, warning_message]
2008# Need buttons to show warnings in different grouping options.
2009# (1) Current, group by severity, id for each warning pattern
2010# sort by severity, warn_id, warning_message
2011# (2) Current --byproject, group by severity,
2012# id for each warning pattern + project name
2013# sort by severity, warn_id, project, warning_message
2014# (3) New, group by project + severity,
2015# id for each warning pattern
2016# sort by project, severity, warn_id, warning_message
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002017def emit_buttons():
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002018 print ('<button class="button" onclick="expandCollapse(1);">'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002019 'Expand all warnings</button>\n'
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002020 '<button class="button" onclick="expandCollapse(0);">'
2021 'Collapse all warnings</button>\n'
2022 '<button class="button" onclick="groupBySeverity();">'
2023 'Group warnings by severity</button>\n'
2024 '<button class="button" onclick="groupByProject();">'
2025 'Group warnings by project</button><br>')
Marco Nelissen594375d2009-07-14 09:04:04 -07002026
2027
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002028def all_patterns(category):
2029 patterns = ''
2030 for i in category['patterns']:
2031 patterns += i
2032 patterns += ' / '
2033 return patterns
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002034
2035
2036def dump_fixed():
2037 """Show which warnings no longer occur."""
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002038 anchor = 'fixed_warnings'
2039 mark = anchor + '_mark'
2040 print ('\n<br><p style="background-color:lightblue"><b>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002041 '<button id="' + mark + '" '
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002042 'class="bt" onclick="expand(\'' + anchor + '\');">'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002043 '&#x2295</button> Fixed warnings. '
2044 'No more occurrences. Please consider turning these into '
2045 'errors if possible, before they are reintroduced in to the build'
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002046 ':</b></p>')
2047 print '<blockquote>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002048 fixed_patterns = []
2049 for i in warn_patterns:
2050 if not i['members']:
2051 fixed_patterns.append(i['description'] + ' (' +
2052 all_patterns(i) + ')')
2053 if i['option']:
2054 fixed_patterns.append(' ' + i['option'])
2055 fixed_patterns.sort()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002056 print '<div id="' + anchor + '" style="display:none;"><table>'
2057 cur_row_class = 0
2058 for text in fixed_patterns:
2059 cur_row_class = 1 - cur_row_class
2060 # remove last '\n'
2061 t = text[:-1] if text[-1] == '\n' else text
2062 print '<tr><td class="c' + str(cur_row_class) + '">' + t + '</td></tr>'
2063 print '</table></div>'
2064 print '</blockquote>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002065
2066
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002067def find_project_index(line):
2068 for p in range(len(project_patterns)):
2069 if project_patterns[p].match(line):
2070 return p
2071 return -1
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002072
2073
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002074def classify_one_warning(line, results):
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002075 for i in range(len(warn_patterns)):
2076 w = warn_patterns[i]
2077 for cpat in w['compiled_patterns']:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002078 if cpat.match(line):
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002079 p = find_project_index(line)
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002080 results.append([line, i, p])
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002081 return
2082 else:
2083 # If we end up here, there was a problem parsing the log
2084 # probably caused by 'make -j' mixing the output from
2085 # 2 or more concurrent compiles
2086 pass
Marco Nelissen594375d2009-07-14 09:04:04 -07002087
2088
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002089def classify_warnings(lines):
2090 results = []
2091 for line in lines:
2092 classify_one_warning(line, results)
2093 return results
2094
2095
2096def parallel_classify_warnings(warning_lines):
2097 """Classify all warning lines with num_cpu parallel processes."""
2098 num_cpu = args.processes
Chih-Hung Hsieh63de3002016-10-28 10:53:34 -07002099 if num_cpu > 1:
2100 groups = [[] for x in range(num_cpu)]
2101 i = 0
2102 for x in warning_lines:
2103 groups[i].append(x)
2104 i = (i + 1) % num_cpu
2105 pool = multiprocessing.Pool(num_cpu)
2106 group_results = pool.map(classify_warnings, groups)
2107 else:
2108 group_results = [classify_warnings(warning_lines)]
2109
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002110 for result in group_results:
2111 for line, pattern_idx, project_idx in result:
2112 pattern = warn_patterns[pattern_idx]
2113 pattern['members'].append(line)
2114 message_idx = len(warning_messages)
2115 warning_messages.append(line)
2116 warning_records.append([pattern_idx, project_idx, message_idx])
2117 pname = '???' if project_idx < 0 else project_names[project_idx]
2118 # Count warnings by project.
2119 if pname in pattern['projects']:
2120 pattern['projects'][pname] += 1
2121 else:
2122 pattern['projects'][pname] = 1
2123
2124
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002125def compile_patterns():
2126 """Precompiling every pattern speeds up parsing by about 30x."""
2127 for i in warn_patterns:
2128 i['compiled_patterns'] = []
2129 for pat in i['patterns']:
2130 i['compiled_patterns'].append(re.compile(pat))
2131
2132
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -07002133def find_android_root(path):
2134 """Set and return android_root path if it is found."""
2135 global android_root
2136 parts = path.split('/')
2137 for idx in reversed(range(2, len(parts))):
2138 root_path = '/'.join(parts[:idx])
2139 # Android root directory should contain this script.
2140 if os.path.exists(root_path + '/build/tools/warn.py'):
2141 android_root = root_path
2142 return root_path
2143 return ''
2144
2145
2146def remove_android_root_prefix(path):
2147 """Remove android_root prefix from path if it is found."""
2148 if path.startswith(android_root):
2149 return path[1 + len(android_root):]
2150 else:
2151 return path
2152
2153
2154def normalize_path(path):
2155 """Normalize file path relative to android_root."""
2156 # If path is not an absolute path, just normalize it.
2157 path = os.path.normpath(path)
2158 if path[0] != '/':
2159 return path
2160 # Remove known prefix of root path and normalize the suffix.
2161 if android_root or find_android_root(path):
2162 return remove_android_root_prefix(path)
2163 else:
2164 return path
2165
2166
2167def normalize_warning_line(line):
2168 """Normalize file path relative to android_root in a warning line."""
2169 # replace fancy quotes with plain ol' quotes
2170 line = line.replace('‘', "'")
2171 line = line.replace('’', "'")
2172 line = line.strip()
2173 first_column = line.find(':')
2174 if first_column > 0:
2175 return normalize_path(line[:first_column]) + line[first_column:]
2176 else:
2177 return line
2178
2179
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002180def parse_input_file():
2181 """Parse input file, match warning lines."""
2182 global platform_version
2183 global target_product
2184 global target_variant
2185 infile = open(args.buildlog, 'r')
2186 line_counter = 0
2187
Chih-Hung Hsieh5722f922016-10-11 15:33:19 -07002188 # handle only warning messages with a file path
2189 warning_pattern = re.compile('^[^ ]*/[^ ]*: warning: .*')
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002190 compile_patterns()
2191
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002192 # Collect all warnings into the warning_lines set.
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002193 warning_lines = set()
2194 for line in infile:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002195 if warning_pattern.match(line):
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -07002196 line = normalize_warning_line(line)
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002197 warning_lines.add(line)
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002198 elif line_counter < 50:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002199 # save a little bit of time by only doing this for the first few lines
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002200 line_counter += 1
2201 m = re.search('(?<=^PLATFORM_VERSION=).*', line)
2202 if m is not None:
2203 platform_version = m.group(0)
2204 m = re.search('(?<=^TARGET_PRODUCT=).*', line)
2205 if m is not None:
2206 target_product = m.group(0)
2207 m = re.search('(?<=^TARGET_BUILD_VARIANT=).*', line)
2208 if m is not None:
2209 target_variant = m.group(0)
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002210 parallel_classify_warnings(warning_lines)
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002211
2212
Chih-Hung Hsieh5722f922016-10-11 15:33:19 -07002213# Return s with escaped backslash and quotation characters.
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002214def escape_string(s):
Chih-Hung Hsieh5722f922016-10-11 15:33:19 -07002215 return s.replace('\\', '\\\\').replace('"', '\\"')
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002216
2217
2218# Return s without trailing '\n' and escape the quotation characters.
2219def strip_escape_string(s):
2220 if not s:
2221 return s
2222 s = s[:-1] if s[-1] == '\n' else s
2223 return escape_string(s)
2224
2225
2226def emit_warning_array(name):
2227 print 'var warning_{} = ['.format(name)
2228 for i in range(len(warn_patterns)):
2229 print '{},'.format(warn_patterns[i][name])
2230 print '];'
2231
2232
2233def emit_warning_arrays():
2234 emit_warning_array('severity')
2235 print 'var warning_description = ['
2236 for i in range(len(warn_patterns)):
2237 if warn_patterns[i]['members']:
2238 print '"{}",'.format(escape_string(warn_patterns[i]['description']))
2239 else:
2240 print '"",' # no such warning
2241 print '];'
2242
2243scripts_for_warning_groups = """
2244 function compareMessages(x1, x2) { // of the same warning type
2245 return (WarningMessages[x1[2]] <= WarningMessages[x2[2]]) ? -1 : 1;
2246 }
2247 function byMessageCount(x1, x2) {
2248 return x2[2] - x1[2]; // reversed order
2249 }
2250 function bySeverityMessageCount(x1, x2) {
2251 // orer by severity first
2252 if (x1[1] != x2[1])
2253 return x1[1] - x2[1];
2254 return byMessageCount(x1, x2);
2255 }
2256 const ParseLinePattern = /^([^ :]+):(\\d+):(.+)/;
2257 function addURL(line) {
2258 if (FlagURL == "") return line;
2259 if (FlagSeparator == "") {
2260 return line.replace(ParseLinePattern,
2261 "<a href='" + FlagURL + "/$1'>$1</a>:$2:$3");
2262 }
2263 return line.replace(ParseLinePattern,
2264 "<a href='" + FlagURL + "/$1" + FlagSeparator + "$2'>$1:$2</a>:$3");
2265 }
2266 function createArrayOfDictionaries(n) {
2267 var result = [];
2268 for (var i=0; i<n; i++) result.push({});
2269 return result;
2270 }
2271 function groupWarningsBySeverity() {
2272 // groups is an array of dictionaries,
2273 // each dictionary maps from warning type to array of warning messages.
2274 var groups = createArrayOfDictionaries(SeverityColors.length);
2275 for (var i=0; i<Warnings.length; i++) {
2276 var w = Warnings[i][0];
2277 var s = WarnPatternsSeverity[w];
2278 var k = w.toString();
2279 if (!(k in groups[s]))
2280 groups[s][k] = [];
2281 groups[s][k].push(Warnings[i]);
2282 }
2283 return groups;
2284 }
2285 function groupWarningsByProject() {
2286 var groups = createArrayOfDictionaries(ProjectNames.length);
2287 for (var i=0; i<Warnings.length; i++) {
2288 var w = Warnings[i][0];
2289 var p = Warnings[i][1];
2290 var k = w.toString();
2291 if (!(k in groups[p]))
2292 groups[p][k] = [];
2293 groups[p][k].push(Warnings[i]);
2294 }
2295 return groups;
2296 }
2297 var GlobalAnchor = 0;
2298 function createWarningSection(header, color, group) {
2299 var result = "";
2300 var groupKeys = [];
2301 var totalMessages = 0;
2302 for (var k in group) {
2303 totalMessages += group[k].length;
2304 groupKeys.push([k, WarnPatternsSeverity[parseInt(k)], group[k].length]);
2305 }
2306 groupKeys.sort(bySeverityMessageCount);
2307 for (var idx=0; idx<groupKeys.length; idx++) {
2308 var k = groupKeys[idx][0];
2309 var messages = group[k];
2310 var w = parseInt(k);
2311 var wcolor = SeverityColors[WarnPatternsSeverity[w]];
2312 var description = WarnPatternsDescription[w];
2313 if (description.length == 0)
2314 description = "???";
2315 GlobalAnchor += 1;
2316 result += "<table class='t1'><tr bgcolor='" + wcolor + "'><td>" +
2317 "<button class='bt' id='" + GlobalAnchor + "_mark" +
2318 "' onclick='expand(\\"" + GlobalAnchor + "\\");'>" +
2319 "&#x2295</button> " +
2320 description + " (" + messages.length + ")</td></tr></table>";
2321 result += "<div id='" + GlobalAnchor +
2322 "' style='display:none;'><table class='t1'>";
2323 var c = 0;
2324 messages.sort(compareMessages);
2325 for (var i=0; i<messages.length; i++) {
2326 result += "<tr><td class='c" + c + "'>" +
2327 addURL(WarningMessages[messages[i][2]]) + "</td></tr>";
2328 c = 1 - c;
2329 }
2330 result += "</table></div>";
2331 }
2332 if (result.length > 0) {
2333 return "<br><span style='background-color:" + color + "'><b>" +
2334 header + ": " + totalMessages +
2335 "</b></span><blockquote><table class='t1'>" +
2336 result + "</table></blockquote>";
2337
2338 }
2339 return ""; // empty section
2340 }
2341 function generateSectionsBySeverity() {
2342 var result = "";
2343 var groups = groupWarningsBySeverity();
2344 for (s=0; s<SeverityColors.length; s++) {
2345 result += createWarningSection(SeverityHeaders[s], SeverityColors[s], groups[s]);
2346 }
2347 return result;
2348 }
2349 function generateSectionsByProject() {
2350 var result = "";
2351 var groups = groupWarningsByProject();
2352 for (i=0; i<groups.length; i++) {
2353 result += createWarningSection(ProjectNames[i], 'lightgrey', groups[i]);
2354 }
2355 return result;
2356 }
2357 function groupWarnings(generator) {
2358 GlobalAnchor = 0;
2359 var e = document.getElementById("warning_groups");
2360 e.innerHTML = generator();
2361 }
2362 function groupBySeverity() {
2363 groupWarnings(generateSectionsBySeverity);
2364 }
2365 function groupByProject() {
2366 groupWarnings(generateSectionsByProject);
2367 }
2368"""
2369
2370
2371# Emit a JavaScript const string
2372def emit_const_string(name, value):
2373 print 'const ' + name + ' = "' + escape_string(value) + '";'
2374
2375
2376# Emit a JavaScript const integer array.
2377def emit_const_int_array(name, array):
2378 print 'const ' + name + ' = ['
2379 for n in array:
2380 print str(n) + ','
2381 print '];'
2382
2383
2384# Emit a JavaScript const string array.
2385def emit_const_string_array(name, array):
2386 print 'const ' + name + ' = ['
2387 for s in array:
2388 print '"' + strip_escape_string(s) + '",'
2389 print '];'
2390
2391
2392# Emit a JavaScript const object array.
2393def emit_const_object_array(name, array):
2394 print 'const ' + name + ' = ['
2395 for x in array:
2396 print str(x) + ','
2397 print '];'
2398
2399
2400def emit_js_data():
2401 """Dump dynamic HTML page's static JavaScript data."""
2402 emit_const_string('FlagURL', args.url if args.url else '')
2403 emit_const_string('FlagSeparator', args.separator if args.separator else '')
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002404 emit_const_string_array('SeverityColors', Severity.colors)
2405 emit_const_string_array('SeverityHeaders', Severity.headers)
2406 emit_const_string_array('SeverityColumnHeaders', Severity.column_headers)
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002407 emit_const_string_array('ProjectNames', project_names)
2408 emit_const_int_array('WarnPatternsSeverity',
2409 [w['severity'] for w in warn_patterns])
2410 emit_const_string_array('WarnPatternsDescription',
2411 [w['description'] for w in warn_patterns])
2412 emit_const_string_array('WarnPatternsOption',
2413 [w['option'] for w in warn_patterns])
2414 emit_const_string_array('WarningMessages', warning_messages)
2415 emit_const_object_array('Warnings', warning_records)
2416
2417draw_table_javascript = """
2418google.charts.load('current', {'packages':['table']});
2419google.charts.setOnLoadCallback(drawTable);
2420function drawTable() {
2421 var data = new google.visualization.DataTable();
2422 data.addColumn('string', StatsHeader[0]);
2423 for (var i=1; i<StatsHeader.length; i++) {
2424 data.addColumn('number', StatsHeader[i]);
2425 }
2426 data.addRows(StatsRows);
2427 for (var i=0; i<StatsRows.length; i++) {
2428 for (var j=0; j<StatsHeader.length; j++) {
2429 data.setProperty(i, j, 'style', 'border:1px solid black;');
2430 }
2431 }
2432 var table = new google.visualization.Table(document.getElementById('stats_table'));
2433 table.draw(data, {allowHtml: true, alternatingRowStyle: true});
2434}
2435"""
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002436
2437
2438def dump_html():
2439 """Dump the html output to stdout."""
2440 dump_html_prologue('Warnings for ' + platform_version + ' - ' +
2441 target_product + ' - ' + target_variant)
2442 dump_stats()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002443 print '<br><div id="stats_table"></div><br>'
2444 print '\n<script>'
2445 emit_js_data()
2446 print scripts_for_warning_groups
2447 print '</script>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002448 emit_buttons()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002449 # Warning messages are grouped by severities or project names.
2450 print '<br><div id="warning_groups"></div>'
2451 if args.byproject:
2452 print '<script>groupByProject();</script>'
2453 else:
2454 print '<script>groupBySeverity();</script>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002455 dump_fixed()
2456 dump_html_epilogue()
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002457
2458
2459##### Functions to count warnings and dump csv file. #########################
2460
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002461
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002462def description_for_csv(category):
2463 if not category['description']:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002464 return '?'
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002465 return category['description']
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002466
2467
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002468def string_for_csv(s):
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002469 # Only some Java warning desciptions have used quotation marks.
2470 # TODO(chh): if s has double quote character, s should be quoted.
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002471 if ',' in s:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002472 # TODO(chh): replace a double quote with two double quotes in s.
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002473 return '"{}"'.format(s)
2474 return s
2475
2476
2477def count_severity(sev, kind):
2478 """Count warnings of given severity."""
2479 total = 0
2480 for i in warn_patterns:
2481 if i['severity'] == sev and i['members']:
2482 n = len(i['members'])
2483 total += n
2484 warning = string_for_csv(kind + ': ' + description_for_csv(i))
2485 print '{},,{}'.format(n, warning)
2486 # print number of warnings for each project, ordered by project name.
2487 projects = i['projects'].keys()
2488 projects.sort()
2489 for p in projects:
2490 print '{},{},{}'.format(i['projects'][p], p, warning)
2491 print '{},,{}'.format(total, kind + ' warnings')
2492 return total
2493
2494
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002495# dump number of warnings in csv format to stdout
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002496def dump_csv():
2497 """Dump number of warnings in csv format to stdout."""
2498 sort_warnings()
2499 total = 0
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002500 for s in Severity.range:
2501 total += count_severity(s, Severity.column_headers[s])
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002502 print '{},,{}'.format(total, 'All warnings')
2503
2504
Meike Baumgärtnerac9d5df2016-09-28 10:48:06 -07002505def main():
2506 parse_input_file()
2507 if args.gencsv:
2508 dump_csv()
2509 else:
2510 dump_html()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002511
Meike Baumgärtnerac9d5df2016-09-28 10:48:06 -07002512
2513# Run main function if warn.py is the main program.
2514if __name__ == '__main__':
2515 main()