blob: 44ad368f8698b45a0be3fd063206f4b6ec97b8f4 [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():
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -070076
Ian Rogersf3829732016-05-10 12:06:01 -070077import argparse
Sam Saccone03aaa7e2017-04-10 15:37:47 -070078import csv
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -070079import multiprocessing
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -070080import os
Marco Nelissen594375d2009-07-14 09:04:04 -070081import re
Chih-Hung Hsieh76d00652016-11-09 18:19:05 -080082import signal
83import sys
Marco Nelissen594375d2009-07-14 09:04:04 -070084
Ian Rogersf3829732016-05-10 12:06:01 -070085parser = argparse.ArgumentParser(description='Convert a build log into HTML')
Sam Saccone03aaa7e2017-04-10 15:37:47 -070086parser.add_argument('--csvpath',
87 help='Save CSV warning file to the passed absolute path',
88 default=None)
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -070089parser.add_argument('--gencsv',
90 help='Generate a CSV file with number of various warnings',
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -070091 action='store_true',
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -070092 default=False)
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -070093parser.add_argument('--byproject',
94 help='Separate warnings in HTML output by project names',
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -070095 action='store_true',
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -070096 default=False)
Ian Rogersf3829732016-05-10 12:06:01 -070097parser.add_argument('--url',
98 help='Root URL of an Android source code tree prefixed '
99 'before files in warnings')
100parser.add_argument('--separator',
101 help='Separator between the end of a URL and the line '
102 'number argument. e.g. #')
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -0700103parser.add_argument('--processes',
104 type=int,
105 default=multiprocessing.cpu_count(),
106 help='Number of parallel processes to process warnings')
Ian Rogersf3829732016-05-10 12:06:01 -0700107parser.add_argument(dest='buildlog', metavar='build.log',
108 help='Path to build.log file')
109args = parser.parse_args()
Marco Nelissen594375d2009-07-14 09:04:04 -0700110
Marco Nelissen594375d2009-07-14 09:04:04 -0700111
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700112class Severity(object):
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700113 """Severity levels and attributes."""
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -0700114 # numbered by dump order
115 FIXMENOW = 0
116 HIGH = 1
117 MEDIUM = 2
118 LOW = 3
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -0700119 ANALYZER = 4
120 TIDY = 5
121 HARMLESS = 6
122 UNKNOWN = 7
123 SKIP = 8
124 range = range(SKIP + 1)
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700125 attributes = [
126 # pylint:disable=bad-whitespace
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700127 ['fuchsia', 'FixNow', 'Critical warnings, fix me now'],
128 ['red', 'High', 'High severity warnings'],
129 ['orange', 'Medium', 'Medium severity warnings'],
130 ['yellow', 'Low', 'Low severity warnings'],
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -0700131 ['hotpink', 'Analyzer', 'Clang-Analyzer warnings'],
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700132 ['peachpuff', 'Tidy', 'Clang-Tidy warnings'],
133 ['limegreen', 'Harmless', 'Harmless warnings'],
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -0700134 ['lightblue', 'Unknown', 'Unknown warnings'],
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700135 ['grey', 'Unhandled', 'Unhandled warnings']
136 ]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -0700137 colors = [a[0] for a in attributes]
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700138 column_headers = [a[1] for a in attributes]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -0700139 headers = [a[2] for a in attributes]
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700140
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -0700141
142def tidy_warn_pattern(description, pattern):
143 return {
144 'category': 'C/C++',
145 'severity': Severity.TIDY,
146 'description': 'clang-tidy ' + description,
147 'patterns': [r'.*: .+\[' + pattern + r'\]$']
148 }
149
150
151def simple_tidy_warn_pattern(description):
152 return tidy_warn_pattern(description, description)
153
154
155def group_tidy_warn_pattern(description):
156 return tidy_warn_pattern(description, description + r'-.+')
157
158
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700159warn_patterns = [
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700160 # pylint:disable=line-too-long,g-inconsistent-quotes
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -0700161 {'category': 'C/C++', 'severity': Severity.ANALYZER,
162 'description': 'clang-analyzer Security warning',
163 'patterns': [r".*: warning: .+\[clang-analyzer-security.*\]"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700164 {'category': 'make', 'severity': Severity.MEDIUM,
165 'description': 'make: overriding commands/ignoring old commands',
166 'patterns': [r".*: warning: overriding commands for target .+",
167 r".*: warning: ignoring old commands for target .+"]},
168 {'category': 'make', 'severity': Severity.HIGH,
169 'description': 'make: LOCAL_CLANG is false',
170 'patterns': [r".*: warning: LOCAL_CLANG is set to false"]},
171 {'category': 'make', 'severity': Severity.HIGH,
172 'description': 'SDK App using platform shared library',
173 'patterns': [r".*: warning: .+ \(.*app:sdk.*\) should not link to .+ \(native:platform\)"]},
174 {'category': 'make', 'severity': Severity.HIGH,
175 'description': 'System module linking to a vendor module',
176 'patterns': [r".*: warning: .+ \(.+\) should not link to .+ \(partition:.+\)"]},
177 {'category': 'make', 'severity': Severity.MEDIUM,
178 'description': 'Invalid SDK/NDK linking',
179 'patterns': [r".*: warning: .+ \(.+\) should not link to .+ \(.+\)"]},
180 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wimplicit-function-declaration',
181 'description': 'Implicit function declaration',
182 'patterns': [r".*: warning: implicit declaration of function .+",
183 r".*: warning: implicitly declaring library function"]},
184 {'category': 'C/C++', 'severity': Severity.SKIP,
185 'description': 'skip, conflicting types for ...',
186 'patterns': [r".*: warning: conflicting types for '.+'"]},
187 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wtype-limits',
188 'description': 'Expression always evaluates to true or false',
189 'patterns': [r".*: warning: comparison is always .+ due to limited range of data type",
190 r".*: warning: comparison of unsigned .*expression .+ is always true",
191 r".*: warning: comparison of unsigned .*expression .+ is always false"]},
192 {'category': 'C/C++', 'severity': Severity.HIGH,
193 'description': 'Potential leak of memory, bad free, use after free',
194 'patterns': [r".*: warning: Potential leak of memory",
195 r".*: warning: Potential memory leak",
196 r".*: warning: Memory allocated by alloca\(\) should not be deallocated",
197 r".*: warning: Memory allocated by .+ should be deallocated by .+ not .+",
198 r".*: warning: 'delete' applied to a pointer that was allocated",
199 r".*: warning: Use of memory after it is freed",
200 r".*: warning: Argument to .+ is the address of .+ variable",
201 r".*: warning: Argument to free\(\) is offset by .+ of memory allocated by",
202 r".*: warning: Attempt to .+ released memory"]},
203 {'category': 'C/C++', 'severity': Severity.HIGH,
204 'description': 'Use transient memory for control value',
205 'patterns': [r".*: warning: .+Using such transient memory for the control value is .*dangerous."]},
206 {'category': 'C/C++', 'severity': Severity.HIGH,
207 'description': 'Return address of stack memory',
208 'patterns': [r".*: warning: Address of stack memory .+ returned to caller",
209 r".*: warning: Address of stack memory .+ will be a dangling reference"]},
210 {'category': 'C/C++', 'severity': Severity.HIGH,
211 'description': 'Problem with vfork',
212 'patterns': [r".*: warning: This .+ is prohibited after a successful vfork",
213 r".*: warning: Call to function '.+' is insecure "]},
214 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': 'infinite-recursion',
215 'description': 'Infinite recursion',
216 'patterns': [r".*: warning: all paths through this function will call itself"]},
217 {'category': 'C/C++', 'severity': Severity.HIGH,
218 'description': 'Potential buffer overflow',
219 'patterns': [r".*: warning: Size argument is greater than .+ the destination buffer",
220 r".*: warning: Potential buffer overflow.",
221 r".*: warning: String copy function overflows destination buffer"]},
222 {'category': 'C/C++', 'severity': Severity.MEDIUM,
223 'description': 'Incompatible pointer types',
224 'patterns': [r".*: warning: assignment from incompatible pointer type",
225 r".*: warning: return from incompatible pointer type",
226 r".*: warning: passing argument [0-9]+ of '.*' from incompatible pointer type",
227 r".*: warning: initialization from incompatible pointer type"]},
228 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-fno-builtin',
229 'description': 'Incompatible declaration of built in function',
230 'patterns': [r".*: warning: incompatible implicit declaration of built-in function .+"]},
231 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wincompatible-library-redeclaration',
232 'description': 'Incompatible redeclaration of library function',
233 'patterns': [r".*: warning: incompatible redeclaration of library function .+"]},
234 {'category': 'C/C++', 'severity': Severity.HIGH,
235 'description': 'Null passed as non-null argument',
236 'patterns': [r".*: warning: Null passed to a callee that requires a non-null"]},
237 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused-parameter',
238 'description': 'Unused parameter',
239 'patterns': [r".*: warning: unused parameter '.*'"]},
240 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused',
241 'description': 'Unused function, variable or label',
242 'patterns': [r".*: warning: '.+' defined but not used",
243 r".*: warning: unused function '.+'",
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -0700244 r".*: warning: lambda capture .* is not used",
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700245 r".*: warning: private field '.+' is not used",
246 r".*: warning: unused variable '.+'"]},
247 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused-value',
248 'description': 'Statement with no effect or result unused',
249 'patterns': [r".*: warning: statement with no effect",
250 r".*: warning: expression result unused"]},
251 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused-result',
252 'description': 'Ignoreing return value of function',
253 'patterns': [r".*: warning: ignoring return value of function .+Wunused-result"]},
254 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-field-initializers',
255 'description': 'Missing initializer',
256 'patterns': [r".*: warning: missing initializer"]},
257 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wdelete-non-virtual-dtor',
258 'description': 'Need virtual destructor',
259 'patterns': [r".*: warning: delete called .* has virtual functions but non-virtual destructor"]},
260 {'category': 'cont.', 'severity': Severity.SKIP,
261 'description': 'skip, near initialization for ...',
262 'patterns': [r".*: warning: \(near initialization for '.+'\)"]},
263 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wdate-time',
264 'description': 'Expansion of data or time macro',
265 'patterns': [r".*: warning: expansion of date or time macro is not reproducible"]},
266 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wformat',
267 'description': 'Format string does not match arguments',
268 'patterns': [r".*: warning: format '.+' expects type '.+', but argument [0-9]+ has type '.+'",
269 r".*: warning: more '%' conversions than data arguments",
270 r".*: warning: data argument not used by format string",
271 r".*: warning: incomplete format specifier",
272 r".*: warning: unknown conversion type .* in format",
273 r".*: warning: format .+ expects .+ but argument .+Wformat=",
274 r".*: warning: field precision should have .+ but argument has .+Wformat",
275 r".*: warning: format specifies type .+ but the argument has .*type .+Wformat"]},
276 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wformat-extra-args',
277 'description': 'Too many arguments for format string',
278 'patterns': [r".*: warning: too many arguments for format"]},
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -0700279 {'category': 'C/C++', 'severity': Severity.MEDIUM,
280 'description': 'Too many arguments in call',
281 'patterns': [r".*: warning: too many arguments in call to "]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700282 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wformat-invalid-specifier',
283 'description': 'Invalid format specifier',
284 'patterns': [r".*: warning: invalid .+ specifier '.+'.+format-invalid-specifier"]},
285 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsign-compare',
286 'description': 'Comparison between signed and unsigned',
287 'patterns': [r".*: warning: comparison between signed and unsigned",
288 r".*: warning: comparison of promoted \~unsigned with unsigned",
289 r".*: warning: signed and unsigned type in conditional expression"]},
290 {'category': 'C/C++', 'severity': Severity.MEDIUM,
291 'description': 'Comparison between enum and non-enum',
292 'patterns': [r".*: warning: enumeral and non-enumeral type in conditional expression"]},
293 {'category': 'libpng', 'severity': Severity.MEDIUM,
294 'description': 'libpng: zero area',
295 'patterns': [r".*libpng warning: Ignoring attempt to set cHRM RGB triangle with zero area"]},
296 {'category': 'aapt', 'severity': Severity.MEDIUM,
297 'description': 'aapt: no comment for public symbol',
298 'patterns': [r".*: warning: No comment for public symbol .+"]},
299 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-braces',
300 'description': 'Missing braces around initializer',
301 'patterns': [r".*: warning: missing braces around initializer.*"]},
302 {'category': 'C/C++', 'severity': Severity.HARMLESS,
303 'description': 'No newline at end of file',
304 'patterns': [r".*: warning: no newline at end of file"]},
305 {'category': 'C/C++', 'severity': Severity.HARMLESS,
306 'description': 'Missing space after macro name',
307 'patterns': [r".*: warning: missing whitespace after the macro name"]},
308 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wcast-align',
309 'description': 'Cast increases required alignment',
310 'patterns': [r".*: warning: cast from .* to .* increases required alignment .*"]},
311 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wcast-qual',
312 'description': 'Qualifier discarded',
313 'patterns': [r".*: warning: passing argument [0-9]+ of '.+' discards qualifiers from pointer target type",
314 r".*: warning: assignment discards qualifiers from pointer target type",
315 r".*: warning: passing .+ to parameter of type .+ discards qualifiers",
316 r".*: warning: assigning to .+ from .+ discards qualifiers",
317 r".*: warning: initializing .+ discards qualifiers .+types-discards-qualifiers",
318 r".*: warning: return discards qualifiers from pointer target type"]},
319 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunknown-attributes',
320 'description': 'Unknown attribute',
321 'patterns': [r".*: warning: unknown attribute '.+'"]},
322 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wignored-attributes',
323 'description': 'Attribute ignored',
324 'patterns': [r".*: warning: '_*packed_*' attribute ignored",
325 r".*: warning: attribute declaration must precede definition .+ignored-attributes"]},
326 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wvisibility',
327 'description': 'Visibility problem',
328 'patterns': [r".*: warning: declaration of '.+' will not be visible outside of this function"]},
329 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wattributes',
330 'description': 'Visibility mismatch',
331 'patterns': [r".*: warning: '.+' declared with greater visibility than the type of its field '.+'"]},
332 {'category': 'C/C++', 'severity': Severity.MEDIUM,
333 'description': 'Shift count greater than width of type',
334 'patterns': [r".*: warning: (left|right) shift count >= width of type"]},
335 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wextern-initializer',
336 'description': 'extern <foo> is initialized',
337 'patterns': [r".*: warning: '.+' initialized and declared 'extern'",
338 r".*: warning: 'extern' variable has an initializer"]},
339 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wold-style-declaration',
340 'description': 'Old style declaration',
341 'patterns': [r".*: warning: 'static' is not at beginning of declaration"]},
342 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wreturn-type',
343 'description': 'Missing return value',
344 'patterns': [r".*: warning: control reaches end of non-void function"]},
345 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wimplicit-int',
346 'description': 'Implicit int type',
347 'patterns': [r".*: warning: type specifier missing, defaults to 'int'",
348 r".*: warning: type defaults to 'int' in declaration of '.+'"]},
349 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmain-return-type',
350 'description': 'Main function should return int',
351 'patterns': [r".*: warning: return type of 'main' is not 'int'"]},
352 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wuninitialized',
353 'description': 'Variable may be used uninitialized',
354 'patterns': [r".*: warning: '.+' may be used uninitialized in this function"]},
355 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wuninitialized',
356 'description': 'Variable is used uninitialized',
357 'patterns': [r".*: warning: '.+' is used uninitialized in this function",
358 r".*: warning: variable '.+' is uninitialized when used here"]},
359 {'category': 'ld', 'severity': Severity.MEDIUM, 'option': '-fshort-enums',
360 'description': 'ld: possible enum size mismatch',
361 'patterns': [r".*: warning: .* uses variable-size enums yet the output is to use 32-bit enums; use of enum values across objects may fail"]},
362 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wpointer-sign',
363 'description': 'Pointer targets differ in signedness',
364 'patterns': [r".*: warning: pointer targets in initialization differ in signedness",
365 r".*: warning: pointer targets in assignment differ in signedness",
366 r".*: warning: pointer targets in return differ in signedness",
367 r".*: warning: pointer targets in passing argument [0-9]+ of '.+' differ in signedness"]},
368 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wstrict-overflow',
369 'description': 'Assuming overflow does not occur',
370 'patterns': [r".*: warning: assuming signed overflow does not occur when assuming that .* is always (true|false)"]},
371 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wempty-body',
372 'description': 'Suggest adding braces around empty body',
373 'patterns': [r".*: warning: suggest braces around empty body in an 'if' statement",
374 r".*: warning: empty body in an if-statement",
375 r".*: warning: suggest braces around empty body in an 'else' statement",
376 r".*: warning: empty body in an else-statement"]},
377 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wparentheses',
378 'description': 'Suggest adding parentheses',
379 'patterns': [r".*: warning: suggest explicit braces to avoid ambiguous 'else'",
380 r".*: warning: suggest parentheses around arithmetic in operand of '.+'",
381 r".*: warning: suggest parentheses around comparison in operand of '.+'",
382 r".*: warning: logical not is only applied to the left hand side of this comparison",
383 r".*: warning: using the result of an assignment as a condition without parentheses",
384 r".*: warning: .+ has lower precedence than .+ be evaluated first .+Wparentheses",
385 r".*: warning: suggest parentheses around '.+?' .+ '.+?'",
386 r".*: warning: suggest parentheses around assignment used as truth value"]},
387 {'category': 'C/C++', 'severity': Severity.MEDIUM,
388 'description': 'Static variable used in non-static inline function',
389 'patterns': [r".*: warning: '.+' is static but used in inline function '.+' which is not static"]},
390 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wimplicit int',
391 'description': 'No type or storage class (will default to int)',
392 'patterns': [r".*: warning: data definition has no type or storage class"]},
393 {'category': 'C/C++', 'severity': Severity.MEDIUM,
394 'description': 'Null pointer',
395 'patterns': [r".*: warning: Dereference of null pointer",
396 r".*: warning: Called .+ pointer is null",
397 r".*: warning: Forming reference to null pointer",
398 r".*: warning: Returning null reference",
399 r".*: warning: Null pointer passed as an argument to a 'nonnull' parameter",
400 r".*: warning: .+ results in a null pointer dereference",
401 r".*: warning: Access to .+ results in a dereference of a null pointer",
402 r".*: warning: Null pointer argument in"]},
403 {'category': 'cont.', 'severity': Severity.SKIP,
404 'description': 'skip, parameter name (without types) in function declaration',
405 'patterns': [r".*: warning: parameter names \(without types\) in function declaration"]},
406 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wstrict-aliasing',
407 'description': 'Dereferencing <foo> breaks strict aliasing rules',
408 'patterns': [r".*: warning: dereferencing .* break strict-aliasing rules"]},
409 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wpointer-to-int-cast',
410 'description': 'Cast from pointer to integer of different size',
411 'patterns': [r".*: warning: cast from pointer to integer of different size",
412 r".*: warning: initialization makes pointer from integer without a cast"]},
413 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wint-to-pointer-cast',
414 'description': 'Cast to pointer from integer of different size',
415 'patterns': [r".*: warning: cast to pointer from integer of different size"]},
416 {'category': 'C/C++', 'severity': Severity.MEDIUM,
417 'description': 'Symbol redefined',
418 'patterns': [r".*: warning: "".+"" redefined"]},
419 {'category': 'cont.', 'severity': Severity.SKIP,
420 'description': 'skip, ... location of the previous definition',
421 'patterns': [r".*: warning: this is the location of the previous definition"]},
422 {'category': 'ld', 'severity': Severity.MEDIUM,
423 'description': 'ld: type and size of dynamic symbol are not defined',
424 'patterns': [r".*: warning: type and size of dynamic symbol `.+' are not defined"]},
425 {'category': 'C/C++', 'severity': Severity.MEDIUM,
426 'description': 'Pointer from integer without cast',
427 'patterns': [r".*: warning: assignment makes pointer from integer without a cast"]},
428 {'category': 'C/C++', 'severity': Severity.MEDIUM,
429 'description': 'Pointer from integer without cast',
430 'patterns': [r".*: warning: passing argument [0-9]+ of '.+' makes pointer from integer without a cast"]},
431 {'category': 'C/C++', 'severity': Severity.MEDIUM,
432 'description': 'Integer from pointer without cast',
433 'patterns': [r".*: warning: assignment makes integer from pointer without a cast"]},
434 {'category': 'C/C++', 'severity': Severity.MEDIUM,
435 'description': 'Integer from pointer without cast',
436 'patterns': [r".*: warning: passing argument [0-9]+ of '.+' makes integer from pointer without a cast"]},
437 {'category': 'C/C++', 'severity': Severity.MEDIUM,
438 'description': 'Integer from pointer without cast',
439 'patterns': [r".*: warning: return makes integer from pointer without a cast"]},
440 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunknown-pragmas',
441 'description': 'Ignoring pragma',
442 'patterns': [r".*: warning: ignoring #pragma .+"]},
443 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-W#pragma-messages',
444 'description': 'Pragma warning messages',
445 'patterns': [r".*: warning: .+W#pragma-messages"]},
446 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wclobbered',
447 'description': 'Variable might be clobbered by longjmp or vfork',
448 'patterns': [r".*: warning: variable '.+' might be clobbered by 'longjmp' or 'vfork'"]},
449 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wclobbered',
450 'description': 'Argument might be clobbered by longjmp or vfork',
451 'patterns': [r".*: warning: argument '.+' might be clobbered by 'longjmp' or 'vfork'"]},
452 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wredundant-decls',
453 'description': 'Redundant declaration',
454 'patterns': [r".*: warning: redundant redeclaration of '.+'"]},
455 {'category': 'cont.', 'severity': Severity.SKIP,
456 'description': 'skip, previous declaration ... was here',
457 'patterns': [r".*: warning: previous declaration of '.+' was here"]},
458 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wswitch-enum',
459 'description': 'Enum value not handled in switch',
460 'patterns': [r".*: warning: .*enumeration value.* not handled in switch.+Wswitch"]},
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -0700461 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wuser-defined-warnings',
462 'description': 'User defined warnings',
463 'patterns': [r".*: warning: .* \[-Wuser-defined-warnings\]$"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700464 {'category': 'java', 'severity': Severity.MEDIUM, 'option': '-encoding',
465 'description': 'Java: Non-ascii characters used, but ascii encoding specified',
466 'patterns': [r".*: warning: unmappable character for encoding ascii"]},
467 {'category': 'java', 'severity': Severity.MEDIUM,
468 'description': 'Java: Non-varargs call of varargs method with inexact argument type for last parameter',
469 'patterns': [r".*: warning: non-varargs call of varargs method with inexact argument type for last parameter"]},
470 {'category': 'java', 'severity': Severity.MEDIUM,
471 'description': 'Java: Unchecked method invocation',
472 'patterns': [r".*: warning: \[unchecked\] unchecked method invocation: .+ in class .+"]},
473 {'category': 'java', 'severity': Severity.MEDIUM,
474 'description': 'Java: Unchecked conversion',
475 'patterns': [r".*: warning: \[unchecked\] unchecked conversion"]},
476 {'category': 'java', 'severity': Severity.MEDIUM,
477 'description': '_ used as an identifier',
478 'patterns': [r".*: warning: '_' used as an identifier"]},
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -0700479 {'category': 'java', 'severity': Severity.HIGH,
480 'description': 'Use of internal proprietary API',
481 'patterns': [r".*: warning: .* is internal proprietary API and may be removed"]},
Ian Rogers32bb9bd2016-05-09 23:19:42 -0700482
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800483 # Warnings from Javac
Ian Rogers6e520032016-05-13 08:59:00 -0700484 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700485 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700486 'description': 'Java: Use of deprecated member',
487 'patterns': [r'.*: warning: \[deprecation\] .+']},
488 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700489 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700490 'description': 'Java: Unchecked conversion',
491 'patterns': [r'.*: warning: \[unchecked\] .+']},
Ian Rogers32bb9bd2016-05-09 23:19:42 -0700492
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800493 # Begin warnings generated by Error Prone
494 {'category': 'java',
495 'severity': Severity.LOW,
496 'description':
497 'Java: @Multibinds is a more efficient and declarative mechanism for ensuring that a set multibinding is present in the graph.',
498 'patterns': [r".*: warning: \[EmptySetMultibindingContributions\] .+"]},
499 {'category': 'java',
500 'severity': Severity.LOW,
501 'description':
502 'Java: Add a private constructor to modules that will not be instantiated by Dagger.',
503 'patterns': [r".*: warning: \[PrivateConstructorForNoninstantiableModuleTest\] .+"]},
504 {'category': 'java',
505 'severity': Severity.LOW,
506 'description':
507 'Java: @Binds is a more efficient and declarative mechanism for delegating a binding.',
508 'patterns': [r".*: warning: \[UseBinds\] .+"]},
509 {'category': 'java',
510 'severity': Severity.LOW,
511 'description':
512 'Java: Field name is CONSTANT CASE, but field is not static and final',
513 'patterns': [r".*: warning: \[ConstantField\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -0700514 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700515 'severity': Severity.LOW,
Ian Rogers6e520032016-05-13 08:59:00 -0700516 'description':
517 'Java: Deprecated item is not annotated with @Deprecated',
518 'patterns': [r".*: warning: \[DepAnn\] .+"]},
519 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700520 'severity': Severity.LOW,
Ian Rogers6e520032016-05-13 08:59:00 -0700521 'description':
Ian Rogers6e520032016-05-13 08:59:00 -0700522 'Java: Prefer \'L\' to \'l\' for the suffix to long literals',
523 'patterns': [r".*: warning: \[LongLiteralLowerCaseSuffix\] .+"]},
524 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700525 'severity': Severity.LOW,
Ian Rogers6e520032016-05-13 08:59:00 -0700526 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800527 'Java: C-style array declarations should not be used',
528 'patterns': [r".*: warning: \[MixedArrayDimensions\] .+"]},
529 {'category': 'java',
530 'severity': Severity.LOW,
531 'description':
532 'Java: Variable declarations should declare only one variable',
533 'patterns': [r".*: warning: \[MultiVariableDeclaration\] .+"]},
534 {'category': 'java',
535 'severity': Severity.LOW,
536 'description':
537 'Java: Source files should not contain multiple top-level class declarations',
538 'patterns': [r".*: warning: \[MultipleTopLevelClasses\] .+"]},
539 {'category': 'java',
540 'severity': Severity.LOW,
541 'description':
542 'Java: Package names should match the directory they are declared in',
543 'patterns': [r".*: warning: \[PackageLocation\] .+"]},
544 {'category': 'java',
545 'severity': Severity.LOW,
546 'description':
547 'Java: Utility classes (only static members) are not designed to be instantiated and should be made noninstantiable with a default constructor.',
548 'patterns': [r".*: warning: \[PrivateConstructorForUtilityClass\] .+"]},
549 {'category': 'java',
550 'severity': Severity.LOW,
551 'description':
552 'Java: Unused imports',
553 'patterns': [r".*: warning: \[RemoveUnusedImports\] .+"]},
554 {'category': 'java',
555 'severity': Severity.LOW,
556 'description':
557 'Java: Unchecked exceptions do not need to be declared in the method signature.',
558 'patterns': [r".*: warning: \[ThrowsUncheckedException\] .+"]},
559 {'category': 'java',
560 'severity': Severity.LOW,
561 'description':
562 'Java: Using static imports for types is unnecessary',
563 'patterns': [r".*: warning: \[UnnecessaryStaticImport\] .+"]},
564 {'category': 'java',
565 'severity': Severity.LOW,
566 'description':
567 'Java: Wildcard imports, static or otherwise, should not be used',
568 'patterns': [r".*: warning: \[WildcardImport\] .+"]},
569 {'category': 'java',
570 'severity': Severity.MEDIUM,
571 'description':
572 'Java: Subclasses of Fragment must be instantiable via Class#newInstance(): the class must be public, static and have a public nullary constructor',
573 'patterns': [r".*: warning: \[FragmentNotInstantiable\] .+"]},
574 {'category': 'java',
575 'severity': Severity.MEDIUM,
576 'description':
577 'Java: Hardcoded reference to /sdcard',
578 'patterns': [r".*: warning: \[HardCodedSdCardPath\] .+"]},
579 {'category': 'java',
580 'severity': Severity.MEDIUM,
581 'description':
582 'Java: @AssistedInject and @Inject should not be used on different constructors in the same class.',
583 'patterns': [r".*: warning: \[AssistedInjectAndInjectOnConstructors\] .+"]},
584 {'category': 'java',
585 'severity': Severity.MEDIUM,
586 'description':
587 'Java: Constructors on abstract classes are never directly @Injected, only the constructors of their subclasses can be @Inject\'ed.',
588 'patterns': [r".*: warning: \[InjectOnConstructorOfAbstractClass\] .+"]},
589 {'category': 'java',
590 'severity': Severity.MEDIUM,
591 'description':
592 'Java: Injection frameworks currently don\'t understand Qualifiers in TYPE PARAMETER or TYPE USE contexts.',
593 'patterns': [r".*: warning: \[QualifierWithTypeUse\] .+"]},
594 {'category': 'java',
595 'severity': Severity.MEDIUM,
596 'description':
597 'Java: This code declares a binding for a common value type without a Qualifier annotation.',
598 'patterns': [r".*: warning: \[BindingToUnqualifiedCommonType\] .+"]},
599 {'category': 'java',
600 'severity': Severity.MEDIUM,
601 'description':
602 '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.',
603 'patterns': [r".*: warning: \[OverridesGuiceInjectableMethod\] .+"]},
604 {'category': 'java',
605 'severity': Severity.MEDIUM,
606 'description':
607 'Java: Double-checked locking on non-volatile fields is unsafe',
608 'patterns': [r".*: warning: \[DoubleCheckedLocking\] .+"]},
609 {'category': 'java',
610 'severity': Severity.MEDIUM,
611 'description':
612 'Java: Enums should always be immutable',
613 'patterns': [r".*: warning: \[ImmutableEnumChecker\] .+"]},
614 {'category': 'java',
615 'severity': Severity.MEDIUM,
616 'description':
617 'Java: Writes to static fields should not be guarded by instance locks',
618 'patterns': [r".*: warning: \[StaticGuardedByInstance\] .+"]},
619 {'category': 'java',
620 'severity': Severity.MEDIUM,
621 'description':
622 'Java: Synchronizing on non-final fields is not safe: if the field is ever updated, different threads may end up locking on different objects.',
623 'patterns': [r".*: warning: \[SynchronizeOnNonFinalField\] .+"]},
624 {'category': 'java',
625 'severity': Severity.MEDIUM,
626 'description':
627 'Java: Method reference is ambiguous',
628 'patterns': [r".*: warning: \[AmbiguousMethodReference\] .+"]},
629 {'category': 'java',
630 'severity': Severity.MEDIUM,
631 'description':
632 'Java: A different potential argument is more similar to the name of the parameter than the existing argument; this may be an error',
633 'patterns': [r".*: warning: \[ArgumentParameterMismatch\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -0700634 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700635 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700636 'description':
637 'Java: Assertions may be disabled at runtime and do not guarantee that execution will halt here; consider throwing an exception instead',
638 'patterns': [r".*: warning: \[AssertFalse\] .+"]},
639 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700640 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700641 'description':
642 'Java: Classes that implement Annotation must override equals and hashCode. Consider using AutoAnnotation instead of implementing Annotation by hand.',
643 'patterns': [r".*: warning: \[BadAnnotationImplementation\] .+"]},
644 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700645 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700646 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800647 'Java: Possible sign flip from narrowing conversion',
648 'patterns': [r".*: warning: \[BadComparable\] .+"]},
649 {'category': 'java',
650 'severity': Severity.MEDIUM,
651 'description':
Ian Rogers6e520032016-05-13 08:59:00 -0700652 'Java: BigDecimal(double) and BigDecimal.valueOf(double) may lose precision, prefer BigDecimal(String) or BigDecimal(long)',
653 'patterns': [r".*: warning: \[BigDecimalLiteralDouble\] .+"]},
654 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700655 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700656 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800657 'Java: valueOf or autoboxing provides better time and space performance',
658 'patterns': [r".*: warning: \[BoxedPrimitiveConstructor\] .+"]},
659 {'category': 'java',
660 'severity': Severity.MEDIUM,
661 'description':
Ian Rogers6e520032016-05-13 08:59:00 -0700662 'Java: Mockito cannot mock final classes',
663 'patterns': [r".*: warning: \[CannotMockFinalClass\] .+"]},
664 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700665 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700666 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800667 'Java: Inner class is non-static but does not reference enclosing class',
668 'patterns': [r".*: warning: \[ClassCanBeStatic\] .+"]},
669 {'category': 'java',
670 'severity': Severity.MEDIUM,
671 'description':
672 'Java: Class.newInstance() bypasses exception checking; prefer getConstructor().newInstance()',
673 'patterns': [r".*: warning: \[ClassNewInstance\] .+"]},
674 {'category': 'java',
675 'severity': Severity.MEDIUM,
676 'description':
677 'Java: Implicit use of the platform default charset, which can result in e.g. non-ASCII characters being silently replaced with \'?\' in many environments',
678 'patterns': [r".*: warning: \[DefaultCharset\] .+"]},
679 {'category': 'java',
680 'severity': Severity.MEDIUM,
681 'description':
Ian Rogers6e520032016-05-13 08:59:00 -0700682 'Java: This code, which counts elements using a loop, can be replaced by a simpler library method',
683 'patterns': [r".*: warning: \[ElementsCountedInLoop\] .+"]},
684 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700685 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700686 'description':
687 'Java: Empty top-level type declaration',
688 'patterns': [r".*: warning: \[EmptyTopLevelDeclaration\] .+"]},
689 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700690 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700691 'description':
692 'Java: Classes that override equals should also override hashCode.',
693 'patterns': [r".*: warning: \[EqualsHashCode\] .+"]},
694 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700695 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700696 'description':
697 'Java: An equality test between objects with incompatible types always returns false',
698 'patterns': [r".*: warning: \[EqualsIncompatibleType\] .+"]},
699 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700700 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700701 'description':
702 '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.',
703 'patterns': [r".*: warning: \[Finally\] .+"]},
704 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700705 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700706 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800707 'Java: Overloads will be ambiguous when passing lambda arguments',
708 'patterns': [r".*: warning: \[FunctionalInterfaceClash\] .+"]},
709 {'category': 'java',
710 'severity': Severity.MEDIUM,
711 'description':
712 'Java: Calling getClass() on an enum may return a subclass of the enum type',
713 'patterns': [r".*: warning: \[GetClassOnEnum\] .+"]},
714 {'category': 'java',
715 'severity': Severity.MEDIUM,
716 'description':
Ian Rogers6e520032016-05-13 08:59:00 -0700717 'Java: This annotation has incompatible modifiers as specified by its @IncompatibleModifiers annotation',
718 'patterns': [r".*: warning: \[IncompatibleModifiers\] .+"]},
719 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700720 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700721 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800722 'Java: Please also override int read(byte[], int, int), otherwise multi-byte reads from this input stream are likely to be slow.',
723 'patterns': [r".*: warning: \[InputStreamSlowMultibyteRead\] .+"]},
724 {'category': 'java',
725 'severity': Severity.MEDIUM,
726 'description':
Ian Rogers6e520032016-05-13 08:59:00 -0700727 'Java: Class should not implement both `Iterable` and `Iterator`',
728 'patterns': [r".*: warning: \[IterableAndIterator\] .+"]},
729 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700730 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700731 'description':
732 'Java: Floating-point comparison without error tolerance',
733 'patterns': [r".*: warning: \[JUnit3FloatingPointComparisonWithoutDelta\] .+"]},
734 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700735 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700736 'description':
737 'Java: Test class inherits from JUnit 3\'s TestCase but has JUnit 4 @Test annotations.',
738 'patterns': [r".*: warning: \[JUnitAmbiguousTestClass\] .+"]},
739 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700740 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700741 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800742 'Java: The Google Java Style Guide requires switch statements to have an explicit default',
Ian Rogers6e520032016-05-13 08:59:00 -0700743 'patterns': [r".*: warning: \[MissingCasesInEnumSwitch\] .+"]},
744 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700745 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700746 'description':
747 'Java: Not calling fail() when expecting an exception masks bugs',
748 'patterns': [r".*: warning: \[MissingFail\] .+"]},
749 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700750 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700751 'description':
752 'Java: method overrides method in supertype; expected @Override',
753 'patterns': [r".*: warning: \[MissingOverride\] .+"]},
754 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700755 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700756 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800757 'Java: Compound assignments to bytes, shorts, chars, and floats hide dangerous casts',
758 'patterns': [r".*: warning: \[NarrowingCompoundAssignment\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -0700759 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700760 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700761 'description':
762 'Java: This update of a volatile variable is non-atomic',
763 'patterns': [r".*: warning: \[NonAtomicVolatileUpdate\] .+"]},
764 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700765 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700766 'description':
767 'Java: Static import of member uses non-canonical name',
768 'patterns': [r".*: warning: \[NonCanonicalStaticMemberImport\] .+"]},
769 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700770 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700771 'description':
772 'Java: equals method doesn\'t override Object.equals',
773 'patterns': [r".*: warning: \[NonOverridingEquals\] .+"]},
774 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700775 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700776 'description':
777 'Java: Constructors should not be annotated with @Nullable since they cannot return null',
778 'patterns': [r".*: warning: \[NullableConstructor\] .+"]},
779 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700780 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700781 'description':
782 'Java: @Nullable should not be used for primitive types since they cannot be null',
783 'patterns': [r".*: warning: \[NullablePrimitive\] .+"]},
784 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700785 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700786 'description':
787 'Java: void-returning methods should not be annotated with @Nullable, since they cannot return null',
788 'patterns': [r".*: warning: \[NullableVoid\] .+"]},
789 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700790 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700791 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800792 'Java: Use grouping parenthesis to make the operator precedence explicit',
793 'patterns': [r".*: warning: \[OperatorPrecedence\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -0700794 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700795 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700796 'description':
797 'Java: Preconditions only accepts the %s placeholder in error message strings',
798 'patterns': [r".*: warning: \[PreconditionsInvalidPlaceholder\] .+"]},
799 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700800 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700801 'description':
802 'Java: Passing a primitive array to a varargs method is usually wrong',
803 'patterns': [r".*: warning: \[PrimitiveArrayPassedToVarargsMethod\] .+"]},
804 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700805 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700806 'description':
807 'Java: Protobuf fields cannot be null, so this check is redundant',
808 'patterns': [r".*: warning: \[ProtoFieldPreconditionsCheckNotNull\] .+"]},
809 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700810 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700811 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800812 'Java: Thrown exception is a subtype of another',
813 'patterns': [r".*: warning: \[RedundantThrows\] .+"]},
814 {'category': 'java',
815 'severity': Severity.MEDIUM,
816 'description':
817 'Java: Comparison using reference equality instead of value equality',
818 'patterns': [r".*: warning: \[ReferenceEquality\] .+"]},
819 {'category': 'java',
820 'severity': Severity.MEDIUM,
821 'description':
Ian Rogers6e520032016-05-13 08:59:00 -0700822 'Java: This annotation is missing required modifiers as specified by its @RequiredModifiers annotation',
823 'patterns': [r".*: warning: \[RequiredModifiers\] .+"]},
824 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700825 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700826 'description':
827 'Java: A static variable or method should not be accessed from an object instance',
828 'patterns': [r".*: warning: \[StaticAccessedFromInstance\] .+"]},
829 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700830 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700831 'description':
832 'Java: String comparison using reference equality instead of value equality',
833 'patterns': [r".*: warning: \[StringEquality\] .+"]},
834 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700835 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700836 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800837 'Java: Truth Library assert is called on a constant.',
838 'patterns': [r".*: warning: \[TruthConstantAsserts\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -0700839 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700840 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700841 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800842 'Java: An object is tested for equality to itself using Truth Libraries.',
843 'patterns': [r".*: warning: \[TruthSelfEquals\] .+"]},
844 {'category': 'java',
845 'severity': Severity.MEDIUM,
846 'description':
847 '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.',
848 'patterns': [r".*: warning: \[TypeParameterUnusedInFormals\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -0700849 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700850 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700851 'description':
852 'Java: Unsynchronized method overrides a synchronized method.',
853 'patterns': [r".*: warning: \[UnsynchronizedOverridesSynchronized\] .+"]},
854 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700855 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700856 'description':
857 'Java: Non-constant variable missing @Var annotation',
858 'patterns': [r".*: warning: \[Var\] .+"]},
859 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700860 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700861 'description':
862 'Java: Because of spurious wakeups, Object.wait() and Condition.await() must always be called in a loop',
863 'patterns': [r".*: warning: \[WaitNotInLoop\] .+"]},
864 {'category': 'java',
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800865 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700866 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800867 'Java: Log tag too long, cannot exceed 23 characters.',
868 'patterns': [r".*: warning: \[IsLoggableTagLength\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -0700869 {'category': 'java',
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800870 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700871 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800872 'Java: Certain resources in `android.R.string` have names that do not match their content',
873 'patterns': [r".*: warning: \[MislabeledAndroidString\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -0700874 {'category': 'java',
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800875 'severity': Severity.HIGH,
876 'description':
877 'Java: Return value of android.graphics.Rect.intersect() must be checked',
878 'patterns': [r".*: warning: \[RectIntersectReturnValueIgnored\] .+"]},
879 {'category': 'java',
880 'severity': Severity.HIGH,
881 'description':
882 'Java: Static and default methods in interfaces are not allowed in android builds.',
883 'patterns': [r".*: warning: \[StaticOrDefaultInterfaceMethod\] .+"]},
884 {'category': 'java',
885 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700886 'description':
887 'Java: Incompatible type as argument to Object-accepting Java collections method',
888 'patterns': [r".*: warning: \[CollectionIncompatibleType\] .+"]},
889 {'category': 'java',
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800890 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700891 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800892 'Java: @CompatibleWith\'s value is not a type argument.',
893 'patterns': [r".*: warning: \[CompatibleWithAnnotationMisuse\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -0700894 {'category': 'java',
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800895 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700896 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800897 'Java: Passing argument to a generic method with an incompatible type.',
898 'patterns': [r".*: warning: \[IncompatibleArgumentType\] .+"]},
899 {'category': 'java',
900 'severity': Severity.HIGH,
901 'description':
902 'Java: Invalid printf-style format string',
903 'patterns': [r".*: warning: \[FormatString\] .+"]},
904 {'category': 'java',
905 'severity': Severity.HIGH,
906 'description':
907 'Java: Invalid format string passed to formatting method.',
908 'patterns': [r".*: warning: \[FormatStringAnnotation\] .+"]},
909 {'category': 'java',
910 'severity': Severity.HIGH,
911 'description':
912 'Java: @AssistedInject and @Inject cannot be used on the same constructor.',
913 'patterns': [r".*: warning: \[AssistedInjectAndInjectOnSameConstructor\] .+"]},
914 {'category': 'java',
915 'severity': Severity.HIGH,
916 'description':
917 'Java: @AutoFactory and @Inject should not be used in the same type.',
918 'patterns': [r".*: warning: \[AutoFactoryAtInject\] .+"]},
919 {'category': 'java',
920 'severity': Severity.HIGH,
921 'description':
922 'Java: Injected constructors cannot be optional nor have binding annotations',
923 'patterns': [r".*: warning: \[InjectedConstructorAnnotations\] .+"]},
924 {'category': 'java',
925 'severity': Severity.HIGH,
926 'description':
927 'Java: A scoping annotation\'s Target should include TYPE and METHOD.',
928 'patterns': [r".*: warning: \[InjectInvalidTargetingOnScopingAnnotation\] .+"]},
929 {'category': 'java',
930 'severity': Severity.HIGH,
931 'description':
932 'Java: Abstract and default methods are not injectable with javax.inject.Inject',
933 'patterns': [r".*: warning: \[JavaxInjectOnAbstractMethod\] .+"]},
934 {'category': 'java',
935 'severity': Severity.HIGH,
936 'description':
937 'Java: @javax.inject.Inject cannot be put on a final field.',
938 'patterns': [r".*: warning: \[JavaxInjectOnFinalField\] .+"]},
939 {'category': 'java',
940 'severity': Severity.HIGH,
941 'description':
942 'Java: This class has more than one @Inject-annotated constructor. Please remove the @Inject annotation from all but one of them.',
943 'patterns': [r".*: warning: \[MoreThanOneInjectableConstructor\] .+"]},
944 {'category': 'java',
945 'severity': Severity.HIGH,
946 'description':
947 'Java: Using more than one qualifier annotation on the same element is not allowed.',
948 'patterns': [r".*: warning: \[InjectMoreThanOneQualifier\] .+"]},
949 {'category': 'java',
950 'severity': Severity.HIGH,
951 'description':
952 'Java: A class can be annotated with at most one scope annotation.',
953 'patterns': [r".*: warning: \[InjectMoreThanOneScopeAnnotationOnClass\] .+"]},
954 {'category': 'java',
955 'severity': Severity.HIGH,
956 'description':
957 'Java: Annotations cannot be both Scope annotations and Qualifier annotations: this causes confusion when trying to use them.',
958 'patterns': [r".*: warning: \[OverlappingQualifierAndScopeAnnotation\] .+"]},
959 {'category': 'java',
960 'severity': Severity.HIGH,
961 'description':
962 'Java: Qualifier applied to a method that isn\'t a @Provides method. This method won\'t be used for dependency injection',
963 'patterns': [r".*: warning: \[QualifierOnMethodWithoutProvides\] .+"]},
964 {'category': 'java',
965 'severity': Severity.HIGH,
966 'description':
967 'Java: Scope annotation on an interface or abstact class is not allowed',
968 'patterns': [r".*: warning: \[InjectScopeAnnotationOnInterfaceOrAbstractClass\] .+"]},
969 {'category': 'java',
970 'severity': Severity.HIGH,
971 'description':
972 'Java: Scoping and qualifier annotations must have runtime retention.',
973 'patterns': [r".*: warning: \[InjectScopeOrQualifierAnnotationRetention\] .+"]},
974 {'category': 'java',
975 'severity': Severity.HIGH,
976 'description':
977 'Java: `@Multibinds` is the new way to declare multibindings.',
978 'patterns': [r".*: warning: \[MultibindsInsteadOfMultibindings\] .+"]},
979 {'category': 'java',
980 'severity': Severity.HIGH,
981 'description':
982 'Java: Dagger @Provides methods may not return null unless annotated with @Nullable',
983 'patterns': [r".*: warning: \[DaggerProvidesNull\] .+"]},
984 {'category': 'java',
985 'severity': Severity.HIGH,
986 'description':
987 'Java: Scope annotation on implementation class of AssistedInject factory is not allowed',
988 'patterns': [r".*: warning: \[GuiceAssistedInjectScoping\] .+"]},
989 {'category': 'java',
990 'severity': Severity.HIGH,
991 'description':
992 'Java: A constructor cannot have two @Assisted parameters of the same type unless they are disambiguated with named @Assisted annotations.',
993 'patterns': [r".*: warning: \[GuiceAssistedParameters\] .+"]},
994 {'category': 'java',
995 'severity': Severity.HIGH,
996 'description':
997 'Java: Although Guice allows injecting final fields, doing so is disallowed because the injected value may not be visible to other threads.',
Ian Rogers6e520032016-05-13 08:59:00 -0700998 'patterns': [r".*: warning: \[GuiceInjectOnFinalField\] .+"]},
999 {'category': 'java',
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001000 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001001 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001002 'Java: This method is not annotated with @Inject, but it overrides a method that is annotated with @javax.inject.Inject. The method will not be Injected.',
1003 'patterns': [r".*: warning: \[OverridesJavaxInjectableMethod\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001004 {'category': 'java',
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001005 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001006 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001007 'Java: @Provides methods need to be declared in a Module to have any effect.',
1008 'patterns': [r".*: warning: \[ProvidesMethodOutsideOfModule\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001009 {'category': 'java',
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001010 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001011 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001012 'Java: Checks for unguarded accesses to fields and methods with @GuardedBy annotations',
1013 'patterns': [r".*: warning: \[GuardedByChecker\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001014 {'category': 'java',
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001015 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001016 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001017 'Java: Invalid @GuardedBy expression',
1018 'patterns': [r".*: warning: \[GuardedByValidator\] .+"]},
1019 {'category': 'java',
1020 'severity': Severity.HIGH,
1021 'description':
1022 'Java: Type declaration annotated with @Immutable is not immutable',
1023 'patterns': [r".*: warning: \[Immutable\] .+"]},
1024 {'category': 'java',
1025 'severity': Severity.HIGH,
1026 'description':
1027 'Java: This method does not acquire the locks specified by its @LockMethod annotation',
1028 'patterns': [r".*: warning: \[LockMethodChecker\] .+"]},
1029 {'category': 'java',
1030 'severity': Severity.HIGH,
1031 'description':
1032 'Java: This method does not acquire the locks specified by its @UnlockMethod annotation',
1033 'patterns': [r".*: warning: \[UnlockMethod\] .+"]},
1034 {'category': 'java',
1035 'severity': Severity.HIGH,
1036 'description':
1037 'Java: An argument is more similar to a different parameter; the arguments may have been swapped.',
1038 'patterns': [r".*: warning: \[ArgumentParameterSwap\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001039 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001040 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001041 'description':
1042 'Java: Reference equality used to compare arrays',
1043 'patterns': [r".*: warning: \[ArrayEquals\] .+"]},
1044 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001045 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001046 'description':
1047 'Java: hashcode method on array does not hash array contents',
1048 'patterns': [r".*: warning: \[ArrayHashCode\] .+"]},
1049 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001050 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001051 'description':
1052 'Java: Calling toString on an array does not provide useful information',
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001053 'patterns': [r".*: warning: \[ArrayToString\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001054 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001055 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001056 'description':
1057 'Java: Arrays.asList does not autobox primitive arrays, as one might expect.',
1058 'patterns': [r".*: warning: \[ArraysAsListPrimitiveArray\] .+"]},
1059 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001060 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001061 'description':
1062 'Java: AsyncCallable should not return a null Future, only a Future whose result is null.',
1063 'patterns': [r".*: warning: \[AsyncCallableReturnsNull\] .+"]},
1064 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001065 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001066 'description':
1067 'Java: AsyncFunction should not return a null Future, only a Future whose result is null.',
1068 'patterns': [r".*: warning: \[AsyncFunctionReturnsNull\] .+"]},
1069 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001070 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001071 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001072 'Java: Shift by an amount that is out of range',
1073 'patterns': [r".*: warning: \[BadShiftAmount\] .+"]},
1074 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001075 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001076 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001077 '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.',
1078 'patterns': [r".*: warning: \[ChainingConstructorIgnoresParameter\] .+"]},
1079 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001080 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001081 'description':
1082 'Java: Ignored return value of method that is annotated with @CheckReturnValue',
1083 'patterns': [r".*: warning: \[CheckReturnValue\] .+"]},
1084 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001085 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001086 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001087 'Java: The source file name should match the name of the top-level class it contains',
1088 'patterns': [r".*: warning: \[ClassName\] .+"]},
1089 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001090 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001091 'description':
1092 'Java: This comparison method violates the contract',
1093 'patterns': [r".*: warning: \[ComparisonContractViolated\] .+"]},
1094 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001095 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001096 'description':
1097 'Java: Comparison to value that is out of range for the compared type',
1098 'patterns': [r".*: warning: \[ComparisonOutOfRange\] .+"]},
1099 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001100 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001101 'description':
1102 'Java: Non-compile-time constant expression passed to parameter with @CompileTimeConstant type annotation.',
1103 'patterns': [r".*: warning: \[CompileTimeConstant\] .+"]},
1104 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001105 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001106 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001107 'Java: Compile-time constant expression overflows',
1108 'patterns': [r".*: warning: \[ConstantOverflow\] .+"]},
1109 {'category': 'java',
1110 'severity': Severity.HIGH,
1111 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001112 'Java: Exception created but not thrown',
1113 'patterns': [r".*: warning: \[DeadException\] .+"]},
1114 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001115 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001116 'description':
1117 'Java: Division by integer literal zero',
1118 'patterns': [r".*: warning: \[DivZero\] .+"]},
1119 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001120 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001121 'description':
1122 'Java: Empty statement after if',
1123 'patterns': [r".*: warning: \[EmptyIf\] .+"]},
1124 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001125 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001126 'description':
1127 'Java: == NaN always returns false; use the isNaN methods instead',
1128 'patterns': [r".*: warning: \[EqualsNaN\] .+"]},
1129 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001130 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001131 'description':
1132 'Java: Method annotated @ForOverride must be protected or package-private and only invoked from declaring class',
1133 'patterns': [r".*: warning: \[ForOverride\] .+"]},
1134 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001135 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001136 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001137 'Java: Casting a lambda to this @FunctionalInterface can cause a behavior change from casting to a functional superinterface, which is surprising to users. Prefer decorator methods to this surprising behavior.',
1138 'patterns': [r".*: warning: \[FunctionalInterfaceMethodChanged\] .+"]},
1139 {'category': 'java',
1140 'severity': Severity.HIGH,
1141 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001142 'Java: Futures.getChecked requires a checked exception type with a standard constructor.',
1143 'patterns': [r".*: warning: \[FuturesGetCheckedIllegalExceptionType\] .+"]},
1144 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001145 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001146 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001147 'Java: Calling getClass() on an annotation may return a proxy class',
1148 'patterns': [r".*: warning: \[GetClassOnAnnotation\] .+"]},
1149 {'category': 'java',
1150 'severity': Severity.HIGH,
1151 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001152 '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',
1153 'patterns': [r".*: warning: \[GetClassOnClass\] .+"]},
1154 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001155 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001156 'description':
1157 'Java: An object is tested for equality to itself using Guava Libraries',
1158 'patterns': [r".*: warning: \[GuavaSelfEquals\] .+"]},
1159 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001160 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001161 'description':
1162 'Java: contains() is a legacy method that is equivalent to containsValue()',
1163 'patterns': [r".*: warning: \[HashtableContains\] .+"]},
1164 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001165 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001166 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001167 'Java: Writing "a && a", "a || a", "a & a", or "a | a" is equivalent to "a".',
1168 'patterns': [r".*: warning: \[IdentityBinaryExpression\] .+"]},
1169 {'category': 'java',
1170 'severity': Severity.HIGH,
1171 'description':
1172 'Java: Modifying an immutable collection is guaranteed to throw an exception and leave the collection unmodified',
1173 'patterns': [r".*: warning: \[ImmutableModification\] .+"]},
1174 {'category': 'java',
1175 'severity': Severity.HIGH,
1176 'description':
1177 'Java: This method always recurses, and will cause a StackOverflowError',
1178 'patterns': [r".*: warning: \[InfiniteRecursion\] .+"]},
1179 {'category': 'java',
1180 'severity': Severity.HIGH,
1181 'description':
1182 'Java: A standard cryptographic operation is used in a mode that is prone to vulnerabilities',
1183 'patterns': [r".*: warning: \[InsecureCryptoUsage\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001184 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001185 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001186 'description':
1187 'Java: Invalid syntax used for a regular expression',
1188 'patterns': [r".*: warning: \[InvalidPatternSyntax\] .+"]},
1189 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001190 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001191 'description':
1192 'Java: The argument to Class#isInstance(Object) should not be a Class',
1193 'patterns': [r".*: warning: \[IsInstanceOfClass\] .+"]},
1194 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001195 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001196 'description':
1197 'Java: jMock tests must have a @RunWith(JMock.class) annotation, or the Mockery field must have a @Rule JUnit annotation',
1198 'patterns': [r".*: warning: \[JMockTestWithoutRunWithOrRuleAnnotation\] .+"]},
1199 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001200 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001201 'description':
1202 'Java: Test method will not be run; please prefix name with "test"',
1203 'patterns': [r".*: warning: \[JUnit3TestNotRun\] .+"]},
1204 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001205 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001206 'description':
1207 'Java: setUp() method will not be run; Please add a @Before annotation',
1208 'patterns': [r".*: warning: \[JUnit4SetUpNotRun\] .+"]},
1209 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001210 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001211 'description':
1212 'Java: tearDown() method will not be run; Please add an @After annotation',
1213 'patterns': [r".*: warning: \[JUnit4TearDownNotRun\] .+"]},
1214 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001215 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001216 'description':
1217 'Java: Test method will not be run; please add @Test annotation',
1218 'patterns': [r".*: warning: \[JUnit4TestNotRun\] .+"]},
1219 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001220 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001221 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001222 'Java: Use of "YYYY" (week year) in a date pattern without "ww" (week in year). You probably meant to use "yyyy" (year) instead.',
1223 'patterns': [r".*: warning: \[MisusedWeekYear\] .+"]},
1224 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001225 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001226 'description':
1227 'Java: A bug in Mockito will cause this test to fail at runtime with a ClassCastException',
1228 'patterns': [r".*: warning: \[MockitoCast\] .+"]},
1229 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001230 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001231 'description':
1232 'Java: Missing method call for verify(mock) here',
1233 'patterns': [r".*: warning: \[MockitoUsage\] .+"]},
1234 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001235 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001236 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001237 'Java: Using a collection function with itself as the argument.',
Ian Rogers6e520032016-05-13 08:59:00 -07001238 'patterns': [r".*: warning: \[ModifyingCollectionWithItself\] .+"]},
1239 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001240 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001241 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001242 'Java: @NoAllocation was specified on this method, but something was found that would trigger an allocation',
1243 'patterns': [r".*: warning: \[NoAllocation\] .+"]},
1244 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001245 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001246 'description':
1247 'Java: Static import of type uses non-canonical name',
1248 'patterns': [r".*: warning: \[NonCanonicalStaticImport\] .+"]},
1249 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001250 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001251 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001252 'Java: @CompileTimeConstant parameters should be final or effectively final',
Ian Rogers6e520032016-05-13 08:59:00 -07001253 'patterns': [r".*: warning: \[NonFinalCompileTimeConstant\] .+"]},
1254 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001255 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001256 'description':
1257 'Java: Calling getAnnotation on an annotation that is not retained at runtime.',
1258 'patterns': [r".*: warning: \[NonRuntimeAnnotation\] .+"]},
1259 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001260 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001261 'description':
1262 'Java: Numeric comparison using reference equality instead of value equality',
1263 'patterns': [r".*: warning: \[NumericEquality\] .+"]},
1264 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001265 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001266 'description':
1267 'Java: Comparison using reference equality instead of value equality',
1268 'patterns': [r".*: warning: \[OptionalEquality\] .+"]},
1269 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001270 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001271 'description':
1272 'Java: Varargs doesn\'t agree for overridden method',
1273 'patterns': [r".*: warning: \[Overrides\] .+"]},
1274 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001275 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001276 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001277 'Java: Declaring types inside package-info.java files is very bad form',
1278 'patterns': [r".*: warning: \[PackageInfo\] .+"]},
1279 {'category': 'java',
1280 'severity': Severity.HIGH,
1281 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001282 'Java: Literal passed as first argument to Preconditions.checkNotNull() can never be null',
1283 'patterns': [r".*: warning: \[PreconditionsCheckNotNull\] .+"]},
1284 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001285 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001286 'description':
1287 'Java: First argument to `Preconditions.checkNotNull()` is a primitive rather than an object reference',
1288 'patterns': [r".*: warning: \[PreconditionsCheckNotNullPrimitive\] .+"]},
1289 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001290 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001291 'description':
1292 'Java: Protobuf fields cannot be null',
1293 'patterns': [r".*: warning: \[ProtoFieldNullComparison\] .+"]},
1294 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001295 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001296 'description':
1297 'Java: Comparing protobuf fields of type String using reference equality',
1298 'patterns': [r".*: warning: \[ProtoStringFieldReferenceEquality\] .+"]},
1299 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001300 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001301 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001302 'Java: Use Random.nextInt(int). Random.nextInt() % n can have negative results',
1303 'patterns': [r".*: warning: \[RandomModInteger\] .+"]},
1304 {'category': 'java',
1305 'severity': Severity.HIGH,
1306 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001307 'Java: Check for non-whitelisted callers to RestrictedApiChecker.',
1308 'patterns': [r".*: warning: \[RestrictedApiChecker\] .+"]},
1309 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001310 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001311 'description':
1312 'Java: Return value of this method must be used',
1313 'patterns': [r".*: warning: \[ReturnValueIgnored\] .+"]},
1314 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001315 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001316 'description':
1317 'Java: Variable assigned to itself',
1318 'patterns': [r".*: warning: \[SelfAssignment\] .+"]},
1319 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001320 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001321 'description':
1322 'Java: An object is compared to itself',
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001323 'patterns': [r".*: warning: \[SelfComparison\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001324 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001325 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001326 'description':
1327 'Java: Variable compared to itself',
1328 'patterns': [r".*: warning: \[SelfEquality\] .+"]},
1329 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001330 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001331 'description':
1332 'Java: An object is tested for equality to itself',
1333 'patterns': [r".*: warning: \[SelfEquals\] .+"]},
1334 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001335 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001336 'description':
1337 'Java: Comparison of a size >= 0 is always true, did you intend to check for non-emptiness?',
1338 'patterns': [r".*: warning: \[SizeGreaterThanOrEqualsZero\] .+"]},
1339 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001340 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001341 'description':
1342 'Java: Calling toString on a Stream does not provide useful information',
1343 'patterns': [r".*: warning: \[StreamToString\] .+"]},
1344 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001345 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001346 'description':
1347 'Java: StringBuilder does not have a char constructor; this invokes the int constructor.',
1348 'patterns': [r".*: warning: \[StringBuilderInitWithChar\] .+"]},
1349 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001350 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001351 'description':
1352 'Java: Suppressing "deprecated" is probably a typo for "deprecation"',
1353 'patterns': [r".*: warning: \[SuppressWarningsDeprecated\] .+"]},
1354 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001355 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001356 'description':
1357 'Java: throwIfUnchecked(knownCheckedException) is a no-op.',
1358 'patterns': [r".*: warning: \[ThrowIfUncheckedKnownChecked\] .+"]},
1359 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001360 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001361 'description':
1362 'Java: Catching Throwable/Error masks failures from fail() or assert*() in the try block',
1363 'patterns': [r".*: warning: \[TryFailThrowable\] .+"]},
1364 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001365 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001366 'description':
1367 'Java: Type parameter used as type qualifier',
1368 'patterns': [r".*: warning: \[TypeParameterQualifier\] .+"]},
1369 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001370 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001371 'description':
1372 'Java: Non-generic methods should not be invoked with type arguments',
1373 'patterns': [r".*: warning: \[UnnecessaryTypeArgument\] .+"]},
1374 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001375 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001376 'description':
1377 'Java: Instance created but never used',
1378 'patterns': [r".*: warning: \[UnusedAnonymousClass\] .+"]},
1379 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001380 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001381 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001382 'Java: Collection is modified in place, but the result is not used',
1383 'patterns': [r".*: warning: \[UnusedCollectionModifiedInPlace\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001384 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001385 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001386 'description':
1387 'Java: Method parameter has wrong package',
1388 'patterns': [r".*: warning: \[ParameterPackage\] .+"]},
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001389
1390 # End warnings generated by Error Prone
Ian Rogers32bb9bd2016-05-09 23:19:42 -07001391
Ian Rogers6e520032016-05-13 08:59:00 -07001392 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001393 'severity': Severity.UNKNOWN,
Ian Rogers6e520032016-05-13 08:59:00 -07001394 'description': 'Java: Unclassified/unrecognized warnings',
1395 'patterns': [r".*: warning: \[.+\] .+"]},
Ian Rogers32bb9bd2016-05-09 23:19:42 -07001396
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001397 {'category': 'aapt', 'severity': Severity.MEDIUM,
1398 'description': 'aapt: No default translation',
1399 'patterns': [r".*: warning: string '.+' has no default translation in .*"]},
1400 {'category': 'aapt', 'severity': Severity.MEDIUM,
1401 'description': 'aapt: Missing default or required localization',
1402 'patterns': [r".*: warning: \*\*\*\* string '.+' has no default or required localization for '.+' in .+"]},
1403 {'category': 'aapt', 'severity': Severity.MEDIUM,
1404 'description': 'aapt: String marked untranslatable, but translation exists',
1405 'patterns': [r".*: warning: string '.+' in .* marked untranslatable but exists in locale '??_??'"]},
1406 {'category': 'aapt', 'severity': Severity.MEDIUM,
1407 'description': 'aapt: empty span in string',
1408 'patterns': [r".*: warning: empty '.+' span found in text '.+"]},
1409 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1410 'description': 'Taking address of temporary',
1411 'patterns': [r".*: warning: taking address of temporary"]},
1412 {'category': 'C/C++', 'severity': Severity.MEDIUM,
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07001413 'description': 'Taking address of packed member',
1414 'patterns': [r".*: warning: taking address of packed member"]},
1415 {'category': 'C/C++', 'severity': Severity.MEDIUM,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001416 'description': 'Possible broken line continuation',
1417 'patterns': [r".*: warning: backslash and newline separated by space"]},
1418 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wundefined-var-template',
1419 'description': 'Undefined variable template',
1420 'patterns': [r".*: warning: instantiation of variable .* no definition is available"]},
1421 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wundefined-inline',
1422 'description': 'Inline function is not defined',
1423 'patterns': [r".*: warning: inline function '.*' is not defined"]},
1424 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Warray-bounds',
1425 'description': 'Array subscript out of bounds',
1426 'patterns': [r".*: warning: array subscript is above array bounds",
1427 r".*: warning: Array subscript is undefined",
1428 r".*: warning: array subscript is below array bounds"]},
1429 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1430 'description': 'Excess elements in initializer',
1431 'patterns': [r".*: warning: excess elements in .+ initializer"]},
1432 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1433 'description': 'Decimal constant is unsigned only in ISO C90',
1434 'patterns': [r".*: warning: this decimal constant is unsigned only in ISO C90"]},
1435 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmain',
1436 'description': 'main is usually a function',
1437 'patterns': [r".*: warning: 'main' is usually a function"]},
1438 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1439 'description': 'Typedef ignored',
1440 'patterns': [r".*: warning: 'typedef' was ignored in this declaration"]},
1441 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Waddress',
1442 'description': 'Address always evaluates to true',
1443 'patterns': [r".*: warning: the address of '.+' will always evaluate as 'true'"]},
1444 {'category': 'C/C++', 'severity': Severity.FIXMENOW,
1445 'description': 'Freeing a non-heap object',
1446 'patterns': [r".*: warning: attempt to free a non-heap object '.+'"]},
1447 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wchar-subscripts',
1448 'description': 'Array subscript has type char',
1449 'patterns': [r".*: warning: array subscript .+ type 'char'.+Wchar-subscripts"]},
1450 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1451 'description': 'Constant too large for type',
1452 'patterns': [r".*: warning: integer constant is too large for '.+' type"]},
1453 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Woverflow',
1454 'description': 'Constant too large for type, truncated',
1455 'patterns': [r".*: warning: large integer implicitly truncated to unsigned type"]},
1456 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Winteger-overflow',
1457 'description': 'Overflow in expression',
1458 'patterns': [r".*: warning: overflow in expression; .*Winteger-overflow"]},
1459 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Woverflow',
1460 'description': 'Overflow in implicit constant conversion',
1461 'patterns': [r".*: warning: overflow in implicit constant conversion"]},
1462 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1463 'description': 'Declaration does not declare anything',
1464 'patterns': [r".*: warning: declaration 'class .+' does not declare anything"]},
1465 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wreorder',
1466 'description': 'Initialization order will be different',
1467 'patterns': [r".*: warning: '.+' will be initialized after",
1468 r".*: warning: field .+ will be initialized after .+Wreorder"]},
1469 {'category': 'cont.', 'severity': Severity.SKIP,
1470 'description': 'skip, ....',
1471 'patterns': [r".*: warning: '.+'"]},
1472 {'category': 'cont.', 'severity': Severity.SKIP,
1473 'description': 'skip, base ...',
1474 'patterns': [r".*: warning: base '.+'"]},
1475 {'category': 'cont.', 'severity': Severity.SKIP,
1476 'description': 'skip, when initialized here',
1477 'patterns': [r".*: warning: when initialized here"]},
1478 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-parameter-type',
1479 'description': 'Parameter type not specified',
1480 'patterns': [r".*: warning: type of '.+' defaults to 'int'"]},
1481 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-declarations',
1482 'description': 'Missing declarations',
1483 'patterns': [r".*: warning: declaration does not declare anything"]},
1484 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-noreturn',
1485 'description': 'Missing noreturn',
1486 'patterns': [r".*: warning: function '.*' could be declared with attribute 'noreturn'"]},
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001487 # pylint:disable=anomalous-backslash-in-string
1488 # TODO(chh): fix the backslash pylint warning.
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001489 {'category': 'gcc', 'severity': Severity.MEDIUM,
1490 'description': 'Invalid option for C file',
1491 'patterns': [r".*: warning: command line option "".+"" is valid for C\+\+\/ObjC\+\+ but not for C"]},
1492 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1493 'description': 'User warning',
1494 'patterns': [r".*: warning: #warning "".+"""]},
1495 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wvexing-parse',
1496 'description': 'Vexing parsing problem',
1497 'patterns': [r".*: warning: empty parentheses interpreted as a function declaration"]},
1498 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wextra',
1499 'description': 'Dereferencing void*',
1500 'patterns': [r".*: warning: dereferencing 'void \*' pointer"]},
1501 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1502 'description': 'Comparison of pointer and integer',
1503 'patterns': [r".*: warning: ordered comparison of pointer with integer zero",
1504 r".*: warning: .*comparison between pointer and integer"]},
1505 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1506 'description': 'Use of error-prone unary operator',
1507 'patterns': [r".*: warning: use of unary operator that may be intended as compound assignment"]},
1508 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wwrite-strings',
1509 'description': 'Conversion of string constant to non-const char*',
1510 'patterns': [r".*: warning: deprecated conversion from string constant to '.+'"]},
1511 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wstrict-prototypes',
1512 'description': 'Function declaration isn''t a prototype',
1513 'patterns': [r".*: warning: function declaration isn't a prototype"]},
1514 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wignored-qualifiers',
1515 'description': 'Type qualifiers ignored on function return value',
1516 'patterns': [r".*: warning: type qualifiers ignored on function return type",
1517 r".*: warning: .+ type qualifier .+ has no effect .+Wignored-qualifiers"]},
1518 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1519 'description': '<foo> declared inside parameter list, scope limited to this definition',
1520 'patterns': [r".*: warning: '.+' declared inside parameter list"]},
1521 {'category': 'cont.', 'severity': Severity.SKIP,
1522 'description': 'skip, its scope is only this ...',
1523 'patterns': [r".*: warning: its scope is only this definition or declaration, which is probably not what you want"]},
1524 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wcomment',
1525 'description': 'Line continuation inside comment',
1526 'patterns': [r".*: warning: multi-line comment"]},
1527 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wcomment',
1528 'description': 'Comment inside comment',
1529 'patterns': [r".*: warning: "".+"" within comment"]},
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001530 # Warning "value stored is never read" could be from clang-tidy or clang static analyzer.
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001531 {'category': 'C/C++', 'severity': Severity.ANALYZER,
1532 'description': 'clang-analyzer Value stored is never read',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001533 'patterns': [r".*: warning: Value stored to .+ is never read.*clang-analyzer-deadcode.DeadStores"]},
1534 {'category': 'C/C++', 'severity': Severity.LOW,
1535 'description': 'Value stored is never read',
1536 'patterns': [r".*: warning: Value stored to .+ is never read"]},
1537 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wdeprecated-declarations',
1538 'description': 'Deprecated declarations',
1539 'patterns': [r".*: warning: .+ is deprecated.+deprecated-declarations"]},
1540 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wdeprecated-register',
1541 'description': 'Deprecated register',
1542 'patterns': [r".*: warning: 'register' storage class specifier is deprecated"]},
1543 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wpointer-sign',
1544 'description': 'Converts between pointers to integer types with different sign',
1545 'patterns': [r".*: warning: .+ converts between pointers to integer types with different sign"]},
1546 {'category': 'C/C++', 'severity': Severity.HARMLESS,
1547 'description': 'Extra tokens after #endif',
1548 'patterns': [r".*: warning: extra tokens at end of #endif directive"]},
1549 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wenum-compare',
1550 'description': 'Comparison between different enums',
1551 'patterns': [r".*: warning: comparison between '.+' and '.+'.+Wenum-compare"]},
1552 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wconversion',
1553 'description': 'Conversion may change value',
1554 'patterns': [r".*: warning: converting negative value '.+' to '.+'",
1555 r".*: warning: conversion to '.+' .+ may (alter|change)"]},
1556 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wconversion-null',
1557 'description': 'Converting to non-pointer type from NULL',
1558 'patterns': [r".*: warning: converting to non-pointer type '.+' from NULL"]},
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07001559 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsign-conversion',
1560 'description': 'Implicit sign conversion',
1561 'patterns': [r".*: warning: implicit conversion changes signedness"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001562 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wnull-conversion',
1563 'description': 'Converting NULL to non-pointer type',
1564 'patterns': [r".*: warning: implicit conversion of NULL constant to '.+'"]},
1565 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wnon-literal-null-conversion',
1566 'description': 'Zero used as null pointer',
1567 'patterns': [r".*: warning: expression .* zero treated as a null pointer constant"]},
1568 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1569 'description': 'Implicit conversion changes value',
1570 'patterns': [r".*: warning: implicit conversion .* changes value from .* to .*-conversion"]},
1571 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1572 'description': 'Passing NULL as non-pointer argument',
1573 'patterns': [r".*: warning: passing NULL to non-pointer argument [0-9]+ of '.+'"]},
1574 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wctor-dtor-privacy',
1575 'description': 'Class seems unusable because of private ctor/dtor',
1576 'patterns': [r".*: warning: all member functions in class '.+' are private"]},
Marco Nelissen594375d2009-07-14 09:04:04 -07001577 # 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 -07001578 {'category': 'C/C++', 'severity': Severity.SKIP, 'option': '-Wctor-dtor-privacy',
1579 'description': 'Class seems unusable because of private ctor/dtor',
1580 'patterns': [r".*: warning: 'class .+' only defines a private destructor and has no friends"]},
1581 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wctor-dtor-privacy',
1582 'description': 'Class seems unusable because of private ctor/dtor',
1583 'patterns': [r".*: warning: 'class .+' only defines private constructors and has no friends"]},
1584 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wgnu-static-float-init',
1585 'description': 'In-class initializer for static const float/double',
1586 'patterns': [r".*: warning: in-class initializer for static data member of .+const (float|double)"]},
1587 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wpointer-arith',
1588 'description': 'void* used in arithmetic',
1589 'patterns': [r".*: warning: pointer of type 'void \*' used in (arithmetic|subtraction)",
1590 r".*: warning: arithmetic on .+ to void is a GNU extension.*Wpointer-arith",
1591 r".*: warning: wrong type argument to increment"]},
1592 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsign-promo',
1593 'description': 'Overload resolution chose to promote from unsigned or enum to signed type',
1594 'patterns': [r".*: warning: passing '.+' chooses '.+' over '.+'.*Wsign-promo"]},
1595 {'category': 'cont.', 'severity': Severity.SKIP,
1596 'description': 'skip, in call to ...',
1597 'patterns': [r".*: warning: in call to '.+'"]},
1598 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wextra',
1599 'description': 'Base should be explicitly initialized in copy constructor',
1600 'patterns': [r".*: warning: base class '.+' should be explicitly initialized in the copy constructor"]},
1601 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1602 'description': 'VLA has zero or negative size',
1603 'patterns': [r".*: warning: Declared variable-length array \(VLA\) has .+ size"]},
1604 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1605 'description': 'Return value from void function',
1606 'patterns': [r".*: warning: 'return' with a value, in function returning void"]},
1607 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'multichar',
1608 'description': 'Multi-character character constant',
1609 'patterns': [r".*: warning: multi-character character constant"]},
1610 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'writable-strings',
1611 'description': 'Conversion from string literal to char*',
1612 'patterns': [r".*: warning: .+ does not allow conversion from string literal to 'char \*'"]},
1613 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wextra-semi',
1614 'description': 'Extra \';\'',
1615 'patterns': [r".*: warning: extra ';' .+extra-semi"]},
1616 {'category': 'C/C++', 'severity': Severity.LOW,
1617 'description': 'Useless specifier',
1618 'patterns': [r".*: warning: useless storage class specifier in empty declaration"]},
1619 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wduplicate-decl-specifier',
1620 'description': 'Duplicate declaration specifier',
1621 'patterns': [r".*: warning: duplicate '.+' declaration specifier"]},
1622 {'category': 'logtags', 'severity': Severity.LOW,
1623 'description': 'Duplicate logtag',
1624 'patterns': [r".*: warning: tag \".+\" \(.+\) duplicated in .+"]},
1625 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'typedef-redefinition',
1626 'description': 'Typedef redefinition',
1627 'patterns': [r".*: warning: redefinition of typedef '.+' is a C11 feature"]},
1628 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'gnu-designator',
1629 'description': 'GNU old-style field designator',
1630 'patterns': [r".*: warning: use of GNU old-style field designator extension"]},
1631 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'missing-field-initializers',
1632 'description': 'Missing field initializers',
1633 'patterns': [r".*: warning: missing field '.+' initializer"]},
1634 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'missing-braces',
1635 'description': 'Missing braces',
1636 'patterns': [r".*: warning: suggest braces around initialization of",
1637 r".*: warning: too many braces around scalar initializer .+Wmany-braces-around-scalar-init",
1638 r".*: warning: braces around scalar initializer"]},
1639 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'sign-compare',
1640 'description': 'Comparison of integers of different signs',
1641 'patterns': [r".*: warning: comparison of integers of different signs.+sign-compare"]},
1642 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'dangling-else',
1643 'description': 'Add braces to avoid dangling else',
1644 'patterns': [r".*: warning: add explicit braces to avoid dangling else"]},
1645 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'initializer-overrides',
1646 'description': 'Initializer overrides prior initialization',
1647 'patterns': [r".*: warning: initializer overrides prior initialization of this subobject"]},
1648 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'self-assign',
1649 'description': 'Assigning value to self',
1650 'patterns': [r".*: warning: explicitly assigning value of .+ to itself"]},
1651 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'gnu-variable-sized-type-not-at-end',
1652 'description': 'GNU extension, variable sized type not at end',
1653 'patterns': [r".*: warning: field '.+' with variable sized type '.+' not at the end of a struct or class"]},
1654 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'tautological-constant-out-of-range-compare',
1655 'description': 'Comparison of constant is always false/true',
1656 'patterns': [r".*: comparison of .+ is always .+Wtautological-constant-out-of-range-compare"]},
1657 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'overloaded-virtual',
1658 'description': 'Hides overloaded virtual function',
1659 'patterns': [r".*: '.+' hides overloaded virtual function"]},
1660 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'incompatible-pointer-types',
1661 'description': 'Incompatible pointer types',
1662 'patterns': [r".*: warning: incompatible pointer types .+Wincompatible-pointer-types"]},
1663 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'asm-operand-widths',
1664 'description': 'ASM value size does not match register size',
1665 'patterns': [r".*: warning: value size does not match register size specified by the constraint and modifier"]},
1666 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'tautological-compare',
1667 'description': 'Comparison of self is always false',
1668 'patterns': [r".*: self-comparison always evaluates to false"]},
1669 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'constant-logical-operand',
1670 'description': 'Logical op with constant operand',
1671 'patterns': [r".*: use of logical '.+' with constant operand"]},
1672 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'literal-suffix',
1673 'description': 'Needs a space between literal and string macro',
1674 'patterns': [r".*: warning: invalid suffix on literal.+ requires a space .+Wliteral-suffix"]},
1675 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '#warnings',
1676 'description': 'Warnings from #warning',
1677 'patterns': [r".*: warning: .+-W#warnings"]},
1678 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'absolute-value',
1679 'description': 'Using float/int absolute value function with int/float argument',
1680 'patterns': [r".*: warning: using .+ absolute value function .+ when argument is .+ type .+Wabsolute-value",
1681 r".*: warning: absolute value function '.+' given .+ which may cause truncation .+Wabsolute-value"]},
1682 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wc++11-extensions',
1683 'description': 'Using C++11 extensions',
1684 'patterns': [r".*: warning: 'auto' type specifier is a C\+\+11 extension"]},
1685 {'category': 'C/C++', 'severity': Severity.LOW,
1686 'description': 'Refers to implicitly defined namespace',
1687 'patterns': [r".*: warning: using directive refers to implicitly-defined namespace .+"]},
1688 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Winvalid-pp-token',
1689 'description': 'Invalid pp token',
1690 'patterns': [r".*: warning: missing .+Winvalid-pp-token"]},
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07001691 {'category': 'link', 'severity': Severity.LOW,
1692 'description': 'need glibc to link',
1693 'patterns': [r".*: warning: .* requires at runtime .* glibc .* for linking"]},
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001694
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001695 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1696 'description': 'Operator new returns NULL',
1697 'patterns': [r".*: warning: 'operator new' must not return NULL unless it is declared 'throw\(\)' .+"]},
1698 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wnull-arithmetic',
1699 'description': 'NULL used in arithmetic',
1700 'patterns': [r".*: warning: NULL used in arithmetic",
1701 r".*: warning: comparison between NULL and non-pointer"]},
1702 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'header-guard',
1703 'description': 'Misspelled header guard',
1704 'patterns': [r".*: warning: '.+' is used as a header guard .+ followed by .+ different macro"]},
1705 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'empty-body',
1706 'description': 'Empty loop body',
1707 'patterns': [r".*: warning: .+ loop has empty body"]},
1708 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'enum-conversion',
1709 'description': 'Implicit conversion from enumeration type',
1710 'patterns': [r".*: warning: implicit conversion from enumeration type '.+'"]},
1711 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'switch',
1712 'description': 'case value not in enumerated type',
1713 'patterns': [r".*: warning: case value not in enumerated type '.+'"]},
1714 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1715 'description': 'Undefined result',
1716 'patterns': [r".*: warning: The result of .+ is undefined",
1717 r".*: warning: passing an object that .+ has undefined behavior \[-Wvarargs\]",
1718 r".*: warning: 'this' pointer cannot be null in well-defined C\+\+ code;",
1719 r".*: warning: shifting a negative signed value is undefined"]},
1720 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1721 'description': 'Division by zero',
1722 'patterns': [r".*: warning: Division by zero"]},
1723 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1724 'description': 'Use of deprecated method',
1725 'patterns': [r".*: warning: '.+' is deprecated .+"]},
1726 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1727 'description': 'Use of garbage or uninitialized value',
1728 'patterns': [r".*: warning: .+ is a garbage value",
1729 r".*: warning: Function call argument is an uninitialized value",
1730 r".*: warning: Undefined or garbage value returned to caller",
1731 r".*: warning: Called .+ pointer is.+uninitialized",
1732 r".*: warning: Called .+ pointer is.+uninitalized", # match a typo in compiler message
1733 r".*: warning: Use of zero-allocated memory",
1734 r".*: warning: Dereference of undefined pointer value",
1735 r".*: warning: Passed-by-value .+ contains uninitialized data",
1736 r".*: warning: Branch condition evaluates to a garbage value",
1737 r".*: warning: The .+ of .+ is an uninitialized value.",
1738 r".*: warning: .+ is used uninitialized whenever .+sometimes-uninitialized",
1739 r".*: warning: Assigned value is garbage or undefined"]},
1740 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1741 'description': 'Result of malloc type incompatible with sizeof operand type',
1742 'patterns': [r".*: warning: Result of '.+' is converted to .+ incompatible with sizeof operand type"]},
1743 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsizeof-array-argument',
1744 'description': 'Sizeof on array argument',
1745 'patterns': [r".*: warning: sizeof on array function parameter will return"]},
1746 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsizeof-pointer-memacces',
1747 'description': 'Bad argument size of memory access functions',
1748 'patterns': [r".*: warning: .+\[-Wsizeof-pointer-memaccess\]"]},
1749 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1750 'description': 'Return value not checked',
1751 'patterns': [r".*: warning: The return value from .+ is not checked"]},
1752 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1753 'description': 'Possible heap pollution',
1754 'patterns': [r".*: warning: .*Possible heap pollution from .+ type .+"]},
1755 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1756 'description': 'Allocation size of 0 byte',
1757 'patterns': [r".*: warning: Call to .+ has an allocation size of 0 byte"]},
1758 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1759 'description': 'Result of malloc type incompatible with sizeof operand type',
1760 'patterns': [r".*: warning: Result of '.+' is converted to .+ incompatible with sizeof operand type"]},
1761 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wfor-loop-analysis',
1762 'description': 'Variable used in loop condition not modified in loop body',
1763 'patterns': [r".*: warning: variable '.+' used in loop condition.*Wfor-loop-analysis"]},
1764 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1765 'description': 'Closing a previously closed file',
1766 'patterns': [r".*: warning: Closing a previously closed file"]},
1767 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunnamed-type-template-args',
1768 'description': 'Unnamed template type argument',
1769 'patterns': [r".*: warning: template argument.+Wunnamed-type-template-args"]},
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001770
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001771 {'category': 'C/C++', 'severity': Severity.HARMLESS,
1772 'description': 'Discarded qualifier from pointer target type',
1773 'patterns': [r".*: warning: .+ discards '.+' qualifier from pointer target type"]},
1774 {'category': 'C/C++', 'severity': Severity.HARMLESS,
1775 'description': 'Use snprintf instead of sprintf',
1776 'patterns': [r".*: warning: .*sprintf is often misused; please use snprintf"]},
1777 {'category': 'C/C++', 'severity': Severity.HARMLESS,
1778 'description': 'Unsupported optimizaton flag',
1779 'patterns': [r".*: warning: optimization flag '.+' is not supported"]},
1780 {'category': 'C/C++', 'severity': Severity.HARMLESS,
1781 'description': 'Extra or missing parentheses',
1782 'patterns': [r".*: warning: equality comparison with extraneous parentheses",
1783 r".*: warning: .+ within .+Wlogical-op-parentheses"]},
1784 {'category': 'C/C++', 'severity': Severity.HARMLESS, 'option': 'mismatched-tags',
1785 'description': 'Mismatched class vs struct tags',
1786 'patterns': [r".*: warning: '.+' defined as a .+ here but previously declared as a .+mismatched-tags",
1787 r".*: warning: .+ was previously declared as a .+mismatched-tags"]},
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07001788 {'category': 'FindEmulator', 'severity': Severity.HARMLESS,
1789 'description': 'FindEmulator: No such file or directory',
1790 'patterns': [r".*: warning: FindEmulator: .* No such file or directory"]},
1791 {'category': 'google_tests', 'severity': Severity.HARMLESS,
1792 'description': 'google_tests: unknown installed file',
1793 'patterns': [r".*: warning: .*_tests: Unknown installed file for module"]},
1794 {'category': 'make', 'severity': Severity.HARMLESS,
1795 'description': 'unusual tags debug eng',
1796 'patterns': [r".*: warning: .*: unusual tags debug eng"]},
Marco Nelissen594375d2009-07-14 09:04:04 -07001797
1798 # 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 -07001799 {'category': 'C/C++', 'severity': Severity.SKIP,
1800 'description': 'skip, ,',
1801 'patterns': [r".*: warning: ,$"]},
1802 {'category': 'C/C++', 'severity': Severity.SKIP,
1803 'description': 'skip,',
1804 'patterns': [r".*: warning: $"]},
1805 {'category': 'C/C++', 'severity': Severity.SKIP,
1806 'description': 'skip, In file included from ...',
1807 'patterns': [r".*: warning: In file included from .+,"]},
Marco Nelissen594375d2009-07-14 09:04:04 -07001808
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001809 # warnings from clang-tidy
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07001810 group_tidy_warn_pattern('cert'),
1811 group_tidy_warn_pattern('clang-diagnostic'),
1812 group_tidy_warn_pattern('cppcoreguidelines'),
1813 group_tidy_warn_pattern('llvm'),
1814 simple_tidy_warn_pattern('google-default-arguments'),
1815 simple_tidy_warn_pattern('google-runtime-int'),
1816 simple_tidy_warn_pattern('google-runtime-operator'),
1817 simple_tidy_warn_pattern('google-runtime-references'),
1818 group_tidy_warn_pattern('google-build'),
1819 group_tidy_warn_pattern('google-explicit'),
1820 group_tidy_warn_pattern('google-redability'),
1821 group_tidy_warn_pattern('google-global'),
1822 group_tidy_warn_pattern('google-redability'),
1823 group_tidy_warn_pattern('google-redability'),
1824 group_tidy_warn_pattern('google'),
1825 simple_tidy_warn_pattern('hicpp-explicit-conversions'),
1826 simple_tidy_warn_pattern('hicpp-function-size'),
1827 simple_tidy_warn_pattern('hicpp-invalid-access-moved'),
1828 simple_tidy_warn_pattern('hicpp-member-init'),
1829 simple_tidy_warn_pattern('hicpp-delete-operators'),
1830 simple_tidy_warn_pattern('hicpp-special-member-functions'),
1831 simple_tidy_warn_pattern('hicpp-use-equals-default'),
1832 simple_tidy_warn_pattern('hicpp-use-equals-delete'),
1833 simple_tidy_warn_pattern('hicpp-no-assembler'),
1834 simple_tidy_warn_pattern('hicpp-noexcept-move'),
1835 simple_tidy_warn_pattern('hicpp-use-override'),
1836 group_tidy_warn_pattern('hicpp'),
1837 group_tidy_warn_pattern('modernize'),
1838 group_tidy_warn_pattern('misc'),
1839 simple_tidy_warn_pattern('performance-faster-string-find'),
1840 simple_tidy_warn_pattern('performance-for-range-copy'),
1841 simple_tidy_warn_pattern('performance-implicit-cast-in-loop'),
1842 simple_tidy_warn_pattern('performance-inefficient-string-concatenation'),
1843 simple_tidy_warn_pattern('performance-type-promotion-in-math-fn'),
1844 simple_tidy_warn_pattern('performance-unnecessary-copy-initialization'),
1845 simple_tidy_warn_pattern('performance-unnecessary-value-param'),
1846 group_tidy_warn_pattern('performance'),
1847 group_tidy_warn_pattern('readability'),
1848
1849 # warnings from clang-tidy's clang-analyzer checks
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001850 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001851 'description': 'clang-analyzer Unreachable code',
1852 'patterns': [r".*: warning: This statement is never executed.*UnreachableCode"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001853 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001854 'description': 'clang-analyzer Size of malloc may overflow',
1855 'patterns': [r".*: warning: .* size of .* may overflow .*MallocOverflow"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001856 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001857 'description': 'clang-analyzer Stream pointer might be NULL',
1858 'patterns': [r".*: warning: Stream pointer might be NULL .*unix.Stream"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001859 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001860 'description': 'clang-analyzer Opened file never closed',
1861 'patterns': [r".*: warning: Opened File never closed.*unix.Stream"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001862 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001863 'description': 'clang-analyzer sozeof() on a pointer type',
1864 'patterns': [r".*: warning: .*calls sizeof.* on a pointer type.*SizeofPtr"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001865 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001866 'description': 'clang-analyzer Pointer arithmetic on non-array variables',
1867 'patterns': [r".*: warning: Pointer arithmetic on non-array variables .*PointerArithm"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001868 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001869 'description': 'clang-analyzer Subtraction of pointers of different memory chunks',
1870 'patterns': [r".*: warning: Subtraction of two pointers .*PointerSub"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001871 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001872 'description': 'clang-analyzer Access out-of-bound array element',
1873 'patterns': [r".*: warning: Access out-of-bound array element .*ArrayBound"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001874 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001875 'description': 'clang-analyzer Out of bound memory access',
1876 'patterns': [r".*: warning: Out of bound memory access .*ArrayBoundV2"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001877 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001878 'description': 'clang-analyzer Possible lock order reversal',
1879 'patterns': [r".*: warning: .* Possible lock order reversal.*PthreadLock"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001880 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001881 'description': 'clang-analyzer Argument is a pointer to uninitialized value',
1882 'patterns': [r".*: warning: .* argument is a pointer to uninitialized value .*CallAndMessage"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001883 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001884 'description': 'clang-analyzer cast to struct',
1885 'patterns': [r".*: warning: Casting a non-structure type to a structure type .*CastToStruct"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001886 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001887 'description': 'clang-analyzer call path problems',
1888 'patterns': [r".*: warning: Call Path : .+"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07001889 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07001890 'description': 'clang-analyzer excessive padding',
1891 'patterns': [r".*: warning: Excessive padding in '.*'"]},
1892 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001893 'description': 'clang-analyzer other',
1894 'patterns': [r".*: .+\[clang-analyzer-.+\]$",
1895 r".*: Call Path : .+$"]},
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001896
Marco Nelissen594375d2009-07-14 09:04:04 -07001897 # catch-all for warnings this script doesn't know about yet
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001898 {'category': 'C/C++', 'severity': Severity.UNKNOWN,
1899 'description': 'Unclassified/unrecognized warnings',
1900 'patterns': [r".*: warning: .+"]},
Marco Nelissen594375d2009-07-14 09:04:04 -07001901]
1902
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001903
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001904def project_name_and_pattern(name, pattern):
1905 return [name, '(^|.*/)' + pattern + '/.*: warning:']
1906
1907
1908def simple_project_pattern(pattern):
1909 return project_name_and_pattern(pattern, pattern)
1910
1911
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001912# A list of [project_name, file_path_pattern].
1913# project_name should not contain comma, to be used in CSV output.
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001914project_list = [
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001915 simple_project_pattern('art'),
1916 simple_project_pattern('bionic'),
1917 simple_project_pattern('bootable'),
1918 simple_project_pattern('build'),
1919 simple_project_pattern('cts'),
1920 simple_project_pattern('dalvik'),
1921 simple_project_pattern('developers'),
1922 simple_project_pattern('development'),
1923 simple_project_pattern('device'),
1924 simple_project_pattern('doc'),
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07001925 # match external/google* before external/
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001926 project_name_and_pattern('external/google', 'external/google.*'),
1927 project_name_and_pattern('external/non-google', 'external'),
1928 simple_project_pattern('frameworks/av/camera'),
1929 simple_project_pattern('frameworks/av/cmds'),
1930 simple_project_pattern('frameworks/av/drm'),
1931 simple_project_pattern('frameworks/av/include'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07001932 simple_project_pattern('frameworks/av/media/common_time'),
1933 simple_project_pattern('frameworks/av/media/img_utils'),
1934 simple_project_pattern('frameworks/av/media/libcpustats'),
1935 simple_project_pattern('frameworks/av/media/libeffects'),
1936 simple_project_pattern('frameworks/av/media/libmediaplayerservice'),
1937 simple_project_pattern('frameworks/av/media/libmedia'),
1938 simple_project_pattern('frameworks/av/media/libstagefright'),
1939 simple_project_pattern('frameworks/av/media/mtp'),
1940 simple_project_pattern('frameworks/av/media/ndk'),
1941 simple_project_pattern('frameworks/av/media/utils'),
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07001942 project_name_and_pattern('frameworks/av/media/Other',
1943 'frameworks/av/media'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001944 simple_project_pattern('frameworks/av/radio'),
1945 simple_project_pattern('frameworks/av/services'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07001946 simple_project_pattern('frameworks/av/soundtrigger'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001947 project_name_and_pattern('frameworks/av/Other', 'frameworks/av'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07001948 simple_project_pattern('frameworks/base/cmds'),
1949 simple_project_pattern('frameworks/base/core'),
1950 simple_project_pattern('frameworks/base/drm'),
1951 simple_project_pattern('frameworks/base/media'),
1952 simple_project_pattern('frameworks/base/libs'),
1953 simple_project_pattern('frameworks/base/native'),
1954 simple_project_pattern('frameworks/base/packages'),
1955 simple_project_pattern('frameworks/base/rs'),
1956 simple_project_pattern('frameworks/base/services'),
1957 simple_project_pattern('frameworks/base/tests'),
1958 simple_project_pattern('frameworks/base/tools'),
1959 project_name_and_pattern('frameworks/base/Other', 'frameworks/base'),
Stephen Hinesd0aec892016-10-17 15:39:53 -07001960 simple_project_pattern('frameworks/compile/libbcc'),
1961 simple_project_pattern('frameworks/compile/mclinker'),
1962 simple_project_pattern('frameworks/compile/slang'),
1963 project_name_and_pattern('frameworks/compile/Other', 'frameworks/compile'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001964 simple_project_pattern('frameworks/minikin'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07001965 simple_project_pattern('frameworks/ml'),
1966 simple_project_pattern('frameworks/native/cmds'),
1967 simple_project_pattern('frameworks/native/include'),
1968 simple_project_pattern('frameworks/native/libs'),
1969 simple_project_pattern('frameworks/native/opengl'),
1970 simple_project_pattern('frameworks/native/services'),
1971 simple_project_pattern('frameworks/native/vulkan'),
1972 project_name_and_pattern('frameworks/native/Other', 'frameworks/native'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001973 simple_project_pattern('frameworks/opt'),
1974 simple_project_pattern('frameworks/rs'),
1975 simple_project_pattern('frameworks/webview'),
1976 simple_project_pattern('frameworks/wilhelm'),
1977 project_name_and_pattern('frameworks/Other', 'frameworks'),
1978 simple_project_pattern('hardware/akm'),
1979 simple_project_pattern('hardware/broadcom'),
1980 simple_project_pattern('hardware/google'),
1981 simple_project_pattern('hardware/intel'),
1982 simple_project_pattern('hardware/interfaces'),
1983 simple_project_pattern('hardware/libhardware'),
1984 simple_project_pattern('hardware/libhardware_legacy'),
1985 simple_project_pattern('hardware/qcom'),
1986 simple_project_pattern('hardware/ril'),
1987 project_name_and_pattern('hardware/Other', 'hardware'),
1988 simple_project_pattern('kernel'),
1989 simple_project_pattern('libcore'),
1990 simple_project_pattern('libnativehelper'),
1991 simple_project_pattern('ndk'),
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001992 # match vendor/unbungled_google/packages before other packages
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001993 simple_project_pattern('unbundled_google'),
1994 simple_project_pattern('packages'),
1995 simple_project_pattern('pdk'),
1996 simple_project_pattern('prebuilts'),
1997 simple_project_pattern('system/bt'),
1998 simple_project_pattern('system/connectivity'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07001999 simple_project_pattern('system/core/adb'),
2000 simple_project_pattern('system/core/base'),
2001 simple_project_pattern('system/core/debuggerd'),
2002 simple_project_pattern('system/core/fastboot'),
2003 simple_project_pattern('system/core/fingerprintd'),
2004 simple_project_pattern('system/core/fs_mgr'),
2005 simple_project_pattern('system/core/gatekeeperd'),
2006 simple_project_pattern('system/core/healthd'),
2007 simple_project_pattern('system/core/include'),
2008 simple_project_pattern('system/core/init'),
2009 simple_project_pattern('system/core/libbacktrace'),
2010 simple_project_pattern('system/core/liblog'),
2011 simple_project_pattern('system/core/libpixelflinger'),
2012 simple_project_pattern('system/core/libprocessgroup'),
2013 simple_project_pattern('system/core/libsysutils'),
2014 simple_project_pattern('system/core/logcat'),
2015 simple_project_pattern('system/core/logd'),
2016 simple_project_pattern('system/core/run-as'),
2017 simple_project_pattern('system/core/sdcard'),
2018 simple_project_pattern('system/core/toolbox'),
2019 project_name_and_pattern('system/core/Other', 'system/core'),
2020 simple_project_pattern('system/extras/ANRdaemon'),
2021 simple_project_pattern('system/extras/cpustats'),
2022 simple_project_pattern('system/extras/crypto-perf'),
2023 simple_project_pattern('system/extras/ext4_utils'),
2024 simple_project_pattern('system/extras/f2fs_utils'),
2025 simple_project_pattern('system/extras/iotop'),
2026 simple_project_pattern('system/extras/libfec'),
2027 simple_project_pattern('system/extras/memory_replay'),
2028 simple_project_pattern('system/extras/micro_bench'),
2029 simple_project_pattern('system/extras/mmap-perf'),
2030 simple_project_pattern('system/extras/multinetwork'),
2031 simple_project_pattern('system/extras/perfprofd'),
2032 simple_project_pattern('system/extras/procrank'),
2033 simple_project_pattern('system/extras/runconuid'),
2034 simple_project_pattern('system/extras/showmap'),
2035 simple_project_pattern('system/extras/simpleperf'),
2036 simple_project_pattern('system/extras/su'),
2037 simple_project_pattern('system/extras/tests'),
2038 simple_project_pattern('system/extras/verity'),
2039 project_name_and_pattern('system/extras/Other', 'system/extras'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002040 simple_project_pattern('system/gatekeeper'),
2041 simple_project_pattern('system/keymaster'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002042 simple_project_pattern('system/libhidl'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002043 simple_project_pattern('system/libhwbinder'),
2044 simple_project_pattern('system/media'),
2045 simple_project_pattern('system/netd'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002046 simple_project_pattern('system/nvram'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002047 simple_project_pattern('system/security'),
2048 simple_project_pattern('system/sepolicy'),
2049 simple_project_pattern('system/tools'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002050 simple_project_pattern('system/update_engine'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002051 simple_project_pattern('system/vold'),
2052 project_name_and_pattern('system/Other', 'system'),
2053 simple_project_pattern('toolchain'),
2054 simple_project_pattern('test'),
2055 simple_project_pattern('tools'),
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07002056 # match vendor/google* before vendor/
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002057 project_name_and_pattern('vendor/google', 'vendor/google.*'),
2058 project_name_and_pattern('vendor/non-google', 'vendor'),
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07002059 # keep out/obj and other patterns at the end.
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002060 ['out/obj',
2061 '.*/(gen|obj[^/]*)/(include|EXECUTABLES|SHARED_LIBRARIES|'
2062 'STATIC_LIBRARIES|NATIVE_TESTS)/.*: warning:'],
2063 ['other', '.*'] # all other unrecognized patterns
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002064]
2065
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002066project_patterns = []
2067project_names = []
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002068warning_messages = []
2069warning_records = []
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002070
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07002071
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002072def initialize_arrays():
2073 """Complete global arrays before they are used."""
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002074 global project_names, project_patterns
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002075 project_names = [p[0] for p in project_list]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002076 project_patterns = [re.compile(p[1]) for p in project_list]
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002077 for w in warn_patterns:
2078 w['members'] = []
2079 if 'option' not in w:
2080 w['option'] = ''
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002081 # Each warning pattern has a 'projects' dictionary, that
2082 # maps a project name to number of warnings in that project.
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002083 w['projects'] = {}
2084
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002085
2086initialize_arrays()
2087
2088
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -07002089android_root = ''
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002090platform_version = 'unknown'
2091target_product = 'unknown'
2092target_variant = 'unknown'
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002093
2094
2095##### Data and functions to dump html file. ##################################
2096
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002097html_head_scripts = """\
2098 <script type="text/javascript">
2099 function expand(id) {
2100 var e = document.getElementById(id);
2101 var f = document.getElementById(id + "_mark");
2102 if (e.style.display == 'block') {
2103 e.style.display = 'none';
2104 f.innerHTML = '&#x2295';
2105 }
2106 else {
2107 e.style.display = 'block';
2108 f.innerHTML = '&#x2296';
2109 }
2110 };
2111 function expandCollapse(show) {
2112 for (var id = 1; ; id++) {
2113 var e = document.getElementById(id + "");
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07002114 var f = document.getElementById(id + "_mark");
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002115 if (!e || !f) break;
2116 e.style.display = (show ? 'block' : 'none');
2117 f.innerHTML = (show ? '&#x2296' : '&#x2295');
2118 }
2119 };
2120 </script>
2121 <style type="text/css">
2122 th,td{border-collapse:collapse; border:1px solid black;}
2123 .button{color:blue;font-size:110%;font-weight:bolder;}
2124 .bt{color:black;background-color:transparent;border:none;outline:none;
2125 font-size:140%;font-weight:bolder;}
2126 .c0{background-color:#e0e0e0;}
2127 .c1{background-color:#d0d0d0;}
2128 .t1{border-collapse:collapse; width:100%; border:1px solid black;}
2129 </style>
2130 <script src="https://www.gstatic.com/charts/loader.js"></script>
2131"""
Marco Nelissen594375d2009-07-14 09:04:04 -07002132
Marco Nelissen594375d2009-07-14 09:04:04 -07002133
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002134def html_big(param):
2135 return '<font size="+2">' + param + '</font>'
Marco Nelissen594375d2009-07-14 09:04:04 -07002136
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07002137
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002138def dump_html_prologue(title):
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002139 print '<html>\n<head>'
2140 print '<title>' + title + '</title>'
2141 print html_head_scripts
2142 emit_stats_by_project()
2143 print '</head>\n<body>'
2144 print html_big(title)
2145 print '<p>'
Marco Nelissen594375d2009-07-14 09:04:04 -07002146
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002147
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002148def dump_html_epilogue():
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002149 print '</body>\n</head>\n</html>'
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07002150
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002151
2152def sort_warnings():
2153 for i in warn_patterns:
2154 i['members'] = sorted(set(i['members']))
2155
2156
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002157def emit_stats_by_project():
2158 """Dump a google chart table of warnings per project and severity."""
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002159 # warnings[p][s] is number of warnings in project p of severity s.
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002160 warnings = {p: {s: 0 for s in Severity.range} for p in project_names}
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002161 for i in warn_patterns:
2162 s = i['severity']
2163 for p in i['projects']:
2164 warnings[p][s] += i['projects'][p]
2165
2166 # total_by_project[p] is number of warnings in project p.
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002167 total_by_project = {p: sum(warnings[p][s] for s in Severity.range)
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002168 for p in project_names}
2169
2170 # total_by_severity[s] is number of warnings of severity s.
2171 total_by_severity = {s: sum(warnings[p][s] for p in project_names)
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002172 for s in Severity.range}
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07002173
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002174 # emit table header
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002175 stats_header = ['Project']
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002176 for s in Severity.range:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002177 if total_by_severity[s]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002178 stats_header.append("<span style='background-color:{}'>{}</span>".
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002179 format(Severity.colors[s],
2180 Severity.column_headers[s]))
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002181 stats_header.append('TOTAL')
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07002182
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002183 # emit a row of warning counts per project, skip no-warning projects
2184 total_all_projects = 0
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002185 stats_rows = []
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002186 for p in project_names:
2187 if total_by_project[p]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002188 one_row = [p]
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002189 for s in Severity.range:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002190 if total_by_severity[s]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002191 one_row.append(warnings[p][s])
2192 one_row.append(total_by_project[p])
2193 stats_rows.append(one_row)
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002194 total_all_projects += total_by_project[p]
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07002195
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002196 # emit a row of warning counts per severity
2197 total_all_severities = 0
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002198 one_row = ['<b>TOTAL</b>']
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002199 for s in Severity.range:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002200 if total_by_severity[s]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002201 one_row.append(total_by_severity[s])
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002202 total_all_severities += total_by_severity[s]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002203 one_row.append(total_all_projects)
2204 stats_rows.append(one_row)
2205 print '<script>'
2206 emit_const_string_array('StatsHeader', stats_header)
2207 emit_const_object_array('StatsRows', stats_rows)
2208 print draw_table_javascript
2209 print '</script>'
Marco Nelissen594375d2009-07-14 09:04:04 -07002210
2211
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002212def dump_stats():
2213 """Dump some stats about total number of warnings and such."""
2214 known = 0
2215 skipped = 0
2216 unknown = 0
2217 sort_warnings()
2218 for i in warn_patterns:
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002219 if i['severity'] == Severity.UNKNOWN:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002220 unknown += len(i['members'])
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002221 elif i['severity'] == Severity.SKIP:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002222 skipped += len(i['members'])
Ian Rogersf3829732016-05-10 12:06:01 -07002223 else:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002224 known += len(i['members'])
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002225 print 'Number of classified warnings: <b>' + str(known) + '</b><br>'
2226 print 'Number of skipped warnings: <b>' + str(skipped) + '</b><br>'
2227 print 'Number of unclassified warnings: <b>' + str(unknown) + '</b><br>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002228 total = unknown + known + skipped
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002229 extra_msg = ''
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002230 if total < 1000:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002231 extra_msg = ' (low count may indicate incremental build)'
2232 print 'Total number of warnings: <b>' + str(total) + '</b>' + extra_msg
Marco Nelissen594375d2009-07-14 09:04:04 -07002233
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07002234
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002235# New base table of warnings, [severity, warn_id, project, warning_message]
2236# Need buttons to show warnings in different grouping options.
2237# (1) Current, group by severity, id for each warning pattern
2238# sort by severity, warn_id, warning_message
2239# (2) Current --byproject, group by severity,
2240# id for each warning pattern + project name
2241# sort by severity, warn_id, project, warning_message
2242# (3) New, group by project + severity,
2243# id for each warning pattern
2244# sort by project, severity, warn_id, warning_message
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002245def emit_buttons():
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002246 print ('<button class="button" onclick="expandCollapse(1);">'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002247 'Expand all warnings</button>\n'
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002248 '<button class="button" onclick="expandCollapse(0);">'
2249 'Collapse all warnings</button>\n'
2250 '<button class="button" onclick="groupBySeverity();">'
2251 'Group warnings by severity</button>\n'
2252 '<button class="button" onclick="groupByProject();">'
2253 'Group warnings by project</button><br>')
Marco Nelissen594375d2009-07-14 09:04:04 -07002254
2255
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002256def all_patterns(category):
2257 patterns = ''
2258 for i in category['patterns']:
2259 patterns += i
2260 patterns += ' / '
2261 return patterns
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002262
2263
2264def dump_fixed():
2265 """Show which warnings no longer occur."""
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002266 anchor = 'fixed_warnings'
2267 mark = anchor + '_mark'
2268 print ('\n<br><p style="background-color:lightblue"><b>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002269 '<button id="' + mark + '" '
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002270 'class="bt" onclick="expand(\'' + anchor + '\');">'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002271 '&#x2295</button> Fixed warnings. '
2272 'No more occurrences. Please consider turning these into '
2273 'errors if possible, before they are reintroduced in to the build'
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002274 ':</b></p>')
2275 print '<blockquote>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002276 fixed_patterns = []
2277 for i in warn_patterns:
2278 if not i['members']:
2279 fixed_patterns.append(i['description'] + ' (' +
2280 all_patterns(i) + ')')
2281 if i['option']:
2282 fixed_patterns.append(' ' + i['option'])
2283 fixed_patterns.sort()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002284 print '<div id="' + anchor + '" style="display:none;"><table>'
2285 cur_row_class = 0
2286 for text in fixed_patterns:
2287 cur_row_class = 1 - cur_row_class
2288 # remove last '\n'
2289 t = text[:-1] if text[-1] == '\n' else text
2290 print '<tr><td class="c' + str(cur_row_class) + '">' + t + '</td></tr>'
2291 print '</table></div>'
2292 print '</blockquote>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002293
2294
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002295def find_project_index(line):
2296 for p in range(len(project_patterns)):
2297 if project_patterns[p].match(line):
2298 return p
2299 return -1
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002300
2301
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002302def classify_one_warning(line, results):
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002303 for i in range(len(warn_patterns)):
2304 w = warn_patterns[i]
2305 for cpat in w['compiled_patterns']:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002306 if cpat.match(line):
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002307 p = find_project_index(line)
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002308 results.append([line, i, p])
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002309 return
2310 else:
2311 # If we end up here, there was a problem parsing the log
2312 # probably caused by 'make -j' mixing the output from
2313 # 2 or more concurrent compiles
2314 pass
Marco Nelissen594375d2009-07-14 09:04:04 -07002315
2316
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002317def classify_warnings(lines):
2318 results = []
2319 for line in lines:
2320 classify_one_warning(line, results)
Chih-Hung Hsieh76d00652016-11-09 18:19:05 -08002321 # After the main work, ignore all other signals to a child process,
2322 # to avoid bad warning/error messages from the exit clean-up process.
2323 if args.processes > 1:
2324 signal.signal(signal.SIGTERM, lambda *args: sys.exit(-signal.SIGTERM))
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002325 return results
2326
2327
2328def parallel_classify_warnings(warning_lines):
2329 """Classify all warning lines with num_cpu parallel processes."""
Chih-Hung Hsieh76d00652016-11-09 18:19:05 -08002330 compile_patterns()
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002331 num_cpu = args.processes
Chih-Hung Hsieh63de3002016-10-28 10:53:34 -07002332 if num_cpu > 1:
2333 groups = [[] for x in range(num_cpu)]
2334 i = 0
2335 for x in warning_lines:
2336 groups[i].append(x)
2337 i = (i + 1) % num_cpu
2338 pool = multiprocessing.Pool(num_cpu)
2339 group_results = pool.map(classify_warnings, groups)
2340 else:
2341 group_results = [classify_warnings(warning_lines)]
2342
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002343 for result in group_results:
2344 for line, pattern_idx, project_idx in result:
2345 pattern = warn_patterns[pattern_idx]
2346 pattern['members'].append(line)
2347 message_idx = len(warning_messages)
2348 warning_messages.append(line)
2349 warning_records.append([pattern_idx, project_idx, message_idx])
2350 pname = '???' if project_idx < 0 else project_names[project_idx]
2351 # Count warnings by project.
2352 if pname in pattern['projects']:
2353 pattern['projects'][pname] += 1
2354 else:
2355 pattern['projects'][pname] = 1
2356
2357
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002358def compile_patterns():
2359 """Precompiling every pattern speeds up parsing by about 30x."""
2360 for i in warn_patterns:
2361 i['compiled_patterns'] = []
2362 for pat in i['patterns']:
2363 i['compiled_patterns'].append(re.compile(pat))
2364
2365
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -07002366def find_android_root(path):
2367 """Set and return android_root path if it is found."""
2368 global android_root
2369 parts = path.split('/')
2370 for idx in reversed(range(2, len(parts))):
2371 root_path = '/'.join(parts[:idx])
2372 # Android root directory should contain this script.
2373 if os.path.exists(root_path + '/build/tools/warn.py'):
2374 android_root = root_path
2375 return root_path
2376 return ''
2377
2378
2379def remove_android_root_prefix(path):
2380 """Remove android_root prefix from path if it is found."""
2381 if path.startswith(android_root):
2382 return path[1 + len(android_root):]
2383 else:
2384 return path
2385
2386
2387def normalize_path(path):
2388 """Normalize file path relative to android_root."""
2389 # If path is not an absolute path, just normalize it.
2390 path = os.path.normpath(path)
2391 if path[0] != '/':
2392 return path
2393 # Remove known prefix of root path and normalize the suffix.
2394 if android_root or find_android_root(path):
2395 return remove_android_root_prefix(path)
2396 else:
2397 return path
2398
2399
2400def normalize_warning_line(line):
2401 """Normalize file path relative to android_root in a warning line."""
2402 # replace fancy quotes with plain ol' quotes
2403 line = line.replace('‘', "'")
2404 line = line.replace('’', "'")
2405 line = line.strip()
2406 first_column = line.find(':')
2407 if first_column > 0:
2408 return normalize_path(line[:first_column]) + line[first_column:]
2409 else:
2410 return line
2411
2412
Chih-Hung Hsieh76d00652016-11-09 18:19:05 -08002413def parse_input_file(infile):
Chih-Hung Hsiehef21d142017-04-27 10:25:37 -07002414 """Parse input file, collect parameters and warning lines."""
2415 global android_root
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002416 global platform_version
2417 global target_product
2418 global target_variant
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002419 line_counter = 0
2420
Chih-Hung Hsieh5722f922016-10-11 15:33:19 -07002421 # handle only warning messages with a file path
2422 warning_pattern = re.compile('^[^ ]*/[^ ]*: warning: .*')
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002423
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002424 # Collect all warnings into the warning_lines set.
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002425 warning_lines = set()
2426 for line in infile:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002427 if warning_pattern.match(line):
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -07002428 line = normalize_warning_line(line)
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002429 warning_lines.add(line)
Chih-Hung Hsieh655c5422017-06-07 15:52:13 -07002430 elif line_counter < 100:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002431 # save a little bit of time by only doing this for the first few lines
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002432 line_counter += 1
2433 m = re.search('(?<=^PLATFORM_VERSION=).*', line)
2434 if m is not None:
2435 platform_version = m.group(0)
2436 m = re.search('(?<=^TARGET_PRODUCT=).*', line)
2437 if m is not None:
2438 target_product = m.group(0)
2439 m = re.search('(?<=^TARGET_BUILD_VARIANT=).*', line)
2440 if m is not None:
2441 target_variant = m.group(0)
Chih-Hung Hsiehef21d142017-04-27 10:25:37 -07002442 m = re.search('.* TOP=([^ ]*) .*', line)
2443 if m is not None:
2444 android_root = m.group(1)
Chih-Hung Hsieh76d00652016-11-09 18:19:05 -08002445 return warning_lines
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002446
2447
Chih-Hung Hsieh5722f922016-10-11 15:33:19 -07002448# Return s with escaped backslash and quotation characters.
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002449def escape_string(s):
Chih-Hung Hsieh5722f922016-10-11 15:33:19 -07002450 return s.replace('\\', '\\\\').replace('"', '\\"')
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002451
2452
2453# Return s without trailing '\n' and escape the quotation characters.
2454def strip_escape_string(s):
2455 if not s:
2456 return s
2457 s = s[:-1] if s[-1] == '\n' else s
2458 return escape_string(s)
2459
2460
2461def emit_warning_array(name):
2462 print 'var warning_{} = ['.format(name)
2463 for i in range(len(warn_patterns)):
2464 print '{},'.format(warn_patterns[i][name])
2465 print '];'
2466
2467
2468def emit_warning_arrays():
2469 emit_warning_array('severity')
2470 print 'var warning_description = ['
2471 for i in range(len(warn_patterns)):
2472 if warn_patterns[i]['members']:
2473 print '"{}",'.format(escape_string(warn_patterns[i]['description']))
2474 else:
2475 print '"",' # no such warning
2476 print '];'
2477
2478scripts_for_warning_groups = """
2479 function compareMessages(x1, x2) { // of the same warning type
2480 return (WarningMessages[x1[2]] <= WarningMessages[x2[2]]) ? -1 : 1;
2481 }
2482 function byMessageCount(x1, x2) {
2483 return x2[2] - x1[2]; // reversed order
2484 }
2485 function bySeverityMessageCount(x1, x2) {
2486 // orer by severity first
2487 if (x1[1] != x2[1])
2488 return x1[1] - x2[1];
2489 return byMessageCount(x1, x2);
2490 }
2491 const ParseLinePattern = /^([^ :]+):(\\d+):(.+)/;
2492 function addURL(line) {
2493 if (FlagURL == "") return line;
2494 if (FlagSeparator == "") {
2495 return line.replace(ParseLinePattern,
George Burgess IV169f5f12017-04-21 13:35:52 -07002496 "<a target='_blank' href='" + FlagURL + "/$1'>$1</a>:$2:$3");
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002497 }
2498 return line.replace(ParseLinePattern,
George Burgess IV169f5f12017-04-21 13:35:52 -07002499 "<a target='_blank' href='" + FlagURL + "/$1" + FlagSeparator +
2500 "$2'>$1:$2</a>:$3");
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002501 }
2502 function createArrayOfDictionaries(n) {
2503 var result = [];
2504 for (var i=0; i<n; i++) result.push({});
2505 return result;
2506 }
2507 function groupWarningsBySeverity() {
2508 // groups is an array of dictionaries,
2509 // each dictionary maps from warning type to array of warning messages.
2510 var groups = createArrayOfDictionaries(SeverityColors.length);
2511 for (var i=0; i<Warnings.length; i++) {
2512 var w = Warnings[i][0];
2513 var s = WarnPatternsSeverity[w];
2514 var k = w.toString();
2515 if (!(k in groups[s]))
2516 groups[s][k] = [];
2517 groups[s][k].push(Warnings[i]);
2518 }
2519 return groups;
2520 }
2521 function groupWarningsByProject() {
2522 var groups = createArrayOfDictionaries(ProjectNames.length);
2523 for (var i=0; i<Warnings.length; i++) {
2524 var w = Warnings[i][0];
2525 var p = Warnings[i][1];
2526 var k = w.toString();
2527 if (!(k in groups[p]))
2528 groups[p][k] = [];
2529 groups[p][k].push(Warnings[i]);
2530 }
2531 return groups;
2532 }
2533 var GlobalAnchor = 0;
2534 function createWarningSection(header, color, group) {
2535 var result = "";
2536 var groupKeys = [];
2537 var totalMessages = 0;
2538 for (var k in group) {
2539 totalMessages += group[k].length;
2540 groupKeys.push([k, WarnPatternsSeverity[parseInt(k)], group[k].length]);
2541 }
2542 groupKeys.sort(bySeverityMessageCount);
2543 for (var idx=0; idx<groupKeys.length; idx++) {
2544 var k = groupKeys[idx][0];
2545 var messages = group[k];
2546 var w = parseInt(k);
2547 var wcolor = SeverityColors[WarnPatternsSeverity[w]];
2548 var description = WarnPatternsDescription[w];
2549 if (description.length == 0)
2550 description = "???";
2551 GlobalAnchor += 1;
2552 result += "<table class='t1'><tr bgcolor='" + wcolor + "'><td>" +
2553 "<button class='bt' id='" + GlobalAnchor + "_mark" +
2554 "' onclick='expand(\\"" + GlobalAnchor + "\\");'>" +
2555 "&#x2295</button> " +
2556 description + " (" + messages.length + ")</td></tr></table>";
2557 result += "<div id='" + GlobalAnchor +
2558 "' style='display:none;'><table class='t1'>";
2559 var c = 0;
2560 messages.sort(compareMessages);
2561 for (var i=0; i<messages.length; i++) {
2562 result += "<tr><td class='c" + c + "'>" +
2563 addURL(WarningMessages[messages[i][2]]) + "</td></tr>";
2564 c = 1 - c;
2565 }
2566 result += "</table></div>";
2567 }
2568 if (result.length > 0) {
2569 return "<br><span style='background-color:" + color + "'><b>" +
2570 header + ": " + totalMessages +
2571 "</b></span><blockquote><table class='t1'>" +
2572 result + "</table></blockquote>";
2573
2574 }
2575 return ""; // empty section
2576 }
2577 function generateSectionsBySeverity() {
2578 var result = "";
2579 var groups = groupWarningsBySeverity();
2580 for (s=0; s<SeverityColors.length; s++) {
2581 result += createWarningSection(SeverityHeaders[s], SeverityColors[s], groups[s]);
2582 }
2583 return result;
2584 }
2585 function generateSectionsByProject() {
2586 var result = "";
2587 var groups = groupWarningsByProject();
2588 for (i=0; i<groups.length; i++) {
2589 result += createWarningSection(ProjectNames[i], 'lightgrey', groups[i]);
2590 }
2591 return result;
2592 }
2593 function groupWarnings(generator) {
2594 GlobalAnchor = 0;
2595 var e = document.getElementById("warning_groups");
2596 e.innerHTML = generator();
2597 }
2598 function groupBySeverity() {
2599 groupWarnings(generateSectionsBySeverity);
2600 }
2601 function groupByProject() {
2602 groupWarnings(generateSectionsByProject);
2603 }
2604"""
2605
2606
2607# Emit a JavaScript const string
2608def emit_const_string(name, value):
2609 print 'const ' + name + ' = "' + escape_string(value) + '";'
2610
2611
2612# Emit a JavaScript const integer array.
2613def emit_const_int_array(name, array):
2614 print 'const ' + name + ' = ['
2615 for n in array:
2616 print str(n) + ','
2617 print '];'
2618
2619
2620# Emit a JavaScript const string array.
2621def emit_const_string_array(name, array):
2622 print 'const ' + name + ' = ['
2623 for s in array:
2624 print '"' + strip_escape_string(s) + '",'
2625 print '];'
2626
2627
2628# Emit a JavaScript const object array.
2629def emit_const_object_array(name, array):
2630 print 'const ' + name + ' = ['
2631 for x in array:
2632 print str(x) + ','
2633 print '];'
2634
2635
2636def emit_js_data():
2637 """Dump dynamic HTML page's static JavaScript data."""
2638 emit_const_string('FlagURL', args.url if args.url else '')
2639 emit_const_string('FlagSeparator', args.separator if args.separator else '')
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002640 emit_const_string_array('SeverityColors', Severity.colors)
2641 emit_const_string_array('SeverityHeaders', Severity.headers)
2642 emit_const_string_array('SeverityColumnHeaders', Severity.column_headers)
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002643 emit_const_string_array('ProjectNames', project_names)
2644 emit_const_int_array('WarnPatternsSeverity',
2645 [w['severity'] for w in warn_patterns])
2646 emit_const_string_array('WarnPatternsDescription',
2647 [w['description'] for w in warn_patterns])
2648 emit_const_string_array('WarnPatternsOption',
2649 [w['option'] for w in warn_patterns])
2650 emit_const_string_array('WarningMessages', warning_messages)
2651 emit_const_object_array('Warnings', warning_records)
2652
2653draw_table_javascript = """
2654google.charts.load('current', {'packages':['table']});
2655google.charts.setOnLoadCallback(drawTable);
2656function drawTable() {
2657 var data = new google.visualization.DataTable();
2658 data.addColumn('string', StatsHeader[0]);
2659 for (var i=1; i<StatsHeader.length; i++) {
2660 data.addColumn('number', StatsHeader[i]);
2661 }
2662 data.addRows(StatsRows);
2663 for (var i=0; i<StatsRows.length; i++) {
2664 for (var j=0; j<StatsHeader.length; j++) {
2665 data.setProperty(i, j, 'style', 'border:1px solid black;');
2666 }
2667 }
2668 var table = new google.visualization.Table(document.getElementById('stats_table'));
2669 table.draw(data, {allowHtml: true, alternatingRowStyle: true});
2670}
2671"""
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002672
2673
2674def dump_html():
2675 """Dump the html output to stdout."""
2676 dump_html_prologue('Warnings for ' + platform_version + ' - ' +
2677 target_product + ' - ' + target_variant)
2678 dump_stats()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002679 print '<br><div id="stats_table"></div><br>'
2680 print '\n<script>'
2681 emit_js_data()
2682 print scripts_for_warning_groups
2683 print '</script>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002684 emit_buttons()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002685 # Warning messages are grouped by severities or project names.
2686 print '<br><div id="warning_groups"></div>'
2687 if args.byproject:
2688 print '<script>groupByProject();</script>'
2689 else:
2690 print '<script>groupBySeverity();</script>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002691 dump_fixed()
2692 dump_html_epilogue()
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002693
2694
2695##### Functions to count warnings and dump csv file. #########################
2696
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002697
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002698def description_for_csv(category):
2699 if not category['description']:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002700 return '?'
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002701 return category['description']
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002702
2703
Sam Saccone03aaa7e2017-04-10 15:37:47 -07002704def count_severity(writer, sev, kind):
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002705 """Count warnings of given severity."""
2706 total = 0
2707 for i in warn_patterns:
2708 if i['severity'] == sev and i['members']:
2709 n = len(i['members'])
2710 total += n
Sam Saccone03aaa7e2017-04-10 15:37:47 -07002711 warning = kind + ': ' + description_for_csv(i)
2712 writer.writerow([n, '', warning])
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002713 # print number of warnings for each project, ordered by project name.
2714 projects = i['projects'].keys()
2715 projects.sort()
2716 for p in projects:
Sam Saccone03aaa7e2017-04-10 15:37:47 -07002717 writer.writerow([i['projects'][p], p, warning])
2718 writer.writerow([total, '', kind + ' warnings'])
2719
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002720 return total
2721
2722
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002723# dump number of warnings in csv format to stdout
Sam Saccone03aaa7e2017-04-10 15:37:47 -07002724def dump_csv(writer):
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002725 """Dump number of warnings in csv format to stdout."""
2726 sort_warnings()
2727 total = 0
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002728 for s in Severity.range:
Sam Saccone03aaa7e2017-04-10 15:37:47 -07002729 total += count_severity(writer, s, Severity.column_headers[s])
2730 writer.writerow([total, '', 'All warnings'])
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002731
2732
Meike Baumgärtnerac9d5df2016-09-28 10:48:06 -07002733def main():
Chih-Hung Hsieh76d00652016-11-09 18:19:05 -08002734 warning_lines = parse_input_file(open(args.buildlog, 'r'))
2735 parallel_classify_warnings(warning_lines)
Sam Saccone03aaa7e2017-04-10 15:37:47 -07002736 # If a user pases a csv path, save the fileoutput to the path
2737 # If the user also passed gencsv write the output to stdout
2738 # If the user did not pass gencsv flag dump the html report to stdout.
2739 if args.csvpath:
2740 with open(args.csvpath, 'w') as f:
2741 dump_csv(csv.writer(f, lineterminator='\n'))
Meike Baumgärtnerac9d5df2016-09-28 10:48:06 -07002742 if args.gencsv:
Sam Saccone03aaa7e2017-04-10 15:37:47 -07002743 dump_csv(csv.writer(sys.stdout, lineterminator='\n'))
Meike Baumgärtnerac9d5df2016-09-28 10:48:06 -07002744 else:
2745 dump_html()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002746
Meike Baumgärtnerac9d5df2016-09-28 10:48:06 -07002747
2748# Run main function if warn.py is the main program.
2749if __name__ == '__main__':
2750 main()