blob: 9dbe12e4256fdd1f656cfdfcc67ab8f520304558 [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'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07001699 simple_project_pattern('frameworks/av/media/common_time'),
1700 simple_project_pattern('frameworks/av/media/img_utils'),
1701 simple_project_pattern('frameworks/av/media/libcpustats'),
1702 simple_project_pattern('frameworks/av/media/libeffects'),
1703 simple_project_pattern('frameworks/av/media/libmediaplayerservice'),
1704 simple_project_pattern('frameworks/av/media/libmedia'),
1705 simple_project_pattern('frameworks/av/media/libstagefright'),
1706 simple_project_pattern('frameworks/av/media/mtp'),
1707 simple_project_pattern('frameworks/av/media/ndk'),
1708 simple_project_pattern('frameworks/av/media/utils'),
1709 project_name_and_pattern('frameworks/av/media/Other', 'frameworks/av/media'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001710 simple_project_pattern('frameworks/av/radio'),
1711 simple_project_pattern('frameworks/av/services'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07001712 simple_project_pattern('frameworks/av/soundtrigger'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001713 project_name_and_pattern('frameworks/av/Other', 'frameworks/av'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07001714 simple_project_pattern('frameworks/base/cmds'),
1715 simple_project_pattern('frameworks/base/core'),
1716 simple_project_pattern('frameworks/base/drm'),
1717 simple_project_pattern('frameworks/base/media'),
1718 simple_project_pattern('frameworks/base/libs'),
1719 simple_project_pattern('frameworks/base/native'),
1720 simple_project_pattern('frameworks/base/packages'),
1721 simple_project_pattern('frameworks/base/rs'),
1722 simple_project_pattern('frameworks/base/services'),
1723 simple_project_pattern('frameworks/base/tests'),
1724 simple_project_pattern('frameworks/base/tools'),
1725 project_name_and_pattern('frameworks/base/Other', 'frameworks/base'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001726 simple_project_pattern('frameworks/compile'),
1727 simple_project_pattern('frameworks/minikin'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07001728 simple_project_pattern('frameworks/ml'),
1729 simple_project_pattern('frameworks/native/cmds'),
1730 simple_project_pattern('frameworks/native/include'),
1731 simple_project_pattern('frameworks/native/libs'),
1732 simple_project_pattern('frameworks/native/opengl'),
1733 simple_project_pattern('frameworks/native/services'),
1734 simple_project_pattern('frameworks/native/vulkan'),
1735 project_name_and_pattern('frameworks/native/Other', 'frameworks/native'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001736 simple_project_pattern('frameworks/opt'),
1737 simple_project_pattern('frameworks/rs'),
1738 simple_project_pattern('frameworks/webview'),
1739 simple_project_pattern('frameworks/wilhelm'),
1740 project_name_and_pattern('frameworks/Other', 'frameworks'),
1741 simple_project_pattern('hardware/akm'),
1742 simple_project_pattern('hardware/broadcom'),
1743 simple_project_pattern('hardware/google'),
1744 simple_project_pattern('hardware/intel'),
1745 simple_project_pattern('hardware/interfaces'),
1746 simple_project_pattern('hardware/libhardware'),
1747 simple_project_pattern('hardware/libhardware_legacy'),
1748 simple_project_pattern('hardware/qcom'),
1749 simple_project_pattern('hardware/ril'),
1750 project_name_and_pattern('hardware/Other', 'hardware'),
1751 simple_project_pattern('kernel'),
1752 simple_project_pattern('libcore'),
1753 simple_project_pattern('libnativehelper'),
1754 simple_project_pattern('ndk'),
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001755 # match vendor/unbungled_google/packages before other packages
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001756 simple_project_pattern('unbundled_google'),
1757 simple_project_pattern('packages'),
1758 simple_project_pattern('pdk'),
1759 simple_project_pattern('prebuilts'),
1760 simple_project_pattern('system/bt'),
1761 simple_project_pattern('system/connectivity'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07001762 simple_project_pattern('system/core/adb'),
1763 simple_project_pattern('system/core/base'),
1764 simple_project_pattern('system/core/debuggerd'),
1765 simple_project_pattern('system/core/fastboot'),
1766 simple_project_pattern('system/core/fingerprintd'),
1767 simple_project_pattern('system/core/fs_mgr'),
1768 simple_project_pattern('system/core/gatekeeperd'),
1769 simple_project_pattern('system/core/healthd'),
1770 simple_project_pattern('system/core/include'),
1771 simple_project_pattern('system/core/init'),
1772 simple_project_pattern('system/core/libbacktrace'),
1773 simple_project_pattern('system/core/liblog'),
1774 simple_project_pattern('system/core/libpixelflinger'),
1775 simple_project_pattern('system/core/libprocessgroup'),
1776 simple_project_pattern('system/core/libsysutils'),
1777 simple_project_pattern('system/core/logcat'),
1778 simple_project_pattern('system/core/logd'),
1779 simple_project_pattern('system/core/run-as'),
1780 simple_project_pattern('system/core/sdcard'),
1781 simple_project_pattern('system/core/toolbox'),
1782 project_name_and_pattern('system/core/Other', 'system/core'),
1783 simple_project_pattern('system/extras/ANRdaemon'),
1784 simple_project_pattern('system/extras/cpustats'),
1785 simple_project_pattern('system/extras/crypto-perf'),
1786 simple_project_pattern('system/extras/ext4_utils'),
1787 simple_project_pattern('system/extras/f2fs_utils'),
1788 simple_project_pattern('system/extras/iotop'),
1789 simple_project_pattern('system/extras/libfec'),
1790 simple_project_pattern('system/extras/memory_replay'),
1791 simple_project_pattern('system/extras/micro_bench'),
1792 simple_project_pattern('system/extras/mmap-perf'),
1793 simple_project_pattern('system/extras/multinetwork'),
1794 simple_project_pattern('system/extras/perfprofd'),
1795 simple_project_pattern('system/extras/procrank'),
1796 simple_project_pattern('system/extras/runconuid'),
1797 simple_project_pattern('system/extras/showmap'),
1798 simple_project_pattern('system/extras/simpleperf'),
1799 simple_project_pattern('system/extras/su'),
1800 simple_project_pattern('system/extras/tests'),
1801 simple_project_pattern('system/extras/verity'),
1802 project_name_and_pattern('system/extras/Other', 'system/extras'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001803 simple_project_pattern('system/gatekeeper'),
1804 simple_project_pattern('system/keymaster'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07001805 simple_project_pattern('system/libhidl'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001806 simple_project_pattern('system/libhwbinder'),
1807 simple_project_pattern('system/media'),
1808 simple_project_pattern('system/netd'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07001809 simple_project_pattern('system/nvram'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001810 simple_project_pattern('system/security'),
1811 simple_project_pattern('system/sepolicy'),
1812 simple_project_pattern('system/tools'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07001813 simple_project_pattern('system/update_engine'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001814 simple_project_pattern('system/vold'),
1815 project_name_and_pattern('system/Other', 'system'),
1816 simple_project_pattern('toolchain'),
1817 simple_project_pattern('test'),
1818 simple_project_pattern('tools'),
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07001819 # match vendor/google* before vendor/
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001820 project_name_and_pattern('vendor/google', 'vendor/google.*'),
1821 project_name_and_pattern('vendor/non-google', 'vendor'),
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07001822 # keep out/obj and other patterns at the end.
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001823 ['out/obj',
1824 '.*/(gen|obj[^/]*)/(include|EXECUTABLES|SHARED_LIBRARIES|'
1825 'STATIC_LIBRARIES|NATIVE_TESTS)/.*: warning:'],
1826 ['other', '.*'] # all other unrecognized patterns
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001827]
1828
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001829project_patterns = []
1830project_names = []
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001831warning_messages = []
1832warning_records = []
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001833
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001834
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001835def initialize_arrays():
1836 """Complete global arrays before they are used."""
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001837 global project_names, project_patterns
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001838 project_names = [p[0] for p in project_list]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001839 project_patterns = [re.compile(p[1]) for p in project_list]
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001840 for w in warn_patterns:
1841 w['members'] = []
1842 if 'option' not in w:
1843 w['option'] = ''
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001844 # Each warning pattern has a 'projects' dictionary, that
1845 # maps a project name to number of warnings in that project.
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001846 w['projects'] = {}
1847
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001848
1849initialize_arrays()
1850
1851
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -07001852android_root = ''
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001853platform_version = 'unknown'
1854target_product = 'unknown'
1855target_variant = 'unknown'
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001856
1857
1858##### Data and functions to dump html file. ##################################
1859
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001860html_head_scripts = """\
1861 <script type="text/javascript">
1862 function expand(id) {
1863 var e = document.getElementById(id);
1864 var f = document.getElementById(id + "_mark");
1865 if (e.style.display == 'block') {
1866 e.style.display = 'none';
1867 f.innerHTML = '&#x2295';
1868 }
1869 else {
1870 e.style.display = 'block';
1871 f.innerHTML = '&#x2296';
1872 }
1873 };
1874 function expandCollapse(show) {
1875 for (var id = 1; ; id++) {
1876 var e = document.getElementById(id + "");
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07001877 var f = document.getElementById(id + "_mark");
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001878 if (!e || !f) break;
1879 e.style.display = (show ? 'block' : 'none');
1880 f.innerHTML = (show ? '&#x2296' : '&#x2295');
1881 }
1882 };
1883 </script>
1884 <style type="text/css">
1885 th,td{border-collapse:collapse; border:1px solid black;}
1886 .button{color:blue;font-size:110%;font-weight:bolder;}
1887 .bt{color:black;background-color:transparent;border:none;outline:none;
1888 font-size:140%;font-weight:bolder;}
1889 .c0{background-color:#e0e0e0;}
1890 .c1{background-color:#d0d0d0;}
1891 .t1{border-collapse:collapse; width:100%; border:1px solid black;}
1892 </style>
1893 <script src="https://www.gstatic.com/charts/loader.js"></script>
1894"""
Marco Nelissen594375d2009-07-14 09:04:04 -07001895
Marco Nelissen594375d2009-07-14 09:04:04 -07001896
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001897def html_big(param):
1898 return '<font size="+2">' + param + '</font>'
Marco Nelissen594375d2009-07-14 09:04:04 -07001899
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07001900
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001901def dump_html_prologue(title):
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001902 print '<html>\n<head>'
1903 print '<title>' + title + '</title>'
1904 print html_head_scripts
1905 emit_stats_by_project()
1906 print '</head>\n<body>'
1907 print html_big(title)
1908 print '<p>'
Marco Nelissen594375d2009-07-14 09:04:04 -07001909
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001910
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001911def dump_html_epilogue():
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001912 print '</body>\n</head>\n</html>'
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001913
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001914
1915def sort_warnings():
1916 for i in warn_patterns:
1917 i['members'] = sorted(set(i['members']))
1918
1919
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001920def emit_stats_by_project():
1921 """Dump a google chart table of warnings per project and severity."""
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001922 # warnings[p][s] is number of warnings in project p of severity s.
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001923 warnings = {p: {s: 0 for s in Severity.range} for p in project_names}
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001924 for i in warn_patterns:
1925 s = i['severity']
1926 for p in i['projects']:
1927 warnings[p][s] += i['projects'][p]
1928
1929 # total_by_project[p] is number of warnings in project p.
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001930 total_by_project = {p: sum(warnings[p][s] for s in Severity.range)
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001931 for p in project_names}
1932
1933 # total_by_severity[s] is number of warnings of severity s.
1934 total_by_severity = {s: sum(warnings[p][s] for p in project_names)
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001935 for s in Severity.range}
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001936
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001937 # emit table header
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001938 stats_header = ['Project']
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001939 for s in Severity.range:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001940 if total_by_severity[s]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001941 stats_header.append("<span style='background-color:{}'>{}</span>".
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001942 format(Severity.colors[s],
1943 Severity.column_headers[s]))
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001944 stats_header.append('TOTAL')
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001945
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001946 # emit a row of warning counts per project, skip no-warning projects
1947 total_all_projects = 0
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001948 stats_rows = []
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001949 for p in project_names:
1950 if total_by_project[p]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001951 one_row = [p]
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001952 for s in Severity.range:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001953 if total_by_severity[s]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001954 one_row.append(warnings[p][s])
1955 one_row.append(total_by_project[p])
1956 stats_rows.append(one_row)
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001957 total_all_projects += total_by_project[p]
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001958
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001959 # emit a row of warning counts per severity
1960 total_all_severities = 0
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001961 one_row = ['<b>TOTAL</b>']
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001962 for s in Severity.range:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001963 if total_by_severity[s]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001964 one_row.append(total_by_severity[s])
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001965 total_all_severities += total_by_severity[s]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001966 one_row.append(total_all_projects)
1967 stats_rows.append(one_row)
1968 print '<script>'
1969 emit_const_string_array('StatsHeader', stats_header)
1970 emit_const_object_array('StatsRows', stats_rows)
1971 print draw_table_javascript
1972 print '</script>'
Marco Nelissen594375d2009-07-14 09:04:04 -07001973
1974
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001975def dump_stats():
1976 """Dump some stats about total number of warnings and such."""
1977 known = 0
1978 skipped = 0
1979 unknown = 0
1980 sort_warnings()
1981 for i in warn_patterns:
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001982 if i['severity'] == Severity.UNKNOWN:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001983 unknown += len(i['members'])
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001984 elif i['severity'] == Severity.SKIP:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001985 skipped += len(i['members'])
Ian Rogersf3829732016-05-10 12:06:01 -07001986 else:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001987 known += len(i['members'])
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001988 print 'Number of classified warnings: <b>' + str(known) + '</b><br>'
1989 print 'Number of skipped warnings: <b>' + str(skipped) + '</b><br>'
1990 print 'Number of unclassified warnings: <b>' + str(unknown) + '</b><br>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001991 total = unknown + known + skipped
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001992 extra_msg = ''
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001993 if total < 1000:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001994 extra_msg = ' (low count may indicate incremental build)'
1995 print 'Total number of warnings: <b>' + str(total) + '</b>' + extra_msg
Marco Nelissen594375d2009-07-14 09:04:04 -07001996
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07001997
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001998# New base table of warnings, [severity, warn_id, project, warning_message]
1999# Need buttons to show warnings in different grouping options.
2000# (1) Current, group by severity, id for each warning pattern
2001# sort by severity, warn_id, warning_message
2002# (2) Current --byproject, group by severity,
2003# id for each warning pattern + project name
2004# sort by severity, warn_id, project, warning_message
2005# (3) New, group by project + severity,
2006# id for each warning pattern
2007# sort by project, severity, warn_id, warning_message
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002008def emit_buttons():
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002009 print ('<button class="button" onclick="expandCollapse(1);">'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002010 'Expand all warnings</button>\n'
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002011 '<button class="button" onclick="expandCollapse(0);">'
2012 'Collapse all warnings</button>\n'
2013 '<button class="button" onclick="groupBySeverity();">'
2014 'Group warnings by severity</button>\n'
2015 '<button class="button" onclick="groupByProject();">'
2016 'Group warnings by project</button><br>')
Marco Nelissen594375d2009-07-14 09:04:04 -07002017
2018
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002019def all_patterns(category):
2020 patterns = ''
2021 for i in category['patterns']:
2022 patterns += i
2023 patterns += ' / '
2024 return patterns
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002025
2026
2027def dump_fixed():
2028 """Show which warnings no longer occur."""
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002029 anchor = 'fixed_warnings'
2030 mark = anchor + '_mark'
2031 print ('\n<br><p style="background-color:lightblue"><b>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002032 '<button id="' + mark + '" '
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002033 'class="bt" onclick="expand(\'' + anchor + '\');">'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002034 '&#x2295</button> Fixed warnings. '
2035 'No more occurrences. Please consider turning these into '
2036 'errors if possible, before they are reintroduced in to the build'
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002037 ':</b></p>')
2038 print '<blockquote>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002039 fixed_patterns = []
2040 for i in warn_patterns:
2041 if not i['members']:
2042 fixed_patterns.append(i['description'] + ' (' +
2043 all_patterns(i) + ')')
2044 if i['option']:
2045 fixed_patterns.append(' ' + i['option'])
2046 fixed_patterns.sort()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002047 print '<div id="' + anchor + '" style="display:none;"><table>'
2048 cur_row_class = 0
2049 for text in fixed_patterns:
2050 cur_row_class = 1 - cur_row_class
2051 # remove last '\n'
2052 t = text[:-1] if text[-1] == '\n' else text
2053 print '<tr><td class="c' + str(cur_row_class) + '">' + t + '</td></tr>'
2054 print '</table></div>'
2055 print '</blockquote>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002056
2057
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002058def find_project_index(line):
2059 for p in range(len(project_patterns)):
2060 if project_patterns[p].match(line):
2061 return p
2062 return -1
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002063
2064
2065def classify_warning(line):
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002066 for i in range(len(warn_patterns)):
2067 w = warn_patterns[i]
2068 for cpat in w['compiled_patterns']:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002069 if cpat.match(line):
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002070 w['members'].append(line)
2071 p = find_project_index(line)
2072 index = len(warning_messages)
2073 warning_messages.append(line)
2074 warning_records.append([i, p, index])
2075 pname = '???' if p < 0 else project_names[p]
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002076 # Count warnings by project.
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002077 if pname in w['projects']:
2078 w['projects'][pname] += 1
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002079 else:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002080 w['projects'][pname] = 1
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002081 return
2082 else:
2083 # If we end up here, there was a problem parsing the log
2084 # probably caused by 'make -j' mixing the output from
2085 # 2 or more concurrent compiles
2086 pass
Marco Nelissen594375d2009-07-14 09:04:04 -07002087
2088
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002089def compile_patterns():
2090 """Precompiling every pattern speeds up parsing by about 30x."""
2091 for i in warn_patterns:
2092 i['compiled_patterns'] = []
2093 for pat in i['patterns']:
2094 i['compiled_patterns'].append(re.compile(pat))
2095
2096
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -07002097def find_android_root(path):
2098 """Set and return android_root path if it is found."""
2099 global android_root
2100 parts = path.split('/')
2101 for idx in reversed(range(2, len(parts))):
2102 root_path = '/'.join(parts[:idx])
2103 # Android root directory should contain this script.
2104 if os.path.exists(root_path + '/build/tools/warn.py'):
2105 android_root = root_path
2106 return root_path
2107 return ''
2108
2109
2110def remove_android_root_prefix(path):
2111 """Remove android_root prefix from path if it is found."""
2112 if path.startswith(android_root):
2113 return path[1 + len(android_root):]
2114 else:
2115 return path
2116
2117
2118def normalize_path(path):
2119 """Normalize file path relative to android_root."""
2120 # If path is not an absolute path, just normalize it.
2121 path = os.path.normpath(path)
2122 if path[0] != '/':
2123 return path
2124 # Remove known prefix of root path and normalize the suffix.
2125 if android_root or find_android_root(path):
2126 return remove_android_root_prefix(path)
2127 else:
2128 return path
2129
2130
2131def normalize_warning_line(line):
2132 """Normalize file path relative to android_root in a warning line."""
2133 # replace fancy quotes with plain ol' quotes
2134 line = line.replace('‘', "'")
2135 line = line.replace('’', "'")
2136 line = line.strip()
2137 first_column = line.find(':')
2138 if first_column > 0:
2139 return normalize_path(line[:first_column]) + line[first_column:]
2140 else:
2141 return line
2142
2143
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002144def parse_input_file():
2145 """Parse input file, match warning lines."""
2146 global platform_version
2147 global target_product
2148 global target_variant
2149 infile = open(args.buildlog, 'r')
2150 line_counter = 0
2151
Chih-Hung Hsieh5722f922016-10-11 15:33:19 -07002152 # handle only warning messages with a file path
2153 warning_pattern = re.compile('^[^ ]*/[^ ]*: warning: .*')
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002154 compile_patterns()
2155
2156 # read the log file and classify all the warnings
2157 warning_lines = set()
2158 for line in infile:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002159 if warning_pattern.match(line):
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -07002160 line = normalize_warning_line(line)
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002161 if line not in warning_lines:
2162 classify_warning(line)
2163 warning_lines.add(line)
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002164 elif line_counter < 50:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002165 # save a little bit of time by only doing this for the first few lines
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002166 line_counter += 1
2167 m = re.search('(?<=^PLATFORM_VERSION=).*', line)
2168 if m is not None:
2169 platform_version = m.group(0)
2170 m = re.search('(?<=^TARGET_PRODUCT=).*', line)
2171 if m is not None:
2172 target_product = m.group(0)
2173 m = re.search('(?<=^TARGET_BUILD_VARIANT=).*', line)
2174 if m is not None:
2175 target_variant = m.group(0)
2176
2177
Chih-Hung Hsieh5722f922016-10-11 15:33:19 -07002178# Return s with escaped backslash and quotation characters.
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002179def escape_string(s):
Chih-Hung Hsieh5722f922016-10-11 15:33:19 -07002180 return s.replace('\\', '\\\\').replace('"', '\\"')
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002181
2182
2183# Return s without trailing '\n' and escape the quotation characters.
2184def strip_escape_string(s):
2185 if not s:
2186 return s
2187 s = s[:-1] if s[-1] == '\n' else s
2188 return escape_string(s)
2189
2190
2191def emit_warning_array(name):
2192 print 'var warning_{} = ['.format(name)
2193 for i in range(len(warn_patterns)):
2194 print '{},'.format(warn_patterns[i][name])
2195 print '];'
2196
2197
2198def emit_warning_arrays():
2199 emit_warning_array('severity')
2200 print 'var warning_description = ['
2201 for i in range(len(warn_patterns)):
2202 if warn_patterns[i]['members']:
2203 print '"{}",'.format(escape_string(warn_patterns[i]['description']))
2204 else:
2205 print '"",' # no such warning
2206 print '];'
2207
2208scripts_for_warning_groups = """
2209 function compareMessages(x1, x2) { // of the same warning type
2210 return (WarningMessages[x1[2]] <= WarningMessages[x2[2]]) ? -1 : 1;
2211 }
2212 function byMessageCount(x1, x2) {
2213 return x2[2] - x1[2]; // reversed order
2214 }
2215 function bySeverityMessageCount(x1, x2) {
2216 // orer by severity first
2217 if (x1[1] != x2[1])
2218 return x1[1] - x2[1];
2219 return byMessageCount(x1, x2);
2220 }
2221 const ParseLinePattern = /^([^ :]+):(\\d+):(.+)/;
2222 function addURL(line) {
2223 if (FlagURL == "") return line;
2224 if (FlagSeparator == "") {
2225 return line.replace(ParseLinePattern,
2226 "<a href='" + FlagURL + "/$1'>$1</a>:$2:$3");
2227 }
2228 return line.replace(ParseLinePattern,
2229 "<a href='" + FlagURL + "/$1" + FlagSeparator + "$2'>$1:$2</a>:$3");
2230 }
2231 function createArrayOfDictionaries(n) {
2232 var result = [];
2233 for (var i=0; i<n; i++) result.push({});
2234 return result;
2235 }
2236 function groupWarningsBySeverity() {
2237 // groups is an array of dictionaries,
2238 // each dictionary maps from warning type to array of warning messages.
2239 var groups = createArrayOfDictionaries(SeverityColors.length);
2240 for (var i=0; i<Warnings.length; i++) {
2241 var w = Warnings[i][0];
2242 var s = WarnPatternsSeverity[w];
2243 var k = w.toString();
2244 if (!(k in groups[s]))
2245 groups[s][k] = [];
2246 groups[s][k].push(Warnings[i]);
2247 }
2248 return groups;
2249 }
2250 function groupWarningsByProject() {
2251 var groups = createArrayOfDictionaries(ProjectNames.length);
2252 for (var i=0; i<Warnings.length; i++) {
2253 var w = Warnings[i][0];
2254 var p = Warnings[i][1];
2255 var k = w.toString();
2256 if (!(k in groups[p]))
2257 groups[p][k] = [];
2258 groups[p][k].push(Warnings[i]);
2259 }
2260 return groups;
2261 }
2262 var GlobalAnchor = 0;
2263 function createWarningSection(header, color, group) {
2264 var result = "";
2265 var groupKeys = [];
2266 var totalMessages = 0;
2267 for (var k in group) {
2268 totalMessages += group[k].length;
2269 groupKeys.push([k, WarnPatternsSeverity[parseInt(k)], group[k].length]);
2270 }
2271 groupKeys.sort(bySeverityMessageCount);
2272 for (var idx=0; idx<groupKeys.length; idx++) {
2273 var k = groupKeys[idx][0];
2274 var messages = group[k];
2275 var w = parseInt(k);
2276 var wcolor = SeverityColors[WarnPatternsSeverity[w]];
2277 var description = WarnPatternsDescription[w];
2278 if (description.length == 0)
2279 description = "???";
2280 GlobalAnchor += 1;
2281 result += "<table class='t1'><tr bgcolor='" + wcolor + "'><td>" +
2282 "<button class='bt' id='" + GlobalAnchor + "_mark" +
2283 "' onclick='expand(\\"" + GlobalAnchor + "\\");'>" +
2284 "&#x2295</button> " +
2285 description + " (" + messages.length + ")</td></tr></table>";
2286 result += "<div id='" + GlobalAnchor +
2287 "' style='display:none;'><table class='t1'>";
2288 var c = 0;
2289 messages.sort(compareMessages);
2290 for (var i=0; i<messages.length; i++) {
2291 result += "<tr><td class='c" + c + "'>" +
2292 addURL(WarningMessages[messages[i][2]]) + "</td></tr>";
2293 c = 1 - c;
2294 }
2295 result += "</table></div>";
2296 }
2297 if (result.length > 0) {
2298 return "<br><span style='background-color:" + color + "'><b>" +
2299 header + ": " + totalMessages +
2300 "</b></span><blockquote><table class='t1'>" +
2301 result + "</table></blockquote>";
2302
2303 }
2304 return ""; // empty section
2305 }
2306 function generateSectionsBySeverity() {
2307 var result = "";
2308 var groups = groupWarningsBySeverity();
2309 for (s=0; s<SeverityColors.length; s++) {
2310 result += createWarningSection(SeverityHeaders[s], SeverityColors[s], groups[s]);
2311 }
2312 return result;
2313 }
2314 function generateSectionsByProject() {
2315 var result = "";
2316 var groups = groupWarningsByProject();
2317 for (i=0; i<groups.length; i++) {
2318 result += createWarningSection(ProjectNames[i], 'lightgrey', groups[i]);
2319 }
2320 return result;
2321 }
2322 function groupWarnings(generator) {
2323 GlobalAnchor = 0;
2324 var e = document.getElementById("warning_groups");
2325 e.innerHTML = generator();
2326 }
2327 function groupBySeverity() {
2328 groupWarnings(generateSectionsBySeverity);
2329 }
2330 function groupByProject() {
2331 groupWarnings(generateSectionsByProject);
2332 }
2333"""
2334
2335
2336# Emit a JavaScript const string
2337def emit_const_string(name, value):
2338 print 'const ' + name + ' = "' + escape_string(value) + '";'
2339
2340
2341# Emit a JavaScript const integer array.
2342def emit_const_int_array(name, array):
2343 print 'const ' + name + ' = ['
2344 for n in array:
2345 print str(n) + ','
2346 print '];'
2347
2348
2349# Emit a JavaScript const string array.
2350def emit_const_string_array(name, array):
2351 print 'const ' + name + ' = ['
2352 for s in array:
2353 print '"' + strip_escape_string(s) + '",'
2354 print '];'
2355
2356
2357# Emit a JavaScript const object array.
2358def emit_const_object_array(name, array):
2359 print 'const ' + name + ' = ['
2360 for x in array:
2361 print str(x) + ','
2362 print '];'
2363
2364
2365def emit_js_data():
2366 """Dump dynamic HTML page's static JavaScript data."""
2367 emit_const_string('FlagURL', args.url if args.url else '')
2368 emit_const_string('FlagSeparator', args.separator if args.separator else '')
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002369 emit_const_string_array('SeverityColors', Severity.colors)
2370 emit_const_string_array('SeverityHeaders', Severity.headers)
2371 emit_const_string_array('SeverityColumnHeaders', Severity.column_headers)
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002372 emit_const_string_array('ProjectNames', project_names)
2373 emit_const_int_array('WarnPatternsSeverity',
2374 [w['severity'] for w in warn_patterns])
2375 emit_const_string_array('WarnPatternsDescription',
2376 [w['description'] for w in warn_patterns])
2377 emit_const_string_array('WarnPatternsOption',
2378 [w['option'] for w in warn_patterns])
2379 emit_const_string_array('WarningMessages', warning_messages)
2380 emit_const_object_array('Warnings', warning_records)
2381
2382draw_table_javascript = """
2383google.charts.load('current', {'packages':['table']});
2384google.charts.setOnLoadCallback(drawTable);
2385function drawTable() {
2386 var data = new google.visualization.DataTable();
2387 data.addColumn('string', StatsHeader[0]);
2388 for (var i=1; i<StatsHeader.length; i++) {
2389 data.addColumn('number', StatsHeader[i]);
2390 }
2391 data.addRows(StatsRows);
2392 for (var i=0; i<StatsRows.length; i++) {
2393 for (var j=0; j<StatsHeader.length; j++) {
2394 data.setProperty(i, j, 'style', 'border:1px solid black;');
2395 }
2396 }
2397 var table = new google.visualization.Table(document.getElementById('stats_table'));
2398 table.draw(data, {allowHtml: true, alternatingRowStyle: true});
2399}
2400"""
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002401
2402
2403def dump_html():
2404 """Dump the html output to stdout."""
2405 dump_html_prologue('Warnings for ' + platform_version + ' - ' +
2406 target_product + ' - ' + target_variant)
2407 dump_stats()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002408 print '<br><div id="stats_table"></div><br>'
2409 print '\n<script>'
2410 emit_js_data()
2411 print scripts_for_warning_groups
2412 print '</script>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002413 emit_buttons()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002414 # Warning messages are grouped by severities or project names.
2415 print '<br><div id="warning_groups"></div>'
2416 if args.byproject:
2417 print '<script>groupByProject();</script>'
2418 else:
2419 print '<script>groupBySeverity();</script>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002420 dump_fixed()
2421 dump_html_epilogue()
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002422
2423
2424##### Functions to count warnings and dump csv file. #########################
2425
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002426
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002427def description_for_csv(category):
2428 if not category['description']:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002429 return '?'
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002430 return category['description']
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002431
2432
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002433def string_for_csv(s):
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002434 # Only some Java warning desciptions have used quotation marks.
2435 # TODO(chh): if s has double quote character, s should be quoted.
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002436 if ',' in s:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002437 # TODO(chh): replace a double quote with two double quotes in s.
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002438 return '"{}"'.format(s)
2439 return s
2440
2441
2442def count_severity(sev, kind):
2443 """Count warnings of given severity."""
2444 total = 0
2445 for i in warn_patterns:
2446 if i['severity'] == sev and i['members']:
2447 n = len(i['members'])
2448 total += n
2449 warning = string_for_csv(kind + ': ' + description_for_csv(i))
2450 print '{},,{}'.format(n, warning)
2451 # print number of warnings for each project, ordered by project name.
2452 projects = i['projects'].keys()
2453 projects.sort()
2454 for p in projects:
2455 print '{},{},{}'.format(i['projects'][p], p, warning)
2456 print '{},,{}'.format(total, kind + ' warnings')
2457 return total
2458
2459
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002460# dump number of warnings in csv format to stdout
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002461def dump_csv():
2462 """Dump number of warnings in csv format to stdout."""
2463 sort_warnings()
2464 total = 0
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002465 for s in Severity.range:
2466 total += count_severity(s, Severity.column_headers[s])
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002467 print '{},,{}'.format(total, 'All warnings')
2468
2469
Meike Baumgärtnerac9d5df2016-09-28 10:48:06 -07002470def main():
2471 parse_input_file()
2472 if args.gencsv:
2473 dump_csv()
2474 else:
2475 dump_html()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002476
Meike Baumgärtnerac9d5df2016-09-28 10:48:06 -07002477
2478# Run main function if warn.py is the main program.
2479if __name__ == '__main__':
2480 main()