blob: e7e877d9aa825d9915446770d66333b56b3af717 [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 Hsieha45c5c12016-10-11 15:30:26 -070084import os
Marco Nelissen594375d2009-07-14 09:04:04 -070085import re
86
Ian Rogersf3829732016-05-10 12:06:01 -070087parser = argparse.ArgumentParser(description='Convert a build log into HTML')
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -070088parser.add_argument('--gencsv',
89 help='Generate a CSV file with number of various warnings',
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -070090 action='store_true',
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -070091 default=False)
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -070092parser.add_argument('--byproject',
93 help='Separate warnings in HTML output by project names',
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -070094 action='store_true',
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -070095 default=False)
Ian Rogersf3829732016-05-10 12:06:01 -070096parser.add_argument('--url',
97 help='Root URL of an Android source code tree prefixed '
98 'before files in warnings')
99parser.add_argument('--separator',
100 help='Separator between the end of a URL and the line '
101 'number argument. e.g. #')
102parser.add_argument(dest='buildlog', metavar='build.log',
103 help='Path to build.log file')
104args = parser.parse_args()
Marco Nelissen594375d2009-07-14 09:04:04 -0700105
Marco Nelissen594375d2009-07-14 09:04:04 -0700106
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700107class Severity(object):
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700108 """Severity levels and attributes."""
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -0700109 # numbered by dump order
110 FIXMENOW = 0
111 HIGH = 1
112 MEDIUM = 2
113 LOW = 3
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -0700114 ANALYZER = 4
115 TIDY = 5
116 HARMLESS = 6
117 UNKNOWN = 7
118 SKIP = 8
119 range = range(SKIP + 1)
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700120 attributes = [
121 # pylint:disable=bad-whitespace
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700122 ['fuchsia', 'FixNow', 'Critical warnings, fix me now'],
123 ['red', 'High', 'High severity warnings'],
124 ['orange', 'Medium', 'Medium severity warnings'],
125 ['yellow', 'Low', 'Low severity warnings'],
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -0700126 ['hotpink', 'Analyzer', 'Clang-Analyzer warnings'],
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700127 ['peachpuff', 'Tidy', 'Clang-Tidy warnings'],
128 ['limegreen', 'Harmless', 'Harmless warnings'],
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -0700129 ['lightblue', 'Unknown', 'Unknown warnings'],
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700130 ['grey', 'Unhandled', 'Unhandled warnings']
131 ]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -0700132 colors = [a[0] for a in attributes]
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700133 column_headers = [a[1] for a in attributes]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -0700134 headers = [a[2] for a in attributes]
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700135
136warn_patterns = [
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700137 # pylint:disable=line-too-long,g-inconsistent-quotes
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -0700138 {'category': 'C/C++', 'severity': Severity.ANALYZER,
139 'description': 'clang-analyzer Security warning',
140 'patterns': [r".*: warning: .+\[clang-analyzer-security.*\]"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700141 {'category': 'make', 'severity': Severity.MEDIUM,
142 'description': 'make: overriding commands/ignoring old commands',
143 'patterns': [r".*: warning: overriding commands for target .+",
144 r".*: warning: ignoring old commands for target .+"]},
145 {'category': 'make', 'severity': Severity.HIGH,
146 'description': 'make: LOCAL_CLANG is false',
147 'patterns': [r".*: warning: LOCAL_CLANG is set to false"]},
148 {'category': 'make', 'severity': Severity.HIGH,
149 'description': 'SDK App using platform shared library',
150 'patterns': [r".*: warning: .+ \(.*app:sdk.*\) should not link to .+ \(native:platform\)"]},
151 {'category': 'make', 'severity': Severity.HIGH,
152 'description': 'System module linking to a vendor module',
153 'patterns': [r".*: warning: .+ \(.+\) should not link to .+ \(partition:.+\)"]},
154 {'category': 'make', 'severity': Severity.MEDIUM,
155 'description': 'Invalid SDK/NDK linking',
156 'patterns': [r".*: warning: .+ \(.+\) should not link to .+ \(.+\)"]},
157 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wimplicit-function-declaration',
158 'description': 'Implicit function declaration',
159 'patterns': [r".*: warning: implicit declaration of function .+",
160 r".*: warning: implicitly declaring library function"]},
161 {'category': 'C/C++', 'severity': Severity.SKIP,
162 'description': 'skip, conflicting types for ...',
163 'patterns': [r".*: warning: conflicting types for '.+'"]},
164 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wtype-limits',
165 'description': 'Expression always evaluates to true or false',
166 'patterns': [r".*: warning: comparison is always .+ due to limited range of data type",
167 r".*: warning: comparison of unsigned .*expression .+ is always true",
168 r".*: warning: comparison of unsigned .*expression .+ is always false"]},
169 {'category': 'C/C++', 'severity': Severity.HIGH,
170 'description': 'Potential leak of memory, bad free, use after free',
171 'patterns': [r".*: warning: Potential leak of memory",
172 r".*: warning: Potential memory leak",
173 r".*: warning: Memory allocated by alloca\(\) should not be deallocated",
174 r".*: warning: Memory allocated by .+ should be deallocated by .+ not .+",
175 r".*: warning: 'delete' applied to a pointer that was allocated",
176 r".*: warning: Use of memory after it is freed",
177 r".*: warning: Argument to .+ is the address of .+ variable",
178 r".*: warning: Argument to free\(\) is offset by .+ of memory allocated by",
179 r".*: warning: Attempt to .+ released memory"]},
180 {'category': 'C/C++', 'severity': Severity.HIGH,
181 'description': 'Use transient memory for control value',
182 'patterns': [r".*: warning: .+Using such transient memory for the control value is .*dangerous."]},
183 {'category': 'C/C++', 'severity': Severity.HIGH,
184 'description': 'Return address of stack memory',
185 'patterns': [r".*: warning: Address of stack memory .+ returned to caller",
186 r".*: warning: Address of stack memory .+ will be a dangling reference"]},
187 {'category': 'C/C++', 'severity': Severity.HIGH,
188 'description': 'Problem with vfork',
189 'patterns': [r".*: warning: This .+ is prohibited after a successful vfork",
190 r".*: warning: Call to function '.+' is insecure "]},
191 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': 'infinite-recursion',
192 'description': 'Infinite recursion',
193 'patterns': [r".*: warning: all paths through this function will call itself"]},
194 {'category': 'C/C++', 'severity': Severity.HIGH,
195 'description': 'Potential buffer overflow',
196 'patterns': [r".*: warning: Size argument is greater than .+ the destination buffer",
197 r".*: warning: Potential buffer overflow.",
198 r".*: warning: String copy function overflows destination buffer"]},
199 {'category': 'C/C++', 'severity': Severity.MEDIUM,
200 'description': 'Incompatible pointer types',
201 'patterns': [r".*: warning: assignment from incompatible pointer type",
202 r".*: warning: return from incompatible pointer type",
203 r".*: warning: passing argument [0-9]+ of '.*' from incompatible pointer type",
204 r".*: warning: initialization from incompatible pointer type"]},
205 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-fno-builtin',
206 'description': 'Incompatible declaration of built in function',
207 'patterns': [r".*: warning: incompatible implicit declaration of built-in function .+"]},
208 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wincompatible-library-redeclaration',
209 'description': 'Incompatible redeclaration of library function',
210 'patterns': [r".*: warning: incompatible redeclaration of library function .+"]},
211 {'category': 'C/C++', 'severity': Severity.HIGH,
212 'description': 'Null passed as non-null argument',
213 'patterns': [r".*: warning: Null passed to a callee that requires a non-null"]},
214 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused-parameter',
215 'description': 'Unused parameter',
216 'patterns': [r".*: warning: unused parameter '.*'"]},
217 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused',
218 'description': 'Unused function, variable or label',
219 'patterns': [r".*: warning: '.+' defined but not used",
220 r".*: warning: unused function '.+'",
221 r".*: warning: private field '.+' is not used",
222 r".*: warning: unused variable '.+'"]},
223 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused-value',
224 'description': 'Statement with no effect or result unused',
225 'patterns': [r".*: warning: statement with no effect",
226 r".*: warning: expression result unused"]},
227 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused-result',
228 'description': 'Ignoreing return value of function',
229 'patterns': [r".*: warning: ignoring return value of function .+Wunused-result"]},
230 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-field-initializers',
231 'description': 'Missing initializer',
232 'patterns': [r".*: warning: missing initializer"]},
233 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wdelete-non-virtual-dtor',
234 'description': 'Need virtual destructor',
235 'patterns': [r".*: warning: delete called .* has virtual functions but non-virtual destructor"]},
236 {'category': 'cont.', 'severity': Severity.SKIP,
237 'description': 'skip, near initialization for ...',
238 'patterns': [r".*: warning: \(near initialization for '.+'\)"]},
239 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wdate-time',
240 'description': 'Expansion of data or time macro',
241 'patterns': [r".*: warning: expansion of date or time macro is not reproducible"]},
242 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wformat',
243 'description': 'Format string does not match arguments',
244 'patterns': [r".*: warning: format '.+' expects type '.+', but argument [0-9]+ has type '.+'",
245 r".*: warning: more '%' conversions than data arguments",
246 r".*: warning: data argument not used by format string",
247 r".*: warning: incomplete format specifier",
248 r".*: warning: unknown conversion type .* in format",
249 r".*: warning: format .+ expects .+ but argument .+Wformat=",
250 r".*: warning: field precision should have .+ but argument has .+Wformat",
251 r".*: warning: format specifies type .+ but the argument has .*type .+Wformat"]},
252 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wformat-extra-args',
253 'description': 'Too many arguments for format string',
254 'patterns': [r".*: warning: too many arguments for format"]},
255 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wformat-invalid-specifier',
256 'description': 'Invalid format specifier',
257 'patterns': [r".*: warning: invalid .+ specifier '.+'.+format-invalid-specifier"]},
258 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsign-compare',
259 'description': 'Comparison between signed and unsigned',
260 'patterns': [r".*: warning: comparison between signed and unsigned",
261 r".*: warning: comparison of promoted \~unsigned with unsigned",
262 r".*: warning: signed and unsigned type in conditional expression"]},
263 {'category': 'C/C++', 'severity': Severity.MEDIUM,
264 'description': 'Comparison between enum and non-enum',
265 'patterns': [r".*: warning: enumeral and non-enumeral type in conditional expression"]},
266 {'category': 'libpng', 'severity': Severity.MEDIUM,
267 'description': 'libpng: zero area',
268 'patterns': [r".*libpng warning: Ignoring attempt to set cHRM RGB triangle with zero area"]},
269 {'category': 'aapt', 'severity': Severity.MEDIUM,
270 'description': 'aapt: no comment for public symbol',
271 'patterns': [r".*: warning: No comment for public symbol .+"]},
272 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-braces',
273 'description': 'Missing braces around initializer',
274 'patterns': [r".*: warning: missing braces around initializer.*"]},
275 {'category': 'C/C++', 'severity': Severity.HARMLESS,
276 'description': 'No newline at end of file',
277 'patterns': [r".*: warning: no newline at end of file"]},
278 {'category': 'C/C++', 'severity': Severity.HARMLESS,
279 'description': 'Missing space after macro name',
280 'patterns': [r".*: warning: missing whitespace after the macro name"]},
281 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wcast-align',
282 'description': 'Cast increases required alignment',
283 'patterns': [r".*: warning: cast from .* to .* increases required alignment .*"]},
284 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wcast-qual',
285 'description': 'Qualifier discarded',
286 'patterns': [r".*: warning: passing argument [0-9]+ of '.+' discards qualifiers from pointer target type",
287 r".*: warning: assignment discards qualifiers from pointer target type",
288 r".*: warning: passing .+ to parameter of type .+ discards qualifiers",
289 r".*: warning: assigning to .+ from .+ discards qualifiers",
290 r".*: warning: initializing .+ discards qualifiers .+types-discards-qualifiers",
291 r".*: warning: return discards qualifiers from pointer target type"]},
292 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunknown-attributes',
293 'description': 'Unknown attribute',
294 'patterns': [r".*: warning: unknown attribute '.+'"]},
295 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wignored-attributes',
296 'description': 'Attribute ignored',
297 'patterns': [r".*: warning: '_*packed_*' attribute ignored",
298 r".*: warning: attribute declaration must precede definition .+ignored-attributes"]},
299 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wvisibility',
300 'description': 'Visibility problem',
301 'patterns': [r".*: warning: declaration of '.+' will not be visible outside of this function"]},
302 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wattributes',
303 'description': 'Visibility mismatch',
304 'patterns': [r".*: warning: '.+' declared with greater visibility than the type of its field '.+'"]},
305 {'category': 'C/C++', 'severity': Severity.MEDIUM,
306 'description': 'Shift count greater than width of type',
307 'patterns': [r".*: warning: (left|right) shift count >= width of type"]},
308 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wextern-initializer',
309 'description': 'extern <foo> is initialized',
310 'patterns': [r".*: warning: '.+' initialized and declared 'extern'",
311 r".*: warning: 'extern' variable has an initializer"]},
312 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wold-style-declaration',
313 'description': 'Old style declaration',
314 'patterns': [r".*: warning: 'static' is not at beginning of declaration"]},
315 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wreturn-type',
316 'description': 'Missing return value',
317 'patterns': [r".*: warning: control reaches end of non-void function"]},
318 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wimplicit-int',
319 'description': 'Implicit int type',
320 'patterns': [r".*: warning: type specifier missing, defaults to 'int'",
321 r".*: warning: type defaults to 'int' in declaration of '.+'"]},
322 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmain-return-type',
323 'description': 'Main function should return int',
324 'patterns': [r".*: warning: return type of 'main' is not 'int'"]},
325 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wuninitialized',
326 'description': 'Variable may be used uninitialized',
327 'patterns': [r".*: warning: '.+' may be used uninitialized in this function"]},
328 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wuninitialized',
329 'description': 'Variable is used uninitialized',
330 'patterns': [r".*: warning: '.+' is used uninitialized in this function",
331 r".*: warning: variable '.+' is uninitialized when used here"]},
332 {'category': 'ld', 'severity': Severity.MEDIUM, 'option': '-fshort-enums',
333 'description': 'ld: possible enum size mismatch',
334 'patterns': [r".*: warning: .* uses variable-size enums yet the output is to use 32-bit enums; use of enum values across objects may fail"]},
335 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wpointer-sign',
336 'description': 'Pointer targets differ in signedness',
337 'patterns': [r".*: warning: pointer targets in initialization differ in signedness",
338 r".*: warning: pointer targets in assignment differ in signedness",
339 r".*: warning: pointer targets in return differ in signedness",
340 r".*: warning: pointer targets in passing argument [0-9]+ of '.+' differ in signedness"]},
341 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wstrict-overflow',
342 'description': 'Assuming overflow does not occur',
343 'patterns': [r".*: warning: assuming signed overflow does not occur when assuming that .* is always (true|false)"]},
344 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wempty-body',
345 'description': 'Suggest adding braces around empty body',
346 'patterns': [r".*: warning: suggest braces around empty body in an 'if' statement",
347 r".*: warning: empty body in an if-statement",
348 r".*: warning: suggest braces around empty body in an 'else' statement",
349 r".*: warning: empty body in an else-statement"]},
350 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wparentheses',
351 'description': 'Suggest adding parentheses',
352 'patterns': [r".*: warning: suggest explicit braces to avoid ambiguous 'else'",
353 r".*: warning: suggest parentheses around arithmetic in operand of '.+'",
354 r".*: warning: suggest parentheses around comparison in operand of '.+'",
355 r".*: warning: logical not is only applied to the left hand side of this comparison",
356 r".*: warning: using the result of an assignment as a condition without parentheses",
357 r".*: warning: .+ has lower precedence than .+ be evaluated first .+Wparentheses",
358 r".*: warning: suggest parentheses around '.+?' .+ '.+?'",
359 r".*: warning: suggest parentheses around assignment used as truth value"]},
360 {'category': 'C/C++', 'severity': Severity.MEDIUM,
361 'description': 'Static variable used in non-static inline function',
362 'patterns': [r".*: warning: '.+' is static but used in inline function '.+' which is not static"]},
363 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wimplicit int',
364 'description': 'No type or storage class (will default to int)',
365 'patterns': [r".*: warning: data definition has no type or storage class"]},
366 {'category': 'C/C++', 'severity': Severity.MEDIUM,
367 'description': 'Null pointer',
368 'patterns': [r".*: warning: Dereference of null pointer",
369 r".*: warning: Called .+ pointer is null",
370 r".*: warning: Forming reference to null pointer",
371 r".*: warning: Returning null reference",
372 r".*: warning: Null pointer passed as an argument to a 'nonnull' parameter",
373 r".*: warning: .+ results in a null pointer dereference",
374 r".*: warning: Access to .+ results in a dereference of a null pointer",
375 r".*: warning: Null pointer argument in"]},
376 {'category': 'cont.', 'severity': Severity.SKIP,
377 'description': 'skip, parameter name (without types) in function declaration',
378 'patterns': [r".*: warning: parameter names \(without types\) in function declaration"]},
379 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wstrict-aliasing',
380 'description': 'Dereferencing <foo> breaks strict aliasing rules',
381 'patterns': [r".*: warning: dereferencing .* break strict-aliasing rules"]},
382 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wpointer-to-int-cast',
383 'description': 'Cast from pointer to integer of different size',
384 'patterns': [r".*: warning: cast from pointer to integer of different size",
385 r".*: warning: initialization makes pointer from integer without a cast"]},
386 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wint-to-pointer-cast',
387 'description': 'Cast to pointer from integer of different size',
388 'patterns': [r".*: warning: cast to pointer from integer of different size"]},
389 {'category': 'C/C++', 'severity': Severity.MEDIUM,
390 'description': 'Symbol redefined',
391 'patterns': [r".*: warning: "".+"" redefined"]},
392 {'category': 'cont.', 'severity': Severity.SKIP,
393 'description': 'skip, ... location of the previous definition',
394 'patterns': [r".*: warning: this is the location of the previous definition"]},
395 {'category': 'ld', 'severity': Severity.MEDIUM,
396 'description': 'ld: type and size of dynamic symbol are not defined',
397 'patterns': [r".*: warning: type and size of dynamic symbol `.+' are not defined"]},
398 {'category': 'C/C++', 'severity': Severity.MEDIUM,
399 'description': 'Pointer from integer without cast',
400 'patterns': [r".*: warning: assignment makes pointer from integer without a cast"]},
401 {'category': 'C/C++', 'severity': Severity.MEDIUM,
402 'description': 'Pointer from integer without cast',
403 'patterns': [r".*: warning: passing argument [0-9]+ of '.+' makes pointer from integer without a cast"]},
404 {'category': 'C/C++', 'severity': Severity.MEDIUM,
405 'description': 'Integer from pointer without cast',
406 'patterns': [r".*: warning: assignment makes integer from pointer without a cast"]},
407 {'category': 'C/C++', 'severity': Severity.MEDIUM,
408 'description': 'Integer from pointer without cast',
409 'patterns': [r".*: warning: passing argument [0-9]+ of '.+' makes integer from pointer without a cast"]},
410 {'category': 'C/C++', 'severity': Severity.MEDIUM,
411 'description': 'Integer from pointer without cast',
412 'patterns': [r".*: warning: return makes integer from pointer without a cast"]},
413 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunknown-pragmas',
414 'description': 'Ignoring pragma',
415 'patterns': [r".*: warning: ignoring #pragma .+"]},
416 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-W#pragma-messages',
417 'description': 'Pragma warning messages',
418 'patterns': [r".*: warning: .+W#pragma-messages"]},
419 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wclobbered',
420 'description': 'Variable might be clobbered by longjmp or vfork',
421 'patterns': [r".*: warning: variable '.+' might be clobbered by 'longjmp' or 'vfork'"]},
422 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wclobbered',
423 'description': 'Argument might be clobbered by longjmp or vfork',
424 'patterns': [r".*: warning: argument '.+' might be clobbered by 'longjmp' or 'vfork'"]},
425 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wredundant-decls',
426 'description': 'Redundant declaration',
427 'patterns': [r".*: warning: redundant redeclaration of '.+'"]},
428 {'category': 'cont.', 'severity': Severity.SKIP,
429 'description': 'skip, previous declaration ... was here',
430 'patterns': [r".*: warning: previous declaration of '.+' was here"]},
431 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wswitch-enum',
432 'description': 'Enum value not handled in switch',
433 'patterns': [r".*: warning: .*enumeration value.* not handled in switch.+Wswitch"]},
434 {'category': 'java', 'severity': Severity.MEDIUM, 'option': '-encoding',
435 'description': 'Java: Non-ascii characters used, but ascii encoding specified',
436 'patterns': [r".*: warning: unmappable character for encoding ascii"]},
437 {'category': 'java', 'severity': Severity.MEDIUM,
438 'description': 'Java: Non-varargs call of varargs method with inexact argument type for last parameter',
439 'patterns': [r".*: warning: non-varargs call of varargs method with inexact argument type for last parameter"]},
440 {'category': 'java', 'severity': Severity.MEDIUM,
441 'description': 'Java: Unchecked method invocation',
442 'patterns': [r".*: warning: \[unchecked\] unchecked method invocation: .+ in class .+"]},
443 {'category': 'java', 'severity': Severity.MEDIUM,
444 'description': 'Java: Unchecked conversion',
445 'patterns': [r".*: warning: \[unchecked\] unchecked conversion"]},
446 {'category': 'java', 'severity': Severity.MEDIUM,
447 'description': '_ used as an identifier',
448 'patterns': [r".*: warning: '_' used as an identifier"]},
Ian Rogers32bb9bd2016-05-09 23:19:42 -0700449
Ian Rogers6e520032016-05-13 08:59:00 -0700450 # Warnings from Error Prone.
451 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700452 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700453 'description': 'Java: Use of deprecated member',
454 'patterns': [r'.*: warning: \[deprecation\] .+']},
455 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700456 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700457 'description': 'Java: Unchecked conversion',
458 'patterns': [r'.*: warning: \[unchecked\] .+']},
Ian Rogers32bb9bd2016-05-09 23:19:42 -0700459
Ian Rogers6e520032016-05-13 08:59:00 -0700460 # Warnings from Error Prone (auto generated list).
461 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700462 'severity': Severity.LOW,
Ian Rogers6e520032016-05-13 08:59:00 -0700463 'description':
464 'Java: Deprecated item is not annotated with @Deprecated',
465 'patterns': [r".*: warning: \[DepAnn\] .+"]},
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: Fallthrough warning suppression has no effect if warning is suppressed',
470 'patterns': [r".*: warning: \[FallthroughSuppression\] .+"]},
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: Prefer \'L\' to \'l\' for the suffix to long literals',
475 'patterns': [r".*: warning: \[LongLiteralLowerCaseSuffix\] .+"]},
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: @Binds is a more efficient and declaritive mechanism for delegating a binding.',
480 'patterns': [r".*: warning: \[UseBinds\] .+"]},
481 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700482 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700483 'description':
484 'Java: Assertions may be disabled at runtime and do not guarantee that execution will halt here; consider throwing an exception instead',
485 'patterns': [r".*: warning: \[AssertFalse\] .+"]},
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: Classes that implement Annotation must override equals and hashCode. Consider using AutoAnnotation instead of implementing Annotation by hand.',
490 'patterns': [r".*: warning: \[BadAnnotationImplementation\] .+"]},
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: BigDecimal(double) and BigDecimal.valueOf(double) may lose precision, prefer BigDecimal(String) or BigDecimal(long)',
495 'patterns': [r".*: warning: \[BigDecimalLiteralDouble\] .+"]},
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: Mockito cannot mock final classes',
500 'patterns': [r".*: warning: \[CannotMockFinalClass\] .+"]},
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: This code, which counts elements using a loop, can be replaced by a simpler library method',
505 'patterns': [r".*: warning: \[ElementsCountedInLoop\] .+"]},
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: Empty top-level type declaration',
510 'patterns': [r".*: warning: \[EmptyTopLevelDeclaration\] .+"]},
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: Classes that override equals should also override hashCode.',
515 'patterns': [r".*: warning: \[EqualsHashCode\] .+"]},
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: An equality test between objects with incompatible types always returns false',
520 'patterns': [r".*: warning: \[EqualsIncompatibleType\] .+"]},
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: 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.',
525 'patterns': [r".*: warning: \[Finally\] .+"]},
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: This annotation has incompatible modifiers as specified by its @IncompatibleModifiers annotation',
530 'patterns': [r".*: warning: \[IncompatibleModifiers\] .+"]},
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: Class should not implement both `Iterable` and `Iterator`',
535 'patterns': [r".*: warning: \[IterableAndIterator\] .+"]},
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: Floating-point comparison without error tolerance',
540 'patterns': [r".*: warning: \[JUnit3FloatingPointComparisonWithoutDelta\] .+"]},
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: Test class inherits from JUnit 3\'s TestCase but has JUnit 4 @Test annotations.',
545 'patterns': [r".*: warning: \[JUnitAmbiguousTestClass\] .+"]},
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: Enum switch statement is missing cases',
550 'patterns': [r".*: warning: \[MissingCasesInEnumSwitch\] .+"]},
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: Not calling fail() when expecting an exception masks bugs',
555 'patterns': [r".*: warning: \[MissingFail\] .+"]},
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: method overrides method in supertype; expected @Override',
560 'patterns': [r".*: warning: \[MissingOverride\] .+"]},
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: Source files should not contain multiple top-level class declarations',
565 'patterns': [r".*: warning: \[MultipleTopLevelClasses\] .+"]},
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: This update of a volatile variable is non-atomic',
570 'patterns': [r".*: warning: \[NonAtomicVolatileUpdate\] .+"]},
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: Static import of member uses non-canonical name',
575 'patterns': [r".*: warning: \[NonCanonicalStaticMemberImport\] .+"]},
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: equals method doesn\'t override Object.equals',
580 'patterns': [r".*: warning: \[NonOverridingEquals\] .+"]},
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: Constructors should not be annotated with @Nullable since they cannot return null',
585 'patterns': [r".*: warning: \[NullableConstructor\] .+"]},
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: @Nullable should not be used for primitive types since they cannot be null',
590 'patterns': [r".*: warning: \[NullablePrimitive\] .+"]},
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: void-returning methods should not be annotated with @Nullable, since they cannot return null',
595 'patterns': [r".*: warning: \[NullableVoid\] .+"]},
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: Package names should match the directory they are declared in',
600 'patterns': [r".*: warning: \[PackageLocation\] .+"]},
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: Second argument to Preconditions.* is a call to String.format(), which can be unwrapped',
605 'patterns': [r".*: warning: \[PreconditionsErrorMessageEagerEvaluation\] .+"]},
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: Preconditions only accepts the %s placeholder in error message strings',
610 'patterns': [r".*: warning: \[PreconditionsInvalidPlaceholder\] .+"]},
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: Passing a primitive array to a varargs method is usually wrong',
615 'patterns': [r".*: warning: \[PrimitiveArrayPassedToVarargsMethod\] .+"]},
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: Protobuf fields cannot be null, so this check is redundant',
620 'patterns': [r".*: warning: \[ProtoFieldPreconditionsCheckNotNull\] .+"]},
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: This annotation is missing required modifiers as specified by its @RequiredModifiers annotation',
625 'patterns': [r".*: warning: \[RequiredModifiers\] .+"]},
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: A static variable or method should not be accessed from an object instance',
630 'patterns': [r".*: warning: \[StaticAccessedFromInstance\] .+"]},
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: String comparison using reference equality instead of value equality',
635 'patterns': [r".*: warning: \[StringEquality\] .+"]},
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: 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.',
640 'patterns': [r".*: warning: \[TypeParameterUnusedInFormals\] .+"]},
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: Using static imports for types is unnecessary',
645 'patterns': [r".*: warning: \[UnnecessaryStaticImport\] .+"]},
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: Unsynchronized method overrides a synchronized method.',
650 'patterns': [r".*: warning: \[UnsynchronizedOverridesSynchronized\] .+"]},
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: Non-constant variable missing @Var annotation',
655 'patterns': [r".*: warning: \[Var\] .+"]},
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: Because of spurious wakeups, Object.wait() and Condition.await() must always be called in a loop',
660 'patterns': [r".*: warning: \[WaitNotInLoop\] .+"]},
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: Subclasses of Fragment must be instantiable via Class#newInstance(): the class must be public, static and have a public nullary constructor',
665 'patterns': [r".*: warning: \[FragmentNotInstantiable\] .+"]},
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: Hardcoded reference to /sdcard',
670 'patterns': [r".*: warning: \[HardCodedSdCardPath\] .+"]},
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: Incompatible type as argument to Object-accepting Java collections method',
675 'patterns': [r".*: warning: \[CollectionIncompatibleType\] .+"]},
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: @AssistedInject and @Inject should not be used on different constructors in the same class.',
680 'patterns': [r".*: warning: \[AssistedInjectAndInjectOnConstructors\] .+"]},
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: Although Guice allows injecting final fields, doing so is not recommended because the injected value may not be visible to other threads.',
685 'patterns': [r".*: warning: \[GuiceInjectOnFinalField\] .+"]},
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: 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.',
690 'patterns': [r".*: warning: \[OverridesGuiceInjectableMethod\] .+"]},
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: Double-checked locking on non-volatile fields is unsafe',
695 'patterns': [r".*: warning: \[DoubleCheckedLocking\] .+"]},
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: Writes to static fields should not be guarded by instance locks',
700 'patterns': [r".*: warning: \[StaticGuardedByInstance\] .+"]},
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: Synchronizing on non-final fields is not safe: if the field is ever updated, different threads may end up locking on different objects.',
705 'patterns': [r".*: warning: \[SynchronizeOnNonFinalField\] .+"]},
706 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700707 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700708 'description':
709 'Java: Reference equality used to compare arrays',
710 'patterns': [r".*: warning: \[ArrayEquals\] .+"]},
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: hashcode method on array does not hash array contents',
715 'patterns': [r".*: warning: \[ArrayHashCode\] .+"]},
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: Calling toString on an array does not provide useful information',
720 'patterns': [r".*: warning: \[ArrayToString.*\] .+"]},
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: Arrays.asList does not autobox primitive arrays, as one might expect.',
725 'patterns': [r".*: warning: \[ArraysAsListPrimitiveArray\] .+"]},
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: AsyncCallable should not return a null Future, only a Future whose result is null.',
730 'patterns': [r".*: warning: \[AsyncCallableReturnsNull\] .+"]},
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: AsyncFunction should not return a null Future, only a Future whose result is null.',
735 'patterns': [r".*: warning: \[AsyncFunctionReturnsNull\] .+"]},
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: Possible sign flip from narrowing conversion',
740 'patterns': [r".*: warning: \[BadComparable\] .+"]},
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: Shift by an amount that is out of range',
745 'patterns': [r".*: warning: \[BadShiftAmount\] .+"]},
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: valueOf provides better time and space performance',
750 'patterns': [r".*: warning: \[BoxedPrimitiveConstructor\] .+"]},
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: 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.',
755 'patterns': [r".*: warning: \[ChainingConstructorIgnoresParameter\] .+"]},
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: Ignored return value of method that is annotated with @CheckReturnValue',
760 'patterns': [r".*: warning: \[CheckReturnValue\] .+"]},
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: Inner class is non-static but does not reference enclosing class',
765 'patterns': [r".*: warning: \[ClassCanBeStatic\] .+"]},
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: The source file name should match the name of the top-level class it contains',
770 'patterns': [r".*: warning: \[ClassName\] .+"]},
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: This comparison method violates the contract',
775 'patterns': [r".*: warning: \[ComparisonContractViolated\] .+"]},
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: Comparison to value that is out of range for the compared type',
780 'patterns': [r".*: warning: \[ComparisonOutOfRange\] .+"]},
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: Non-compile-time constant expression passed to parameter with @CompileTimeConstant type annotation.',
785 'patterns': [r".*: warning: \[CompileTimeConstant\] .+"]},
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: Exception created but not thrown',
790 'patterns': [r".*: warning: \[DeadException\] .+"]},
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: Division by integer literal zero',
795 'patterns': [r".*: warning: \[DivZero\] .+"]},
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: Empty statement after if',
800 'patterns': [r".*: warning: \[EmptyIf\] .+"]},
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: == NaN always returns false; use the isNaN methods instead',
805 'patterns': [r".*: warning: \[EqualsNaN\] .+"]},
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: Method annotated @ForOverride must be protected or package-private and only invoked from declaring class',
810 'patterns': [r".*: warning: \[ForOverride\] .+"]},
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: Futures.getChecked requires a checked exception type with a standard constructor.',
815 'patterns': [r".*: warning: \[FuturesGetCheckedIllegalExceptionType\] .+"]},
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: 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',
820 'patterns': [r".*: warning: \[GetClassOnClass\] .+"]},
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: An object is tested for equality to itself using Guava Libraries',
825 'patterns': [r".*: warning: \[GuavaSelfEquals\] .+"]},
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: contains() is a legacy method that is equivalent to containsValue()',
830 'patterns': [r".*: warning: \[HashtableContains\] .+"]},
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: Cipher.getInstance() is invoked using either the default settings or ECB mode',
835 'patterns': [r".*: warning: \[InsecureCipherMode\] .+"]},
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: Invalid syntax used for a regular expression',
840 'patterns': [r".*: warning: \[InvalidPatternSyntax\] .+"]},
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: The argument to Class#isInstance(Object) should not be a Class',
845 'patterns': [r".*: warning: \[IsInstanceOfClass\] .+"]},
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: jMock tests must have a @RunWith(JMock.class) annotation, or the Mockery field must have a @Rule JUnit annotation',
850 'patterns': [r".*: warning: \[JMockTestWithoutRunWithOrRuleAnnotation\] .+"]},
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: Test method will not be run; please prefix name with "test"',
855 'patterns': [r".*: warning: \[JUnit3TestNotRun\] .+"]},
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: setUp() method will not be run; Please add a @Before annotation',
860 'patterns': [r".*: warning: \[JUnit4SetUpNotRun\] .+"]},
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: tearDown() method will not be run; Please add an @After annotation',
865 'patterns': [r".*: warning: \[JUnit4TearDownNotRun\] .+"]},
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: Test method will not be run; please add @Test annotation',
870 'patterns': [r".*: warning: \[JUnit4TestNotRun\] .+"]},
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: Printf-like format string does not match its arguments',
875 'patterns': [r".*: warning: \[MalformedFormatString\] .+"]},
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: Use of "YYYY" (week year) in a date pattern without "ww" (week in year). You probably meant to use "yyyy" (year) instead.',
880 'patterns': [r".*: warning: \[MisusedWeekYear\] .+"]},
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: A bug in Mockito will cause this test to fail at runtime with a ClassCastException',
885 'patterns': [r".*: warning: \[MockitoCast\] .+"]},
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: Missing method call for verify(mock) here',
890 'patterns': [r".*: warning: \[MockitoUsage\] .+"]},
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: Modifying a collection with itself',
895 'patterns': [r".*: warning: \[ModifyingCollectionWithItself\] .+"]},
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: Compound assignments to bytes, shorts, chars, and floats hide dangerous casts',
900 'patterns': [r".*: warning: \[NarrowingCompoundAssignment\] .+"]},
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: @NoAllocation was specified on this method, but something was found that would trigger an allocation',
905 'patterns': [r".*: warning: \[NoAllocation\] .+"]},
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: Static import of type uses non-canonical name',
910 'patterns': [r".*: warning: \[NonCanonicalStaticImport\] .+"]},
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: @CompileTimeConstant parameters should be final',
915 'patterns': [r".*: warning: \[NonFinalCompileTimeConstant\] .+"]},
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: Calling getAnnotation on an annotation that is not retained at runtime.',
920 'patterns': [r".*: warning: \[NonRuntimeAnnotation\] .+"]},
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: Numeric comparison using reference equality instead of value equality',
925 'patterns': [r".*: warning: \[NumericEquality\] .+"]},
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: Comparison using reference equality instead of value equality',
930 'patterns': [r".*: warning: \[OptionalEquality\] .+"]},
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: Varargs doesn\'t agree for overridden method',
935 'patterns': [r".*: warning: \[Overrides\] .+"]},
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: Literal passed as first argument to Preconditions.checkNotNull() can never be null',
940 'patterns': [r".*: warning: \[PreconditionsCheckNotNull\] .+"]},
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: First argument to `Preconditions.checkNotNull()` is a primitive rather than an object reference',
945 'patterns': [r".*: warning: \[PreconditionsCheckNotNullPrimitive\] .+"]},
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: Protobuf fields cannot be null',
950 'patterns': [r".*: warning: \[ProtoFieldNullComparison\] .+"]},
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: Comparing protobuf fields of type String using reference equality',
955 'patterns': [r".*: warning: \[ProtoStringFieldReferenceEquality\] .+"]},
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: Check for non-whitelisted callers to RestrictedApiChecker.',
960 'patterns': [r".*: warning: \[RestrictedApiChecker\] .+"]},
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: Return value of this method must be used',
965 'patterns': [r".*: warning: \[ReturnValueIgnored\] .+"]},
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: Variable assigned to itself',
970 'patterns': [r".*: warning: \[SelfAssignment\] .+"]},
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: An object is compared to itself',
975 'patterns': [r".*: warning: \[SelfComparision\] .+"]},
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: Variable compared to itself',
980 'patterns': [r".*: warning: \[SelfEquality\] .+"]},
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: An object is tested for equality to itself',
985 'patterns': [r".*: warning: \[SelfEquals\] .+"]},
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: Comparison of a size >= 0 is always true, did you intend to check for non-emptiness?',
990 'patterns': [r".*: warning: \[SizeGreaterThanOrEqualsZero\] .+"]},
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: Calling toString on a Stream does not provide useful information',
995 'patterns': [r".*: warning: \[StreamToString\] .+"]},
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: StringBuilder does not have a char constructor; this invokes the int constructor.',
1000 'patterns': [r".*: warning: \[StringBuilderInitWithChar\] .+"]},
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: Suppressing "deprecated" is probably a typo for "deprecation"',
1005 'patterns': [r".*: warning: \[SuppressWarningsDeprecated\] .+"]},
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: throwIfUnchecked(knownCheckedException) is a no-op.',
1010 'patterns': [r".*: warning: \[ThrowIfUncheckedKnownChecked\] .+"]},
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: Catching Throwable/Error masks failures from fail() or assert*() in the try block',
1015 'patterns': [r".*: warning: \[TryFailThrowable\] .+"]},
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: Type parameter used as type qualifier',
1020 'patterns': [r".*: warning: \[TypeParameterQualifier\] .+"]},
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: Non-generic methods should not be invoked with type arguments',
1025 'patterns': [r".*: warning: \[UnnecessaryTypeArgument\] .+"]},
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: Instance created but never used',
1030 'patterns': [r".*: warning: \[UnusedAnonymousClass\] .+"]},
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: Use of wildcard imports is forbidden',
1035 'patterns': [r".*: warning: \[WildcardImport\] .+"]},
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: Method parameter has wrong package',
1040 'patterns': [r".*: warning: \[ParameterPackage\] .+"]},
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: Certain resources in `android.R.string` have names that do not match their content',
1045 'patterns': [r".*: warning: \[MislabeledAndroidString\] .+"]},
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: Return value of android.graphics.Rect.intersect() must be checked',
1050 'patterns': [r".*: warning: \[RectIntersectReturnValueIgnored\] .+"]},
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: Invalid printf-style format string',
1055 'patterns': [r".*: warning: \[FormatString\] .+"]},
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: @AssistedInject and @Inject cannot be used on the same constructor.',
1060 'patterns': [r".*: warning: \[AssistedInjectAndInjectOnSameConstructor\] .+"]},
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: Injected constructors cannot be optional nor have binding annotations',
1065 'patterns': [r".*: warning: \[InjectedConstructorAnnotations\] .+"]},
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: The target of a scoping annotation must be set to METHOD and/or TYPE.',
1070 'patterns': [r".*: warning: \[InjectInvalidTargetingOnScopingAnnotation\] .+"]},
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: Abstract methods are not injectable with javax.inject.Inject.',
1075 'patterns': [r".*: warning: \[JavaxInjectOnAbstractMethod\] .+"]},
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: @javax.inject.Inject cannot be put on a final field.',
1080 'patterns': [r".*: warning: \[JavaxInjectOnFinalField\] .+"]},
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: A class may not have more than one injectable constructor.',
1085 'patterns': [r".*: warning: \[MoreThanOneInjectableConstructor\] .+"]},
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: Using more than one qualifier annotation on the same element is not allowed.',
1090 'patterns': [r".*: warning: \[InjectMoreThanOneQualifier\] .+"]},
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: A class can be annotated with at most one scope annotation',
1095 'patterns': [r".*: warning: \[InjectMoreThanOneScopeAnnotationOnClass\] .+"]},
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: Annotations cannot be both Qualifiers/BindingAnnotations and Scopes',
1100 'patterns': [r".*: warning: \[OverlappingQualifierAndScopeAnnotation\] .+"]},
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: Scope annotation on an interface or abstact class is not allowed',
1105 'patterns': [r".*: warning: \[InjectScopeAnnotationOnInterfaceOrAbstractClass\] .+"]},
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: Scoping and qualifier annotations must have runtime retention.',
1110 'patterns': [r".*: warning: \[InjectScopeOrQualifierAnnotationRetention\] .+"]},
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: Dagger @Provides methods may not return null unless annotated with @Nullable',
1115 'patterns': [r".*: warning: \[DaggerProvidesNull\] .+"]},
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: Scope annotation on implementation class of AssistedInject factory is not allowed',
1120 'patterns': [r".*: warning: \[GuiceAssistedInjectScoping\] .+"]},
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: A constructor cannot have two @Assisted parameters of the same type unless they are disambiguated with named @Assisted annotations. ',
1125 'patterns': [r".*: warning: \[GuiceAssistedParameters\] .+"]},
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: This method is not annotated with @Inject, but it overrides a method that is annotated with @javax.inject.Inject.',
1130 'patterns': [r".*: warning: \[OverridesJavaxInjectableMethod\] .+"]},
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: Checks for unguarded accesses to fields and methods with @GuardedBy annotations',
1135 'patterns': [r".*: warning: \[GuardedByChecker\] .+"]},
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: Invalid @GuardedBy expression',
1140 'patterns': [r".*: warning: \[GuardedByValidator\] .+"]},
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: Type declaration annotated with @Immutable is not immutable',
1145 'patterns': [r".*: warning: \[Immutable\] .+"]},
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: This method does not acquire the locks specified by its @LockMethod annotation',
1150 'patterns': [r".*: warning: \[LockMethodChecker\] .+"]},
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 @UnlockMethod annotation',
1155 'patterns': [r".*: warning: \[UnlockMethod\] .+"]},
Ian Rogers32bb9bd2016-05-09 23:19:42 -07001156
Ian Rogers6e520032016-05-13 08:59:00 -07001157 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001158 'severity': Severity.UNKNOWN,
Ian Rogers6e520032016-05-13 08:59:00 -07001159 'description': 'Java: Unclassified/unrecognized warnings',
1160 'patterns': [r".*: warning: \[.+\] .+"]},
Ian Rogers32bb9bd2016-05-09 23:19:42 -07001161
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001162 {'category': 'aapt', 'severity': Severity.MEDIUM,
1163 'description': 'aapt: No default translation',
1164 'patterns': [r".*: warning: string '.+' has no default translation in .*"]},
1165 {'category': 'aapt', 'severity': Severity.MEDIUM,
1166 'description': 'aapt: Missing default or required localization',
1167 'patterns': [r".*: warning: \*\*\*\* string '.+' has no default or required localization for '.+' in .+"]},
1168 {'category': 'aapt', 'severity': Severity.MEDIUM,
1169 'description': 'aapt: String marked untranslatable, but translation exists',
1170 'patterns': [r".*: warning: string '.+' in .* marked untranslatable but exists in locale '??_??'"]},
1171 {'category': 'aapt', 'severity': Severity.MEDIUM,
1172 'description': 'aapt: empty span in string',
1173 'patterns': [r".*: warning: empty '.+' span found in text '.+"]},
1174 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1175 'description': 'Taking address of temporary',
1176 'patterns': [r".*: warning: taking address of temporary"]},
1177 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1178 'description': 'Possible broken line continuation',
1179 'patterns': [r".*: warning: backslash and newline separated by space"]},
1180 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wundefined-var-template',
1181 'description': 'Undefined variable template',
1182 'patterns': [r".*: warning: instantiation of variable .* no definition is available"]},
1183 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wundefined-inline',
1184 'description': 'Inline function is not defined',
1185 'patterns': [r".*: warning: inline function '.*' is not defined"]},
1186 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Warray-bounds',
1187 'description': 'Array subscript out of bounds',
1188 'patterns': [r".*: warning: array subscript is above array bounds",
1189 r".*: warning: Array subscript is undefined",
1190 r".*: warning: array subscript is below array bounds"]},
1191 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1192 'description': 'Excess elements in initializer',
1193 'patterns': [r".*: warning: excess elements in .+ initializer"]},
1194 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1195 'description': 'Decimal constant is unsigned only in ISO C90',
1196 'patterns': [r".*: warning: this decimal constant is unsigned only in ISO C90"]},
1197 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmain',
1198 'description': 'main is usually a function',
1199 'patterns': [r".*: warning: 'main' is usually a function"]},
1200 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1201 'description': 'Typedef ignored',
1202 'patterns': [r".*: warning: 'typedef' was ignored in this declaration"]},
1203 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Waddress',
1204 'description': 'Address always evaluates to true',
1205 'patterns': [r".*: warning: the address of '.+' will always evaluate as 'true'"]},
1206 {'category': 'C/C++', 'severity': Severity.FIXMENOW,
1207 'description': 'Freeing a non-heap object',
1208 'patterns': [r".*: warning: attempt to free a non-heap object '.+'"]},
1209 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wchar-subscripts',
1210 'description': 'Array subscript has type char',
1211 'patterns': [r".*: warning: array subscript .+ type 'char'.+Wchar-subscripts"]},
1212 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1213 'description': 'Constant too large for type',
1214 'patterns': [r".*: warning: integer constant is too large for '.+' type"]},
1215 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Woverflow',
1216 'description': 'Constant too large for type, truncated',
1217 'patterns': [r".*: warning: large integer implicitly truncated to unsigned type"]},
1218 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Winteger-overflow',
1219 'description': 'Overflow in expression',
1220 'patterns': [r".*: warning: overflow in expression; .*Winteger-overflow"]},
1221 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Woverflow',
1222 'description': 'Overflow in implicit constant conversion',
1223 'patterns': [r".*: warning: overflow in implicit constant conversion"]},
1224 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1225 'description': 'Declaration does not declare anything',
1226 'patterns': [r".*: warning: declaration 'class .+' does not declare anything"]},
1227 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wreorder',
1228 'description': 'Initialization order will be different',
1229 'patterns': [r".*: warning: '.+' will be initialized after",
1230 r".*: warning: field .+ will be initialized after .+Wreorder"]},
1231 {'category': 'cont.', 'severity': Severity.SKIP,
1232 'description': 'skip, ....',
1233 'patterns': [r".*: warning: '.+'"]},
1234 {'category': 'cont.', 'severity': Severity.SKIP,
1235 'description': 'skip, base ...',
1236 'patterns': [r".*: warning: base '.+'"]},
1237 {'category': 'cont.', 'severity': Severity.SKIP,
1238 'description': 'skip, when initialized here',
1239 'patterns': [r".*: warning: when initialized here"]},
1240 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-parameter-type',
1241 'description': 'Parameter type not specified',
1242 'patterns': [r".*: warning: type of '.+' defaults to 'int'"]},
1243 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-declarations',
1244 'description': 'Missing declarations',
1245 'patterns': [r".*: warning: declaration does not declare anything"]},
1246 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-noreturn',
1247 'description': 'Missing noreturn',
1248 'patterns': [r".*: warning: function '.*' could be declared with attribute 'noreturn'"]},
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001249 # pylint:disable=anomalous-backslash-in-string
1250 # TODO(chh): fix the backslash pylint warning.
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001251 {'category': 'gcc', 'severity': Severity.MEDIUM,
1252 'description': 'Invalid option for C file',
1253 'patterns': [r".*: warning: command line option "".+"" is valid for C\+\+\/ObjC\+\+ but not for C"]},
1254 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1255 'description': 'User warning',
1256 'patterns': [r".*: warning: #warning "".+"""]},
1257 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wvexing-parse',
1258 'description': 'Vexing parsing problem',
1259 'patterns': [r".*: warning: empty parentheses interpreted as a function declaration"]},
1260 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wextra',
1261 'description': 'Dereferencing void*',
1262 'patterns': [r".*: warning: dereferencing 'void \*' pointer"]},
1263 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1264 'description': 'Comparison of pointer and integer',
1265 'patterns': [r".*: warning: ordered comparison of pointer with integer zero",
1266 r".*: warning: .*comparison between pointer and integer"]},
1267 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1268 'description': 'Use of error-prone unary operator',
1269 'patterns': [r".*: warning: use of unary operator that may be intended as compound assignment"]},
1270 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wwrite-strings',
1271 'description': 'Conversion of string constant to non-const char*',
1272 'patterns': [r".*: warning: deprecated conversion from string constant to '.+'"]},
1273 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wstrict-prototypes',
1274 'description': 'Function declaration isn''t a prototype',
1275 'patterns': [r".*: warning: function declaration isn't a prototype"]},
1276 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wignored-qualifiers',
1277 'description': 'Type qualifiers ignored on function return value',
1278 'patterns': [r".*: warning: type qualifiers ignored on function return type",
1279 r".*: warning: .+ type qualifier .+ has no effect .+Wignored-qualifiers"]},
1280 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1281 'description': '<foo> declared inside parameter list, scope limited to this definition',
1282 'patterns': [r".*: warning: '.+' declared inside parameter list"]},
1283 {'category': 'cont.', 'severity': Severity.SKIP,
1284 'description': 'skip, its scope is only this ...',
1285 'patterns': [r".*: warning: its scope is only this definition or declaration, which is probably not what you want"]},
1286 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wcomment',
1287 'description': 'Line continuation inside comment',
1288 'patterns': [r".*: warning: multi-line comment"]},
1289 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wcomment',
1290 'description': 'Comment inside comment',
1291 'patterns': [r".*: warning: "".+"" within comment"]},
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001292 # Warning "value stored is never read" could be from clang-tidy or clang static analyzer.
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001293 {'category': 'C/C++', 'severity': Severity.ANALYZER,
1294 'description': 'clang-analyzer Value stored is never read',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001295 'patterns': [r".*: warning: Value stored to .+ is never read.*clang-analyzer-deadcode.DeadStores"]},
1296 {'category': 'C/C++', 'severity': Severity.LOW,
1297 'description': 'Value stored is never read',
1298 'patterns': [r".*: warning: Value stored to .+ is never read"]},
1299 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wdeprecated-declarations',
1300 'description': 'Deprecated declarations',
1301 'patterns': [r".*: warning: .+ is deprecated.+deprecated-declarations"]},
1302 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wdeprecated-register',
1303 'description': 'Deprecated register',
1304 'patterns': [r".*: warning: 'register' storage class specifier is deprecated"]},
1305 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wpointer-sign',
1306 'description': 'Converts between pointers to integer types with different sign',
1307 'patterns': [r".*: warning: .+ converts between pointers to integer types with different sign"]},
1308 {'category': 'C/C++', 'severity': Severity.HARMLESS,
1309 'description': 'Extra tokens after #endif',
1310 'patterns': [r".*: warning: extra tokens at end of #endif directive"]},
1311 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wenum-compare',
1312 'description': 'Comparison between different enums',
1313 'patterns': [r".*: warning: comparison between '.+' and '.+'.+Wenum-compare"]},
1314 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wconversion',
1315 'description': 'Conversion may change value',
1316 'patterns': [r".*: warning: converting negative value '.+' to '.+'",
1317 r".*: warning: conversion to '.+' .+ may (alter|change)"]},
1318 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wconversion-null',
1319 'description': 'Converting to non-pointer type from NULL',
1320 'patterns': [r".*: warning: converting to non-pointer type '.+' from NULL"]},
1321 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wnull-conversion',
1322 'description': 'Converting NULL to non-pointer type',
1323 'patterns': [r".*: warning: implicit conversion of NULL constant to '.+'"]},
1324 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wnon-literal-null-conversion',
1325 'description': 'Zero used as null pointer',
1326 'patterns': [r".*: warning: expression .* zero treated as a null pointer constant"]},
1327 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1328 'description': 'Implicit conversion changes value',
1329 'patterns': [r".*: warning: implicit conversion .* changes value from .* to .*-conversion"]},
1330 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1331 'description': 'Passing NULL as non-pointer argument',
1332 'patterns': [r".*: warning: passing NULL to non-pointer argument [0-9]+ of '.+'"]},
1333 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wctor-dtor-privacy',
1334 'description': 'Class seems unusable because of private ctor/dtor',
1335 'patterns': [r".*: warning: all member functions in class '.+' are private"]},
Marco Nelissen594375d2009-07-14 09:04:04 -07001336 # 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 -07001337 {'category': 'C/C++', 'severity': Severity.SKIP, 'option': '-Wctor-dtor-privacy',
1338 'description': 'Class seems unusable because of private ctor/dtor',
1339 'patterns': [r".*: warning: 'class .+' only defines a private destructor and has no friends"]},
1340 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wctor-dtor-privacy',
1341 'description': 'Class seems unusable because of private ctor/dtor',
1342 'patterns': [r".*: warning: 'class .+' only defines private constructors and has no friends"]},
1343 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wgnu-static-float-init',
1344 'description': 'In-class initializer for static const float/double',
1345 'patterns': [r".*: warning: in-class initializer for static data member of .+const (float|double)"]},
1346 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wpointer-arith',
1347 'description': 'void* used in arithmetic',
1348 'patterns': [r".*: warning: pointer of type 'void \*' used in (arithmetic|subtraction)",
1349 r".*: warning: arithmetic on .+ to void is a GNU extension.*Wpointer-arith",
1350 r".*: warning: wrong type argument to increment"]},
1351 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsign-promo',
1352 'description': 'Overload resolution chose to promote from unsigned or enum to signed type',
1353 'patterns': [r".*: warning: passing '.+' chooses '.+' over '.+'.*Wsign-promo"]},
1354 {'category': 'cont.', 'severity': Severity.SKIP,
1355 'description': 'skip, in call to ...',
1356 'patterns': [r".*: warning: in call to '.+'"]},
1357 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wextra',
1358 'description': 'Base should be explicitly initialized in copy constructor',
1359 'patterns': [r".*: warning: base class '.+' should be explicitly initialized in the copy constructor"]},
1360 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1361 'description': 'VLA has zero or negative size',
1362 'patterns': [r".*: warning: Declared variable-length array \(VLA\) has .+ size"]},
1363 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1364 'description': 'Return value from void function',
1365 'patterns': [r".*: warning: 'return' with a value, in function returning void"]},
1366 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'multichar',
1367 'description': 'Multi-character character constant',
1368 'patterns': [r".*: warning: multi-character character constant"]},
1369 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'writable-strings',
1370 'description': 'Conversion from string literal to char*',
1371 'patterns': [r".*: warning: .+ does not allow conversion from string literal to 'char \*'"]},
1372 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wextra-semi',
1373 'description': 'Extra \';\'',
1374 'patterns': [r".*: warning: extra ';' .+extra-semi"]},
1375 {'category': 'C/C++', 'severity': Severity.LOW,
1376 'description': 'Useless specifier',
1377 'patterns': [r".*: warning: useless storage class specifier in empty declaration"]},
1378 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wduplicate-decl-specifier',
1379 'description': 'Duplicate declaration specifier',
1380 'patterns': [r".*: warning: duplicate '.+' declaration specifier"]},
1381 {'category': 'logtags', 'severity': Severity.LOW,
1382 'description': 'Duplicate logtag',
1383 'patterns': [r".*: warning: tag \".+\" \(.+\) duplicated in .+"]},
1384 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'typedef-redefinition',
1385 'description': 'Typedef redefinition',
1386 'patterns': [r".*: warning: redefinition of typedef '.+' is a C11 feature"]},
1387 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'gnu-designator',
1388 'description': 'GNU old-style field designator',
1389 'patterns': [r".*: warning: use of GNU old-style field designator extension"]},
1390 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'missing-field-initializers',
1391 'description': 'Missing field initializers',
1392 'patterns': [r".*: warning: missing field '.+' initializer"]},
1393 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'missing-braces',
1394 'description': 'Missing braces',
1395 'patterns': [r".*: warning: suggest braces around initialization of",
1396 r".*: warning: too many braces around scalar initializer .+Wmany-braces-around-scalar-init",
1397 r".*: warning: braces around scalar initializer"]},
1398 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'sign-compare',
1399 'description': 'Comparison of integers of different signs',
1400 'patterns': [r".*: warning: comparison of integers of different signs.+sign-compare"]},
1401 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'dangling-else',
1402 'description': 'Add braces to avoid dangling else',
1403 'patterns': [r".*: warning: add explicit braces to avoid dangling else"]},
1404 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'initializer-overrides',
1405 'description': 'Initializer overrides prior initialization',
1406 'patterns': [r".*: warning: initializer overrides prior initialization of this subobject"]},
1407 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'self-assign',
1408 'description': 'Assigning value to self',
1409 'patterns': [r".*: warning: explicitly assigning value of .+ to itself"]},
1410 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'gnu-variable-sized-type-not-at-end',
1411 'description': 'GNU extension, variable sized type not at end',
1412 'patterns': [r".*: warning: field '.+' with variable sized type '.+' not at the end of a struct or class"]},
1413 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'tautological-constant-out-of-range-compare',
1414 'description': 'Comparison of constant is always false/true',
1415 'patterns': [r".*: comparison of .+ is always .+Wtautological-constant-out-of-range-compare"]},
1416 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'overloaded-virtual',
1417 'description': 'Hides overloaded virtual function',
1418 'patterns': [r".*: '.+' hides overloaded virtual function"]},
1419 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'incompatible-pointer-types',
1420 'description': 'Incompatible pointer types',
1421 'patterns': [r".*: warning: incompatible pointer types .+Wincompatible-pointer-types"]},
1422 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'asm-operand-widths',
1423 'description': 'ASM value size does not match register size',
1424 'patterns': [r".*: warning: value size does not match register size specified by the constraint and modifier"]},
1425 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'tautological-compare',
1426 'description': 'Comparison of self is always false',
1427 'patterns': [r".*: self-comparison always evaluates to false"]},
1428 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'constant-logical-operand',
1429 'description': 'Logical op with constant operand',
1430 'patterns': [r".*: use of logical '.+' with constant operand"]},
1431 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'literal-suffix',
1432 'description': 'Needs a space between literal and string macro',
1433 'patterns': [r".*: warning: invalid suffix on literal.+ requires a space .+Wliteral-suffix"]},
1434 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '#warnings',
1435 'description': 'Warnings from #warning',
1436 'patterns': [r".*: warning: .+-W#warnings"]},
1437 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'absolute-value',
1438 'description': 'Using float/int absolute value function with int/float argument',
1439 'patterns': [r".*: warning: using .+ absolute value function .+ when argument is .+ type .+Wabsolute-value",
1440 r".*: warning: absolute value function '.+' given .+ which may cause truncation .+Wabsolute-value"]},
1441 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wc++11-extensions',
1442 'description': 'Using C++11 extensions',
1443 'patterns': [r".*: warning: 'auto' type specifier is a C\+\+11 extension"]},
1444 {'category': 'C/C++', 'severity': Severity.LOW,
1445 'description': 'Refers to implicitly defined namespace',
1446 'patterns': [r".*: warning: using directive refers to implicitly-defined namespace .+"]},
1447 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Winvalid-pp-token',
1448 'description': 'Invalid pp token',
1449 'patterns': [r".*: warning: missing .+Winvalid-pp-token"]},
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001450
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001451 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1452 'description': 'Operator new returns NULL',
1453 'patterns': [r".*: warning: 'operator new' must not return NULL unless it is declared 'throw\(\)' .+"]},
1454 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wnull-arithmetic',
1455 'description': 'NULL used in arithmetic',
1456 'patterns': [r".*: warning: NULL used in arithmetic",
1457 r".*: warning: comparison between NULL and non-pointer"]},
1458 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'header-guard',
1459 'description': 'Misspelled header guard',
1460 'patterns': [r".*: warning: '.+' is used as a header guard .+ followed by .+ different macro"]},
1461 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'empty-body',
1462 'description': 'Empty loop body',
1463 'patterns': [r".*: warning: .+ loop has empty body"]},
1464 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'enum-conversion',
1465 'description': 'Implicit conversion from enumeration type',
1466 'patterns': [r".*: warning: implicit conversion from enumeration type '.+'"]},
1467 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'switch',
1468 'description': 'case value not in enumerated type',
1469 'patterns': [r".*: warning: case value not in enumerated type '.+'"]},
1470 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1471 'description': 'Undefined result',
1472 'patterns': [r".*: warning: The result of .+ is undefined",
1473 r".*: warning: passing an object that .+ has undefined behavior \[-Wvarargs\]",
1474 r".*: warning: 'this' pointer cannot be null in well-defined C\+\+ code;",
1475 r".*: warning: shifting a negative signed value is undefined"]},
1476 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1477 'description': 'Division by zero',
1478 'patterns': [r".*: warning: Division by zero"]},
1479 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1480 'description': 'Use of deprecated method',
1481 'patterns': [r".*: warning: '.+' is deprecated .+"]},
1482 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1483 'description': 'Use of garbage or uninitialized value',
1484 'patterns': [r".*: warning: .+ is a garbage value",
1485 r".*: warning: Function call argument is an uninitialized value",
1486 r".*: warning: Undefined or garbage value returned to caller",
1487 r".*: warning: Called .+ pointer is.+uninitialized",
1488 r".*: warning: Called .+ pointer is.+uninitalized", # match a typo in compiler message
1489 r".*: warning: Use of zero-allocated memory",
1490 r".*: warning: Dereference of undefined pointer value",
1491 r".*: warning: Passed-by-value .+ contains uninitialized data",
1492 r".*: warning: Branch condition evaluates to a garbage value",
1493 r".*: warning: The .+ of .+ is an uninitialized value.",
1494 r".*: warning: .+ is used uninitialized whenever .+sometimes-uninitialized",
1495 r".*: warning: Assigned value is garbage or undefined"]},
1496 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1497 'description': 'Result of malloc type incompatible with sizeof operand type',
1498 'patterns': [r".*: warning: Result of '.+' is converted to .+ incompatible with sizeof operand type"]},
1499 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsizeof-array-argument',
1500 'description': 'Sizeof on array argument',
1501 'patterns': [r".*: warning: sizeof on array function parameter will return"]},
1502 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsizeof-pointer-memacces',
1503 'description': 'Bad argument size of memory access functions',
1504 'patterns': [r".*: warning: .+\[-Wsizeof-pointer-memaccess\]"]},
1505 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1506 'description': 'Return value not checked',
1507 'patterns': [r".*: warning: The return value from .+ is not checked"]},
1508 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1509 'description': 'Possible heap pollution',
1510 'patterns': [r".*: warning: .*Possible heap pollution from .+ type .+"]},
1511 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1512 'description': 'Allocation size of 0 byte',
1513 'patterns': [r".*: warning: Call to .+ has an allocation size of 0 byte"]},
1514 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1515 'description': 'Result of malloc type incompatible with sizeof operand type',
1516 'patterns': [r".*: warning: Result of '.+' is converted to .+ incompatible with sizeof operand type"]},
1517 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wfor-loop-analysis',
1518 'description': 'Variable used in loop condition not modified in loop body',
1519 'patterns': [r".*: warning: variable '.+' used in loop condition.*Wfor-loop-analysis"]},
1520 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1521 'description': 'Closing a previously closed file',
1522 'patterns': [r".*: warning: Closing a previously closed file"]},
1523 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunnamed-type-template-args',
1524 'description': 'Unnamed template type argument',
1525 'patterns': [r".*: warning: template argument.+Wunnamed-type-template-args"]},
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001526
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001527 {'category': 'C/C++', 'severity': Severity.HARMLESS,
1528 'description': 'Discarded qualifier from pointer target type',
1529 'patterns': [r".*: warning: .+ discards '.+' qualifier from pointer target type"]},
1530 {'category': 'C/C++', 'severity': Severity.HARMLESS,
1531 'description': 'Use snprintf instead of sprintf',
1532 'patterns': [r".*: warning: .*sprintf is often misused; please use snprintf"]},
1533 {'category': 'C/C++', 'severity': Severity.HARMLESS,
1534 'description': 'Unsupported optimizaton flag',
1535 'patterns': [r".*: warning: optimization flag '.+' is not supported"]},
1536 {'category': 'C/C++', 'severity': Severity.HARMLESS,
1537 'description': 'Extra or missing parentheses',
1538 'patterns': [r".*: warning: equality comparison with extraneous parentheses",
1539 r".*: warning: .+ within .+Wlogical-op-parentheses"]},
1540 {'category': 'C/C++', 'severity': Severity.HARMLESS, 'option': 'mismatched-tags',
1541 'description': 'Mismatched class vs struct tags',
1542 'patterns': [r".*: warning: '.+' defined as a .+ here but previously declared as a .+mismatched-tags",
1543 r".*: warning: .+ was previously declared as a .+mismatched-tags"]},
Marco Nelissen594375d2009-07-14 09:04:04 -07001544
1545 # 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 -07001546 {'category': 'C/C++', 'severity': Severity.SKIP,
1547 'description': 'skip, ,',
1548 'patterns': [r".*: warning: ,$"]},
1549 {'category': 'C/C++', 'severity': Severity.SKIP,
1550 'description': 'skip,',
1551 'patterns': [r".*: warning: $"]},
1552 {'category': 'C/C++', 'severity': Severity.SKIP,
1553 'description': 'skip, In file included from ...',
1554 'patterns': [r".*: warning: In file included from .+,"]},
Marco Nelissen594375d2009-07-14 09:04:04 -07001555
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001556 # warnings from clang-tidy
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001557 {'category': 'C/C++', 'severity': Severity.TIDY,
1558 'description': 'clang-tidy readability',
1559 'patterns': [r".*: .+\[readability-.+\]$"]},
1560 {'category': 'C/C++', 'severity': Severity.TIDY,
1561 'description': 'clang-tidy c++ core guidelines',
1562 'patterns': [r".*: .+\[cppcoreguidelines-.+\]$"]},
1563 {'category': 'C/C++', 'severity': Severity.TIDY,
1564 'description': 'clang-tidy google-default-arguments',
1565 'patterns': [r".*: .+\[google-default-arguments\]$"]},
1566 {'category': 'C/C++', 'severity': Severity.TIDY,
1567 'description': 'clang-tidy google-runtime-int',
1568 'patterns': [r".*: .+\[google-runtime-int\]$"]},
1569 {'category': 'C/C++', 'severity': Severity.TIDY,
1570 'description': 'clang-tidy google-runtime-operator',
1571 'patterns': [r".*: .+\[google-runtime-operator\]$"]},
1572 {'category': 'C/C++', 'severity': Severity.TIDY,
1573 'description': 'clang-tidy google-runtime-references',
1574 'patterns': [r".*: .+\[google-runtime-references\]$"]},
1575 {'category': 'C/C++', 'severity': Severity.TIDY,
1576 'description': 'clang-tidy google-build',
1577 'patterns': [r".*: .+\[google-build-.+\]$"]},
1578 {'category': 'C/C++', 'severity': Severity.TIDY,
1579 'description': 'clang-tidy google-explicit',
1580 'patterns': [r".*: .+\[google-explicit-.+\]$"]},
1581 {'category': 'C/C++', 'severity': Severity.TIDY,
1582 'description': 'clang-tidy google-readability',
1583 'patterns': [r".*: .+\[google-readability-.+\]$"]},
1584 {'category': 'C/C++', 'severity': Severity.TIDY,
1585 'description': 'clang-tidy google-global',
1586 'patterns': [r".*: .+\[google-global-.+\]$"]},
1587 {'category': 'C/C++', 'severity': Severity.TIDY,
1588 'description': 'clang-tidy google- other',
1589 'patterns': [r".*: .+\[google-.+\]$"]},
1590 {'category': 'C/C++', 'severity': Severity.TIDY,
1591 'description': 'clang-tidy modernize',
1592 'patterns': [r".*: .+\[modernize-.+\]$"]},
1593 {'category': 'C/C++', 'severity': Severity.TIDY,
1594 'description': 'clang-tidy misc',
1595 'patterns': [r".*: .+\[misc-.+\]$"]},
1596 {'category': 'C/C++', 'severity': Severity.TIDY,
1597 'description': 'clang-tidy performance-faster-string-find',
1598 'patterns': [r".*: .+\[performance-faster-string-find\]$"]},
1599 {'category': 'C/C++', 'severity': Severity.TIDY,
1600 'description': 'clang-tidy performance-for-range-copy',
1601 'patterns': [r".*: .+\[performance-for-range-copy\]$"]},
1602 {'category': 'C/C++', 'severity': Severity.TIDY,
1603 'description': 'clang-tidy performance-implicit-cast-in-loop',
1604 'patterns': [r".*: .+\[performance-implicit-cast-in-loop\]$"]},
1605 {'category': 'C/C++', 'severity': Severity.TIDY,
1606 'description': 'clang-tidy performance-unnecessary-copy-initialization',
1607 'patterns': [r".*: .+\[performance-unnecessary-copy-initialization\]$"]},
1608 {'category': 'C/C++', 'severity': Severity.TIDY,
1609 'description': 'clang-tidy performance-unnecessary-value-param',
1610 'patterns': [r".*: .+\[performance-unnecessary-value-param\]$"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001611 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001612 'description': 'clang-analyzer Unreachable code',
1613 'patterns': [r".*: warning: This statement is never executed.*UnreachableCode"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001614 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001615 'description': 'clang-analyzer Size of malloc may overflow',
1616 'patterns': [r".*: warning: .* size of .* may overflow .*MallocOverflow"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001617 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001618 'description': 'clang-analyzer Stream pointer might be NULL',
1619 'patterns': [r".*: warning: Stream pointer might be NULL .*unix.Stream"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001620 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001621 'description': 'clang-analyzer Opened file never closed',
1622 'patterns': [r".*: warning: Opened File never closed.*unix.Stream"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001623 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001624 'description': 'clang-analyzer sozeof() on a pointer type',
1625 'patterns': [r".*: warning: .*calls sizeof.* on a pointer type.*SizeofPtr"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001626 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001627 'description': 'clang-analyzer Pointer arithmetic on non-array variables',
1628 'patterns': [r".*: warning: Pointer arithmetic on non-array variables .*PointerArithm"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001629 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001630 'description': 'clang-analyzer Subtraction of pointers of different memory chunks',
1631 'patterns': [r".*: warning: Subtraction of two pointers .*PointerSub"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001632 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001633 'description': 'clang-analyzer Access out-of-bound array element',
1634 'patterns': [r".*: warning: Access out-of-bound array element .*ArrayBound"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001635 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001636 'description': 'clang-analyzer Out of bound memory access',
1637 'patterns': [r".*: warning: Out of bound memory access .*ArrayBoundV2"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001638 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001639 'description': 'clang-analyzer Possible lock order reversal',
1640 'patterns': [r".*: warning: .* Possible lock order reversal.*PthreadLock"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001641 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001642 'description': 'clang-analyzer Argument is a pointer to uninitialized value',
1643 'patterns': [r".*: warning: .* argument is a pointer to uninitialized value .*CallAndMessage"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001644 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001645 'description': 'clang-analyzer cast to struct',
1646 'patterns': [r".*: warning: Casting a non-structure type to a structure type .*CastToStruct"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001647 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001648 'description': 'clang-analyzer call path problems',
1649 'patterns': [r".*: warning: Call Path : .+"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001650 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001651 'description': 'clang-analyzer other',
1652 'patterns': [r".*: .+\[clang-analyzer-.+\]$",
1653 r".*: Call Path : .+$"]},
1654 {'category': 'C/C++', 'severity': Severity.TIDY,
1655 'description': 'clang-tidy CERT',
1656 'patterns': [r".*: .+\[cert-.+\]$"]},
1657 {'category': 'C/C++', 'severity': Severity.TIDY,
1658 'description': 'clang-tidy llvm',
1659 'patterns': [r".*: .+\[llvm-.+\]$"]},
1660 {'category': 'C/C++', 'severity': Severity.TIDY,
1661 'description': 'clang-diagnostic',
1662 'patterns': [r".*: .+\[clang-diagnostic-.+\]$"]},
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001663
Marco Nelissen594375d2009-07-14 09:04:04 -07001664 # catch-all for warnings this script doesn't know about yet
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001665 {'category': 'C/C++', 'severity': Severity.UNKNOWN,
1666 'description': 'Unclassified/unrecognized warnings',
1667 'patterns': [r".*: warning: .+"]},
Marco Nelissen594375d2009-07-14 09:04:04 -07001668]
1669
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001670
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001671def project_name_and_pattern(name, pattern):
1672 return [name, '(^|.*/)' + pattern + '/.*: warning:']
1673
1674
1675def simple_project_pattern(pattern):
1676 return project_name_and_pattern(pattern, pattern)
1677
1678
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001679# A list of [project_name, file_path_pattern].
1680# project_name should not contain comma, to be used in CSV output.
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001681project_list = [
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001682 simple_project_pattern('art'),
1683 simple_project_pattern('bionic'),
1684 simple_project_pattern('bootable'),
1685 simple_project_pattern('build'),
1686 simple_project_pattern('cts'),
1687 simple_project_pattern('dalvik'),
1688 simple_project_pattern('developers'),
1689 simple_project_pattern('development'),
1690 simple_project_pattern('device'),
1691 simple_project_pattern('doc'),
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07001692 # match external/google* before external/
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001693 project_name_and_pattern('external/google', 'external/google.*'),
1694 project_name_and_pattern('external/non-google', 'external'),
1695 simple_project_pattern('frameworks/av/camera'),
1696 simple_project_pattern('frameworks/av/cmds'),
1697 simple_project_pattern('frameworks/av/drm'),
1698 simple_project_pattern('frameworks/av/include'),
1699 simple_project_pattern('frameworks/av/media'),
1700 simple_project_pattern('frameworks/av/radio'),
1701 simple_project_pattern('frameworks/av/services'),
1702 project_name_and_pattern('frameworks/av/Other', 'frameworks/av'),
1703 simple_project_pattern('frameworks/base'),
1704 simple_project_pattern('frameworks/compile'),
1705 simple_project_pattern('frameworks/minikin'),
1706 simple_project_pattern('frameworks/native'),
1707 simple_project_pattern('frameworks/opt'),
1708 simple_project_pattern('frameworks/rs'),
1709 simple_project_pattern('frameworks/webview'),
1710 simple_project_pattern('frameworks/wilhelm'),
1711 project_name_and_pattern('frameworks/Other', 'frameworks'),
1712 simple_project_pattern('hardware/akm'),
1713 simple_project_pattern('hardware/broadcom'),
1714 simple_project_pattern('hardware/google'),
1715 simple_project_pattern('hardware/intel'),
1716 simple_project_pattern('hardware/interfaces'),
1717 simple_project_pattern('hardware/libhardware'),
1718 simple_project_pattern('hardware/libhardware_legacy'),
1719 simple_project_pattern('hardware/qcom'),
1720 simple_project_pattern('hardware/ril'),
1721 project_name_and_pattern('hardware/Other', 'hardware'),
1722 simple_project_pattern('kernel'),
1723 simple_project_pattern('libcore'),
1724 simple_project_pattern('libnativehelper'),
1725 simple_project_pattern('ndk'),
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001726 # match vendor/unbungled_google/packages before other packages
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001727 simple_project_pattern('unbundled_google'),
1728 simple_project_pattern('packages'),
1729 simple_project_pattern('pdk'),
1730 simple_project_pattern('prebuilts'),
1731 simple_project_pattern('system/bt'),
1732 simple_project_pattern('system/connectivity'),
1733 simple_project_pattern('system/core'),
1734 simple_project_pattern('system/extras'),
1735 simple_project_pattern('system/gatekeeper'),
1736 simple_project_pattern('system/keymaster'),
1737 simple_project_pattern('system/libhwbinder'),
1738 simple_project_pattern('system/media'),
1739 simple_project_pattern('system/netd'),
1740 simple_project_pattern('system/security'),
1741 simple_project_pattern('system/sepolicy'),
1742 simple_project_pattern('system/tools'),
1743 simple_project_pattern('system/vold'),
1744 project_name_and_pattern('system/Other', 'system'),
1745 simple_project_pattern('toolchain'),
1746 simple_project_pattern('test'),
1747 simple_project_pattern('tools'),
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07001748 # match vendor/google* before vendor/
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001749 project_name_and_pattern('vendor/google', 'vendor/google.*'),
1750 project_name_and_pattern('vendor/non-google', 'vendor'),
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07001751 # keep out/obj and other patterns at the end.
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001752 ['out/obj',
1753 '.*/(gen|obj[^/]*)/(include|EXECUTABLES|SHARED_LIBRARIES|'
1754 'STATIC_LIBRARIES|NATIVE_TESTS)/.*: warning:'],
1755 ['other', '.*'] # all other unrecognized patterns
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001756]
1757
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001758project_patterns = []
1759project_names = []
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001760warning_messages = []
1761warning_records = []
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001762
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001763
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001764def initialize_arrays():
1765 """Complete global arrays before they are used."""
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001766 global project_names, project_patterns
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001767 project_names = [p[0] for p in project_list]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001768 project_patterns = [re.compile(p[1]) for p in project_list]
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001769 for w in warn_patterns:
1770 w['members'] = []
1771 if 'option' not in w:
1772 w['option'] = ''
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001773 # Each warning pattern has a 'projects' dictionary, that
1774 # maps a project name to number of warnings in that project.
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001775 w['projects'] = {}
1776
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001777
1778initialize_arrays()
1779
1780
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -07001781android_root = ''
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001782platform_version = 'unknown'
1783target_product = 'unknown'
1784target_variant = 'unknown'
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001785
1786
1787##### Data and functions to dump html file. ##################################
1788
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001789html_head_scripts = """\
1790 <script type="text/javascript">
1791 function expand(id) {
1792 var e = document.getElementById(id);
1793 var f = document.getElementById(id + "_mark");
1794 if (e.style.display == 'block') {
1795 e.style.display = 'none';
1796 f.innerHTML = '&#x2295';
1797 }
1798 else {
1799 e.style.display = 'block';
1800 f.innerHTML = '&#x2296';
1801 }
1802 };
1803 function expandCollapse(show) {
1804 for (var id = 1; ; id++) {
1805 var e = document.getElementById(id + "");
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07001806 var f = document.getElementById(id + "_mark");
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001807 if (!e || !f) break;
1808 e.style.display = (show ? 'block' : 'none');
1809 f.innerHTML = (show ? '&#x2296' : '&#x2295');
1810 }
1811 };
1812 </script>
1813 <style type="text/css">
1814 th,td{border-collapse:collapse; border:1px solid black;}
1815 .button{color:blue;font-size:110%;font-weight:bolder;}
1816 .bt{color:black;background-color:transparent;border:none;outline:none;
1817 font-size:140%;font-weight:bolder;}
1818 .c0{background-color:#e0e0e0;}
1819 .c1{background-color:#d0d0d0;}
1820 .t1{border-collapse:collapse; width:100%; border:1px solid black;}
1821 </style>
1822 <script src="https://www.gstatic.com/charts/loader.js"></script>
1823"""
Marco Nelissen594375d2009-07-14 09:04:04 -07001824
Marco Nelissen594375d2009-07-14 09:04:04 -07001825
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001826def html_big(param):
1827 return '<font size="+2">' + param + '</font>'
Marco Nelissen594375d2009-07-14 09:04:04 -07001828
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07001829
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001830def dump_html_prologue(title):
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001831 print '<html>\n<head>'
1832 print '<title>' + title + '</title>'
1833 print html_head_scripts
1834 emit_stats_by_project()
1835 print '</head>\n<body>'
1836 print html_big(title)
1837 print '<p>'
Marco Nelissen594375d2009-07-14 09:04:04 -07001838
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001839
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001840def dump_html_epilogue():
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001841 print '</body>\n</head>\n</html>'
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001842
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001843
1844def sort_warnings():
1845 for i in warn_patterns:
1846 i['members'] = sorted(set(i['members']))
1847
1848
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001849def emit_stats_by_project():
1850 """Dump a google chart table of warnings per project and severity."""
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001851 # warnings[p][s] is number of warnings in project p of severity s.
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001852 warnings = {p: {s: 0 for s in Severity.range} for p in project_names}
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001853 for i in warn_patterns:
1854 s = i['severity']
1855 for p in i['projects']:
1856 warnings[p][s] += i['projects'][p]
1857
1858 # total_by_project[p] is number of warnings in project p.
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001859 total_by_project = {p: sum(warnings[p][s] for s in Severity.range)
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001860 for p in project_names}
1861
1862 # total_by_severity[s] is number of warnings of severity s.
1863 total_by_severity = {s: sum(warnings[p][s] for p in project_names)
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001864 for s in Severity.range}
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001865
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001866 # emit table header
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001867 stats_header = ['Project']
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001868 for s in Severity.range:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001869 if total_by_severity[s]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001870 stats_header.append("<span style='background-color:{}'>{}</span>".
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001871 format(Severity.colors[s],
1872 Severity.column_headers[s]))
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001873 stats_header.append('TOTAL')
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001874
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001875 # emit a row of warning counts per project, skip no-warning projects
1876 total_all_projects = 0
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001877 stats_rows = []
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001878 for p in project_names:
1879 if total_by_project[p]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001880 one_row = [p]
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001881 for s in Severity.range:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001882 if total_by_severity[s]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001883 one_row.append(warnings[p][s])
1884 one_row.append(total_by_project[p])
1885 stats_rows.append(one_row)
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001886 total_all_projects += total_by_project[p]
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001887
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001888 # emit a row of warning counts per severity
1889 total_all_severities = 0
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001890 one_row = ['<b>TOTAL</b>']
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001891 for s in Severity.range:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001892 if total_by_severity[s]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001893 one_row.append(total_by_severity[s])
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001894 total_all_severities += total_by_severity[s]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001895 one_row.append(total_all_projects)
1896 stats_rows.append(one_row)
1897 print '<script>'
1898 emit_const_string_array('StatsHeader', stats_header)
1899 emit_const_object_array('StatsRows', stats_rows)
1900 print draw_table_javascript
1901 print '</script>'
Marco Nelissen594375d2009-07-14 09:04:04 -07001902
1903
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001904def dump_stats():
1905 """Dump some stats about total number of warnings and such."""
1906 known = 0
1907 skipped = 0
1908 unknown = 0
1909 sort_warnings()
1910 for i in warn_patterns:
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001911 if i['severity'] == Severity.UNKNOWN:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001912 unknown += len(i['members'])
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001913 elif i['severity'] == Severity.SKIP:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001914 skipped += len(i['members'])
Ian Rogersf3829732016-05-10 12:06:01 -07001915 else:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001916 known += len(i['members'])
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001917 print 'Number of classified warnings: <b>' + str(known) + '</b><br>'
1918 print 'Number of skipped warnings: <b>' + str(skipped) + '</b><br>'
1919 print 'Number of unclassified warnings: <b>' + str(unknown) + '</b><br>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001920 total = unknown + known + skipped
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001921 extra_msg = ''
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001922 if total < 1000:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001923 extra_msg = ' (low count may indicate incremental build)'
1924 print 'Total number of warnings: <b>' + str(total) + '</b>' + extra_msg
Marco Nelissen594375d2009-07-14 09:04:04 -07001925
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07001926
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001927# New base table of warnings, [severity, warn_id, project, warning_message]
1928# Need buttons to show warnings in different grouping options.
1929# (1) Current, group by severity, id for each warning pattern
1930# sort by severity, warn_id, warning_message
1931# (2) Current --byproject, group by severity,
1932# id for each warning pattern + project name
1933# sort by severity, warn_id, project, warning_message
1934# (3) New, group by project + severity,
1935# id for each warning pattern
1936# sort by project, severity, warn_id, warning_message
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001937def emit_buttons():
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001938 print ('<button class="button" onclick="expandCollapse(1);">'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001939 'Expand all warnings</button>\n'
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001940 '<button class="button" onclick="expandCollapse(0);">'
1941 'Collapse all warnings</button>\n'
1942 '<button class="button" onclick="groupBySeverity();">'
1943 'Group warnings by severity</button>\n'
1944 '<button class="button" onclick="groupByProject();">'
1945 'Group warnings by project</button><br>')
Marco Nelissen594375d2009-07-14 09:04:04 -07001946
1947
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001948def all_patterns(category):
1949 patterns = ''
1950 for i in category['patterns']:
1951 patterns += i
1952 patterns += ' / '
1953 return patterns
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001954
1955
1956def dump_fixed():
1957 """Show which warnings no longer occur."""
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001958 anchor = 'fixed_warnings'
1959 mark = anchor + '_mark'
1960 print ('\n<br><p style="background-color:lightblue"><b>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001961 '<button id="' + mark + '" '
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001962 'class="bt" onclick="expand(\'' + anchor + '\');">'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001963 '&#x2295</button> Fixed warnings. '
1964 'No more occurrences. Please consider turning these into '
1965 'errors if possible, before they are reintroduced in to the build'
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001966 ':</b></p>')
1967 print '<blockquote>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001968 fixed_patterns = []
1969 for i in warn_patterns:
1970 if not i['members']:
1971 fixed_patterns.append(i['description'] + ' (' +
1972 all_patterns(i) + ')')
1973 if i['option']:
1974 fixed_patterns.append(' ' + i['option'])
1975 fixed_patterns.sort()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001976 print '<div id="' + anchor + '" style="display:none;"><table>'
1977 cur_row_class = 0
1978 for text in fixed_patterns:
1979 cur_row_class = 1 - cur_row_class
1980 # remove last '\n'
1981 t = text[:-1] if text[-1] == '\n' else text
1982 print '<tr><td class="c' + str(cur_row_class) + '">' + t + '</td></tr>'
1983 print '</table></div>'
1984 print '</blockquote>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001985
1986
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001987def find_project_index(line):
1988 for p in range(len(project_patterns)):
1989 if project_patterns[p].match(line):
1990 return p
1991 return -1
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001992
1993
1994def classify_warning(line):
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001995 for i in range(len(warn_patterns)):
1996 w = warn_patterns[i]
1997 for cpat in w['compiled_patterns']:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001998 if cpat.match(line):
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001999 w['members'].append(line)
2000 p = find_project_index(line)
2001 index = len(warning_messages)
2002 warning_messages.append(line)
2003 warning_records.append([i, p, index])
2004 pname = '???' if p < 0 else project_names[p]
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002005 # Count warnings by project.
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002006 if pname in w['projects']:
2007 w['projects'][pname] += 1
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002008 else:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002009 w['projects'][pname] = 1
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002010 return
2011 else:
2012 # If we end up here, there was a problem parsing the log
2013 # probably caused by 'make -j' mixing the output from
2014 # 2 or more concurrent compiles
2015 pass
Marco Nelissen594375d2009-07-14 09:04:04 -07002016
2017
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002018def compile_patterns():
2019 """Precompiling every pattern speeds up parsing by about 30x."""
2020 for i in warn_patterns:
2021 i['compiled_patterns'] = []
2022 for pat in i['patterns']:
2023 i['compiled_patterns'].append(re.compile(pat))
2024
2025
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -07002026def find_android_root(path):
2027 """Set and return android_root path if it is found."""
2028 global android_root
2029 parts = path.split('/')
2030 for idx in reversed(range(2, len(parts))):
2031 root_path = '/'.join(parts[:idx])
2032 # Android root directory should contain this script.
2033 if os.path.exists(root_path + '/build/tools/warn.py'):
2034 android_root = root_path
2035 return root_path
2036 return ''
2037
2038
2039def remove_android_root_prefix(path):
2040 """Remove android_root prefix from path if it is found."""
2041 if path.startswith(android_root):
2042 return path[1 + len(android_root):]
2043 else:
2044 return path
2045
2046
2047def normalize_path(path):
2048 """Normalize file path relative to android_root."""
2049 # If path is not an absolute path, just normalize it.
2050 path = os.path.normpath(path)
2051 if path[0] != '/':
2052 return path
2053 # Remove known prefix of root path and normalize the suffix.
2054 if android_root or find_android_root(path):
2055 return remove_android_root_prefix(path)
2056 else:
2057 return path
2058
2059
2060def normalize_warning_line(line):
2061 """Normalize file path relative to android_root in a warning line."""
2062 # replace fancy quotes with plain ol' quotes
2063 line = line.replace('‘', "'")
2064 line = line.replace('’', "'")
2065 line = line.strip()
2066 first_column = line.find(':')
2067 if first_column > 0:
2068 return normalize_path(line[:first_column]) + line[first_column:]
2069 else:
2070 return line
2071
2072
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002073def parse_input_file():
2074 """Parse input file, match warning lines."""
2075 global platform_version
2076 global target_product
2077 global target_variant
2078 infile = open(args.buildlog, 'r')
2079 line_counter = 0
2080
2081 warning_pattern = re.compile('.* warning:.*')
2082 compile_patterns()
2083
2084 # read the log file and classify all the warnings
2085 warning_lines = set()
2086 for line in infile:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002087 if warning_pattern.match(line):
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -07002088 line = normalize_warning_line(line)
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002089 if line not in warning_lines:
2090 classify_warning(line)
2091 warning_lines.add(line)
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002092 elif line_counter < 50:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002093 # save a little bit of time by only doing this for the first few lines
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002094 line_counter += 1
2095 m = re.search('(?<=^PLATFORM_VERSION=).*', line)
2096 if m is not None:
2097 platform_version = m.group(0)
2098 m = re.search('(?<=^TARGET_PRODUCT=).*', line)
2099 if m is not None:
2100 target_product = m.group(0)
2101 m = re.search('(?<=^TARGET_BUILD_VARIANT=).*', line)
2102 if m is not None:
2103 target_variant = m.group(0)
2104
2105
2106# Return s with escaped quotation characters.
2107def escape_string(s):
2108 return s.replace('"', '\\"')
2109
2110
2111# Return s without trailing '\n' and escape the quotation characters.
2112def strip_escape_string(s):
2113 if not s:
2114 return s
2115 s = s[:-1] if s[-1] == '\n' else s
2116 return escape_string(s)
2117
2118
2119def emit_warning_array(name):
2120 print 'var warning_{} = ['.format(name)
2121 for i in range(len(warn_patterns)):
2122 print '{},'.format(warn_patterns[i][name])
2123 print '];'
2124
2125
2126def emit_warning_arrays():
2127 emit_warning_array('severity')
2128 print 'var warning_description = ['
2129 for i in range(len(warn_patterns)):
2130 if warn_patterns[i]['members']:
2131 print '"{}",'.format(escape_string(warn_patterns[i]['description']))
2132 else:
2133 print '"",' # no such warning
2134 print '];'
2135
2136scripts_for_warning_groups = """
2137 function compareMessages(x1, x2) { // of the same warning type
2138 return (WarningMessages[x1[2]] <= WarningMessages[x2[2]]) ? -1 : 1;
2139 }
2140 function byMessageCount(x1, x2) {
2141 return x2[2] - x1[2]; // reversed order
2142 }
2143 function bySeverityMessageCount(x1, x2) {
2144 // orer by severity first
2145 if (x1[1] != x2[1])
2146 return x1[1] - x2[1];
2147 return byMessageCount(x1, x2);
2148 }
2149 const ParseLinePattern = /^([^ :]+):(\\d+):(.+)/;
2150 function addURL(line) {
2151 if (FlagURL == "") return line;
2152 if (FlagSeparator == "") {
2153 return line.replace(ParseLinePattern,
2154 "<a href='" + FlagURL + "/$1'>$1</a>:$2:$3");
2155 }
2156 return line.replace(ParseLinePattern,
2157 "<a href='" + FlagURL + "/$1" + FlagSeparator + "$2'>$1:$2</a>:$3");
2158 }
2159 function createArrayOfDictionaries(n) {
2160 var result = [];
2161 for (var i=0; i<n; i++) result.push({});
2162 return result;
2163 }
2164 function groupWarningsBySeverity() {
2165 // groups is an array of dictionaries,
2166 // each dictionary maps from warning type to array of warning messages.
2167 var groups = createArrayOfDictionaries(SeverityColors.length);
2168 for (var i=0; i<Warnings.length; i++) {
2169 var w = Warnings[i][0];
2170 var s = WarnPatternsSeverity[w];
2171 var k = w.toString();
2172 if (!(k in groups[s]))
2173 groups[s][k] = [];
2174 groups[s][k].push(Warnings[i]);
2175 }
2176 return groups;
2177 }
2178 function groupWarningsByProject() {
2179 var groups = createArrayOfDictionaries(ProjectNames.length);
2180 for (var i=0; i<Warnings.length; i++) {
2181 var w = Warnings[i][0];
2182 var p = Warnings[i][1];
2183 var k = w.toString();
2184 if (!(k in groups[p]))
2185 groups[p][k] = [];
2186 groups[p][k].push(Warnings[i]);
2187 }
2188 return groups;
2189 }
2190 var GlobalAnchor = 0;
2191 function createWarningSection(header, color, group) {
2192 var result = "";
2193 var groupKeys = [];
2194 var totalMessages = 0;
2195 for (var k in group) {
2196 totalMessages += group[k].length;
2197 groupKeys.push([k, WarnPatternsSeverity[parseInt(k)], group[k].length]);
2198 }
2199 groupKeys.sort(bySeverityMessageCount);
2200 for (var idx=0; idx<groupKeys.length; idx++) {
2201 var k = groupKeys[idx][0];
2202 var messages = group[k];
2203 var w = parseInt(k);
2204 var wcolor = SeverityColors[WarnPatternsSeverity[w]];
2205 var description = WarnPatternsDescription[w];
2206 if (description.length == 0)
2207 description = "???";
2208 GlobalAnchor += 1;
2209 result += "<table class='t1'><tr bgcolor='" + wcolor + "'><td>" +
2210 "<button class='bt' id='" + GlobalAnchor + "_mark" +
2211 "' onclick='expand(\\"" + GlobalAnchor + "\\");'>" +
2212 "&#x2295</button> " +
2213 description + " (" + messages.length + ")</td></tr></table>";
2214 result += "<div id='" + GlobalAnchor +
2215 "' style='display:none;'><table class='t1'>";
2216 var c = 0;
2217 messages.sort(compareMessages);
2218 for (var i=0; i<messages.length; i++) {
2219 result += "<tr><td class='c" + c + "'>" +
2220 addURL(WarningMessages[messages[i][2]]) + "</td></tr>";
2221 c = 1 - c;
2222 }
2223 result += "</table></div>";
2224 }
2225 if (result.length > 0) {
2226 return "<br><span style='background-color:" + color + "'><b>" +
2227 header + ": " + totalMessages +
2228 "</b></span><blockquote><table class='t1'>" +
2229 result + "</table></blockquote>";
2230
2231 }
2232 return ""; // empty section
2233 }
2234 function generateSectionsBySeverity() {
2235 var result = "";
2236 var groups = groupWarningsBySeverity();
2237 for (s=0; s<SeverityColors.length; s++) {
2238 result += createWarningSection(SeverityHeaders[s], SeverityColors[s], groups[s]);
2239 }
2240 return result;
2241 }
2242 function generateSectionsByProject() {
2243 var result = "";
2244 var groups = groupWarningsByProject();
2245 for (i=0; i<groups.length; i++) {
2246 result += createWarningSection(ProjectNames[i], 'lightgrey', groups[i]);
2247 }
2248 return result;
2249 }
2250 function groupWarnings(generator) {
2251 GlobalAnchor = 0;
2252 var e = document.getElementById("warning_groups");
2253 e.innerHTML = generator();
2254 }
2255 function groupBySeverity() {
2256 groupWarnings(generateSectionsBySeverity);
2257 }
2258 function groupByProject() {
2259 groupWarnings(generateSectionsByProject);
2260 }
2261"""
2262
2263
2264# Emit a JavaScript const string
2265def emit_const_string(name, value):
2266 print 'const ' + name + ' = "' + escape_string(value) + '";'
2267
2268
2269# Emit a JavaScript const integer array.
2270def emit_const_int_array(name, array):
2271 print 'const ' + name + ' = ['
2272 for n in array:
2273 print str(n) + ','
2274 print '];'
2275
2276
2277# Emit a JavaScript const string array.
2278def emit_const_string_array(name, array):
2279 print 'const ' + name + ' = ['
2280 for s in array:
2281 print '"' + strip_escape_string(s) + '",'
2282 print '];'
2283
2284
2285# Emit a JavaScript const object array.
2286def emit_const_object_array(name, array):
2287 print 'const ' + name + ' = ['
2288 for x in array:
2289 print str(x) + ','
2290 print '];'
2291
2292
2293def emit_js_data():
2294 """Dump dynamic HTML page's static JavaScript data."""
2295 emit_const_string('FlagURL', args.url if args.url else '')
2296 emit_const_string('FlagSeparator', args.separator if args.separator else '')
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002297 emit_const_string_array('SeverityColors', Severity.colors)
2298 emit_const_string_array('SeverityHeaders', Severity.headers)
2299 emit_const_string_array('SeverityColumnHeaders', Severity.column_headers)
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002300 emit_const_string_array('ProjectNames', project_names)
2301 emit_const_int_array('WarnPatternsSeverity',
2302 [w['severity'] for w in warn_patterns])
2303 emit_const_string_array('WarnPatternsDescription',
2304 [w['description'] for w in warn_patterns])
2305 emit_const_string_array('WarnPatternsOption',
2306 [w['option'] for w in warn_patterns])
2307 emit_const_string_array('WarningMessages', warning_messages)
2308 emit_const_object_array('Warnings', warning_records)
2309
2310draw_table_javascript = """
2311google.charts.load('current', {'packages':['table']});
2312google.charts.setOnLoadCallback(drawTable);
2313function drawTable() {
2314 var data = new google.visualization.DataTable();
2315 data.addColumn('string', StatsHeader[0]);
2316 for (var i=1; i<StatsHeader.length; i++) {
2317 data.addColumn('number', StatsHeader[i]);
2318 }
2319 data.addRows(StatsRows);
2320 for (var i=0; i<StatsRows.length; i++) {
2321 for (var j=0; j<StatsHeader.length; j++) {
2322 data.setProperty(i, j, 'style', 'border:1px solid black;');
2323 }
2324 }
2325 var table = new google.visualization.Table(document.getElementById('stats_table'));
2326 table.draw(data, {allowHtml: true, alternatingRowStyle: true});
2327}
2328"""
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002329
2330
2331def dump_html():
2332 """Dump the html output to stdout."""
2333 dump_html_prologue('Warnings for ' + platform_version + ' - ' +
2334 target_product + ' - ' + target_variant)
2335 dump_stats()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002336 print '<br><div id="stats_table"></div><br>'
2337 print '\n<script>'
2338 emit_js_data()
2339 print scripts_for_warning_groups
2340 print '</script>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002341 emit_buttons()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002342 # Warning messages are grouped by severities or project names.
2343 print '<br><div id="warning_groups"></div>'
2344 if args.byproject:
2345 print '<script>groupByProject();</script>'
2346 else:
2347 print '<script>groupBySeverity();</script>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002348 dump_fixed()
2349 dump_html_epilogue()
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002350
2351
2352##### Functions to count warnings and dump csv file. #########################
2353
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002354
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002355def description_for_csv(category):
2356 if not category['description']:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002357 return '?'
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002358 return category['description']
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002359
2360
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002361def string_for_csv(s):
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002362 # Only some Java warning desciptions have used quotation marks.
2363 # TODO(chh): if s has double quote character, s should be quoted.
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002364 if ',' in s:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002365 # TODO(chh): replace a double quote with two double quotes in s.
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002366 return '"{}"'.format(s)
2367 return s
2368
2369
2370def count_severity(sev, kind):
2371 """Count warnings of given severity."""
2372 total = 0
2373 for i in warn_patterns:
2374 if i['severity'] == sev and i['members']:
2375 n = len(i['members'])
2376 total += n
2377 warning = string_for_csv(kind + ': ' + description_for_csv(i))
2378 print '{},,{}'.format(n, warning)
2379 # print number of warnings for each project, ordered by project name.
2380 projects = i['projects'].keys()
2381 projects.sort()
2382 for p in projects:
2383 print '{},{},{}'.format(i['projects'][p], p, warning)
2384 print '{},,{}'.format(total, kind + ' warnings')
2385 return total
2386
2387
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002388# dump number of warnings in csv format to stdout
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002389def dump_csv():
2390 """Dump number of warnings in csv format to stdout."""
2391 sort_warnings()
2392 total = 0
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002393 for s in Severity.range:
2394 total += count_severity(s, Severity.column_headers[s])
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002395 print '{},,{}'.format(total, 'All warnings')
2396
2397
Meike Baumgärtnerac9d5df2016-09-28 10:48:06 -07002398def main():
2399 parse_input_file()
2400 if args.gencsv:
2401 dump_csv()
2402 else:
2403 dump_html()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002404
Meike Baumgärtnerac9d5df2016-09-28 10:48:06 -07002405
2406# Run main function if warn.py is the main program.
2407if __name__ == '__main__':
2408 main()