blob: 5de818621bdb495a644cfdf526a4c4146efbde47 [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'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001732 simple_project_pattern('frameworks/compile'),
1733 simple_project_pattern('frameworks/minikin'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07001734 simple_project_pattern('frameworks/ml'),
1735 simple_project_pattern('frameworks/native/cmds'),
1736 simple_project_pattern('frameworks/native/include'),
1737 simple_project_pattern('frameworks/native/libs'),
1738 simple_project_pattern('frameworks/native/opengl'),
1739 simple_project_pattern('frameworks/native/services'),
1740 simple_project_pattern('frameworks/native/vulkan'),
1741 project_name_and_pattern('frameworks/native/Other', 'frameworks/native'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001742 simple_project_pattern('frameworks/opt'),
1743 simple_project_pattern('frameworks/rs'),
1744 simple_project_pattern('frameworks/webview'),
1745 simple_project_pattern('frameworks/wilhelm'),
1746 project_name_and_pattern('frameworks/Other', 'frameworks'),
1747 simple_project_pattern('hardware/akm'),
1748 simple_project_pattern('hardware/broadcom'),
1749 simple_project_pattern('hardware/google'),
1750 simple_project_pattern('hardware/intel'),
1751 simple_project_pattern('hardware/interfaces'),
1752 simple_project_pattern('hardware/libhardware'),
1753 simple_project_pattern('hardware/libhardware_legacy'),
1754 simple_project_pattern('hardware/qcom'),
1755 simple_project_pattern('hardware/ril'),
1756 project_name_and_pattern('hardware/Other', 'hardware'),
1757 simple_project_pattern('kernel'),
1758 simple_project_pattern('libcore'),
1759 simple_project_pattern('libnativehelper'),
1760 simple_project_pattern('ndk'),
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001761 # match vendor/unbungled_google/packages before other packages
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001762 simple_project_pattern('unbundled_google'),
1763 simple_project_pattern('packages'),
1764 simple_project_pattern('pdk'),
1765 simple_project_pattern('prebuilts'),
1766 simple_project_pattern('system/bt'),
1767 simple_project_pattern('system/connectivity'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07001768 simple_project_pattern('system/core/adb'),
1769 simple_project_pattern('system/core/base'),
1770 simple_project_pattern('system/core/debuggerd'),
1771 simple_project_pattern('system/core/fastboot'),
1772 simple_project_pattern('system/core/fingerprintd'),
1773 simple_project_pattern('system/core/fs_mgr'),
1774 simple_project_pattern('system/core/gatekeeperd'),
1775 simple_project_pattern('system/core/healthd'),
1776 simple_project_pattern('system/core/include'),
1777 simple_project_pattern('system/core/init'),
1778 simple_project_pattern('system/core/libbacktrace'),
1779 simple_project_pattern('system/core/liblog'),
1780 simple_project_pattern('system/core/libpixelflinger'),
1781 simple_project_pattern('system/core/libprocessgroup'),
1782 simple_project_pattern('system/core/libsysutils'),
1783 simple_project_pattern('system/core/logcat'),
1784 simple_project_pattern('system/core/logd'),
1785 simple_project_pattern('system/core/run-as'),
1786 simple_project_pattern('system/core/sdcard'),
1787 simple_project_pattern('system/core/toolbox'),
1788 project_name_and_pattern('system/core/Other', 'system/core'),
1789 simple_project_pattern('system/extras/ANRdaemon'),
1790 simple_project_pattern('system/extras/cpustats'),
1791 simple_project_pattern('system/extras/crypto-perf'),
1792 simple_project_pattern('system/extras/ext4_utils'),
1793 simple_project_pattern('system/extras/f2fs_utils'),
1794 simple_project_pattern('system/extras/iotop'),
1795 simple_project_pattern('system/extras/libfec'),
1796 simple_project_pattern('system/extras/memory_replay'),
1797 simple_project_pattern('system/extras/micro_bench'),
1798 simple_project_pattern('system/extras/mmap-perf'),
1799 simple_project_pattern('system/extras/multinetwork'),
1800 simple_project_pattern('system/extras/perfprofd'),
1801 simple_project_pattern('system/extras/procrank'),
1802 simple_project_pattern('system/extras/runconuid'),
1803 simple_project_pattern('system/extras/showmap'),
1804 simple_project_pattern('system/extras/simpleperf'),
1805 simple_project_pattern('system/extras/su'),
1806 simple_project_pattern('system/extras/tests'),
1807 simple_project_pattern('system/extras/verity'),
1808 project_name_and_pattern('system/extras/Other', 'system/extras'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001809 simple_project_pattern('system/gatekeeper'),
1810 simple_project_pattern('system/keymaster'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07001811 simple_project_pattern('system/libhidl'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001812 simple_project_pattern('system/libhwbinder'),
1813 simple_project_pattern('system/media'),
1814 simple_project_pattern('system/netd'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07001815 simple_project_pattern('system/nvram'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001816 simple_project_pattern('system/security'),
1817 simple_project_pattern('system/sepolicy'),
1818 simple_project_pattern('system/tools'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07001819 simple_project_pattern('system/update_engine'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001820 simple_project_pattern('system/vold'),
1821 project_name_and_pattern('system/Other', 'system'),
1822 simple_project_pattern('toolchain'),
1823 simple_project_pattern('test'),
1824 simple_project_pattern('tools'),
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07001825 # match vendor/google* before vendor/
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001826 project_name_and_pattern('vendor/google', 'vendor/google.*'),
1827 project_name_and_pattern('vendor/non-google', 'vendor'),
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07001828 # keep out/obj and other patterns at the end.
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001829 ['out/obj',
1830 '.*/(gen|obj[^/]*)/(include|EXECUTABLES|SHARED_LIBRARIES|'
1831 'STATIC_LIBRARIES|NATIVE_TESTS)/.*: warning:'],
1832 ['other', '.*'] # all other unrecognized patterns
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001833]
1834
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001835project_patterns = []
1836project_names = []
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001837warning_messages = []
1838warning_records = []
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001839
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001840
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001841def initialize_arrays():
1842 """Complete global arrays before they are used."""
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001843 global project_names, project_patterns
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001844 project_names = [p[0] for p in project_list]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001845 project_patterns = [re.compile(p[1]) for p in project_list]
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001846 for w in warn_patterns:
1847 w['members'] = []
1848 if 'option' not in w:
1849 w['option'] = ''
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001850 # Each warning pattern has a 'projects' dictionary, that
1851 # maps a project name to number of warnings in that project.
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001852 w['projects'] = {}
1853
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001854
1855initialize_arrays()
1856
1857
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -07001858android_root = ''
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001859platform_version = 'unknown'
1860target_product = 'unknown'
1861target_variant = 'unknown'
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001862
1863
1864##### Data and functions to dump html file. ##################################
1865
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001866html_head_scripts = """\
1867 <script type="text/javascript">
1868 function expand(id) {
1869 var e = document.getElementById(id);
1870 var f = document.getElementById(id + "_mark");
1871 if (e.style.display == 'block') {
1872 e.style.display = 'none';
1873 f.innerHTML = '&#x2295';
1874 }
1875 else {
1876 e.style.display = 'block';
1877 f.innerHTML = '&#x2296';
1878 }
1879 };
1880 function expandCollapse(show) {
1881 for (var id = 1; ; id++) {
1882 var e = document.getElementById(id + "");
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07001883 var f = document.getElementById(id + "_mark");
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001884 if (!e || !f) break;
1885 e.style.display = (show ? 'block' : 'none');
1886 f.innerHTML = (show ? '&#x2296' : '&#x2295');
1887 }
1888 };
1889 </script>
1890 <style type="text/css">
1891 th,td{border-collapse:collapse; border:1px solid black;}
1892 .button{color:blue;font-size:110%;font-weight:bolder;}
1893 .bt{color:black;background-color:transparent;border:none;outline:none;
1894 font-size:140%;font-weight:bolder;}
1895 .c0{background-color:#e0e0e0;}
1896 .c1{background-color:#d0d0d0;}
1897 .t1{border-collapse:collapse; width:100%; border:1px solid black;}
1898 </style>
1899 <script src="https://www.gstatic.com/charts/loader.js"></script>
1900"""
Marco Nelissen594375d2009-07-14 09:04:04 -07001901
Marco Nelissen594375d2009-07-14 09:04:04 -07001902
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001903def html_big(param):
1904 return '<font size="+2">' + param + '</font>'
Marco Nelissen594375d2009-07-14 09:04:04 -07001905
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07001906
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001907def dump_html_prologue(title):
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001908 print '<html>\n<head>'
1909 print '<title>' + title + '</title>'
1910 print html_head_scripts
1911 emit_stats_by_project()
1912 print '</head>\n<body>'
1913 print html_big(title)
1914 print '<p>'
Marco Nelissen594375d2009-07-14 09:04:04 -07001915
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001916
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001917def dump_html_epilogue():
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001918 print '</body>\n</head>\n</html>'
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001919
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001920
1921def sort_warnings():
1922 for i in warn_patterns:
1923 i['members'] = sorted(set(i['members']))
1924
1925
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001926def emit_stats_by_project():
1927 """Dump a google chart table of warnings per project and severity."""
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001928 # warnings[p][s] is number of warnings in project p of severity s.
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001929 warnings = {p: {s: 0 for s in Severity.range} for p in project_names}
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001930 for i in warn_patterns:
1931 s = i['severity']
1932 for p in i['projects']:
1933 warnings[p][s] += i['projects'][p]
1934
1935 # total_by_project[p] is number of warnings in project p.
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001936 total_by_project = {p: sum(warnings[p][s] for s in Severity.range)
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001937 for p in project_names}
1938
1939 # total_by_severity[s] is number of warnings of severity s.
1940 total_by_severity = {s: sum(warnings[p][s] for p in project_names)
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001941 for s in Severity.range}
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001942
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001943 # emit table header
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001944 stats_header = ['Project']
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001945 for s in Severity.range:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001946 if total_by_severity[s]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001947 stats_header.append("<span style='background-color:{}'>{}</span>".
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001948 format(Severity.colors[s],
1949 Severity.column_headers[s]))
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001950 stats_header.append('TOTAL')
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001951
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001952 # emit a row of warning counts per project, skip no-warning projects
1953 total_all_projects = 0
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001954 stats_rows = []
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001955 for p in project_names:
1956 if total_by_project[p]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001957 one_row = [p]
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001958 for s in Severity.range:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001959 if total_by_severity[s]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001960 one_row.append(warnings[p][s])
1961 one_row.append(total_by_project[p])
1962 stats_rows.append(one_row)
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001963 total_all_projects += total_by_project[p]
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001964
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001965 # emit a row of warning counts per severity
1966 total_all_severities = 0
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001967 one_row = ['<b>TOTAL</b>']
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001968 for s in Severity.range:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001969 if total_by_severity[s]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001970 one_row.append(total_by_severity[s])
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001971 total_all_severities += total_by_severity[s]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001972 one_row.append(total_all_projects)
1973 stats_rows.append(one_row)
1974 print '<script>'
1975 emit_const_string_array('StatsHeader', stats_header)
1976 emit_const_object_array('StatsRows', stats_rows)
1977 print draw_table_javascript
1978 print '</script>'
Marco Nelissen594375d2009-07-14 09:04:04 -07001979
1980
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001981def dump_stats():
1982 """Dump some stats about total number of warnings and such."""
1983 known = 0
1984 skipped = 0
1985 unknown = 0
1986 sort_warnings()
1987 for i in warn_patterns:
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001988 if i['severity'] == Severity.UNKNOWN:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001989 unknown += len(i['members'])
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001990 elif i['severity'] == Severity.SKIP:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001991 skipped += len(i['members'])
Ian Rogersf3829732016-05-10 12:06:01 -07001992 else:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001993 known += len(i['members'])
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001994 print 'Number of classified warnings: <b>' + str(known) + '</b><br>'
1995 print 'Number of skipped warnings: <b>' + str(skipped) + '</b><br>'
1996 print 'Number of unclassified warnings: <b>' + str(unknown) + '</b><br>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001997 total = unknown + known + skipped
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001998 extra_msg = ''
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001999 if total < 1000:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002000 extra_msg = ' (low count may indicate incremental build)'
2001 print 'Total number of warnings: <b>' + str(total) + '</b>' + extra_msg
Marco Nelissen594375d2009-07-14 09:04:04 -07002002
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07002003
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002004# New base table of warnings, [severity, warn_id, project, warning_message]
2005# Need buttons to show warnings in different grouping options.
2006# (1) Current, group by severity, id for each warning pattern
2007# sort by severity, warn_id, warning_message
2008# (2) Current --byproject, group by severity,
2009# id for each warning pattern + project name
2010# sort by severity, warn_id, project, warning_message
2011# (3) New, group by project + severity,
2012# id for each warning pattern
2013# sort by project, severity, warn_id, warning_message
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002014def emit_buttons():
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002015 print ('<button class="button" onclick="expandCollapse(1);">'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002016 'Expand all warnings</button>\n'
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002017 '<button class="button" onclick="expandCollapse(0);">'
2018 'Collapse all warnings</button>\n'
2019 '<button class="button" onclick="groupBySeverity();">'
2020 'Group warnings by severity</button>\n'
2021 '<button class="button" onclick="groupByProject();">'
2022 'Group warnings by project</button><br>')
Marco Nelissen594375d2009-07-14 09:04:04 -07002023
2024
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002025def all_patterns(category):
2026 patterns = ''
2027 for i in category['patterns']:
2028 patterns += i
2029 patterns += ' / '
2030 return patterns
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002031
2032
2033def dump_fixed():
2034 """Show which warnings no longer occur."""
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002035 anchor = 'fixed_warnings'
2036 mark = anchor + '_mark'
2037 print ('\n<br><p style="background-color:lightblue"><b>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002038 '<button id="' + mark + '" '
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002039 'class="bt" onclick="expand(\'' + anchor + '\');">'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002040 '&#x2295</button> Fixed warnings. '
2041 'No more occurrences. Please consider turning these into '
2042 'errors if possible, before they are reintroduced in to the build'
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002043 ':</b></p>')
2044 print '<blockquote>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002045 fixed_patterns = []
2046 for i in warn_patterns:
2047 if not i['members']:
2048 fixed_patterns.append(i['description'] + ' (' +
2049 all_patterns(i) + ')')
2050 if i['option']:
2051 fixed_patterns.append(' ' + i['option'])
2052 fixed_patterns.sort()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002053 print '<div id="' + anchor + '" style="display:none;"><table>'
2054 cur_row_class = 0
2055 for text in fixed_patterns:
2056 cur_row_class = 1 - cur_row_class
2057 # remove last '\n'
2058 t = text[:-1] if text[-1] == '\n' else text
2059 print '<tr><td class="c' + str(cur_row_class) + '">' + t + '</td></tr>'
2060 print '</table></div>'
2061 print '</blockquote>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002062
2063
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002064def find_project_index(line):
2065 for p in range(len(project_patterns)):
2066 if project_patterns[p].match(line):
2067 return p
2068 return -1
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002069
2070
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002071def classify_one_warning(line, results):
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002072 for i in range(len(warn_patterns)):
2073 w = warn_patterns[i]
2074 for cpat in w['compiled_patterns']:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002075 if cpat.match(line):
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002076 p = find_project_index(line)
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002077 results.append([line, i, p])
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002078 return
2079 else:
2080 # If we end up here, there was a problem parsing the log
2081 # probably caused by 'make -j' mixing the output from
2082 # 2 or more concurrent compiles
2083 pass
Marco Nelissen594375d2009-07-14 09:04:04 -07002084
2085
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002086def classify_warnings(lines):
2087 results = []
2088 for line in lines:
2089 classify_one_warning(line, results)
2090 return results
2091
2092
2093def parallel_classify_warnings(warning_lines):
2094 """Classify all warning lines with num_cpu parallel processes."""
2095 num_cpu = args.processes
2096 groups = [[] for x in range(num_cpu)]
2097 i = 0
2098 for x in warning_lines:
2099 groups[i].append(x)
2100 i = (i + 1) % num_cpu
2101 pool = multiprocessing.Pool(num_cpu)
2102 group_results = pool.map(classify_warnings, groups)
2103 for result in group_results:
2104 for line, pattern_idx, project_idx in result:
2105 pattern = warn_patterns[pattern_idx]
2106 pattern['members'].append(line)
2107 message_idx = len(warning_messages)
2108 warning_messages.append(line)
2109 warning_records.append([pattern_idx, project_idx, message_idx])
2110 pname = '???' if project_idx < 0 else project_names[project_idx]
2111 # Count warnings by project.
2112 if pname in pattern['projects']:
2113 pattern['projects'][pname] += 1
2114 else:
2115 pattern['projects'][pname] = 1
2116
2117
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002118def compile_patterns():
2119 """Precompiling every pattern speeds up parsing by about 30x."""
2120 for i in warn_patterns:
2121 i['compiled_patterns'] = []
2122 for pat in i['patterns']:
2123 i['compiled_patterns'].append(re.compile(pat))
2124
2125
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -07002126def find_android_root(path):
2127 """Set and return android_root path if it is found."""
2128 global android_root
2129 parts = path.split('/')
2130 for idx in reversed(range(2, len(parts))):
2131 root_path = '/'.join(parts[:idx])
2132 # Android root directory should contain this script.
2133 if os.path.exists(root_path + '/build/tools/warn.py'):
2134 android_root = root_path
2135 return root_path
2136 return ''
2137
2138
2139def remove_android_root_prefix(path):
2140 """Remove android_root prefix from path if it is found."""
2141 if path.startswith(android_root):
2142 return path[1 + len(android_root):]
2143 else:
2144 return path
2145
2146
2147def normalize_path(path):
2148 """Normalize file path relative to android_root."""
2149 # If path is not an absolute path, just normalize it.
2150 path = os.path.normpath(path)
2151 if path[0] != '/':
2152 return path
2153 # Remove known prefix of root path and normalize the suffix.
2154 if android_root or find_android_root(path):
2155 return remove_android_root_prefix(path)
2156 else:
2157 return path
2158
2159
2160def normalize_warning_line(line):
2161 """Normalize file path relative to android_root in a warning line."""
2162 # replace fancy quotes with plain ol' quotes
2163 line = line.replace('‘', "'")
2164 line = line.replace('’', "'")
2165 line = line.strip()
2166 first_column = line.find(':')
2167 if first_column > 0:
2168 return normalize_path(line[:first_column]) + line[first_column:]
2169 else:
2170 return line
2171
2172
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002173def parse_input_file():
2174 """Parse input file, match warning lines."""
2175 global platform_version
2176 global target_product
2177 global target_variant
2178 infile = open(args.buildlog, 'r')
2179 line_counter = 0
2180
Chih-Hung Hsieh5722f922016-10-11 15:33:19 -07002181 # handle only warning messages with a file path
2182 warning_pattern = re.compile('^[^ ]*/[^ ]*: warning: .*')
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002183 compile_patterns()
2184
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002185 # Collect all warnings into the warning_lines set.
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002186 warning_lines = set()
2187 for line in infile:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002188 if warning_pattern.match(line):
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -07002189 line = normalize_warning_line(line)
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002190 warning_lines.add(line)
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002191 elif line_counter < 50:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002192 # save a little bit of time by only doing this for the first few lines
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002193 line_counter += 1
2194 m = re.search('(?<=^PLATFORM_VERSION=).*', line)
2195 if m is not None:
2196 platform_version = m.group(0)
2197 m = re.search('(?<=^TARGET_PRODUCT=).*', line)
2198 if m is not None:
2199 target_product = m.group(0)
2200 m = re.search('(?<=^TARGET_BUILD_VARIANT=).*', line)
2201 if m is not None:
2202 target_variant = m.group(0)
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002203 parallel_classify_warnings(warning_lines)
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002204
2205
Chih-Hung Hsieh5722f922016-10-11 15:33:19 -07002206# Return s with escaped backslash and quotation characters.
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002207def escape_string(s):
Chih-Hung Hsieh5722f922016-10-11 15:33:19 -07002208 return s.replace('\\', '\\\\').replace('"', '\\"')
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002209
2210
2211# Return s without trailing '\n' and escape the quotation characters.
2212def strip_escape_string(s):
2213 if not s:
2214 return s
2215 s = s[:-1] if s[-1] == '\n' else s
2216 return escape_string(s)
2217
2218
2219def emit_warning_array(name):
2220 print 'var warning_{} = ['.format(name)
2221 for i in range(len(warn_patterns)):
2222 print '{},'.format(warn_patterns[i][name])
2223 print '];'
2224
2225
2226def emit_warning_arrays():
2227 emit_warning_array('severity')
2228 print 'var warning_description = ['
2229 for i in range(len(warn_patterns)):
2230 if warn_patterns[i]['members']:
2231 print '"{}",'.format(escape_string(warn_patterns[i]['description']))
2232 else:
2233 print '"",' # no such warning
2234 print '];'
2235
2236scripts_for_warning_groups = """
2237 function compareMessages(x1, x2) { // of the same warning type
2238 return (WarningMessages[x1[2]] <= WarningMessages[x2[2]]) ? -1 : 1;
2239 }
2240 function byMessageCount(x1, x2) {
2241 return x2[2] - x1[2]; // reversed order
2242 }
2243 function bySeverityMessageCount(x1, x2) {
2244 // orer by severity first
2245 if (x1[1] != x2[1])
2246 return x1[1] - x2[1];
2247 return byMessageCount(x1, x2);
2248 }
2249 const ParseLinePattern = /^([^ :]+):(\\d+):(.+)/;
2250 function addURL(line) {
2251 if (FlagURL == "") return line;
2252 if (FlagSeparator == "") {
2253 return line.replace(ParseLinePattern,
2254 "<a href='" + FlagURL + "/$1'>$1</a>:$2:$3");
2255 }
2256 return line.replace(ParseLinePattern,
2257 "<a href='" + FlagURL + "/$1" + FlagSeparator + "$2'>$1:$2</a>:$3");
2258 }
2259 function createArrayOfDictionaries(n) {
2260 var result = [];
2261 for (var i=0; i<n; i++) result.push({});
2262 return result;
2263 }
2264 function groupWarningsBySeverity() {
2265 // groups is an array of dictionaries,
2266 // each dictionary maps from warning type to array of warning messages.
2267 var groups = createArrayOfDictionaries(SeverityColors.length);
2268 for (var i=0; i<Warnings.length; i++) {
2269 var w = Warnings[i][0];
2270 var s = WarnPatternsSeverity[w];
2271 var k = w.toString();
2272 if (!(k in groups[s]))
2273 groups[s][k] = [];
2274 groups[s][k].push(Warnings[i]);
2275 }
2276 return groups;
2277 }
2278 function groupWarningsByProject() {
2279 var groups = createArrayOfDictionaries(ProjectNames.length);
2280 for (var i=0; i<Warnings.length; i++) {
2281 var w = Warnings[i][0];
2282 var p = Warnings[i][1];
2283 var k = w.toString();
2284 if (!(k in groups[p]))
2285 groups[p][k] = [];
2286 groups[p][k].push(Warnings[i]);
2287 }
2288 return groups;
2289 }
2290 var GlobalAnchor = 0;
2291 function createWarningSection(header, color, group) {
2292 var result = "";
2293 var groupKeys = [];
2294 var totalMessages = 0;
2295 for (var k in group) {
2296 totalMessages += group[k].length;
2297 groupKeys.push([k, WarnPatternsSeverity[parseInt(k)], group[k].length]);
2298 }
2299 groupKeys.sort(bySeverityMessageCount);
2300 for (var idx=0; idx<groupKeys.length; idx++) {
2301 var k = groupKeys[idx][0];
2302 var messages = group[k];
2303 var w = parseInt(k);
2304 var wcolor = SeverityColors[WarnPatternsSeverity[w]];
2305 var description = WarnPatternsDescription[w];
2306 if (description.length == 0)
2307 description = "???";
2308 GlobalAnchor += 1;
2309 result += "<table class='t1'><tr bgcolor='" + wcolor + "'><td>" +
2310 "<button class='bt' id='" + GlobalAnchor + "_mark" +
2311 "' onclick='expand(\\"" + GlobalAnchor + "\\");'>" +
2312 "&#x2295</button> " +
2313 description + " (" + messages.length + ")</td></tr></table>";
2314 result += "<div id='" + GlobalAnchor +
2315 "' style='display:none;'><table class='t1'>";
2316 var c = 0;
2317 messages.sort(compareMessages);
2318 for (var i=0; i<messages.length; i++) {
2319 result += "<tr><td class='c" + c + "'>" +
2320 addURL(WarningMessages[messages[i][2]]) + "</td></tr>";
2321 c = 1 - c;
2322 }
2323 result += "</table></div>";
2324 }
2325 if (result.length > 0) {
2326 return "<br><span style='background-color:" + color + "'><b>" +
2327 header + ": " + totalMessages +
2328 "</b></span><blockquote><table class='t1'>" +
2329 result + "</table></blockquote>";
2330
2331 }
2332 return ""; // empty section
2333 }
2334 function generateSectionsBySeverity() {
2335 var result = "";
2336 var groups = groupWarningsBySeverity();
2337 for (s=0; s<SeverityColors.length; s++) {
2338 result += createWarningSection(SeverityHeaders[s], SeverityColors[s], groups[s]);
2339 }
2340 return result;
2341 }
2342 function generateSectionsByProject() {
2343 var result = "";
2344 var groups = groupWarningsByProject();
2345 for (i=0; i<groups.length; i++) {
2346 result += createWarningSection(ProjectNames[i], 'lightgrey', groups[i]);
2347 }
2348 return result;
2349 }
2350 function groupWarnings(generator) {
2351 GlobalAnchor = 0;
2352 var e = document.getElementById("warning_groups");
2353 e.innerHTML = generator();
2354 }
2355 function groupBySeverity() {
2356 groupWarnings(generateSectionsBySeverity);
2357 }
2358 function groupByProject() {
2359 groupWarnings(generateSectionsByProject);
2360 }
2361"""
2362
2363
2364# Emit a JavaScript const string
2365def emit_const_string(name, value):
2366 print 'const ' + name + ' = "' + escape_string(value) + '";'
2367
2368
2369# Emit a JavaScript const integer array.
2370def emit_const_int_array(name, array):
2371 print 'const ' + name + ' = ['
2372 for n in array:
2373 print str(n) + ','
2374 print '];'
2375
2376
2377# Emit a JavaScript const string array.
2378def emit_const_string_array(name, array):
2379 print 'const ' + name + ' = ['
2380 for s in array:
2381 print '"' + strip_escape_string(s) + '",'
2382 print '];'
2383
2384
2385# Emit a JavaScript const object array.
2386def emit_const_object_array(name, array):
2387 print 'const ' + name + ' = ['
2388 for x in array:
2389 print str(x) + ','
2390 print '];'
2391
2392
2393def emit_js_data():
2394 """Dump dynamic HTML page's static JavaScript data."""
2395 emit_const_string('FlagURL', args.url if args.url else '')
2396 emit_const_string('FlagSeparator', args.separator if args.separator else '')
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002397 emit_const_string_array('SeverityColors', Severity.colors)
2398 emit_const_string_array('SeverityHeaders', Severity.headers)
2399 emit_const_string_array('SeverityColumnHeaders', Severity.column_headers)
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002400 emit_const_string_array('ProjectNames', project_names)
2401 emit_const_int_array('WarnPatternsSeverity',
2402 [w['severity'] for w in warn_patterns])
2403 emit_const_string_array('WarnPatternsDescription',
2404 [w['description'] for w in warn_patterns])
2405 emit_const_string_array('WarnPatternsOption',
2406 [w['option'] for w in warn_patterns])
2407 emit_const_string_array('WarningMessages', warning_messages)
2408 emit_const_object_array('Warnings', warning_records)
2409
2410draw_table_javascript = """
2411google.charts.load('current', {'packages':['table']});
2412google.charts.setOnLoadCallback(drawTable);
2413function drawTable() {
2414 var data = new google.visualization.DataTable();
2415 data.addColumn('string', StatsHeader[0]);
2416 for (var i=1; i<StatsHeader.length; i++) {
2417 data.addColumn('number', StatsHeader[i]);
2418 }
2419 data.addRows(StatsRows);
2420 for (var i=0; i<StatsRows.length; i++) {
2421 for (var j=0; j<StatsHeader.length; j++) {
2422 data.setProperty(i, j, 'style', 'border:1px solid black;');
2423 }
2424 }
2425 var table = new google.visualization.Table(document.getElementById('stats_table'));
2426 table.draw(data, {allowHtml: true, alternatingRowStyle: true});
2427}
2428"""
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002429
2430
2431def dump_html():
2432 """Dump the html output to stdout."""
2433 dump_html_prologue('Warnings for ' + platform_version + ' - ' +
2434 target_product + ' - ' + target_variant)
2435 dump_stats()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002436 print '<br><div id="stats_table"></div><br>'
2437 print '\n<script>'
2438 emit_js_data()
2439 print scripts_for_warning_groups
2440 print '</script>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002441 emit_buttons()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002442 # Warning messages are grouped by severities or project names.
2443 print '<br><div id="warning_groups"></div>'
2444 if args.byproject:
2445 print '<script>groupByProject();</script>'
2446 else:
2447 print '<script>groupBySeverity();</script>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002448 dump_fixed()
2449 dump_html_epilogue()
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002450
2451
2452##### Functions to count warnings and dump csv file. #########################
2453
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002454
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002455def description_for_csv(category):
2456 if not category['description']:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002457 return '?'
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002458 return category['description']
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002459
2460
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002461def string_for_csv(s):
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002462 # Only some Java warning desciptions have used quotation marks.
2463 # TODO(chh): if s has double quote character, s should be quoted.
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002464 if ',' in s:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002465 # TODO(chh): replace a double quote with two double quotes in s.
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002466 return '"{}"'.format(s)
2467 return s
2468
2469
2470def count_severity(sev, kind):
2471 """Count warnings of given severity."""
2472 total = 0
2473 for i in warn_patterns:
2474 if i['severity'] == sev and i['members']:
2475 n = len(i['members'])
2476 total += n
2477 warning = string_for_csv(kind + ': ' + description_for_csv(i))
2478 print '{},,{}'.format(n, warning)
2479 # print number of warnings for each project, ordered by project name.
2480 projects = i['projects'].keys()
2481 projects.sort()
2482 for p in projects:
2483 print '{},{},{}'.format(i['projects'][p], p, warning)
2484 print '{},,{}'.format(total, kind + ' warnings')
2485 return total
2486
2487
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002488# dump number of warnings in csv format to stdout
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002489def dump_csv():
2490 """Dump number of warnings in csv format to stdout."""
2491 sort_warnings()
2492 total = 0
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002493 for s in Severity.range:
2494 total += count_severity(s, Severity.column_headers[s])
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002495 print '{},,{}'.format(total, 'All warnings')
2496
2497
Meike Baumgärtnerac9d5df2016-09-28 10:48:06 -07002498def main():
2499 parse_input_file()
2500 if args.gencsv:
2501 dump_csv()
2502 else:
2503 dump_html()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002504
Meike Baumgärtnerac9d5df2016-09-28 10:48:06 -07002505
2506# Run main function if warn.py is the main program.
2507if __name__ == '__main__':
2508 main()