blob: 6218f9318b5a7225cd7cceb91039c7c734c9e92a [file] [log] [blame]
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001#!/usr/bin/python
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07002# Prefer python3 but work also with python2.
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
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -070077from __future__ import print_function
Ian Rogersf3829732016-05-10 12:06:01 -070078import argparse
Chih-Hung Hsiehb2afb632018-07-20 15:36:26 -070079import cgi
Sam Saccone03aaa7e2017-04-10 15:37:47 -070080import csv
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -070081import io
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -070082import multiprocessing
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -070083import os
Marco Nelissen594375d2009-07-14 09:04:04 -070084import re
Chih-Hung Hsieh76d00652016-11-09 18:19:05 -080085import signal
86import sys
Marco Nelissen594375d2009-07-14 09:04:04 -070087
Ian Rogersf3829732016-05-10 12:06:01 -070088parser = argparse.ArgumentParser(description='Convert a build log into HTML')
Sam Saccone03aaa7e2017-04-10 15:37:47 -070089parser.add_argument('--csvpath',
90 help='Save CSV warning file to the passed absolute path',
91 default=None)
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -070092parser.add_argument('--gencsv',
93 help='Generate a CSV file with number of various warnings',
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -070094 action='store_true',
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -070095 default=False)
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -070096parser.add_argument('--byproject',
97 help='Separate warnings in HTML output by project names',
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -070098 action='store_true',
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -070099 default=False)
Ian Rogersf3829732016-05-10 12:06:01 -0700100parser.add_argument('--url',
101 help='Root URL of an Android source code tree prefixed '
102 'before files in warnings')
103parser.add_argument('--separator',
104 help='Separator between the end of a URL and the line '
105 'number argument. e.g. #')
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -0700106parser.add_argument('--processes',
107 type=int,
108 default=multiprocessing.cpu_count(),
109 help='Number of parallel processes to process warnings')
Ian Rogersf3829732016-05-10 12:06:01 -0700110parser.add_argument(dest='buildlog', metavar='build.log',
111 help='Path to build.log file')
112args = parser.parse_args()
Marco Nelissen594375d2009-07-14 09:04:04 -0700113
Marco Nelissen594375d2009-07-14 09:04:04 -0700114
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700115class Severity(object):
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700116 """Severity levels and attributes."""
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -0700117 # numbered by dump order
118 FIXMENOW = 0
119 HIGH = 1
120 MEDIUM = 2
121 LOW = 3
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -0700122 ANALYZER = 4
123 TIDY = 5
124 HARMLESS = 6
125 UNKNOWN = 7
126 SKIP = 8
127 range = range(SKIP + 1)
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700128 attributes = [
129 # pylint:disable=bad-whitespace
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700130 ['fuchsia', 'FixNow', 'Critical warnings, fix me now'],
131 ['red', 'High', 'High severity warnings'],
132 ['orange', 'Medium', 'Medium severity warnings'],
133 ['yellow', 'Low', 'Low severity warnings'],
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -0700134 ['hotpink', 'Analyzer', 'Clang-Analyzer warnings'],
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700135 ['peachpuff', 'Tidy', 'Clang-Tidy warnings'],
136 ['limegreen', 'Harmless', 'Harmless warnings'],
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -0700137 ['lightblue', 'Unknown', 'Unknown warnings'],
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700138 ['grey', 'Unhandled', 'Unhandled warnings']
139 ]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -0700140 colors = [a[0] for a in attributes]
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700141 column_headers = [a[1] for a in attributes]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -0700142 headers = [a[2] for a in attributes]
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700143
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -0700144
145def tidy_warn_pattern(description, pattern):
146 return {
147 'category': 'C/C++',
148 'severity': Severity.TIDY,
149 'description': 'clang-tidy ' + description,
150 'patterns': [r'.*: .+\[' + pattern + r'\]$']
151 }
152
153
154def simple_tidy_warn_pattern(description):
155 return tidy_warn_pattern(description, description)
156
157
158def group_tidy_warn_pattern(description):
159 return tidy_warn_pattern(description, description + r'-.+')
160
161
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -0700162def analyzer_high(description, patterns):
163 # Important clang analyzer warnings to be fixed ASAP.
164 return {
165 'category': 'C/C++',
166 'severity': Severity.HIGH,
167 'description': description,
168 'patterns': patterns
169 }
170
171
172def analyzer_high_check(check):
173 return analyzer_high(check, [r'.*: .+\[' + check + r'\]$'])
174
175
176def analyzer_group_high(check):
177 return analyzer_high(check, [r'.*: .+\[' + check + r'.+\]$'])
178
179
180def analyzer_warn(description, patterns):
181 return {
182 'category': 'C/C++',
183 'severity': Severity.ANALYZER,
184 'description': description,
185 'patterns': patterns
186 }
187
188
189def analyzer_warn_check(check):
190 return analyzer_warn(check, [r'.*: .+\[' + check + r'\]$'])
191
192
193def analyzer_group_check(check):
194 return analyzer_warn(check, [r'.*: .+\[' + check + r'.+\]$'])
195
196
Chih-Hung Hsieh79002042019-09-25 13:34:08 -0700197def java_warn(severity, description, patterns):
198 return {
199 'category': 'Java',
200 'severity': severity,
201 'description': 'Java: ' + description,
202 'patterns': patterns
203 }
204
205
206def java_high(description, patterns):
207 return java_warn(Severity.HIGH, description, patterns)
208
209
210def java_medium(description, patterns):
211 return java_warn(Severity.MEDIUM, description, patterns)
212
213
214def java_low(description, patterns):
215 return java_warn(Severity.LOW, description, patterns)
216
217
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700218warn_patterns = [
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700219 # pylint:disable=line-too-long,g-inconsistent-quotes
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700220 {'category': 'make', 'severity': Severity.MEDIUM,
221 'description': 'make: overriding commands/ignoring old commands',
222 'patterns': [r".*: warning: overriding commands for target .+",
223 r".*: warning: ignoring old commands for target .+"]},
224 {'category': 'make', 'severity': Severity.HIGH,
225 'description': 'make: LOCAL_CLANG is false',
226 'patterns': [r".*: warning: LOCAL_CLANG is set to false"]},
227 {'category': 'make', 'severity': Severity.HIGH,
228 'description': 'SDK App using platform shared library',
229 'patterns': [r".*: warning: .+ \(.*app:sdk.*\) should not link to .+ \(native:platform\)"]},
230 {'category': 'make', 'severity': Severity.HIGH,
231 'description': 'System module linking to a vendor module',
232 'patterns': [r".*: warning: .+ \(.+\) should not link to .+ \(partition:.+\)"]},
233 {'category': 'make', 'severity': Severity.MEDIUM,
234 'description': 'Invalid SDK/NDK linking',
235 'patterns': [r".*: warning: .+ \(.+\) should not link to .+ \(.+\)"]},
Chih-Hung Hsieh9e9355d2018-06-04 11:32:32 -0700236 {'category': 'make', 'severity': Severity.MEDIUM,
237 'description': 'Duplicate header copy',
238 'patterns': [r".*: warning: Duplicate header copy: .+"]},
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -0700239 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wimplicit-function-declaration',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700240 'description': 'Implicit function declaration',
241 'patterns': [r".*: warning: implicit declaration of function .+",
242 r".*: warning: implicitly declaring library function"]},
243 {'category': 'C/C++', 'severity': Severity.SKIP,
244 'description': 'skip, conflicting types for ...',
245 'patterns': [r".*: warning: conflicting types for '.+'"]},
246 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wtype-limits',
247 'description': 'Expression always evaluates to true or false',
248 'patterns': [r".*: warning: comparison is always .+ due to limited range of data type",
249 r".*: warning: comparison of unsigned .*expression .+ is always true",
250 r".*: warning: comparison of unsigned .*expression .+ is always false"]},
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -0700251 # {'category': 'C/C++', 'severity': Severity.HIGH,
252 # 'description': 'Potential leak of memory, bad free, use after free',
253 # 'patterns': [r".*: warning: Potential leak of memory",
254 # r".*: warning: Potential memory leak",
255 # r".*: warning: Memory allocated by alloca\(\) should not be deallocated",
256 # r".*: warning: Memory allocated by .+ should be deallocated by .+ not .+",
257 # r".*: warning: 'delete' applied to a pointer that was allocated",
258 # r".*: warning: Use of memory after it is freed",
259 # r".*: warning: Argument to .+ is the address of .+ variable",
260 # r".*: warning: Argument to free\(\) is offset by .+ of memory allocated by",
261 # r".*: warning: Attempt to .+ released memory"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700262 {'category': 'C/C++', 'severity': Severity.HIGH,
263 'description': 'Use transient memory for control value',
264 'patterns': [r".*: warning: .+Using such transient memory for the control value is .*dangerous."]},
265 {'category': 'C/C++', 'severity': Severity.HIGH,
266 'description': 'Return address of stack memory',
267 'patterns': [r".*: warning: Address of stack memory .+ returned to caller",
268 r".*: warning: Address of stack memory .+ will be a dangling reference"]},
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -0700269 # {'category': 'C/C++', 'severity': Severity.HIGH,
270 # 'description': 'Problem with vfork',
271 # 'patterns': [r".*: warning: This .+ is prohibited after a successful vfork",
272 # r".*: warning: Call to function '.+' is insecure "]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700273 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': 'infinite-recursion',
274 'description': 'Infinite recursion',
275 'patterns': [r".*: warning: all paths through this function will call itself"]},
276 {'category': 'C/C++', 'severity': Severity.HIGH,
277 'description': 'Potential buffer overflow',
278 'patterns': [r".*: warning: Size argument is greater than .+ the destination buffer",
279 r".*: warning: Potential buffer overflow.",
280 r".*: warning: String copy function overflows destination buffer"]},
281 {'category': 'C/C++', 'severity': Severity.MEDIUM,
282 'description': 'Incompatible pointer types',
283 'patterns': [r".*: warning: assignment from incompatible pointer type",
284 r".*: warning: return from incompatible pointer type",
285 r".*: warning: passing argument [0-9]+ of '.*' from incompatible pointer type",
286 r".*: warning: initialization from incompatible pointer type"]},
287 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-fno-builtin',
288 'description': 'Incompatible declaration of built in function',
289 'patterns': [r".*: warning: incompatible implicit declaration of built-in function .+"]},
290 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wincompatible-library-redeclaration',
291 'description': 'Incompatible redeclaration of library function',
292 'patterns': [r".*: warning: incompatible redeclaration of library function .+"]},
293 {'category': 'C/C++', 'severity': Severity.HIGH,
294 'description': 'Null passed as non-null argument',
295 'patterns': [r".*: warning: Null passed to a callee that requires a non-null"]},
296 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused-parameter',
297 'description': 'Unused parameter',
298 'patterns': [r".*: warning: unused parameter '.*'"]},
299 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused',
Chih-Hung Hsieh9e9355d2018-06-04 11:32:32 -0700300 'description': 'Unused function, variable, label, comparison, etc.',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700301 'patterns': [r".*: warning: '.+' defined but not used",
302 r".*: warning: unused function '.+'",
Chih-Hung Hsieh9e9355d2018-06-04 11:32:32 -0700303 r".*: warning: unused label '.+'",
304 r".*: warning: relational comparison result unused",
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -0700305 r".*: warning: lambda capture .* is not used",
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700306 r".*: warning: private field '.+' is not used",
307 r".*: warning: unused variable '.+'"]},
308 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused-value',
309 'description': 'Statement with no effect or result unused',
310 'patterns': [r".*: warning: statement with no effect",
311 r".*: warning: expression result unused"]},
312 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused-result',
313 'description': 'Ignoreing return value of function',
314 'patterns': [r".*: warning: ignoring return value of function .+Wunused-result"]},
315 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-field-initializers',
316 'description': 'Missing initializer',
317 'patterns': [r".*: warning: missing initializer"]},
318 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wdelete-non-virtual-dtor',
319 'description': 'Need virtual destructor',
320 'patterns': [r".*: warning: delete called .* has virtual functions but non-virtual destructor"]},
321 {'category': 'cont.', 'severity': Severity.SKIP,
322 'description': 'skip, near initialization for ...',
323 'patterns': [r".*: warning: \(near initialization for '.+'\)"]},
324 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wdate-time',
325 'description': 'Expansion of data or time macro',
326 'patterns': [r".*: warning: expansion of date or time macro is not reproducible"]},
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -0700327 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wexpansion-to-defined',
328 'description': 'Macro expansion has undefined behavior',
329 'patterns': [r".*: warning: macro expansion .* has undefined behavior"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700330 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wformat',
331 'description': 'Format string does not match arguments',
332 'patterns': [r".*: warning: format '.+' expects type '.+', but argument [0-9]+ has type '.+'",
333 r".*: warning: more '%' conversions than data arguments",
334 r".*: warning: data argument not used by format string",
335 r".*: warning: incomplete format specifier",
336 r".*: warning: unknown conversion type .* in format",
337 r".*: warning: format .+ expects .+ but argument .+Wformat=",
338 r".*: warning: field precision should have .+ but argument has .+Wformat",
339 r".*: warning: format specifies type .+ but the argument has .*type .+Wformat"]},
340 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wformat-extra-args',
341 'description': 'Too many arguments for format string',
342 'patterns': [r".*: warning: too many arguments for format"]},
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -0700343 {'category': 'C/C++', 'severity': Severity.MEDIUM,
344 'description': 'Too many arguments in call',
345 'patterns': [r".*: warning: too many arguments in call to "]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700346 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wformat-invalid-specifier',
347 'description': 'Invalid format specifier',
348 'patterns': [r".*: warning: invalid .+ specifier '.+'.+format-invalid-specifier"]},
349 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsign-compare',
350 'description': 'Comparison between signed and unsigned',
351 'patterns': [r".*: warning: comparison between signed and unsigned",
352 r".*: warning: comparison of promoted \~unsigned with unsigned",
353 r".*: warning: signed and unsigned type in conditional expression"]},
354 {'category': 'C/C++', 'severity': Severity.MEDIUM,
355 'description': 'Comparison between enum and non-enum',
356 'patterns': [r".*: warning: enumeral and non-enumeral type in conditional expression"]},
357 {'category': 'libpng', 'severity': Severity.MEDIUM,
358 'description': 'libpng: zero area',
359 'patterns': [r".*libpng warning: Ignoring attempt to set cHRM RGB triangle with zero area"]},
360 {'category': 'aapt', 'severity': Severity.MEDIUM,
361 'description': 'aapt: no comment for public symbol',
362 'patterns': [r".*: warning: No comment for public symbol .+"]},
363 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-braces',
364 'description': 'Missing braces around initializer',
365 'patterns': [r".*: warning: missing braces around initializer.*"]},
366 {'category': 'C/C++', 'severity': Severity.HARMLESS,
367 'description': 'No newline at end of file',
368 'patterns': [r".*: warning: no newline at end of file"]},
369 {'category': 'C/C++', 'severity': Severity.HARMLESS,
370 'description': 'Missing space after macro name',
371 'patterns': [r".*: warning: missing whitespace after the macro name"]},
372 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wcast-align',
373 'description': 'Cast increases required alignment',
374 'patterns': [r".*: warning: cast from .* to .* increases required alignment .*"]},
375 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wcast-qual',
376 'description': 'Qualifier discarded',
377 'patterns': [r".*: warning: passing argument [0-9]+ of '.+' discards qualifiers from pointer target type",
378 r".*: warning: assignment discards qualifiers from pointer target type",
379 r".*: warning: passing .+ to parameter of type .+ discards qualifiers",
380 r".*: warning: assigning to .+ from .+ discards qualifiers",
381 r".*: warning: initializing .+ discards qualifiers .+types-discards-qualifiers",
382 r".*: warning: return discards qualifiers from pointer target type"]},
383 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunknown-attributes',
384 'description': 'Unknown attribute',
385 'patterns': [r".*: warning: unknown attribute '.+'"]},
386 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wignored-attributes',
387 'description': 'Attribute ignored',
388 'patterns': [r".*: warning: '_*packed_*' attribute ignored",
389 r".*: warning: attribute declaration must precede definition .+ignored-attributes"]},
390 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wvisibility',
391 'description': 'Visibility problem',
392 'patterns': [r".*: warning: declaration of '.+' will not be visible outside of this function"]},
393 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wattributes',
394 'description': 'Visibility mismatch',
395 'patterns': [r".*: warning: '.+' declared with greater visibility than the type of its field '.+'"]},
396 {'category': 'C/C++', 'severity': Severity.MEDIUM,
397 'description': 'Shift count greater than width of type',
398 'patterns': [r".*: warning: (left|right) shift count >= width of type"]},
399 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wextern-initializer',
400 'description': 'extern <foo> is initialized',
401 'patterns': [r".*: warning: '.+' initialized and declared 'extern'",
402 r".*: warning: 'extern' variable has an initializer"]},
403 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wold-style-declaration',
404 'description': 'Old style declaration',
405 'patterns': [r".*: warning: 'static' is not at beginning of declaration"]},
406 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wreturn-type',
407 'description': 'Missing return value',
408 'patterns': [r".*: warning: control reaches end of non-void function"]},
409 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wimplicit-int',
410 'description': 'Implicit int type',
411 'patterns': [r".*: warning: type specifier missing, defaults to 'int'",
412 r".*: warning: type defaults to 'int' in declaration of '.+'"]},
413 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmain-return-type',
414 'description': 'Main function should return int',
415 'patterns': [r".*: warning: return type of 'main' is not 'int'"]},
416 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wuninitialized',
417 'description': 'Variable may be used uninitialized',
418 'patterns': [r".*: warning: '.+' may be used uninitialized in this function"]},
419 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wuninitialized',
420 'description': 'Variable is used uninitialized',
421 'patterns': [r".*: warning: '.+' is used uninitialized in this function",
422 r".*: warning: variable '.+' is uninitialized when used here"]},
423 {'category': 'ld', 'severity': Severity.MEDIUM, 'option': '-fshort-enums',
424 'description': 'ld: possible enum size mismatch',
425 'patterns': [r".*: warning: .* uses variable-size enums yet the output is to use 32-bit enums; use of enum values across objects may fail"]},
426 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wpointer-sign',
427 'description': 'Pointer targets differ in signedness',
428 'patterns': [r".*: warning: pointer targets in initialization differ in signedness",
429 r".*: warning: pointer targets in assignment differ in signedness",
430 r".*: warning: pointer targets in return differ in signedness",
431 r".*: warning: pointer targets in passing argument [0-9]+ of '.+' differ in signedness"]},
432 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wstrict-overflow',
433 'description': 'Assuming overflow does not occur',
434 'patterns': [r".*: warning: assuming signed overflow does not occur when assuming that .* is always (true|false)"]},
435 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wempty-body',
436 'description': 'Suggest adding braces around empty body',
437 'patterns': [r".*: warning: suggest braces around empty body in an 'if' statement",
438 r".*: warning: empty body in an if-statement",
439 r".*: warning: suggest braces around empty body in an 'else' statement",
440 r".*: warning: empty body in an else-statement"]},
441 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wparentheses',
442 'description': 'Suggest adding parentheses',
443 'patterns': [r".*: warning: suggest explicit braces to avoid ambiguous 'else'",
444 r".*: warning: suggest parentheses around arithmetic in operand of '.+'",
445 r".*: warning: suggest parentheses around comparison in operand of '.+'",
446 r".*: warning: logical not is only applied to the left hand side of this comparison",
447 r".*: warning: using the result of an assignment as a condition without parentheses",
448 r".*: warning: .+ has lower precedence than .+ be evaluated first .+Wparentheses",
449 r".*: warning: suggest parentheses around '.+?' .+ '.+?'",
450 r".*: warning: suggest parentheses around assignment used as truth value"]},
451 {'category': 'C/C++', 'severity': Severity.MEDIUM,
452 'description': 'Static variable used in non-static inline function',
453 'patterns': [r".*: warning: '.+' is static but used in inline function '.+' which is not static"]},
454 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wimplicit int',
455 'description': 'No type or storage class (will default to int)',
456 'patterns': [r".*: warning: data definition has no type or storage class"]},
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -0700457 # {'category': 'C/C++', 'severity': Severity.MEDIUM,
458 # 'description': 'Null pointer',
459 # 'patterns': [r".*: warning: Dereference of null pointer",
460 # r".*: warning: Called .+ pointer is null",
461 # r".*: warning: Forming reference to null pointer",
462 # r".*: warning: Returning null reference",
463 # r".*: warning: Null pointer passed as an argument to a 'nonnull' parameter",
464 # r".*: warning: .+ results in a null pointer dereference",
465 # r".*: warning: Access to .+ results in a dereference of a null pointer",
466 # r".*: warning: Null pointer argument in"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700467 {'category': 'cont.', 'severity': Severity.SKIP,
468 'description': 'skip, parameter name (without types) in function declaration',
469 'patterns': [r".*: warning: parameter names \(without types\) in function declaration"]},
470 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wstrict-aliasing',
471 'description': 'Dereferencing <foo> breaks strict aliasing rules',
472 'patterns': [r".*: warning: dereferencing .* break strict-aliasing rules"]},
473 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wpointer-to-int-cast',
474 'description': 'Cast from pointer to integer of different size',
475 'patterns': [r".*: warning: cast from pointer to integer of different size",
476 r".*: warning: initialization makes pointer from integer without a cast"]},
477 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wint-to-pointer-cast',
478 'description': 'Cast to pointer from integer of different size',
479 'patterns': [r".*: warning: cast to pointer from integer of different size"]},
480 {'category': 'C/C++', 'severity': Severity.MEDIUM,
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -0700481 'description': 'Macro redefined',
482 'patterns': [r".*: warning: '.+' macro redefined"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700483 {'category': 'cont.', 'severity': Severity.SKIP,
484 'description': 'skip, ... location of the previous definition',
485 'patterns': [r".*: warning: this is the location of the previous definition"]},
486 {'category': 'ld', 'severity': Severity.MEDIUM,
487 'description': 'ld: type and size of dynamic symbol are not defined',
488 'patterns': [r".*: warning: type and size of dynamic symbol `.+' are not defined"]},
489 {'category': 'C/C++', 'severity': Severity.MEDIUM,
490 'description': 'Pointer from integer without cast',
491 'patterns': [r".*: warning: assignment makes pointer from integer without a cast"]},
492 {'category': 'C/C++', 'severity': Severity.MEDIUM,
493 'description': 'Pointer from integer without cast',
494 'patterns': [r".*: warning: passing argument [0-9]+ of '.+' makes pointer from integer without a cast"]},
495 {'category': 'C/C++', 'severity': Severity.MEDIUM,
496 'description': 'Integer from pointer without cast',
497 'patterns': [r".*: warning: assignment makes integer from pointer without a cast"]},
498 {'category': 'C/C++', 'severity': Severity.MEDIUM,
499 'description': 'Integer from pointer without cast',
500 'patterns': [r".*: warning: passing argument [0-9]+ of '.+' makes integer from pointer without a cast"]},
501 {'category': 'C/C++', 'severity': Severity.MEDIUM,
502 'description': 'Integer from pointer without cast',
503 'patterns': [r".*: warning: return makes integer from pointer without a cast"]},
504 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunknown-pragmas',
505 'description': 'Ignoring pragma',
506 'patterns': [r".*: warning: ignoring #pragma .+"]},
507 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-W#pragma-messages',
508 'description': 'Pragma warning messages',
509 'patterns': [r".*: warning: .+W#pragma-messages"]},
510 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wclobbered',
511 'description': 'Variable might be clobbered by longjmp or vfork',
512 'patterns': [r".*: warning: variable '.+' might be clobbered by 'longjmp' or 'vfork'"]},
513 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wclobbered',
514 'description': 'Argument might be clobbered by longjmp or vfork',
515 'patterns': [r".*: warning: argument '.+' might be clobbered by 'longjmp' or 'vfork'"]},
516 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wredundant-decls',
517 'description': 'Redundant declaration',
518 'patterns': [r".*: warning: redundant redeclaration of '.+'"]},
519 {'category': 'cont.', 'severity': Severity.SKIP,
520 'description': 'skip, previous declaration ... was here',
521 'patterns': [r".*: warning: previous declaration of '.+' was here"]},
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -0700522 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wswitch-enum',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700523 'description': 'Enum value not handled in switch',
524 'patterns': [r".*: warning: .*enumeration value.* not handled in switch.+Wswitch"]},
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -0700525 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wuser-defined-warnings',
526 'description': 'User defined warnings',
527 'patterns': [r".*: warning: .* \[-Wuser-defined-warnings\]$"]},
Chih-Hung Hsieh79002042019-09-25 13:34:08 -0700528
529 # Java warnings
530 java_medium('Non-ascii characters used, but ascii encoding specified',
531 [r".*: warning: unmappable character for encoding ascii"]),
532 java_medium('Non-varargs call of varargs method with inexact argument type for last parameter',
533 [r".*: warning: non-varargs call of varargs method with inexact argument type for last parameter"]),
534 java_medium('Unchecked method invocation',
535 [r".*: warning: \[unchecked\] unchecked method invocation: .+ in class .+"]),
536 java_medium('Unchecked conversion',
537 [r".*: warning: \[unchecked\] unchecked conversion"]),
538 java_medium('_ used as an identifier',
539 [r".*: warning: '_' used as an identifier"]),
540 java_medium('hidden superclass',
541 [r".*: warning: .* stripped of .* superclass .* \[HiddenSuperclass\]"]),
542 java_high('Use of internal proprietary API',
543 [r".*: warning: .* is internal proprietary API and may be removed"]),
Ian Rogers32bb9bd2016-05-09 23:19:42 -0700544
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800545 # Warnings from Javac
Chih-Hung Hsieh79002042019-09-25 13:34:08 -0700546 java_medium('Use of deprecated member',
547 [r'.*: warning: \[deprecation\] .+']),
548 java_medium('Unchecked conversion',
549 [r'.*: warning: \[unchecked\] .+']),
Ian Rogers32bb9bd2016-05-09 23:19:42 -0700550
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800551 # Begin warnings generated by Error Prone
Chih-Hung Hsieh79002042019-09-25 13:34:08 -0700552 java_low('Use parameter comments to document ambiguous literals',
553 [r".*: warning: \[BooleanParameter\] .+"]),
554 java_low('This class\'s name looks like a Type Parameter.',
555 [r".*: warning: \[ClassNamedLikeTypeParameter\] .+"]),
556 java_low('Field name is CONSTANT_CASE, but field is not static and final',
557 [r".*: warning: \[ConstantField\] .+"]),
558 java_low('@Multibinds is a more efficient and declarative mechanism for ensuring that a set multibinding is present in the graph.',
559 [r".*: warning: \[EmptySetMultibindingContributions\] .+"]),
560 java_low('Prefer assertThrows to ExpectedException',
561 [r".*: warning: \[ExpectedExceptionRefactoring\] .+"]),
562 java_low('This field is only assigned during initialization; consider making it final',
563 [r".*: warning: \[FieldCanBeFinal\] .+"]),
564 java_low('Fields that can be null should be annotated @Nullable',
565 [r".*: warning: \[FieldMissingNullable\] .+"]),
566 java_low('Refactors uses of the JSR 305 @Immutable to Error Prone\'s annotation',
567 [r".*: warning: \[ImmutableRefactoring\] .+"]),
568 java_low(u'Use Java\'s utility functional interfaces instead of Function\u003cA, B> for primitive types.',
569 [r".*: warning: \[LambdaFunctionalInterface\] .+"]),
570 java_low('A private method that does not reference the enclosing instance can be static',
571 [r".*: warning: \[MethodCanBeStatic\] .+"]),
572 java_low('C-style array declarations should not be used',
573 [r".*: warning: \[MixedArrayDimensions\] .+"]),
574 java_low('Variable declarations should declare only one variable',
575 [r".*: warning: \[MultiVariableDeclaration\] .+"]),
576 java_low('Source files should not contain multiple top-level class declarations',
577 [r".*: warning: \[MultipleTopLevelClasses\] .+"]),
578 java_low('Avoid having multiple unary operators acting on the same variable in a method call',
579 [r".*: warning: \[MultipleUnaryOperatorsInMethodCall\] .+"]),
580 java_low('Package names should match the directory they are declared in',
581 [r".*: warning: \[PackageLocation\] .+"]),
582 java_low('Non-standard parameter comment; prefer `/* paramName= */ arg`',
583 [r".*: warning: \[ParameterComment\] .+"]),
584 java_low('Method parameters that aren\'t checked for null shouldn\'t be annotated @Nullable',
585 [r".*: warning: \[ParameterNotNullable\] .+"]),
586 java_low('Add a private constructor to modules that will not be instantiated by Dagger.',
587 [r".*: warning: \[PrivateConstructorForNoninstantiableModule\] .+"]),
588 java_low('Utility classes (only static members) are not designed to be instantiated and should be made noninstantiable with a default constructor.',
589 [r".*: warning: \[PrivateConstructorForUtilityClass\] .+"]),
590 java_low('Unused imports',
591 [r".*: warning: \[RemoveUnusedImports\] .+"]),
592 java_low('Methods that can return null should be annotated @Nullable',
593 [r".*: warning: \[ReturnMissingNullable\] .+"]),
594 java_low('Scopes on modules have no function and will soon be an error.',
595 [r".*: warning: \[ScopeOnModule\] .+"]),
596 java_low('The default case of a switch should appear at the end of the last statement group',
597 [r".*: warning: \[SwitchDefault\] .+"]),
598 java_low('Prefer assertThrows to @Test(expected=...)',
599 [r".*: warning: \[TestExceptionRefactoring\] .+"]),
600 java_low('Unchecked exceptions do not need to be declared in the method signature.',
601 [r".*: warning: \[ThrowsUncheckedException\] .+"]),
602 java_low('Prefer assertThrows to try/fail',
603 [r".*: warning: \[TryFailRefactoring\] .+"]),
604 java_low('Type parameters must be a single letter with an optional numeric suffix, or an UpperCamelCase name followed by the letter \'T\'.',
605 [r".*: warning: \[TypeParameterNaming\] .+"]),
606 java_low('Constructors and methods with the same name should appear sequentially with no other code in between. Please re-order or re-name methods.',
607 [r".*: warning: \[UngroupedOverloads\] .+"]),
608 java_low('Unnecessary call to NullPointerTester#setDefault',
609 [r".*: warning: \[UnnecessarySetDefault\] .+"]),
610 java_low('Using static imports for types is unnecessary',
611 [r".*: warning: \[UnnecessaryStaticImport\] .+"]),
612 java_low('@Binds is a more efficient and declarative mechanism for delegating a binding.',
613 [r".*: warning: \[UseBinds\] .+"]),
614 java_low('Wildcard imports, static or otherwise, should not be used',
615 [r".*: warning: \[WildcardImport\] .+"]),
616 java_medium('Method reference is ambiguous',
617 [r".*: warning: \[AmbiguousMethodReference\] .+"]),
618 java_medium('This method passes a pair of parameters through to String.format, but the enclosing method wasn\'t annotated @FormatMethod. Doing so gives compile-time rather than run-time protection against malformed format strings.',
619 [r".*: warning: \[AnnotateFormatMethod\] .+"]),
620 java_medium('Annotations should be positioned after Javadocs, but before modifiers..',
621 [r".*: warning: \[AnnotationPosition\] .+"]),
622 java_medium('Arguments are in the wrong order or could be commented for clarity.',
623 [r".*: warning: \[ArgumentSelectionDefectChecker\] .+"]),
624 java_medium('Arrays do not override equals() or hashCode, so comparisons will be done on reference equality only. If neither deduplication nor lookup are needed, consider using a List instead. Otherwise, use IdentityHashMap/Set, a Map from a library that handles object arrays, or an Iterable/List of pairs.',
625 [r".*: warning: \[ArrayAsKeyOfSetOrMap\] .+"]),
626 java_medium('Arguments are swapped in assertEquals-like call',
627 [r".*: warning: \[AssertEqualsArgumentOrderChecker\] .+"]),
628 java_medium('Assertions may be disabled at runtime and do not guarantee that execution will halt here; consider throwing an exception instead',
629 [r".*: warning: \[AssertFalse\] .+"]),
630 java_medium('The lambda passed to assertThrows should contain exactly one statement',
631 [r".*: warning: \[AssertThrowsMultipleStatements\] .+"]),
632 java_medium('This assertion throws an AssertionError if it fails, which will be caught by an enclosing try block.',
633 [r".*: warning: \[AssertionFailureIgnored\] .+"]),
634 java_medium('@AssistedInject and @Inject should not be used on different constructors in the same class.',
635 [r".*: warning: \[AssistedInjectAndInjectOnConstructors\] .+"]),
636 java_medium('Make toString(), hashCode() and equals() final in AutoValue classes, so it is clear to readers that AutoValue is not overriding them',
637 [r".*: warning: \[AutoValueFinalMethods\] .+"]),
638 java_medium('Classes that implement Annotation must override equals and hashCode. Consider using AutoAnnotation instead of implementing Annotation by hand.',
639 [r".*: warning: \[BadAnnotationImplementation\] .+"]),
640 java_medium('Possible sign flip from narrowing conversion',
641 [r".*: warning: \[BadComparable\] .+"]),
642 java_medium('Importing nested classes/static methods/static fields with commonly-used names can make code harder to read, because it may not be clear from the context exactly which type is being referred to. Qualifying the name with that of the containing class can make the code clearer.',
643 [r".*: warning: \[BadImport\] .+"]),
644 java_medium('instanceof used in a way that is equivalent to a null check.',
645 [r".*: warning: \[BadInstanceof\] .+"]),
646 java_medium('BigDecimal#equals has surprising behavior: it also compares scale.',
647 [r".*: warning: \[BigDecimalEquals\] .+"]),
648 java_medium('new BigDecimal(double) loses precision in this case.',
649 [r".*: warning: \[BigDecimalLiteralDouble\] .+"]),
650 java_medium('A call to Binder.clearCallingIdentity() should be followed by Binder.restoreCallingIdentity() in a finally block. Otherwise the wrong Binder identity may be used by subsequent code.',
651 [r".*: warning: \[BinderIdentityRestoredDangerously\] .+"]),
652 java_medium('This code declares a binding for a common value type without a Qualifier annotation.',
653 [r".*: warning: \[BindingToUnqualifiedCommonType\] .+"]),
654 java_medium('valueOf or autoboxing provides better time and space performance',
655 [r".*: warning: \[BoxedPrimitiveConstructor\] .+"]),
656 java_medium('ByteBuffer.array() shouldn\'t be called unless ByteBuffer.arrayOffset() is used or if the ByteBuffer was initialized using ByteBuffer.wrap() or ByteBuffer.allocate().',
657 [r".*: warning: \[ByteBufferBackingArray\] .+"]),
658 java_medium('Mockito cannot mock final classes',
659 [r".*: warning: \[CannotMockFinalClass\] .+"]),
660 java_medium('Duration can be expressed more clearly with different units',
661 [r".*: warning: \[CanonicalDuration\] .+"]),
662 java_medium('Logging or rethrowing exceptions should usually be preferred to catching and calling printStackTrace',
663 [r".*: warning: \[CatchAndPrintStackTrace\] .+"]),
664 java_medium('Ignoring exceptions and calling fail() is unnecessary, and makes test output less useful',
665 [r".*: warning: \[CatchFail\] .+"]),
666 java_medium('Inner class is non-static but does not reference enclosing class',
667 [r".*: warning: \[ClassCanBeStatic\] .+"]),
668 java_medium('Class.newInstance() bypasses exception checking; prefer getDeclaredConstructor().newInstance()',
669 [r".*: warning: \[ClassNewInstance\] .+"]),
670 java_medium('Providing Closeable resources makes their lifecycle unclear',
671 [r".*: warning: \[CloseableProvides\] .+"]),
672 java_medium('The type of the array parameter of Collection.toArray needs to be compatible with the array type',
673 [r".*: warning: \[CollectionToArraySafeParameter\] .+"]),
674 java_medium('Collector.of() should not use state',
675 [r".*: warning: \[CollectorShouldNotUseState\] .+"]),
676 java_medium('Class should not implement both `Comparable` and `Comparator`',
677 [r".*: warning: \[ComparableAndComparator\] .+"]),
678 java_medium('Constructors should not invoke overridable methods.',
679 [r".*: warning: \[ConstructorInvokesOverridable\] .+"]),
680 java_medium('Constructors should not pass the \'this\' reference out in method invocations, since the object may not be fully constructed.',
681 [r".*: warning: \[ConstructorLeaksThis\] .+"]),
682 java_medium('DateFormat is not thread-safe, and should not be used as a constant field.',
683 [r".*: warning: \[DateFormatConstant\] .+"]),
684 java_medium('Implicit use of the platform default charset, which can result in differing behaviour between JVM executions or incorrect behavior if the encoding of the data source doesn\'t match expectations.',
685 [r".*: warning: \[DefaultCharset\] .+"]),
686 java_medium('Avoid deprecated Thread methods; read the method\'s javadoc for details.',
687 [r".*: warning: \[DeprecatedThreadMethods\] .+"]),
688 java_medium('Prefer collection factory methods or builders to the double-brace initialization pattern.',
689 [r".*: warning: \[DoubleBraceInitialization\] .+"]),
690 java_medium('Double-checked locking on non-volatile fields is unsafe',
691 [r".*: warning: \[DoubleCheckedLocking\] .+"]),
692 java_medium('Empty top-level type declaration',
693 [r".*: warning: \[EmptyTopLevelDeclaration\] .+"]),
694 java_medium('equals() implementation may throw NullPointerException when given null',
695 [r".*: warning: \[EqualsBrokenForNull\] .+"]),
696 java_medium('Overriding Object#equals in a non-final class by using getClass rather than instanceof breaks substitutability of subclasses.',
697 [r".*: warning: \[EqualsGetClass\] .+"]),
698 java_medium('Classes that override equals should also override hashCode.',
699 [r".*: warning: \[EqualsHashCode\] .+"]),
700 java_medium('An equality test between objects with incompatible types always returns false',
701 [r".*: warning: \[EqualsIncompatibleType\] .+"]),
702 java_medium('The contract of #equals states that it should return false for incompatible types, while this implementation may throw ClassCastException.',
703 [r".*: warning: \[EqualsUnsafeCast\] .+"]),
704 java_medium('Implementing #equals by just comparing hashCodes is fragile. Hashes collide frequently, and this will lead to false positives in #equals.',
705 [r".*: warning: \[EqualsUsingHashCode\] .+"]),
706 java_medium('Calls to ExpectedException#expect should always be followed by exactly one statement.',
707 [r".*: warning: \[ExpectedExceptionChecker\] .+"]),
708 java_medium('When only using JUnit Assert\'s static methods, you should import statically instead of extending.',
709 [r".*: warning: \[ExtendingJUnitAssert\] .+"]),
710 java_medium('Switch case may fall through',
711 [r".*: warning: \[FallThrough\] .+"]),
712 java_medium('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.',
713 [r".*: warning: \[Finally\] .+"]),
714 java_medium('Use parentheses to make the precedence explicit',
715 [r".*: warning: \[FloatCast\] .+"]),
716 java_medium('This fuzzy equality check is using a tolerance less than the gap to the next number. You may want a less restrictive tolerance, or to assert equality.',
717 [r".*: warning: \[FloatingPointAssertionWithinEpsilon\] .+"]),
718 java_medium('Floating point literal loses precision',
719 [r".*: warning: \[FloatingPointLiteralPrecision\] .+"]),
720 java_medium('Classes extending PreferenceActivity must implement isValidFragment such that it does not unconditionally return true to prevent vulnerability to fragment injection attacks.',
721 [r".*: warning: \[FragmentInjection\] .+"]),
722 java_medium('Subclasses of Fragment must be instantiable via Class#newInstance(): the class must be public, static and have a public nullary constructor',
723 [r".*: warning: \[FragmentNotInstantiable\] .+"]),
724 java_medium('Overloads will be ambiguous when passing lambda arguments',
725 [r".*: warning: \[FunctionalInterfaceClash\] .+"]),
726 java_medium('Return value of methods returning Future must be checked. Ignoring returned Futures suppresses exceptions thrown from the code that completes the Future.',
727 [r".*: warning: \[FutureReturnValueIgnored\] .+"]),
728 java_medium('Calling getClass() on an enum may return a subclass of the enum type',
729 [r".*: warning: \[GetClassOnEnum\] .+"]),
730 java_medium('Hardcoded reference to /sdcard',
731 [r".*: warning: \[HardCodedSdCardPath\] .+"]),
732 java_medium('Hiding fields of superclasses may cause confusion and errors',
733 [r".*: warning: \[HidingField\] .+"]),
734 java_medium('Annotations should always be immutable',
735 [r".*: warning: \[ImmutableAnnotationChecker\] .+"]),
736 java_medium('Enums should always be immutable',
737 [r".*: warning: \[ImmutableEnumChecker\] .+"]),
738 java_medium('This annotation has incompatible modifiers as specified by its @IncompatibleModifiers annotation',
739 [r".*: warning: \[IncompatibleModifiers\] .+"]),
740 java_medium('It is confusing to have a field and a parameter under the same scope that differ only in capitalization.',
741 [r".*: warning: \[InconsistentCapitalization\] .+"]),
742 java_medium('Including fields in hashCode which are not compared in equals violates the contract of hashCode.',
743 [r".*: warning: \[InconsistentHashCode\] .+"]),
744 java_medium('The ordering of parameters in overloaded methods should be as consistent as possible (when viewed from left to right)',
745 [r".*: warning: \[InconsistentOverloads\] .+"]),
746 java_medium('This for loop increments the same variable in the header and in the body',
747 [r".*: warning: \[IncrementInForLoopAndHeader\] .+"]),
748 java_medium('Constructors on abstract classes are never directly @Injected, only the constructors of their subclasses can be @Inject\'ed.',
749 [r".*: warning: \[InjectOnConstructorOfAbstractClass\] .+"]),
750 java_medium('Please also override int read(byte[], int, int), otherwise multi-byte reads from this input stream are likely to be slow.',
751 [r".*: warning: \[InputStreamSlowMultibyteRead\] .+"]),
752 java_medium('Casting inside an if block should be plausibly consistent with the instanceof type',
753 [r".*: warning: \[InstanceOfAndCastMatchWrongType\] .+"]),
754 java_medium('Expression of type int may overflow before being assigned to a long',
755 [r".*: warning: \[IntLongMath\] .+"]),
756 java_medium('This @param tag doesn\'t refer to a parameter of the method.',
757 [r".*: warning: \[InvalidParam\] .+"]),
758 java_medium('This tag is invalid.',
759 [r".*: warning: \[InvalidTag\] .+"]),
760 java_medium('The documented method doesn\'t actually throw this checked exception.',
761 [r".*: warning: \[InvalidThrows\] .+"]),
762 java_medium('Class should not implement both `Iterable` and `Iterator`',
763 [r".*: warning: \[IterableAndIterator\] .+"]),
764 java_medium('Floating-point comparison without error tolerance',
765 [r".*: warning: \[JUnit3FloatingPointComparisonWithoutDelta\] .+"]),
766 java_medium('Some JUnit4 construct cannot be used in a JUnit3 context. Convert your class to JUnit4 style to use them.',
767 [r".*: warning: \[JUnit4ClassUsedInJUnit3\] .+"]),
768 java_medium('Test class inherits from JUnit 3\'s TestCase but has JUnit 4 @Test annotations.',
769 [r".*: warning: \[JUnitAmbiguousTestClass\] .+"]),
770 java_medium('Never reuse class names from java.lang',
771 [r".*: warning: \[JavaLangClash\] .+"]),
772 java_medium('Suggests alternatives to obsolete JDK classes.',
773 [r".*: warning: \[JdkObsolete\] .+"]),
774 java_medium('Calls to Lock#lock should be immediately followed by a try block which releases the lock.',
775 [r".*: warning: \[LockNotBeforeTry\] .+"]),
776 java_medium('Assignment where a boolean expression was expected; use == if this assignment wasn\'t expected or add parentheses for clarity.',
777 [r".*: warning: \[LogicalAssignment\] .+"]),
778 java_medium('Math.abs does not always give a positive result. Please consider other methods for positive random numbers.',
779 [r".*: warning: \[MathAbsoluteRandom\] .+"]),
780 java_medium('Switches on enum types should either handle all values, or have a default case.',
781 [r".*: warning: \[MissingCasesInEnumSwitch\] .+"]),
782 java_medium('The Google Java Style Guide requires that each switch statement includes a default statement group, even if it contains no code. (This requirement is lifted for any switch statement that covers all values of an enum.)',
783 [r".*: warning: \[MissingDefault\] .+"]),
784 java_medium('Not calling fail() when expecting an exception masks bugs',
785 [r".*: warning: \[MissingFail\] .+"]),
786 java_medium('method overrides method in supertype; expected @Override',
787 [r".*: warning: \[MissingOverride\] .+"]),
788 java_medium('A collection or proto builder was created, but its values were never accessed.',
789 [r".*: warning: \[ModifiedButNotUsed\] .+"]),
790 java_medium('Modifying a collection while iterating over it in a loop may cause a ConcurrentModificationException to be thrown.',
791 [r".*: warning: \[ModifyCollectionInEnhancedForLoop\] .+"]),
792 java_medium('Multiple calls to either parallel or sequential are unnecessary and cause confusion.',
793 [r".*: warning: \[MultipleParallelOrSequentialCalls\] .+"]),
794 java_medium('Constant field declarations should use the immutable type (such as ImmutableList) instead of the general collection interface type (such as List)',
795 [r".*: warning: \[MutableConstantField\] .+"]),
796 java_medium('Method return type should use the immutable type (such as ImmutableList) instead of the general collection interface type (such as List)',
797 [r".*: warning: \[MutableMethodReturnType\] .+"]),
798 java_medium('Compound assignments may hide dangerous casts',
799 [r".*: warning: \[NarrowingCompoundAssignment\] .+"]),
800 java_medium('Nested instanceOf conditions of disjoint types create blocks of code that never execute',
801 [r".*: warning: \[NestedInstanceOfConditions\] .+"]),
802 java_medium('Instead of returning a functional type, return the actual type that the returned function would return and use lambdas at use site.',
803 [r".*: warning: \[NoFunctionalReturnType\] .+"]),
804 java_medium('This update of a volatile variable is non-atomic',
805 [r".*: warning: \[NonAtomicVolatileUpdate\] .+"]),
806 java_medium('Static import of member uses non-canonical name',
807 [r".*: warning: \[NonCanonicalStaticMemberImport\] .+"]),
808 java_medium('equals method doesn\'t override Object.equals',
809 [r".*: warning: \[NonOverridingEquals\] .+"]),
810 java_medium('Constructors should not be annotated with @Nullable since they cannot return null',
811 [r".*: warning: \[NullableConstructor\] .+"]),
812 java_medium('Dereference of possibly-null value',
813 [r".*: warning: \[NullableDereference\] .+"]),
814 java_medium('@Nullable should not be used for primitive types since they cannot be null',
815 [r".*: warning: \[NullablePrimitive\] .+"]),
816 java_medium('void-returning methods should not be annotated with @Nullable, since they cannot return null',
817 [r".*: warning: \[NullableVoid\] .+"]),
818 java_medium('Calling toString on Objects that don\'t override toString() doesn\'t provide useful information',
819 [r".*: warning: \[ObjectToString\] .+"]),
820 java_medium('Objects.hashCode(Object o) should not be passed a primitive value',
821 [r".*: warning: \[ObjectsHashCodePrimitive\] .+"]),
822 java_medium('Use grouping parenthesis to make the operator precedence explicit',
823 [r".*: warning: \[OperatorPrecedence\] .+"]),
824 java_medium('One should not call optional.get() inside an if statement that checks !optional.isPresent',
825 [r".*: warning: \[OptionalNotPresent\] .+"]),
826 java_medium('String literal contains format specifiers, but is not passed to a format method',
827 [r".*: warning: \[OrphanedFormatString\] .+"]),
828 java_medium('To return a custom message with a Throwable class, one should override getMessage() instead of toString() for Throwable.',
829 [r".*: warning: \[OverrideThrowableToString\] .+"]),
830 java_medium('Varargs doesn\'t agree for overridden method',
831 [r".*: warning: \[Overrides\] .+"]),
832 java_medium('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.',
833 [r".*: warning: \[OverridesGuiceInjectableMethod\] .+"]),
834 java_medium('Detects `/* name= */`-style comments on actual parameters where the name doesn\'t match the formal parameter',
835 [r".*: warning: \[ParameterName\] .+"]),
836 java_medium('Preconditions only accepts the %s placeholder in error message strings',
837 [r".*: warning: \[PreconditionsInvalidPlaceholder\] .+"]),
838 java_medium('Passing a primitive array to a varargs method is usually wrong',
839 [r".*: warning: \[PrimitiveArrayPassedToVarargsMethod\] .+"]),
840 java_medium('A field on a protocol buffer was set twice in the same chained expression.',
841 [r".*: warning: \[ProtoRedundantSet\] .+"]),
842 java_medium('Protos should not be used as a key to a map, in a set, or in a contains method on a descendant of a collection. Protos have non deterministic ordering and proto equality is deep, which is a performance issue.',
843 [r".*: warning: \[ProtosAsKeyOfSetOrMap\] .+"]),
844 java_medium('BugChecker has incorrect ProvidesFix tag, please update',
845 [r".*: warning: \[ProvidesFix\] .+"]),
846 java_medium('Qualifiers/Scope annotations on @Inject methods don\'t have any effect. Move the qualifier annotation to the binding location.',
847 [r".*: warning: \[QualifierOrScopeOnInjectMethod\] .+"]),
848 java_medium('Injection frameworks currently don\'t understand Qualifiers in TYPE_PARAMETER or TYPE_USE contexts.',
849 [r".*: warning: \[QualifierWithTypeUse\] .+"]),
850 java_medium('reachabilityFence should always be called inside a finally block',
851 [r".*: warning: \[ReachabilityFenceUsage\] .+"]),
852 java_medium('Thrown exception is a subtype of another',
853 [r".*: warning: \[RedundantThrows\] .+"]),
854 java_medium('Comparison using reference equality instead of value equality',
855 [r".*: warning: \[ReferenceEquality\] .+"]),
856 java_medium('This annotation is missing required modifiers as specified by its @RequiredModifiers annotation',
857 [r".*: warning: \[RequiredModifiers\] .+"]),
858 java_medium('Void methods should not have a @return tag.',
859 [r".*: warning: \[ReturnFromVoid\] .+"]),
860 java_medium(u'Prefer the short-circuiting boolean operators \u0026\u0026 and || to \u0026 and |.',
861 [r".*: warning: \[ShortCircuitBoolean\] .+"]),
862 java_medium('Writes to static fields should not be guarded by instance locks',
863 [r".*: warning: \[StaticGuardedByInstance\] .+"]),
864 java_medium('A static variable or method should be qualified with a class name, not expression',
865 [r".*: warning: \[StaticQualifiedUsingExpression\] .+"]),
866 java_medium('Streams that encapsulate a closeable resource should be closed using try-with-resources',
867 [r".*: warning: \[StreamResourceLeak\] .+"]),
868 java_medium('String comparison using reference equality instead of value equality',
869 [r".*: warning: \[StringEquality\] .+"]),
870 java_medium('String.split(String) has surprising behavior',
871 [r".*: warning: \[StringSplitter\] .+"]),
872 java_medium('SWIG generated code that can\'t call a C++ destructor will leak memory',
873 [r".*: warning: \[SwigMemoryLeak\] .+"]),
874 java_medium('Synchronizing on non-final fields is not safe: if the field is ever updated, different threads may end up locking on different objects.',
875 [r".*: warning: \[SynchronizeOnNonFinalField\] .+"]),
876 java_medium('Code that contains System.exit() is untestable.',
877 [r".*: warning: \[SystemExitOutsideMain\] .+"]),
878 java_medium('Using @Test(expected=...) is discouraged, since the test will pass if *any* statement in the test method throws the expected exception',
879 [r".*: warning: \[TestExceptionChecker\] .+"]),
880 java_medium('Thread.join needs to be surrounded by a loop until it succeeds, as in Uninterruptibles.joinUninterruptibly.',
881 [r".*: warning: \[ThreadJoinLoop\] .+"]),
882 java_medium('ThreadLocals should be stored in static fields',
883 [r".*: warning: \[ThreadLocalUsage\] .+"]),
884 java_medium('Relying on the thread scheduler is discouraged; see Effective Java Item 72 (2nd edition) / 84 (3rd edition).',
885 [r".*: warning: \[ThreadPriorityCheck\] .+"]),
886 java_medium('Three-letter time zone identifiers are deprecated, may be ambiguous, and might not do what you intend; the full IANA time zone ID should be used instead.',
887 [r".*: warning: \[ThreeLetterTimeZoneID\] .+"]),
888 java_medium('An implementation of Object.toString() should never return null.',
889 [r".*: warning: \[ToStringReturnsNull\] .+"]),
890 java_medium('The actual and expected values appear to be swapped, which results in poor assertion failure messages. The actual value should come first.',
891 [r".*: warning: \[TruthAssertExpected\] .+"]),
892 java_medium('Truth Library assert is called on a constant.',
893 [r".*: warning: \[TruthConstantAsserts\] .+"]),
894 java_medium('Argument is not compatible with the subject\'s type.',
895 [r".*: warning: \[TruthIncompatibleType\] .+"]),
896 java_medium('Type parameter declaration shadows another named type',
897 [r".*: warning: \[TypeNameShadowing\] .+"]),
898 java_medium('Type parameter declaration overrides another type parameter already declared',
899 [r".*: warning: \[TypeParameterShadowing\] .+"]),
900 java_medium('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.',
901 [r".*: warning: \[TypeParameterUnusedInFormals\] .+"]),
902 java_medium('Avoid hash-based containers of java.net.URL--the containers rely on equals() and hashCode(), which cause java.net.URL to make blocking internet connections.',
903 [r".*: warning: \[URLEqualsHashCode\] .+"]),
904 java_medium('Collection, Iterable, Multimap, and Queue do not have well-defined equals behavior',
905 [r".*: warning: \[UndefinedEquals\] .+"]),
906 java_medium('Switch handles all enum values: an explicit default case is unnecessary and defeats error checking for non-exhaustive switches.',
907 [r".*: warning: \[UnnecessaryDefaultInEnumSwitch\] .+"]),
908 java_medium('Unnecessary use of grouping parentheses',
909 [r".*: warning: \[UnnecessaryParentheses\] .+"]),
910 java_medium('Finalizer may run before native code finishes execution',
911 [r".*: warning: \[UnsafeFinalization\] .+"]),
912 java_medium('Prefer `asSubclass` instead of casting the result of `newInstance`, to detect classes of incorrect type before invoking their constructors.This way, if the class is of the incorrect type,it will throw an exception before invoking its constructor.',
913 [r".*: warning: \[UnsafeReflectiveConstructionCast\] .+"]),
914 java_medium('Unsynchronized method overrides a synchronized method.',
915 [r".*: warning: \[UnsynchronizedOverridesSynchronized\] .+"]),
916 java_medium('Unused.',
917 [r".*: warning: \[Unused\] .+"]),
918 java_medium('This catch block catches an exception and re-throws another, but swallows the caught exception rather than setting it as a cause. This can make debugging harder.',
919 [r".*: warning: \[UnusedException\] .+"]),
920 java_medium('Java assert is used in test. For testing purposes Assert.* matchers should be used.',
921 [r".*: warning: \[UseCorrectAssertInTests\] .+"]),
922 java_medium('Non-constant variable missing @Var annotation',
923 [r".*: warning: \[Var\] .+"]),
924 java_medium('variableName and type with the same name would refer to the static field instead of the class',
925 [r".*: warning: \[VariableNameSameAsType\] .+"]),
926 java_medium('Because of spurious wakeups, Object.wait() and Condition.await() must always be called in a loop',
927 [r".*: warning: \[WaitNotInLoop\] .+"]),
928 java_medium('A wakelock acquired with a timeout may be released by the system before calling `release`, even after checking `isHeld()`. If so, it will throw a RuntimeException. Please wrap in a try/catch block.',
929 [r".*: warning: \[WakelockReleasedDangerously\] .+"]),
930 java_high('AndroidInjection.inject() should always be invoked before calling super.lifecycleMethod()',
931 [r".*: warning: \[AndroidInjectionBeforeSuper\] .+"]),
932 java_high('Use of class, field, or method that is not compatible with legacy Android devices',
933 [r".*: warning: \[AndroidJdkLibsChecker\] .+"]),
934 java_high('Reference equality used to compare arrays',
935 [r".*: warning: \[ArrayEquals\] .+"]),
936 java_high('Arrays.fill(Object[], Object) called with incompatible types.',
937 [r".*: warning: \[ArrayFillIncompatibleType\] .+"]),
938 java_high('hashcode method on array does not hash array contents',
939 [r".*: warning: \[ArrayHashCode\] .+"]),
940 java_high('Calling toString on an array does not provide useful information',
941 [r".*: warning: \[ArrayToString\] .+"]),
942 java_high('Arrays.asList does not autobox primitive arrays, as one might expect.',
943 [r".*: warning: \[ArraysAsListPrimitiveArray\] .+"]),
944 java_high('@AssistedInject and @Inject cannot be used on the same constructor.',
945 [r".*: warning: \[AssistedInjectAndInjectOnSameConstructor\] .+"]),
946 java_high('AsyncCallable should not return a null Future, only a Future whose result is null.',
947 [r".*: warning: \[AsyncCallableReturnsNull\] .+"]),
948 java_high('AsyncFunction should not return a null Future, only a Future whose result is null.',
949 [r".*: warning: \[AsyncFunctionReturnsNull\] .+"]),
950 java_high('@AutoFactory and @Inject should not be used in the same type.',
951 [r".*: warning: \[AutoFactoryAtInject\] .+"]),
952 java_high('Arguments to AutoValue constructor are in the wrong order',
953 [r".*: warning: \[AutoValueConstructorOrderChecker\] .+"]),
954 java_high('Shift by an amount that is out of range',
955 [r".*: warning: \[BadShiftAmount\] .+"]),
956 java_high('Object serialized in Bundle may have been flattened to base type.',
957 [r".*: warning: \[BundleDeserializationCast\] .+"]),
958 java_high('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.',
959 [r".*: warning: \[ChainingConstructorIgnoresParameter\] .+"]),
960 java_high('Ignored return value of method that is annotated with @CheckReturnValue',
961 [r".*: warning: \[CheckReturnValue\] .+"]),
962 java_high('The source file name should match the name of the top-level class it contains',
963 [r".*: warning: \[ClassName\] .+"]),
964 java_high('Incompatible type as argument to Object-accepting Java collections method',
965 [r".*: warning: \[CollectionIncompatibleType\] .+"]),
966 java_high(u'Implementing \'Comparable\u003cT>\' where T is not compatible with the implementing class.',
967 [r".*: warning: \[ComparableType\] .+"]),
968 java_high('this == null is always false, this != null is always true',
969 [r".*: warning: \[ComparingThisWithNull\] .+"]),
970 java_high('This comparison method violates the contract',
971 [r".*: warning: \[ComparisonContractViolated\] .+"]),
972 java_high('Comparison to value that is out of range for the compared type',
973 [r".*: warning: \[ComparisonOutOfRange\] .+"]),
974 java_high('@CompatibleWith\'s value is not a type argument.',
975 [r".*: warning: \[CompatibleWithAnnotationMisuse\] .+"]),
976 java_high('Non-compile-time constant expression passed to parameter with @CompileTimeConstant type annotation.',
977 [r".*: warning: \[CompileTimeConstant\] .+"]),
978 java_high('Non-trivial compile time constant boolean expressions shouldn\'t be used.',
979 [r".*: warning: \[ComplexBooleanConstant\] .+"]),
980 java_high('A conditional expression with numeric operands of differing types will perform binary numeric promotion of the operands; when these operands are of reference types, the expression\'s result may not be of the expected type.',
981 [r".*: warning: \[ConditionalExpressionNumericPromotion\] .+"]),
982 java_high('Compile-time constant expression overflows',
983 [r".*: warning: \[ConstantOverflow\] .+"]),
984 java_high('Dagger @Provides methods may not return null unless annotated with @Nullable',
985 [r".*: warning: \[DaggerProvidesNull\] .+"]),
986 java_high('Exception created but not thrown',
987 [r".*: warning: \[DeadException\] .+"]),
988 java_high('Thread created but not started',
989 [r".*: warning: \[DeadThread\] .+"]),
990 java_high('Deprecated item is not annotated with @Deprecated',
991 [r".*: warning: \[DepAnn\] .+"]),
992 java_high('Division by integer literal zero',
993 [r".*: warning: \[DivZero\] .+"]),
994 java_high('This method should not be called.',
995 [r".*: warning: \[DoNotCall\] .+"]),
996 java_high('Empty statement after if',
997 [r".*: warning: \[EmptyIf\] .+"]),
998 java_high('== NaN always returns false; use the isNaN methods instead',
999 [r".*: warning: \[EqualsNaN\] .+"]),
1000 java_high('== must be used in equals method to check equality to itself or an infinite loop will occur.',
1001 [r".*: warning: \[EqualsReference\] .+"]),
1002 java_high('Comparing different pairs of fields/getters in an equals implementation is probably a mistake.',
1003 [r".*: warning: \[EqualsWrongThing\] .+"]),
1004 java_high('Method annotated @ForOverride must be protected or package-private and only invoked from declaring class, or from an override of the method',
1005 [r".*: warning: \[ForOverride\] .+"]),
1006 java_high('Invalid printf-style format string',
1007 [r".*: warning: \[FormatString\] .+"]),
1008 java_high('Invalid format string passed to formatting method.',
1009 [r".*: warning: \[FormatStringAnnotation\] .+"]),
1010 java_high('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.',
1011 [r".*: warning: \[FunctionalInterfaceMethodChanged\] .+"]),
1012 java_high('Futures.getChecked requires a checked exception type with a standard constructor.',
1013 [r".*: warning: \[FuturesGetCheckedIllegalExceptionType\] .+"]),
1014 java_high('DoubleMath.fuzzyEquals should never be used in an Object.equals() method',
1015 [r".*: warning: \[FuzzyEqualsShouldNotBeUsedInEqualsMethod\] .+"]),
1016 java_high('Calling getClass() on an annotation may return a proxy class',
1017 [r".*: warning: \[GetClassOnAnnotation\] .+"]),
1018 java_high('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',
1019 [r".*: warning: \[GetClassOnClass\] .+"]),
1020 java_high('Checks for unguarded accesses to fields and methods with @GuardedBy annotations',
1021 [r".*: warning: \[GuardedBy\] .+"]),
1022 java_high('Scope annotation on implementation class of AssistedInject factory is not allowed',
1023 [r".*: warning: \[GuiceAssistedInjectScoping\] .+"]),
1024 java_high('A constructor cannot have two @Assisted parameters of the same type unless they are disambiguated with named @Assisted annotations.',
1025 [r".*: warning: \[GuiceAssistedParameters\] .+"]),
1026 java_high('Although Guice allows injecting final fields, doing so is disallowed because the injected value may not be visible to other threads.',
1027 [r".*: warning: \[GuiceInjectOnFinalField\] .+"]),
1028 java_high('contains() is a legacy method that is equivalent to containsValue()',
1029 [r".*: warning: \[HashtableContains\] .+"]),
1030 java_high('A binary expression where both operands are the same is usually incorrect.',
1031 [r".*: warning: \[IdentityBinaryExpression\] .+"]),
1032 java_high('Type declaration annotated with @Immutable is not immutable',
1033 [r".*: warning: \[Immutable\] .+"]),
1034 java_high('Modifying an immutable collection is guaranteed to throw an exception and leave the collection unmodified',
1035 [r".*: warning: \[ImmutableModification\] .+"]),
1036 java_high('Passing argument to a generic method with an incompatible type.',
1037 [r".*: warning: \[IncompatibleArgumentType\] .+"]),
1038 java_high('The first argument to indexOf is a Unicode code point, and the second is the index to start the search from',
1039 [r".*: warning: \[IndexOfChar\] .+"]),
1040 java_high('Conditional expression in varargs call contains array and non-array arguments',
1041 [r".*: warning: \[InexactVarargsConditional\] .+"]),
1042 java_high('This method always recurses, and will cause a StackOverflowError',
1043 [r".*: warning: \[InfiniteRecursion\] .+"]),
1044 java_high('A scoping annotation\'s Target should include TYPE and METHOD.',
1045 [r".*: warning: \[InjectInvalidTargetingOnScopingAnnotation\] .+"]),
1046 java_high('Using more than one qualifier annotation on the same element is not allowed.',
1047 [r".*: warning: \[InjectMoreThanOneQualifier\] .+"]),
1048 java_high('A class can be annotated with at most one scope annotation.',
1049 [r".*: warning: \[InjectMoreThanOneScopeAnnotationOnClass\] .+"]),
1050 java_high('Members shouldn\'t be annotated with @Inject if constructor is already annotated @Inject',
1051 [r".*: warning: \[InjectOnMemberAndConstructor\] .+"]),
1052 java_high('Scope annotation on an interface or abstact class is not allowed',
1053 [r".*: warning: \[InjectScopeAnnotationOnInterfaceOrAbstractClass\] .+"]),
1054 java_high('Scoping and qualifier annotations must have runtime retention.',
1055 [r".*: warning: \[InjectScopeOrQualifierAnnotationRetention\] .+"]),
1056 java_high('Injected constructors cannot be optional nor have binding annotations',
1057 [r".*: warning: \[InjectedConstructorAnnotations\] .+"]),
1058 java_high('A standard cryptographic operation is used in a mode that is prone to vulnerabilities',
1059 [r".*: warning: \[InsecureCryptoUsage\] .+"]),
1060 java_high('Invalid syntax used for a regular expression',
1061 [r".*: warning: \[InvalidPatternSyntax\] .+"]),
1062 java_high('Invalid time zone identifier. TimeZone.getTimeZone(String) will silently return GMT instead of the time zone you intended.',
1063 [r".*: warning: \[InvalidTimeZoneID\] .+"]),
1064 java_high('The argument to Class#isInstance(Object) should not be a Class',
1065 [r".*: warning: \[IsInstanceOfClass\] .+"]),
1066 java_high('Log tag too long, cannot exceed 23 characters.',
1067 [r".*: warning: \[IsLoggableTagLength\] .+"]),
1068 java_high(u'Path implements Iterable\u003cPath>; prefer Collection\u003cPath> for clarity',
1069 [r".*: warning: \[IterablePathParameter\] .+"]),
1070 java_high('jMock tests must have a @RunWith(JMock.class) annotation, or the Mockery field must have a @Rule JUnit annotation',
1071 [r".*: warning: \[JMockTestWithoutRunWithOrRuleAnnotation\] .+"]),
1072 java_high('Test method will not be run; please correct method signature (Should be public, non-static, and method name should begin with "test").',
1073 [r".*: warning: \[JUnit3TestNotRun\] .+"]),
1074 java_high('This method should be static',
1075 [r".*: warning: \[JUnit4ClassAnnotationNonStatic\] .+"]),
1076 java_high('setUp() method will not be run; please add JUnit\'s @Before annotation',
1077 [r".*: warning: \[JUnit4SetUpNotRun\] .+"]),
1078 java_high('tearDown() method will not be run; please add JUnit\'s @After annotation',
1079 [r".*: warning: \[JUnit4TearDownNotRun\] .+"]),
1080 java_high('This looks like a test method but is not run; please add @Test and @Ignore, or, if this is a helper method, reduce its visibility.',
1081 [r".*: warning: \[JUnit4TestNotRun\] .+"]),
1082 java_high('An object is tested for reference equality to itself using JUnit library.',
1083 [r".*: warning: \[JUnitAssertSameCheck\] .+"]),
1084 java_high('Use of class, field, or method that is not compatible with JDK 7',
1085 [r".*: warning: \[Java7ApiChecker\] .+"]),
1086 java_high('Abstract and default methods are not injectable with javax.inject.Inject',
1087 [r".*: warning: \[JavaxInjectOnAbstractMethod\] .+"]),
1088 java_high('@javax.inject.Inject cannot be put on a final field.',
1089 [r".*: warning: \[JavaxInjectOnFinalField\] .+"]),
1090 java_high('This pattern will silently corrupt certain byte sequences from the serialized protocol message. Use ByteString or byte[] directly',
1091 [r".*: warning: \[LiteByteStringUtf8\] .+"]),
1092 java_high('This method does not acquire the locks specified by its @LockMethod annotation',
1093 [r".*: warning: \[LockMethodChecker\] .+"]),
1094 java_high('Prefer \'L\' to \'l\' for the suffix to long literals',
1095 [r".*: warning: \[LongLiteralLowerCaseSuffix\] .+"]),
1096 java_high('Loop condition is never modified in loop body.',
1097 [r".*: warning: \[LoopConditionChecker\] .+"]),
1098 java_high('Math.round(Integer) results in truncation',
1099 [r".*: warning: \[MathRoundIntLong\] .+"]),
1100 java_high('Certain resources in `android.R.string` have names that do not match their content',
1101 [r".*: warning: \[MislabeledAndroidString\] .+"]),
1102 java_high('Overriding method is missing a call to overridden super method',
1103 [r".*: warning: \[MissingSuperCall\] .+"]),
1104 java_high('A terminating method call is required for a test helper to have any effect.',
1105 [r".*: warning: \[MissingTestCall\] .+"]),
1106 java_high('Use of "YYYY" (week year) in a date pattern without "ww" (week in year). You probably meant to use "yyyy" (year) instead.',
1107 [r".*: warning: \[MisusedWeekYear\] .+"]),
1108 java_high('A bug in Mockito will cause this test to fail at runtime with a ClassCastException',
1109 [r".*: warning: \[MockitoCast\] .+"]),
1110 java_high('Missing method call for verify(mock) here',
1111 [r".*: warning: \[MockitoUsage\] .+"]),
1112 java_high('Using a collection function with itself as the argument.',
1113 [r".*: warning: \[ModifyingCollectionWithItself\] .+"]),
1114 java_high('This class has more than one @Inject-annotated constructor. Please remove the @Inject annotation from all but one of them.',
1115 [r".*: warning: \[MoreThanOneInjectableConstructor\] .+"]),
1116 java_high('The result of this method must be closed.',
1117 [r".*: warning: \[MustBeClosedChecker\] .+"]),
1118 java_high('The first argument to nCopies is the number of copies, and the second is the item to copy',
1119 [r".*: warning: \[NCopiesOfChar\] .+"]),
1120 java_high('@NoAllocation was specified on this method, but something was found that would trigger an allocation',
1121 [r".*: warning: \[NoAllocation\] .+"]),
1122 java_high('Static import of type uses non-canonical name',
1123 [r".*: warning: \[NonCanonicalStaticImport\] .+"]),
1124 java_high('@CompileTimeConstant parameters should be final or effectively final',
1125 [r".*: warning: \[NonFinalCompileTimeConstant\] .+"]),
1126 java_high('Calling getAnnotation on an annotation that is not retained at runtime.',
1127 [r".*: warning: \[NonRuntimeAnnotation\] .+"]),
1128 java_high('This conditional expression may evaluate to null, which will result in an NPE when the result is unboxed.',
1129 [r".*: warning: \[NullTernary\] .+"]),
1130 java_high('Numeric comparison using reference equality instead of value equality',
1131 [r".*: warning: \[NumericEquality\] .+"]),
1132 java_high('Comparison using reference equality instead of value equality',
1133 [r".*: warning: \[OptionalEquality\] .+"]),
1134 java_high('Annotations cannot be both Scope annotations and Qualifier annotations: this causes confusion when trying to use them.',
1135 [r".*: warning: \[OverlappingQualifierAndScopeAnnotation\] .+"]),
1136 java_high('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.',
1137 [r".*: warning: \[OverridesJavaxInjectableMethod\] .+"]),
1138 java_high('Declaring types inside package-info.java files is very bad form',
1139 [r".*: warning: \[PackageInfo\] .+"]),
1140 java_high('Method parameter has wrong package',
1141 [r".*: warning: \[ParameterPackage\] .+"]),
1142 java_high('Detects classes which implement Parcelable but don\'t have CREATOR',
1143 [r".*: warning: \[ParcelableCreator\] .+"]),
1144 java_high('Literal passed as first argument to Preconditions.checkNotNull() can never be null',
1145 [r".*: warning: \[PreconditionsCheckNotNull\] .+"]),
1146 java_high('First argument to `Preconditions.checkNotNull()` is a primitive rather than an object reference',
1147 [r".*: warning: \[PreconditionsCheckNotNullPrimitive\] .+"]),
1148 java_high('Using ::equals or ::isInstance as an incompatible Predicate; the predicate will always return false',
1149 [r".*: warning: \[PredicateIncompatibleType\] .+"]),
1150 java_high('Access to a private protocol buffer field is forbidden. This protocol buffer carries a security contract, and can only be created using an approved library. Direct access to the fields is forbidden.',
1151 [r".*: warning: \[PrivateSecurityContractProtoAccess\] .+"]),
1152 java_high('Protobuf fields cannot be null.',
1153 [r".*: warning: \[ProtoFieldNullComparison\] .+"]),
1154 java_high('Comparing protobuf fields of type String using reference equality',
1155 [r".*: warning: \[ProtoStringFieldReferenceEquality\] .+"]),
1156 java_high('To get the tag number of a protocol buffer enum, use getNumber() instead.',
1157 [r".*: warning: \[ProtocolBufferOrdinal\] .+"]),
1158 java_high('@Provides methods need to be declared in a Module to have any effect.',
1159 [r".*: warning: \[ProvidesMethodOutsideOfModule\] .+"]),
1160 java_high('Casting a random number in the range [0.0, 1.0) to an integer or long always results in 0.',
1161 [r".*: warning: \[RandomCast\] .+"]),
1162 java_high('Use Random.nextInt(int). Random.nextInt() % n can have negative results',
1163 [r".*: warning: \[RandomModInteger\] .+"]),
1164 java_high('Return value of android.graphics.Rect.intersect() must be checked',
1165 [r".*: warning: \[RectIntersectReturnValueIgnored\] .+"]),
1166 java_high('Use of method or class annotated with @RestrictTo',
1167 [r".*: warning: \[RestrictTo\] .+"]),
1168 java_high(' Check for non-whitelisted callers to RestrictedApiChecker.',
1169 [r".*: warning: \[RestrictedApiChecker\] .+"]),
1170 java_high('Return value of this method must be used',
1171 [r".*: warning: \[ReturnValueIgnored\] .+"]),
1172 java_high('Variable assigned to itself',
1173 [r".*: warning: \[SelfAssignment\] .+"]),
1174 java_high('An object is compared to itself',
1175 [r".*: warning: \[SelfComparison\] .+"]),
1176 java_high('Testing an object for equality with itself will always be true.',
1177 [r".*: warning: \[SelfEquals\] .+"]),
1178 java_high('This method must be called with an even number of arguments.',
1179 [r".*: warning: \[ShouldHaveEvenArgs\] .+"]),
1180 java_high('Comparison of a size >= 0 is always true, did you intend to check for non-emptiness?',
1181 [r".*: warning: \[SizeGreaterThanOrEqualsZero\] .+"]),
1182 java_high('Static and default interface methods are not natively supported on older Android devices. ',
1183 [r".*: warning: \[StaticOrDefaultInterfaceMethod\] .+"]),
1184 java_high('Calling toString on a Stream does not provide useful information',
1185 [r".*: warning: \[StreamToString\] .+"]),
1186 java_high('StringBuilder does not have a char constructor; this invokes the int constructor.',
1187 [r".*: warning: \[StringBuilderInitWithChar\] .+"]),
1188 java_high('String.substring(0) returns the original String',
1189 [r".*: warning: \[SubstringOfZero\] .+"]),
1190 java_high('Suppressing "deprecated" is probably a typo for "deprecation"',
1191 [r".*: warning: \[SuppressWarningsDeprecated\] .+"]),
1192 java_high('throwIfUnchecked(knownCheckedException) is a no-op.',
1193 [r".*: warning: \[ThrowIfUncheckedKnownChecked\] .+"]),
1194 java_high('Throwing \'null\' always results in a NullPointerException being thrown.',
1195 [r".*: warning: \[ThrowNull\] .+"]),
1196 java_high('isEqualTo should not be used to test an object for equality with itself; the assertion will never fail.',
1197 [r".*: warning: \[TruthSelfEquals\] .+"]),
1198 java_high('Catching Throwable/Error masks failures from fail() or assert*() in the try block',
1199 [r".*: warning: \[TryFailThrowable\] .+"]),
1200 java_high('Type parameter used as type qualifier',
1201 [r".*: warning: \[TypeParameterQualifier\] .+"]),
1202 java_high('This method does not acquire the locks specified by its @UnlockMethod annotation',
1203 [r".*: warning: \[UnlockMethod\] .+"]),
1204 java_high('Non-generic methods should not be invoked with type arguments',
1205 [r".*: warning: \[UnnecessaryTypeArgument\] .+"]),
1206 java_high('Instance created but never used',
1207 [r".*: warning: \[UnusedAnonymousClass\] .+"]),
1208 java_high('Collection is modified in place, but the result is not used',
1209 [r".*: warning: \[UnusedCollectionModifiedInPlace\] .+"]),
1210 java_high('`var` should not be used as a type name.',
1211 [r".*: warning: \[VarTypeName\] .+"]),
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001212
1213 # End warnings generated by Error Prone
Ian Rogers32bb9bd2016-05-09 23:19:42 -07001214
Chih-Hung Hsieh79002042019-09-25 13:34:08 -07001215 java_warn(Severity.UNKNOWN,
1216 'Unclassified/unrecognized warnings',
1217 [r".*: warning: \[.+\] .+"]), # TODO(chh) use more specific pattern
Ian Rogers32bb9bd2016-05-09 23:19:42 -07001218
Chih-Hung Hsieh79002042019-09-25 13:34:08 -07001219 # aapt warnings
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001220 {'category': 'aapt', 'severity': Severity.MEDIUM,
1221 'description': 'aapt: No default translation',
1222 'patterns': [r".*: warning: string '.+' has no default translation in .*"]},
1223 {'category': 'aapt', 'severity': Severity.MEDIUM,
1224 'description': 'aapt: Missing default or required localization',
1225 'patterns': [r".*: warning: \*\*\*\* string '.+' has no default or required localization for '.+' in .+"]},
1226 {'category': 'aapt', 'severity': Severity.MEDIUM,
1227 'description': 'aapt: String marked untranslatable, but translation exists',
1228 'patterns': [r".*: warning: string '.+' in .* marked untranslatable but exists in locale '??_??'"]},
1229 {'category': 'aapt', 'severity': Severity.MEDIUM,
1230 'description': 'aapt: empty span in string',
1231 'patterns': [r".*: warning: empty '.+' span found in text '.+"]},
Chih-Hung Hsieh79002042019-09-25 13:34:08 -07001232
1233 # C/C++ warnings
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001234 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1235 'description': 'Taking address of temporary',
1236 'patterns': [r".*: warning: taking address of temporary"]},
1237 {'category': 'C/C++', 'severity': Severity.MEDIUM,
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07001238 'description': 'Taking address of packed member',
1239 'patterns': [r".*: warning: taking address of packed member"]},
1240 {'category': 'C/C++', 'severity': Severity.MEDIUM,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001241 'description': 'Possible broken line continuation',
1242 'patterns': [r".*: warning: backslash and newline separated by space"]},
1243 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wundefined-var-template',
1244 'description': 'Undefined variable template',
1245 'patterns': [r".*: warning: instantiation of variable .* no definition is available"]},
1246 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wundefined-inline',
1247 'description': 'Inline function is not defined',
1248 'patterns': [r".*: warning: inline function '.*' is not defined"]},
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -07001249 # {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Warray-bounds',
1250 # 'description': 'Array subscript out of bounds',
1251 # 'patterns': [r".*: warning: array subscript is above array bounds",
1252 # r".*: warning: Array subscript is undefined",
1253 # r".*: warning: array subscript is below array bounds"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001254 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1255 'description': 'Excess elements in initializer',
1256 'patterns': [r".*: warning: excess elements in .+ initializer"]},
1257 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1258 'description': 'Decimal constant is unsigned only in ISO C90',
1259 'patterns': [r".*: warning: this decimal constant is unsigned only in ISO C90"]},
1260 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmain',
1261 'description': 'main is usually a function',
1262 'patterns': [r".*: warning: 'main' is usually a function"]},
1263 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1264 'description': 'Typedef ignored',
1265 'patterns': [r".*: warning: 'typedef' was ignored in this declaration"]},
1266 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Waddress',
1267 'description': 'Address always evaluates to true',
1268 'patterns': [r".*: warning: the address of '.+' will always evaluate as 'true'"]},
1269 {'category': 'C/C++', 'severity': Severity.FIXMENOW,
1270 'description': 'Freeing a non-heap object',
1271 'patterns': [r".*: warning: attempt to free a non-heap object '.+'"]},
1272 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wchar-subscripts',
1273 'description': 'Array subscript has type char',
1274 'patterns': [r".*: warning: array subscript .+ type 'char'.+Wchar-subscripts"]},
1275 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1276 'description': 'Constant too large for type',
1277 'patterns': [r".*: warning: integer constant is too large for '.+' type"]},
1278 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Woverflow',
1279 'description': 'Constant too large for type, truncated',
1280 'patterns': [r".*: warning: large integer implicitly truncated to unsigned type"]},
1281 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Winteger-overflow',
1282 'description': 'Overflow in expression',
1283 'patterns': [r".*: warning: overflow in expression; .*Winteger-overflow"]},
1284 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Woverflow',
1285 'description': 'Overflow in implicit constant conversion',
1286 'patterns': [r".*: warning: overflow in implicit constant conversion"]},
1287 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1288 'description': 'Declaration does not declare anything',
1289 'patterns': [r".*: warning: declaration 'class .+' does not declare anything"]},
1290 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wreorder',
1291 'description': 'Initialization order will be different',
1292 'patterns': [r".*: warning: '.+' will be initialized after",
1293 r".*: warning: field .+ will be initialized after .+Wreorder"]},
1294 {'category': 'cont.', 'severity': Severity.SKIP,
1295 'description': 'skip, ....',
1296 'patterns': [r".*: warning: '.+'"]},
1297 {'category': 'cont.', 'severity': Severity.SKIP,
1298 'description': 'skip, base ...',
1299 'patterns': [r".*: warning: base '.+'"]},
1300 {'category': 'cont.', 'severity': Severity.SKIP,
1301 'description': 'skip, when initialized here',
1302 'patterns': [r".*: warning: when initialized here"]},
1303 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-parameter-type',
1304 'description': 'Parameter type not specified',
1305 'patterns': [r".*: warning: type of '.+' defaults to 'int'"]},
1306 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-declarations',
1307 'description': 'Missing declarations',
1308 'patterns': [r".*: warning: declaration does not declare anything"]},
1309 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-noreturn',
1310 'description': 'Missing noreturn',
1311 'patterns': [r".*: warning: function '.*' could be declared with attribute 'noreturn'"]},
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001312 # pylint:disable=anomalous-backslash-in-string
1313 # TODO(chh): fix the backslash pylint warning.
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001314 {'category': 'gcc', 'severity': Severity.MEDIUM,
1315 'description': 'Invalid option for C file',
1316 'patterns': [r".*: warning: command line option "".+"" is valid for C\+\+\/ObjC\+\+ but not for C"]},
1317 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1318 'description': 'User warning',
1319 'patterns': [r".*: warning: #warning "".+"""]},
1320 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wvexing-parse',
1321 'description': 'Vexing parsing problem',
1322 'patterns': [r".*: warning: empty parentheses interpreted as a function declaration"]},
1323 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wextra',
1324 'description': 'Dereferencing void*',
1325 'patterns': [r".*: warning: dereferencing 'void \*' pointer"]},
1326 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1327 'description': 'Comparison of pointer and integer',
1328 'patterns': [r".*: warning: ordered comparison of pointer with integer zero",
1329 r".*: warning: .*comparison between pointer and integer"]},
1330 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1331 'description': 'Use of error-prone unary operator',
1332 'patterns': [r".*: warning: use of unary operator that may be intended as compound assignment"]},
1333 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wwrite-strings',
1334 'description': 'Conversion of string constant to non-const char*',
1335 'patterns': [r".*: warning: deprecated conversion from string constant to '.+'"]},
1336 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wstrict-prototypes',
1337 'description': 'Function declaration isn''t a prototype',
1338 'patterns': [r".*: warning: function declaration isn't a prototype"]},
1339 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wignored-qualifiers',
1340 'description': 'Type qualifiers ignored on function return value',
1341 'patterns': [r".*: warning: type qualifiers ignored on function return type",
1342 r".*: warning: .+ type qualifier .+ has no effect .+Wignored-qualifiers"]},
1343 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1344 'description': '<foo> declared inside parameter list, scope limited to this definition',
1345 'patterns': [r".*: warning: '.+' declared inside parameter list"]},
1346 {'category': 'cont.', 'severity': Severity.SKIP,
1347 'description': 'skip, its scope is only this ...',
1348 'patterns': [r".*: warning: its scope is only this definition or declaration, which is probably not what you want"]},
1349 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wcomment',
1350 'description': 'Line continuation inside comment',
1351 'patterns': [r".*: warning: multi-line comment"]},
1352 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wcomment',
1353 'description': 'Comment inside comment',
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -07001354 'patterns': [r".*: warning: '.+' within block comment .*-Wcomment"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001355 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wdeprecated-declarations',
1356 'description': 'Deprecated declarations',
1357 'patterns': [r".*: warning: .+ is deprecated.+deprecated-declarations"]},
1358 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wdeprecated-register',
1359 'description': 'Deprecated register',
1360 'patterns': [r".*: warning: 'register' storage class specifier is deprecated"]},
1361 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wpointer-sign',
1362 'description': 'Converts between pointers to integer types with different sign',
1363 'patterns': [r".*: warning: .+ converts between pointers to integer types with different sign"]},
1364 {'category': 'C/C++', 'severity': Severity.HARMLESS,
1365 'description': 'Extra tokens after #endif',
1366 'patterns': [r".*: warning: extra tokens at end of #endif directive"]},
1367 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wenum-compare',
1368 'description': 'Comparison between different enums',
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -07001369 'patterns': [r".*: warning: comparison between '.+' and '.+'.+Wenum-compare",
1370 r".*: warning: comparison of .* enumeration types .*-Wenum-compare-switch"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001371 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wconversion',
1372 'description': 'Conversion may change value',
1373 'patterns': [r".*: warning: converting negative value '.+' to '.+'",
1374 r".*: warning: conversion to '.+' .+ may (alter|change)"]},
1375 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wconversion-null',
1376 'description': 'Converting to non-pointer type from NULL',
1377 'patterns': [r".*: warning: converting to non-pointer type '.+' from NULL"]},
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07001378 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsign-conversion',
1379 'description': 'Implicit sign conversion',
1380 'patterns': [r".*: warning: implicit conversion changes signedness"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001381 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wnull-conversion',
1382 'description': 'Converting NULL to non-pointer type',
1383 'patterns': [r".*: warning: implicit conversion of NULL constant to '.+'"]},
1384 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wnon-literal-null-conversion',
1385 'description': 'Zero used as null pointer',
1386 'patterns': [r".*: warning: expression .* zero treated as a null pointer constant"]},
1387 {'category': 'C/C++', 'severity': Severity.MEDIUM,
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -07001388 'description': 'Implicit conversion changes value or loses precision',
1389 'patterns': [r".*: warning: implicit conversion .* changes value from .* to .*-conversion",
1390 r".*: warning: implicit conversion loses integer precision:"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001391 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1392 'description': 'Passing NULL as non-pointer argument',
1393 'patterns': [r".*: warning: passing NULL to non-pointer argument [0-9]+ of '.+'"]},
1394 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wctor-dtor-privacy',
1395 'description': 'Class seems unusable because of private ctor/dtor',
1396 'patterns': [r".*: warning: all member functions in class '.+' are private"]},
Marco Nelissen594375d2009-07-14 09:04:04 -07001397 # 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 -07001398 {'category': 'C/C++', 'severity': Severity.SKIP, 'option': '-Wctor-dtor-privacy',
1399 'description': 'Class seems unusable because of private ctor/dtor',
1400 'patterns': [r".*: warning: 'class .+' only defines a private destructor and has no friends"]},
1401 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wctor-dtor-privacy',
1402 'description': 'Class seems unusable because of private ctor/dtor',
1403 'patterns': [r".*: warning: 'class .+' only defines private constructors and has no friends"]},
1404 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wgnu-static-float-init',
1405 'description': 'In-class initializer for static const float/double',
1406 'patterns': [r".*: warning: in-class initializer for static data member of .+const (float|double)"]},
1407 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wpointer-arith',
1408 'description': 'void* used in arithmetic',
1409 'patterns': [r".*: warning: pointer of type 'void \*' used in (arithmetic|subtraction)",
1410 r".*: warning: arithmetic on .+ to void is a GNU extension.*Wpointer-arith",
1411 r".*: warning: wrong type argument to increment"]},
1412 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsign-promo',
1413 'description': 'Overload resolution chose to promote from unsigned or enum to signed type',
1414 'patterns': [r".*: warning: passing '.+' chooses '.+' over '.+'.*Wsign-promo"]},
1415 {'category': 'cont.', 'severity': Severity.SKIP,
1416 'description': 'skip, in call to ...',
1417 'patterns': [r".*: warning: in call to '.+'"]},
1418 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wextra',
1419 'description': 'Base should be explicitly initialized in copy constructor',
1420 'patterns': [r".*: warning: base class '.+' should be explicitly initialized in the copy constructor"]},
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -07001421 # {'category': 'C/C++', 'severity': Severity.MEDIUM,
1422 # 'description': 'VLA has zero or negative size',
1423 # 'patterns': [r".*: warning: Declared variable-length array \(VLA\) has .+ size"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001424 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1425 'description': 'Return value from void function',
1426 'patterns': [r".*: warning: 'return' with a value, in function returning void"]},
1427 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'multichar',
1428 'description': 'Multi-character character constant',
1429 'patterns': [r".*: warning: multi-character character constant"]},
1430 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'writable-strings',
1431 'description': 'Conversion from string literal to char*',
1432 'patterns': [r".*: warning: .+ does not allow conversion from string literal to 'char \*'"]},
1433 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wextra-semi',
1434 'description': 'Extra \';\'',
1435 'patterns': [r".*: warning: extra ';' .+extra-semi"]},
1436 {'category': 'C/C++', 'severity': Severity.LOW,
1437 'description': 'Useless specifier',
1438 'patterns': [r".*: warning: useless storage class specifier in empty declaration"]},
1439 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wduplicate-decl-specifier',
1440 'description': 'Duplicate declaration specifier',
1441 'patterns': [r".*: warning: duplicate '.+' declaration specifier"]},
1442 {'category': 'logtags', 'severity': Severity.LOW,
1443 'description': 'Duplicate logtag',
1444 'patterns': [r".*: warning: tag \".+\" \(.+\) duplicated in .+"]},
1445 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'typedef-redefinition',
1446 'description': 'Typedef redefinition',
1447 'patterns': [r".*: warning: redefinition of typedef '.+' is a C11 feature"]},
1448 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'gnu-designator',
1449 'description': 'GNU old-style field designator',
1450 'patterns': [r".*: warning: use of GNU old-style field designator extension"]},
1451 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'missing-field-initializers',
1452 'description': 'Missing field initializers',
1453 'patterns': [r".*: warning: missing field '.+' initializer"]},
1454 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'missing-braces',
1455 'description': 'Missing braces',
1456 'patterns': [r".*: warning: suggest braces around initialization of",
1457 r".*: warning: too many braces around scalar initializer .+Wmany-braces-around-scalar-init",
1458 r".*: warning: braces around scalar initializer"]},
1459 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'sign-compare',
1460 'description': 'Comparison of integers of different signs',
1461 'patterns': [r".*: warning: comparison of integers of different signs.+sign-compare"]},
1462 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'dangling-else',
1463 'description': 'Add braces to avoid dangling else',
1464 'patterns': [r".*: warning: add explicit braces to avoid dangling else"]},
1465 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'initializer-overrides',
1466 'description': 'Initializer overrides prior initialization',
1467 'patterns': [r".*: warning: initializer overrides prior initialization of this subobject"]},
1468 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'self-assign',
1469 'description': 'Assigning value to self',
1470 'patterns': [r".*: warning: explicitly assigning value of .+ to itself"]},
1471 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'gnu-variable-sized-type-not-at-end',
1472 'description': 'GNU extension, variable sized type not at end',
1473 'patterns': [r".*: warning: field '.+' with variable sized type '.+' not at the end of a struct or class"]},
1474 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'tautological-constant-out-of-range-compare',
1475 'description': 'Comparison of constant is always false/true',
1476 'patterns': [r".*: comparison of .+ is always .+Wtautological-constant-out-of-range-compare"]},
1477 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'overloaded-virtual',
1478 'description': 'Hides overloaded virtual function',
1479 'patterns': [r".*: '.+' hides overloaded virtual function"]},
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -07001480 {'category': 'logtags', 'severity': Severity.LOW,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001481 'description': 'Incompatible pointer types',
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -07001482 'patterns': [r".*: warning: incompatible .*pointer types .*-Wincompatible-.*pointer-types"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001483 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'asm-operand-widths',
1484 'description': 'ASM value size does not match register size',
1485 'patterns': [r".*: warning: value size does not match register size specified by the constraint and modifier"]},
1486 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'tautological-compare',
1487 'description': 'Comparison of self is always false',
1488 'patterns': [r".*: self-comparison always evaluates to false"]},
1489 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'constant-logical-operand',
1490 'description': 'Logical op with constant operand',
1491 'patterns': [r".*: use of logical '.+' with constant operand"]},
1492 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'literal-suffix',
1493 'description': 'Needs a space between literal and string macro',
1494 'patterns': [r".*: warning: invalid suffix on literal.+ requires a space .+Wliteral-suffix"]},
1495 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '#warnings',
1496 'description': 'Warnings from #warning',
1497 'patterns': [r".*: warning: .+-W#warnings"]},
1498 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'absolute-value',
1499 'description': 'Using float/int absolute value function with int/float argument',
1500 'patterns': [r".*: warning: using .+ absolute value function .+ when argument is .+ type .+Wabsolute-value",
1501 r".*: warning: absolute value function '.+' given .+ which may cause truncation .+Wabsolute-value"]},
1502 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wc++11-extensions',
1503 'description': 'Using C++11 extensions',
1504 'patterns': [r".*: warning: 'auto' type specifier is a C\+\+11 extension"]},
1505 {'category': 'C/C++', 'severity': Severity.LOW,
1506 'description': 'Refers to implicitly defined namespace',
1507 'patterns': [r".*: warning: using directive refers to implicitly-defined namespace .+"]},
1508 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Winvalid-pp-token',
1509 'description': 'Invalid pp token',
1510 'patterns': [r".*: warning: missing .+Winvalid-pp-token"]},
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07001511 {'category': 'link', 'severity': Severity.LOW,
1512 'description': 'need glibc to link',
1513 'patterns': [r".*: warning: .* requires at runtime .* glibc .* for linking"]},
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001514
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001515 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1516 'description': 'Operator new returns NULL',
1517 'patterns': [r".*: warning: 'operator new' must not return NULL unless it is declared 'throw\(\)' .+"]},
1518 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wnull-arithmetic',
1519 'description': 'NULL used in arithmetic',
1520 'patterns': [r".*: warning: NULL used in arithmetic",
1521 r".*: warning: comparison between NULL and non-pointer"]},
1522 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'header-guard',
1523 'description': 'Misspelled header guard',
1524 'patterns': [r".*: warning: '.+' is used as a header guard .+ followed by .+ different macro"]},
1525 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'empty-body',
1526 'description': 'Empty loop body',
1527 'patterns': [r".*: warning: .+ loop has empty body"]},
1528 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'enum-conversion',
1529 'description': 'Implicit conversion from enumeration type',
1530 'patterns': [r".*: warning: implicit conversion from enumeration type '.+'"]},
1531 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'switch',
1532 'description': 'case value not in enumerated type',
1533 'patterns': [r".*: warning: case value not in enumerated type '.+'"]},
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -07001534 # {'category': 'C/C++', 'severity': Severity.MEDIUM,
1535 # 'description': 'Undefined result',
1536 # 'patterns': [r".*: warning: The result of .+ is undefined",
1537 # r".*: warning: passing an object that .+ has undefined behavior \[-Wvarargs\]",
1538 # r".*: warning: 'this' pointer cannot be null in well-defined C\+\+ code;",
1539 # r".*: warning: shifting a negative signed value is undefined"]},
1540 # {'category': 'C/C++', 'severity': Severity.MEDIUM,
1541 # 'description': 'Division by zero',
1542 # 'patterns': [r".*: warning: Division by zero"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001543 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1544 'description': 'Use of deprecated method',
1545 'patterns': [r".*: warning: '.+' is deprecated .+"]},
1546 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1547 'description': 'Use of garbage or uninitialized value',
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -07001548 'patterns': [r".*: warning: .+ uninitialized .+\[-Wsometimes-uninitialized\]"]},
1549 # {'category': 'C/C++', 'severity': Severity.MEDIUM,
1550 # 'description': 'Use of garbage or uninitialized value',
1551 # 'patterns': [r".*: warning: .+ is a garbage value",
1552 # r".*: warning: Function call argument is an uninitialized value",
1553 # r".*: warning: Undefined or garbage value returned to caller",
1554 # r".*: warning: Called .+ pointer is.+uninitialized",
1555 # r".*: warning: Called .+ pointer is.+uninitalized", # match a typo in compiler message
1556 # r".*: warning: Use of zero-allocated memory",
1557 # r".*: warning: Dereference of undefined pointer value",
1558 # r".*: warning: Passed-by-value .+ contains uninitialized data",
1559 # r".*: warning: Branch condition evaluates to a garbage value",
1560 # r".*: warning: The .+ of .+ is an uninitialized value.",
1561 # r".*: warning: .+ is used uninitialized whenever .+sometimes-uninitialized",
1562 # r".*: warning: Assigned value is garbage or undefined"]},
1563 # {'category': 'C/C++', 'severity': Severity.MEDIUM,
1564 # 'description': 'Result of malloc type incompatible with sizeof operand type',
1565 # 'patterns': [r".*: warning: Result of '.+' is converted to .+ incompatible with sizeof operand type"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001566 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsizeof-array-argument',
1567 'description': 'Sizeof on array argument',
1568 'patterns': [r".*: warning: sizeof on array function parameter will return"]},
1569 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsizeof-pointer-memacces',
1570 'description': 'Bad argument size of memory access functions',
1571 'patterns': [r".*: warning: .+\[-Wsizeof-pointer-memaccess\]"]},
1572 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1573 'description': 'Return value not checked',
1574 'patterns': [r".*: warning: The return value from .+ is not checked"]},
1575 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1576 'description': 'Possible heap pollution',
1577 'patterns': [r".*: warning: .*Possible heap pollution from .+ type .+"]},
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -07001578 # {'category': 'C/C++', 'severity': Severity.MEDIUM,
1579 # 'description': 'Allocation size of 0 byte',
1580 # 'patterns': [r".*: warning: Call to .+ has an allocation size of 0 byte"]},
1581 # {'category': 'C/C++', 'severity': Severity.MEDIUM,
1582 # 'description': 'Result of malloc type incompatible with sizeof operand type',
1583 # 'patterns': [r".*: warning: Result of '.+' is converted to .+ incompatible with sizeof operand type"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001584 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wfor-loop-analysis',
1585 'description': 'Variable used in loop condition not modified in loop body',
1586 'patterns': [r".*: warning: variable '.+' used in loop condition.*Wfor-loop-analysis"]},
1587 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1588 'description': 'Closing a previously closed file',
1589 'patterns': [r".*: warning: Closing a previously closed file"]},
1590 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunnamed-type-template-args',
1591 'description': 'Unnamed template type argument',
1592 'patterns': [r".*: warning: template argument.+Wunnamed-type-template-args"]},
Chih-Hung Hsiehe1672862018-08-31 16:19:19 -07001593 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wimplicit-fallthrough',
1594 'description': 'Unannotated fall-through between switch labels',
1595 'patterns': [r".*: warning: unannotated fall-through between switch labels.+Wimplicit-fallthrough"]},
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001596
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001597 {'category': 'C/C++', 'severity': Severity.HARMLESS,
1598 'description': 'Discarded qualifier from pointer target type',
1599 'patterns': [r".*: warning: .+ discards '.+' qualifier from pointer target type"]},
1600 {'category': 'C/C++', 'severity': Severity.HARMLESS,
1601 'description': 'Use snprintf instead of sprintf',
1602 'patterns': [r".*: warning: .*sprintf is often misused; please use snprintf"]},
1603 {'category': 'C/C++', 'severity': Severity.HARMLESS,
1604 'description': 'Unsupported optimizaton flag',
1605 'patterns': [r".*: warning: optimization flag '.+' is not supported"]},
1606 {'category': 'C/C++', 'severity': Severity.HARMLESS,
1607 'description': 'Extra or missing parentheses',
1608 'patterns': [r".*: warning: equality comparison with extraneous parentheses",
1609 r".*: warning: .+ within .+Wlogical-op-parentheses"]},
1610 {'category': 'C/C++', 'severity': Severity.HARMLESS, 'option': 'mismatched-tags',
1611 'description': 'Mismatched class vs struct tags',
1612 'patterns': [r".*: warning: '.+' defined as a .+ here but previously declared as a .+mismatched-tags",
1613 r".*: warning: .+ was previously declared as a .+mismatched-tags"]},
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07001614 {'category': 'FindEmulator', 'severity': Severity.HARMLESS,
1615 'description': 'FindEmulator: No such file or directory',
1616 'patterns': [r".*: warning: FindEmulator: .* No such file or directory"]},
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -07001617 {'category': 'make', 'severity': Severity.HARMLESS,
1618 'description': 'make: unknown installed file',
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07001619 'patterns': [r".*: warning: .*_tests: Unknown installed file for module"]},
1620 {'category': 'make', 'severity': Severity.HARMLESS,
1621 'description': 'unusual tags debug eng',
1622 'patterns': [r".*: warning: .*: unusual tags debug eng"]},
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -07001623 {'category': 'make', 'severity': Severity.MEDIUM,
1624 'description': 'make: please convert to soong',
1625 'patterns': [r".*: warning: .* has been deprecated. Please convert to Soong."]},
Marco Nelissen594375d2009-07-14 09:04:04 -07001626
1627 # 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 -07001628 {'category': 'C/C++', 'severity': Severity.SKIP,
1629 'description': 'skip, ,',
1630 'patterns': [r".*: warning: ,$"]},
1631 {'category': 'C/C++', 'severity': Severity.SKIP,
1632 'description': 'skip,',
1633 'patterns': [r".*: warning: $"]},
1634 {'category': 'C/C++', 'severity': Severity.SKIP,
1635 'description': 'skip, In file included from ...',
1636 'patterns': [r".*: warning: In file included from .+,"]},
Marco Nelissen594375d2009-07-14 09:04:04 -07001637
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001638 # warnings from clang-tidy
Chih-Hung Hsieh2cd467b2017-11-16 15:42:11 -08001639 group_tidy_warn_pattern('android'),
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -07001640 simple_tidy_warn_pattern('abseil-string-find-startswith'),
Chih-Hung Hsieh9e9355d2018-06-04 11:32:32 -07001641 simple_tidy_warn_pattern('bugprone-argument-comment'),
1642 simple_tidy_warn_pattern('bugprone-copy-constructor-init'),
1643 simple_tidy_warn_pattern('bugprone-fold-init-type'),
1644 simple_tidy_warn_pattern('bugprone-forward-declaration-namespace'),
1645 simple_tidy_warn_pattern('bugprone-forwarding-reference-overload'),
1646 simple_tidy_warn_pattern('bugprone-inaccurate-erase'),
1647 simple_tidy_warn_pattern('bugprone-incorrect-roundings'),
1648 simple_tidy_warn_pattern('bugprone-integer-division'),
1649 simple_tidy_warn_pattern('bugprone-lambda-function-name'),
1650 simple_tidy_warn_pattern('bugprone-macro-parentheses'),
1651 simple_tidy_warn_pattern('bugprone-misplaced-widening-cast'),
1652 simple_tidy_warn_pattern('bugprone-move-forwarding-reference'),
1653 simple_tidy_warn_pattern('bugprone-sizeof-expression'),
1654 simple_tidy_warn_pattern('bugprone-string-constructor'),
1655 simple_tidy_warn_pattern('bugprone-string-integer-assignment'),
1656 simple_tidy_warn_pattern('bugprone-suspicious-enum-usage'),
1657 simple_tidy_warn_pattern('bugprone-suspicious-missing-comma'),
1658 simple_tidy_warn_pattern('bugprone-suspicious-string-compare'),
1659 simple_tidy_warn_pattern('bugprone-suspicious-semicolon'),
1660 simple_tidy_warn_pattern('bugprone-undefined-memory-manipulation'),
1661 simple_tidy_warn_pattern('bugprone-unused-raii'),
1662 simple_tidy_warn_pattern('bugprone-use-after-move'),
1663 group_tidy_warn_pattern('bugprone'),
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07001664 group_tidy_warn_pattern('cert'),
1665 group_tidy_warn_pattern('clang-diagnostic'),
1666 group_tidy_warn_pattern('cppcoreguidelines'),
1667 group_tidy_warn_pattern('llvm'),
1668 simple_tidy_warn_pattern('google-default-arguments'),
1669 simple_tidy_warn_pattern('google-runtime-int'),
1670 simple_tidy_warn_pattern('google-runtime-operator'),
1671 simple_tidy_warn_pattern('google-runtime-references'),
1672 group_tidy_warn_pattern('google-build'),
1673 group_tidy_warn_pattern('google-explicit'),
1674 group_tidy_warn_pattern('google-redability'),
1675 group_tidy_warn_pattern('google-global'),
1676 group_tidy_warn_pattern('google-redability'),
1677 group_tidy_warn_pattern('google-redability'),
1678 group_tidy_warn_pattern('google'),
1679 simple_tidy_warn_pattern('hicpp-explicit-conversions'),
1680 simple_tidy_warn_pattern('hicpp-function-size'),
1681 simple_tidy_warn_pattern('hicpp-invalid-access-moved'),
1682 simple_tidy_warn_pattern('hicpp-member-init'),
1683 simple_tidy_warn_pattern('hicpp-delete-operators'),
1684 simple_tidy_warn_pattern('hicpp-special-member-functions'),
1685 simple_tidy_warn_pattern('hicpp-use-equals-default'),
1686 simple_tidy_warn_pattern('hicpp-use-equals-delete'),
1687 simple_tidy_warn_pattern('hicpp-no-assembler'),
1688 simple_tidy_warn_pattern('hicpp-noexcept-move'),
1689 simple_tidy_warn_pattern('hicpp-use-override'),
1690 group_tidy_warn_pattern('hicpp'),
1691 group_tidy_warn_pattern('modernize'),
1692 group_tidy_warn_pattern('misc'),
1693 simple_tidy_warn_pattern('performance-faster-string-find'),
1694 simple_tidy_warn_pattern('performance-for-range-copy'),
1695 simple_tidy_warn_pattern('performance-implicit-cast-in-loop'),
1696 simple_tidy_warn_pattern('performance-inefficient-string-concatenation'),
1697 simple_tidy_warn_pattern('performance-type-promotion-in-math-fn'),
1698 simple_tidy_warn_pattern('performance-unnecessary-copy-initialization'),
1699 simple_tidy_warn_pattern('performance-unnecessary-value-param'),
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -07001700 simple_tidy_warn_pattern('portability-simd-intrinsics'),
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07001701 group_tidy_warn_pattern('performance'),
1702 group_tidy_warn_pattern('readability'),
1703
1704 # warnings from clang-tidy's clang-analyzer checks
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -07001705 analyzer_high('clang-analyzer-core, null pointer',
1706 [r".*: warning: .+ pointer is null .*\[clang-analyzer-core"]),
1707 analyzer_high('clang-analyzer-core, uninitialized value',
1708 [r".*: warning: .+ uninitialized (value|data) .*\[clang-analyzer-core"]),
1709 analyzer_warn('clang-analyzer-optin.performance.Padding',
1710 [r".*: warning: Excessive padding in '.*'"]),
1711 # analyzer_warn('clang-analyzer Unreachable code',
1712 # [r".*: warning: This statement is never executed.*UnreachableCode"]),
1713 analyzer_warn('clang-analyzer Size of malloc may overflow',
1714 [r".*: warning: .* size of .* may overflow .*MallocOverflow"]),
1715 analyzer_warn('clang-analyzer sozeof() on a pointer type',
1716 [r".*: warning: .*calls sizeof.* on a pointer type.*SizeofPtr"]),
1717 analyzer_warn('clang-analyzer Pointer arithmetic on non-array variables',
1718 [r".*: warning: Pointer arithmetic on non-array variables .*PointerArithm"]),
1719 analyzer_warn('clang-analyzer Subtraction of pointers of different memory chunks',
1720 [r".*: warning: Subtraction of two pointers .*PointerSub"]),
1721 analyzer_warn('clang-analyzer Access out-of-bound array element',
1722 [r".*: warning: Access out-of-bound array element .*ArrayBound"]),
1723 analyzer_warn('clang-analyzer Out of bound memory access',
1724 [r".*: warning: Out of bound memory access .*ArrayBoundV2"]),
1725 analyzer_warn('clang-analyzer Possible lock order reversal',
1726 [r".*: warning: .* Possible lock order reversal.*PthreadLock"]),
1727 analyzer_warn('clang-analyzer call path problems',
1728 [r".*: warning: Call Path : .+"]),
1729 analyzer_warn_check('clang-analyzer-core.CallAndMessage'),
1730 analyzer_high_check('clang-analyzer-core.NonNullParamChecker'),
1731 analyzer_high_check('clang-analyzer-core.NullDereference'),
1732 analyzer_warn_check('clang-analyzer-core.UndefinedBinaryOperatorResult'),
1733 analyzer_warn_check('clang-analyzer-core.DivideZero'),
1734 analyzer_warn_check('clang-analyzer-core.VLASize'),
1735 analyzer_warn_check('clang-analyzer-core.uninitialized.ArraySubscript'),
1736 analyzer_warn_check('clang-analyzer-core.uninitialized.Assign'),
1737 analyzer_warn_check('clang-analyzer-core.uninitialized.UndefReturn'),
1738 analyzer_warn_check('clang-analyzer-cplusplus.Move'),
1739 analyzer_warn_check('clang-analyzer-deadcode.DeadStores'),
1740 analyzer_warn_check('clang-analyzer-optin.cplusplus.UninitializedObject'),
1741 analyzer_warn_check('clang-analyzer-optin.cplusplus.VirtualCall'),
1742 analyzer_warn_check('clang-analyzer-portability.UnixAPI'),
1743 analyzer_warn_check('clang-analyzer-unix.cstring.NullArg'),
1744 analyzer_high_check('clang-analyzer-unix.MallocSizeof'),
1745 analyzer_warn_check('clang-analyzer-valist.Uninitialized'),
1746 analyzer_warn_check('clang-analyzer-valist.Unterminated'),
1747 analyzer_group_check('clang-analyzer-core.uninitialized'),
1748 analyzer_group_check('clang-analyzer-deadcode'),
1749 analyzer_warn_check('clang-analyzer-security.insecureAPI.strcpy'),
1750 analyzer_group_high('clang-analyzer-security.insecureAPI'),
1751 analyzer_group_high('clang-analyzer-security'),
Chih-Hung Hsieh83980502019-09-26 12:09:55 -07001752 analyzer_high_check('clang-analyzer-unix.Malloc'),
1753 analyzer_high_check('clang-analyzer-cplusplus.NewDeleteLeaks'),
1754 analyzer_high_check('clang-analyzer-cplusplus.NewDelete'),
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -07001755 analyzer_group_check('clang-analyzer-unix'),
1756 analyzer_group_check('clang-analyzer'), # catch al
1757
1758 # Assembler warnings
1759 {'category': 'Asm', 'severity': Severity.MEDIUM,
1760 'description': 'Asm: IT instruction is deprecated',
1761 'patterns': [r".*: warning: applying IT instruction .* is deprecated"]},
1762
1763 # NDK warnings
1764 {'category': 'NDK', 'severity': Severity.HIGH,
1765 'description': 'NDK: Generate guard with empty availability, obsoleted',
1766 'patterns': [r".*: warning: .* generate guard with empty availability: obsoleted ="]},
1767
1768 # Protoc warnings
1769 {'category': 'Protoc', 'severity': Severity.MEDIUM,
1770 'description': 'Proto: Enum name colision after strip',
1771 'patterns': [r".*: warning: Enum .* has the same name .* ignore case and strip"]},
Chih-Hung Hsieh83980502019-09-26 12:09:55 -07001772 {'category': 'Protoc', 'severity': Severity.MEDIUM,
1773 'description': 'Proto: Import not used',
1774 'patterns': [r".*: warning: Import .*/.*\.proto but not used.$"]},
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -07001775
1776 # Kotlin warnings
1777 {'category': 'Kotlin', 'severity': Severity.MEDIUM,
Chih-Hung Hsieh83980502019-09-26 12:09:55 -07001778 'description': 'Kotlin: never used parameter or variable',
1779 'patterns': [r".*: warning: (parameter|variable) '.*' is never used$"]},
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -07001780 {'category': 'Kotlin', 'severity': Severity.MEDIUM,
1781 'description': 'Kotlin: Deprecated in Java',
1782 'patterns': [r".*: warning: '.*' is deprecated. Deprecated in Java"]},
1783 {'category': 'Kotlin', 'severity': Severity.MEDIUM,
1784 'description': 'Kotlin: library has Kotlin runtime',
1785 'patterns': [r".*: warning: library has Kotlin runtime bundled into it",
1786 r".*: warning: some JAR files .* have the Kotlin Runtime library"]},
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001787
Chih-Hung Hsieha1187072019-09-19 14:49:57 -07001788 # rustc warnings
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -07001789 {'category': 'Rust', 'severity': Severity.HIGH,
1790 'description': 'Rust: Does not derive Copy',
Chih-Hung Hsieha1187072019-09-19 14:49:57 -07001791 'patterns': [r".*: warning: .+ does not derive Copy"]},
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -07001792 {'category': 'Rust', 'severity': Severity.MEDIUM,
1793 'description': 'Rust: Deprecated range pattern',
Chih-Hung Hsieha1187072019-09-19 14:49:57 -07001794 'patterns': [r".*: warning: .+ range patterns are deprecated"]},
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -07001795 {'category': 'Rust', 'severity': Severity.MEDIUM,
1796 'description': 'Rust: Deprecated missing explicit \'dyn\'',
Chih-Hung Hsieha1187072019-09-19 14:49:57 -07001797 'patterns': [r".*: warning: .+ without an explicit `dyn` are deprecated"]},
1798
Marco Nelissen594375d2009-07-14 09:04:04 -07001799 # catch-all for warnings this script doesn't know about yet
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001800 {'category': 'C/C++', 'severity': Severity.UNKNOWN,
1801 'description': 'Unclassified/unrecognized warnings',
1802 'patterns': [r".*: warning: .+"]},
Marco Nelissen594375d2009-07-14 09:04:04 -07001803]
1804
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001805
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001806def project_name_and_pattern(name, pattern):
1807 return [name, '(^|.*/)' + pattern + '/.*: warning:']
1808
1809
1810def simple_project_pattern(pattern):
1811 return project_name_and_pattern(pattern, pattern)
1812
1813
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001814# A list of [project_name, file_path_pattern].
1815# project_name should not contain comma, to be used in CSV output.
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001816project_list = [
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001817 simple_project_pattern('art'),
1818 simple_project_pattern('bionic'),
1819 simple_project_pattern('bootable'),
1820 simple_project_pattern('build'),
1821 simple_project_pattern('cts'),
1822 simple_project_pattern('dalvik'),
1823 simple_project_pattern('developers'),
1824 simple_project_pattern('development'),
1825 simple_project_pattern('device'),
1826 simple_project_pattern('doc'),
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07001827 # match external/google* before external/
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001828 project_name_and_pattern('external/google', 'external/google.*'),
1829 project_name_and_pattern('external/non-google', 'external'),
1830 simple_project_pattern('frameworks/av/camera'),
1831 simple_project_pattern('frameworks/av/cmds'),
1832 simple_project_pattern('frameworks/av/drm'),
1833 simple_project_pattern('frameworks/av/include'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07001834 simple_project_pattern('frameworks/av/media/img_utils'),
1835 simple_project_pattern('frameworks/av/media/libcpustats'),
1836 simple_project_pattern('frameworks/av/media/libeffects'),
1837 simple_project_pattern('frameworks/av/media/libmediaplayerservice'),
1838 simple_project_pattern('frameworks/av/media/libmedia'),
1839 simple_project_pattern('frameworks/av/media/libstagefright'),
1840 simple_project_pattern('frameworks/av/media/mtp'),
1841 simple_project_pattern('frameworks/av/media/ndk'),
1842 simple_project_pattern('frameworks/av/media/utils'),
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07001843 project_name_and_pattern('frameworks/av/media/Other',
1844 'frameworks/av/media'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001845 simple_project_pattern('frameworks/av/radio'),
1846 simple_project_pattern('frameworks/av/services'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07001847 simple_project_pattern('frameworks/av/soundtrigger'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001848 project_name_and_pattern('frameworks/av/Other', 'frameworks/av'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07001849 simple_project_pattern('frameworks/base/cmds'),
1850 simple_project_pattern('frameworks/base/core'),
1851 simple_project_pattern('frameworks/base/drm'),
1852 simple_project_pattern('frameworks/base/media'),
1853 simple_project_pattern('frameworks/base/libs'),
1854 simple_project_pattern('frameworks/base/native'),
1855 simple_project_pattern('frameworks/base/packages'),
1856 simple_project_pattern('frameworks/base/rs'),
1857 simple_project_pattern('frameworks/base/services'),
1858 simple_project_pattern('frameworks/base/tests'),
1859 simple_project_pattern('frameworks/base/tools'),
1860 project_name_and_pattern('frameworks/base/Other', 'frameworks/base'),
Stephen Hinesd0aec892016-10-17 15:39:53 -07001861 simple_project_pattern('frameworks/compile/libbcc'),
1862 simple_project_pattern('frameworks/compile/mclinker'),
1863 simple_project_pattern('frameworks/compile/slang'),
1864 project_name_and_pattern('frameworks/compile/Other', 'frameworks/compile'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001865 simple_project_pattern('frameworks/minikin'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07001866 simple_project_pattern('frameworks/ml'),
1867 simple_project_pattern('frameworks/native/cmds'),
1868 simple_project_pattern('frameworks/native/include'),
1869 simple_project_pattern('frameworks/native/libs'),
1870 simple_project_pattern('frameworks/native/opengl'),
1871 simple_project_pattern('frameworks/native/services'),
1872 simple_project_pattern('frameworks/native/vulkan'),
1873 project_name_and_pattern('frameworks/native/Other', 'frameworks/native'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001874 simple_project_pattern('frameworks/opt'),
1875 simple_project_pattern('frameworks/rs'),
1876 simple_project_pattern('frameworks/webview'),
1877 simple_project_pattern('frameworks/wilhelm'),
1878 project_name_and_pattern('frameworks/Other', 'frameworks'),
1879 simple_project_pattern('hardware/akm'),
1880 simple_project_pattern('hardware/broadcom'),
1881 simple_project_pattern('hardware/google'),
1882 simple_project_pattern('hardware/intel'),
1883 simple_project_pattern('hardware/interfaces'),
1884 simple_project_pattern('hardware/libhardware'),
1885 simple_project_pattern('hardware/libhardware_legacy'),
1886 simple_project_pattern('hardware/qcom'),
1887 simple_project_pattern('hardware/ril'),
1888 project_name_and_pattern('hardware/Other', 'hardware'),
1889 simple_project_pattern('kernel'),
1890 simple_project_pattern('libcore'),
1891 simple_project_pattern('libnativehelper'),
1892 simple_project_pattern('ndk'),
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001893 # match vendor/unbungled_google/packages before other packages
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001894 simple_project_pattern('unbundled_google'),
1895 simple_project_pattern('packages'),
1896 simple_project_pattern('pdk'),
1897 simple_project_pattern('prebuilts'),
1898 simple_project_pattern('system/bt'),
1899 simple_project_pattern('system/connectivity'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07001900 simple_project_pattern('system/core/adb'),
1901 simple_project_pattern('system/core/base'),
1902 simple_project_pattern('system/core/debuggerd'),
1903 simple_project_pattern('system/core/fastboot'),
1904 simple_project_pattern('system/core/fingerprintd'),
1905 simple_project_pattern('system/core/fs_mgr'),
1906 simple_project_pattern('system/core/gatekeeperd'),
1907 simple_project_pattern('system/core/healthd'),
1908 simple_project_pattern('system/core/include'),
1909 simple_project_pattern('system/core/init'),
1910 simple_project_pattern('system/core/libbacktrace'),
1911 simple_project_pattern('system/core/liblog'),
1912 simple_project_pattern('system/core/libpixelflinger'),
1913 simple_project_pattern('system/core/libprocessgroup'),
1914 simple_project_pattern('system/core/libsysutils'),
1915 simple_project_pattern('system/core/logcat'),
1916 simple_project_pattern('system/core/logd'),
1917 simple_project_pattern('system/core/run-as'),
1918 simple_project_pattern('system/core/sdcard'),
1919 simple_project_pattern('system/core/toolbox'),
1920 project_name_and_pattern('system/core/Other', 'system/core'),
1921 simple_project_pattern('system/extras/ANRdaemon'),
1922 simple_project_pattern('system/extras/cpustats'),
1923 simple_project_pattern('system/extras/crypto-perf'),
1924 simple_project_pattern('system/extras/ext4_utils'),
1925 simple_project_pattern('system/extras/f2fs_utils'),
1926 simple_project_pattern('system/extras/iotop'),
1927 simple_project_pattern('system/extras/libfec'),
1928 simple_project_pattern('system/extras/memory_replay'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07001929 simple_project_pattern('system/extras/mmap-perf'),
1930 simple_project_pattern('system/extras/multinetwork'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07001931 simple_project_pattern('system/extras/procrank'),
1932 simple_project_pattern('system/extras/runconuid'),
1933 simple_project_pattern('system/extras/showmap'),
1934 simple_project_pattern('system/extras/simpleperf'),
1935 simple_project_pattern('system/extras/su'),
1936 simple_project_pattern('system/extras/tests'),
1937 simple_project_pattern('system/extras/verity'),
1938 project_name_and_pattern('system/extras/Other', 'system/extras'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001939 simple_project_pattern('system/gatekeeper'),
1940 simple_project_pattern('system/keymaster'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07001941 simple_project_pattern('system/libhidl'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001942 simple_project_pattern('system/libhwbinder'),
1943 simple_project_pattern('system/media'),
1944 simple_project_pattern('system/netd'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07001945 simple_project_pattern('system/nvram'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001946 simple_project_pattern('system/security'),
1947 simple_project_pattern('system/sepolicy'),
1948 simple_project_pattern('system/tools'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07001949 simple_project_pattern('system/update_engine'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001950 simple_project_pattern('system/vold'),
1951 project_name_and_pattern('system/Other', 'system'),
1952 simple_project_pattern('toolchain'),
1953 simple_project_pattern('test'),
1954 simple_project_pattern('tools'),
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07001955 # match vendor/google* before vendor/
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001956 project_name_and_pattern('vendor/google', 'vendor/google.*'),
1957 project_name_and_pattern('vendor/non-google', 'vendor'),
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07001958 # keep out/obj and other patterns at the end.
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07001959 ['out/obj',
1960 '.*/(gen|obj[^/]*)/(include|EXECUTABLES|SHARED_LIBRARIES|'
1961 'STATIC_LIBRARIES|NATIVE_TESTS)/.*: warning:'],
1962 ['other', '.*'] # all other unrecognized patterns
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001963]
1964
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001965project_patterns = []
1966project_names = []
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001967warning_messages = []
1968warning_records = []
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001969
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001970
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001971def initialize_arrays():
1972 """Complete global arrays before they are used."""
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001973 global project_names, project_patterns
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001974 project_names = [p[0] for p in project_list]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001975 project_patterns = [re.compile(p[1]) for p in project_list]
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001976 for w in warn_patterns:
1977 w['members'] = []
1978 if 'option' not in w:
1979 w['option'] = ''
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001980 # Each warning pattern has a 'projects' dictionary, that
1981 # maps a project name to number of warnings in that project.
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001982 w['projects'] = {}
1983
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001984
1985initialize_arrays()
1986
1987
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -07001988android_root = ''
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001989platform_version = 'unknown'
1990target_product = 'unknown'
1991target_variant = 'unknown'
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001992
1993
1994##### Data and functions to dump html file. ##################################
1995
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001996html_head_scripts = """\
1997 <script type="text/javascript">
1998 function expand(id) {
1999 var e = document.getElementById(id);
2000 var f = document.getElementById(id + "_mark");
2001 if (e.style.display == 'block') {
2002 e.style.display = 'none';
2003 f.innerHTML = '&#x2295';
2004 }
2005 else {
2006 e.style.display = 'block';
2007 f.innerHTML = '&#x2296';
2008 }
2009 };
2010 function expandCollapse(show) {
2011 for (var id = 1; ; id++) {
2012 var e = document.getElementById(id + "");
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07002013 var f = document.getElementById(id + "_mark");
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002014 if (!e || !f) break;
2015 e.style.display = (show ? 'block' : 'none');
2016 f.innerHTML = (show ? '&#x2296' : '&#x2295');
2017 }
2018 };
2019 </script>
2020 <style type="text/css">
2021 th,td{border-collapse:collapse; border:1px solid black;}
2022 .button{color:blue;font-size:110%;font-weight:bolder;}
2023 .bt{color:black;background-color:transparent;border:none;outline:none;
2024 font-size:140%;font-weight:bolder;}
2025 .c0{background-color:#e0e0e0;}
2026 .c1{background-color:#d0d0d0;}
2027 .t1{border-collapse:collapse; width:100%; border:1px solid black;}
2028 </style>
2029 <script src="https://www.gstatic.com/charts/loader.js"></script>
2030"""
Marco Nelissen594375d2009-07-14 09:04:04 -07002031
Marco Nelissen594375d2009-07-14 09:04:04 -07002032
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002033def html_big(param):
2034 return '<font size="+2">' + param + '</font>'
Marco Nelissen594375d2009-07-14 09:04:04 -07002035
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07002036
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002037def dump_html_prologue(title):
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07002038 print('<html>\n<head>')
2039 print('<title>' + title + '</title>')
2040 print(html_head_scripts)
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002041 emit_stats_by_project()
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07002042 print('</head>\n<body>')
2043 print(html_big(title))
2044 print('<p>')
Marco Nelissen594375d2009-07-14 09:04:04 -07002045
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002046
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002047def dump_html_epilogue():
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07002048 print('</body>\n</head>\n</html>')
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07002049
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002050
2051def sort_warnings():
2052 for i in warn_patterns:
2053 i['members'] = sorted(set(i['members']))
2054
2055
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002056def emit_stats_by_project():
2057 """Dump a google chart table of warnings per project and severity."""
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002058 # warnings[p][s] is number of warnings in project p of severity s.
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07002059 # pylint:disable=g-complex-comprehension
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002060 warnings = {p: {s: 0 for s in Severity.range} for p in project_names}
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002061 for i in warn_patterns:
2062 s = i['severity']
2063 for p in i['projects']:
2064 warnings[p][s] += i['projects'][p]
2065
2066 # total_by_project[p] is number of warnings in project p.
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002067 total_by_project = {p: sum(warnings[p][s] for s in Severity.range)
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002068 for p in project_names}
2069
2070 # total_by_severity[s] is number of warnings of severity s.
2071 total_by_severity = {s: sum(warnings[p][s] for p in project_names)
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002072 for s in Severity.range}
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07002073
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002074 # emit table header
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002075 stats_header = ['Project']
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002076 for s in Severity.range:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002077 if total_by_severity[s]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002078 stats_header.append("<span style='background-color:{}'>{}</span>".
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002079 format(Severity.colors[s],
2080 Severity.column_headers[s]))
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002081 stats_header.append('TOTAL')
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07002082
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002083 # emit a row of warning counts per project, skip no-warning projects
2084 total_all_projects = 0
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002085 stats_rows = []
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002086 for p in project_names:
2087 if total_by_project[p]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002088 one_row = [p]
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002089 for s in Severity.range:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002090 if total_by_severity[s]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002091 one_row.append(warnings[p][s])
2092 one_row.append(total_by_project[p])
2093 stats_rows.append(one_row)
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002094 total_all_projects += total_by_project[p]
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07002095
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002096 # emit a row of warning counts per severity
2097 total_all_severities = 0
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002098 one_row = ['<b>TOTAL</b>']
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002099 for s in Severity.range:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002100 if total_by_severity[s]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002101 one_row.append(total_by_severity[s])
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002102 total_all_severities += total_by_severity[s]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002103 one_row.append(total_all_projects)
2104 stats_rows.append(one_row)
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07002105 print('<script>')
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002106 emit_const_string_array('StatsHeader', stats_header)
2107 emit_const_object_array('StatsRows', stats_rows)
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07002108 print(draw_table_javascript)
2109 print('</script>')
Marco Nelissen594375d2009-07-14 09:04:04 -07002110
2111
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002112def dump_stats():
2113 """Dump some stats about total number of warnings and such."""
2114 known = 0
2115 skipped = 0
2116 unknown = 0
2117 sort_warnings()
2118 for i in warn_patterns:
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002119 if i['severity'] == Severity.UNKNOWN:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002120 unknown += len(i['members'])
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002121 elif i['severity'] == Severity.SKIP:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002122 skipped += len(i['members'])
Ian Rogersf3829732016-05-10 12:06:01 -07002123 else:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002124 known += len(i['members'])
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07002125 print('Number of classified warnings: <b>' + str(known) + '</b><br>')
2126 print('Number of skipped warnings: <b>' + str(skipped) + '</b><br>')
2127 print('Number of unclassified warnings: <b>' + str(unknown) + '</b><br>')
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002128 total = unknown + known + skipped
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002129 extra_msg = ''
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002130 if total < 1000:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002131 extra_msg = ' (low count may indicate incremental build)'
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07002132 print('Total number of warnings: <b>' + str(total) + '</b>' + extra_msg)
Marco Nelissen594375d2009-07-14 09:04:04 -07002133
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07002134
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002135# New base table of warnings, [severity, warn_id, project, warning_message]
2136# Need buttons to show warnings in different grouping options.
2137# (1) Current, group by severity, id for each warning pattern
2138# sort by severity, warn_id, warning_message
2139# (2) Current --byproject, group by severity,
2140# id for each warning pattern + project name
2141# sort by severity, warn_id, project, warning_message
2142# (3) New, group by project + severity,
2143# id for each warning pattern
2144# sort by project, severity, warn_id, warning_message
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002145def emit_buttons():
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07002146 print('<button class="button" onclick="expandCollapse(1);">'
2147 'Expand all warnings</button>\n'
2148 '<button class="button" onclick="expandCollapse(0);">'
2149 'Collapse all warnings</button>\n'
2150 '<button class="button" onclick="groupBySeverity();">'
2151 'Group warnings by severity</button>\n'
2152 '<button class="button" onclick="groupByProject();">'
2153 'Group warnings by project</button><br>')
Marco Nelissen594375d2009-07-14 09:04:04 -07002154
2155
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002156def all_patterns(category):
2157 patterns = ''
2158 for i in category['patterns']:
2159 patterns += i
2160 patterns += ' / '
2161 return patterns
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002162
2163
2164def dump_fixed():
2165 """Show which warnings no longer occur."""
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002166 anchor = 'fixed_warnings'
2167 mark = anchor + '_mark'
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07002168 print('\n<br><p style="background-color:lightblue"><b>'
2169 '<button id="' + mark + '" '
2170 'class="bt" onclick="expand(\'' + anchor + '\');">'
2171 '&#x2295</button> Fixed warnings. '
2172 'No more occurrences. Please consider turning these into '
2173 'errors if possible, before they are reintroduced in to the build'
2174 ':</b></p>')
2175 print('<blockquote>')
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002176 fixed_patterns = []
2177 for i in warn_patterns:
2178 if not i['members']:
2179 fixed_patterns.append(i['description'] + ' (' +
2180 all_patterns(i) + ')')
2181 if i['option']:
2182 fixed_patterns.append(' ' + i['option'])
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07002183 fixed_patterns = sorted(fixed_patterns)
2184 print('<div id="' + anchor + '" style="display:none;"><table>')
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002185 cur_row_class = 0
2186 for text in fixed_patterns:
2187 cur_row_class = 1 - cur_row_class
2188 # remove last '\n'
2189 t = text[:-1] if text[-1] == '\n' else text
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07002190 print('<tr><td class="c' + str(cur_row_class) + '">' + t + '</td></tr>')
2191 print('</table></div>')
2192 print('</blockquote>')
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002193
2194
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002195def find_project_index(line):
2196 for p in range(len(project_patterns)):
2197 if project_patterns[p].match(line):
2198 return p
2199 return -1
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002200
2201
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002202def classify_one_warning(line, results):
Chih-Hung Hsieh9be27762018-06-07 10:51:47 -07002203 """Classify one warning line."""
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002204 for i in range(len(warn_patterns)):
2205 w = warn_patterns[i]
2206 for cpat in w['compiled_patterns']:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002207 if cpat.match(line):
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002208 p = find_project_index(line)
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002209 results.append([line, i, p])
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002210 return
2211 else:
2212 # If we end up here, there was a problem parsing the log
2213 # probably caused by 'make -j' mixing the output from
2214 # 2 or more concurrent compiles
2215 pass
Marco Nelissen594375d2009-07-14 09:04:04 -07002216
2217
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002218def classify_warnings(lines):
2219 results = []
2220 for line in lines:
2221 classify_one_warning(line, results)
Chih-Hung Hsieh76d00652016-11-09 18:19:05 -08002222 # After the main work, ignore all other signals to a child process,
2223 # to avoid bad warning/error messages from the exit clean-up process.
2224 if args.processes > 1:
2225 signal.signal(signal.SIGTERM, lambda *args: sys.exit(-signal.SIGTERM))
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002226 return results
2227
2228
2229def parallel_classify_warnings(warning_lines):
2230 """Classify all warning lines with num_cpu parallel processes."""
Chih-Hung Hsieh76d00652016-11-09 18:19:05 -08002231 compile_patterns()
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002232 num_cpu = args.processes
Chih-Hung Hsieh63de3002016-10-28 10:53:34 -07002233 if num_cpu > 1:
2234 groups = [[] for x in range(num_cpu)]
2235 i = 0
2236 for x in warning_lines:
2237 groups[i].append(x)
2238 i = (i + 1) % num_cpu
2239 pool = multiprocessing.Pool(num_cpu)
2240 group_results = pool.map(classify_warnings, groups)
2241 else:
2242 group_results = [classify_warnings(warning_lines)]
2243
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002244 for result in group_results:
2245 for line, pattern_idx, project_idx in result:
2246 pattern = warn_patterns[pattern_idx]
2247 pattern['members'].append(line)
2248 message_idx = len(warning_messages)
2249 warning_messages.append(line)
2250 warning_records.append([pattern_idx, project_idx, message_idx])
2251 pname = '???' if project_idx < 0 else project_names[project_idx]
2252 # Count warnings by project.
2253 if pname in pattern['projects']:
2254 pattern['projects'][pname] += 1
2255 else:
2256 pattern['projects'][pname] = 1
2257
2258
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002259def compile_patterns():
2260 """Precompiling every pattern speeds up parsing by about 30x."""
2261 for i in warn_patterns:
2262 i['compiled_patterns'] = []
2263 for pat in i['patterns']:
2264 i['compiled_patterns'].append(re.compile(pat))
2265
2266
Chih-Hung Hsiehf5db8982019-09-23 23:00:09 -07002267def find_warn_py_and_android_root(path):
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -07002268 """Set and return android_root path if it is found."""
2269 global android_root
2270 parts = path.split('/')
2271 for idx in reversed(range(2, len(parts))):
2272 root_path = '/'.join(parts[:idx])
2273 # Android root directory should contain this script.
Colin Crossfdea8932017-12-06 14:38:40 -08002274 if os.path.exists(root_path + '/build/make/tools/warn.py'):
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -07002275 android_root = root_path
Chih-Hung Hsiehf5db8982019-09-23 23:00:09 -07002276 return True
2277 return False
2278
2279
2280def find_android_root():
2281 """Guess android_root from common prefix of file paths."""
2282 # Use the longest common prefix of the absolute file paths
2283 # of the first 10000 warning messages as the android_root.
2284 global android_root
2285 warning_lines = set()
2286 warning_pattern = re.compile('^/[^ ]*/[^ ]*: warning: .*')
2287 count = 0
2288 infile = io.open(args.buildlog, mode='r', encoding='utf-8')
2289 for line in infile:
2290 if warning_pattern.match(line):
2291 warning_lines.add(line)
2292 count += 1
2293 if count > 9999:
2294 break
2295 # Try to find warn.py and use its location to find
2296 # the source tree root.
2297 if count < 100:
2298 path = os.path.normpath(re.sub(':.*$', '', line))
2299 if find_warn_py_and_android_root(path):
2300 return
2301 # Do not use common prefix of a small number of paths.
2302 if count > 10:
2303 root_path = os.path.commonprefix(warning_lines)
2304 if len(root_path) > 2 and root_path[len(root_path) - 1] == '/':
2305 android_root = root_path[:-1]
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -07002306
2307
2308def remove_android_root_prefix(path):
2309 """Remove android_root prefix from path if it is found."""
2310 if path.startswith(android_root):
2311 return path[1 + len(android_root):]
2312 else:
2313 return path
2314
2315
2316def normalize_path(path):
2317 """Normalize file path relative to android_root."""
2318 # If path is not an absolute path, just normalize it.
2319 path = os.path.normpath(path)
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -07002320 # Remove known prefix of root path and normalize the suffix.
Chih-Hung Hsiehf5db8982019-09-23 23:00:09 -07002321 if path[0] == '/' and android_root:
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -07002322 return remove_android_root_prefix(path)
Chih-Hung Hsiehf5db8982019-09-23 23:00:09 -07002323 return path
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -07002324
2325
2326def normalize_warning_line(line):
2327 """Normalize file path relative to android_root in a warning line."""
2328 # replace fancy quotes with plain ol' quotes
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07002329 line = re.sub(u'[\u2018\u2019]', '\'', line)
2330 # replace non-ASCII chars to spaces
2331 line = re.sub(u'[^\x00-\x7f]', ' ', line)
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -07002332 line = line.strip()
2333 first_column = line.find(':')
2334 if first_column > 0:
2335 return normalize_path(line[:first_column]) + line[first_column:]
2336 else:
2337 return line
2338
2339
Chih-Hung Hsieh76d00652016-11-09 18:19:05 -08002340def parse_input_file(infile):
Chih-Hung Hsiehef21d142017-04-27 10:25:37 -07002341 """Parse input file, collect parameters and warning lines."""
2342 global android_root
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002343 global platform_version
2344 global target_product
2345 global target_variant
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002346 line_counter = 0
2347
Chih-Hung Hsieha1187072019-09-19 14:49:57 -07002348 # rustc warning messages have two lines that should be combined:
2349 # warning: description
2350 # --> file_path:line_number:column_number
2351 # Some warning messages have no file name:
2352 # warning: macro replacement list ... [bugprone-macro-parentheses]
2353 # Some makefile warning messages have no line number:
2354 # some/path/file.mk: warning: description
2355 # C/C++ compiler warning messages have line and column numbers:
2356 # some/path/file.c:line_number:column_number: warning: description
2357 warning_pattern = re.compile('(^[^ ]*/[^ ]*: warning: .*)|(^warning: .*)')
2358 warning_without_file = re.compile('^warning: .*')
2359 rustc_file_position = re.compile('^[ ]+--> [^ ]*/[^ ]*:[0-9]+:[0-9]+')
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002360
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002361 # Collect all warnings into the warning_lines set.
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002362 warning_lines = set()
Chih-Hung Hsieha1187072019-09-19 14:49:57 -07002363 prev_warning = ''
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002364 for line in infile:
Chih-Hung Hsieha1187072019-09-19 14:49:57 -07002365 if prev_warning:
2366 if rustc_file_position.match(line):
2367 # must be a rustc warning, combine 2 lines into one warning
2368 line = line.strip().replace('--> ', '') + ': ' + prev_warning
2369 warning_lines.add(normalize_warning_line(line))
2370 prev_warning = ''
2371 continue
2372 # add prev_warning, and then process the current line
2373 prev_warning = 'unknown_source_file: ' + prev_warning
2374 warning_lines.add(normalize_warning_line(prev_warning))
2375 prev_warning = ''
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002376 if warning_pattern.match(line):
Chih-Hung Hsieha1187072019-09-19 14:49:57 -07002377 if warning_without_file.match(line):
2378 # save this line and combine it with the next line
2379 prev_warning = line
2380 else:
2381 warning_lines.add(normalize_warning_line(line))
2382 continue
2383 if line_counter < 100:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002384 # save a little bit of time by only doing this for the first few lines
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002385 line_counter += 1
2386 m = re.search('(?<=^PLATFORM_VERSION=).*', line)
2387 if m is not None:
2388 platform_version = m.group(0)
2389 m = re.search('(?<=^TARGET_PRODUCT=).*', line)
2390 if m is not None:
2391 target_product = m.group(0)
2392 m = re.search('(?<=^TARGET_BUILD_VARIANT=).*', line)
2393 if m is not None:
2394 target_variant = m.group(0)
Chih-Hung Hsiehef21d142017-04-27 10:25:37 -07002395 m = re.search('.* TOP=([^ ]*) .*', line)
2396 if m is not None:
2397 android_root = m.group(1)
Chih-Hung Hsieh76d00652016-11-09 18:19:05 -08002398 return warning_lines
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002399
2400
Chih-Hung Hsieh5722f922016-10-11 15:33:19 -07002401# Return s with escaped backslash and quotation characters.
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002402def escape_string(s):
Chih-Hung Hsieh5722f922016-10-11 15:33:19 -07002403 return s.replace('\\', '\\\\').replace('"', '\\"')
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002404
2405
2406# Return s without trailing '\n' and escape the quotation characters.
2407def strip_escape_string(s):
2408 if not s:
2409 return s
2410 s = s[:-1] if s[-1] == '\n' else s
2411 return escape_string(s)
2412
2413
2414def emit_warning_array(name):
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07002415 print('var warning_{} = ['.format(name))
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002416 for i in range(len(warn_patterns)):
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07002417 print('{},'.format(warn_patterns[i][name]))
2418 print('];')
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002419
2420
2421def emit_warning_arrays():
2422 emit_warning_array('severity')
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07002423 print('var warning_description = [')
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002424 for i in range(len(warn_patterns)):
2425 if warn_patterns[i]['members']:
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07002426 print('"{}",'.format(escape_string(warn_patterns[i]['description'])))
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002427 else:
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07002428 print('"",') # no such warning
2429 print('];')
2430
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002431
2432scripts_for_warning_groups = """
2433 function compareMessages(x1, x2) { // of the same warning type
2434 return (WarningMessages[x1[2]] <= WarningMessages[x2[2]]) ? -1 : 1;
2435 }
2436 function byMessageCount(x1, x2) {
2437 return x2[2] - x1[2]; // reversed order
2438 }
2439 function bySeverityMessageCount(x1, x2) {
2440 // orer by severity first
2441 if (x1[1] != x2[1])
2442 return x1[1] - x2[1];
2443 return byMessageCount(x1, x2);
2444 }
2445 const ParseLinePattern = /^([^ :]+):(\\d+):(.+)/;
2446 function addURL(line) {
2447 if (FlagURL == "") return line;
2448 if (FlagSeparator == "") {
2449 return line.replace(ParseLinePattern,
George Burgess IV169f5f12017-04-21 13:35:52 -07002450 "<a target='_blank' href='" + FlagURL + "/$1'>$1</a>:$2:$3");
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002451 }
2452 return line.replace(ParseLinePattern,
George Burgess IV169f5f12017-04-21 13:35:52 -07002453 "<a target='_blank' href='" + FlagURL + "/$1" + FlagSeparator +
2454 "$2'>$1:$2</a>:$3");
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002455 }
2456 function createArrayOfDictionaries(n) {
2457 var result = [];
2458 for (var i=0; i<n; i++) result.push({});
2459 return result;
2460 }
2461 function groupWarningsBySeverity() {
2462 // groups is an array of dictionaries,
2463 // each dictionary maps from warning type to array of warning messages.
2464 var groups = createArrayOfDictionaries(SeverityColors.length);
2465 for (var i=0; i<Warnings.length; i++) {
2466 var w = Warnings[i][0];
2467 var s = WarnPatternsSeverity[w];
2468 var k = w.toString();
2469 if (!(k in groups[s]))
2470 groups[s][k] = [];
2471 groups[s][k].push(Warnings[i]);
2472 }
2473 return groups;
2474 }
2475 function groupWarningsByProject() {
2476 var groups = createArrayOfDictionaries(ProjectNames.length);
2477 for (var i=0; i<Warnings.length; i++) {
2478 var w = Warnings[i][0];
2479 var p = Warnings[i][1];
2480 var k = w.toString();
2481 if (!(k in groups[p]))
2482 groups[p][k] = [];
2483 groups[p][k].push(Warnings[i]);
2484 }
2485 return groups;
2486 }
2487 var GlobalAnchor = 0;
2488 function createWarningSection(header, color, group) {
2489 var result = "";
2490 var groupKeys = [];
2491 var totalMessages = 0;
2492 for (var k in group) {
2493 totalMessages += group[k].length;
2494 groupKeys.push([k, WarnPatternsSeverity[parseInt(k)], group[k].length]);
2495 }
2496 groupKeys.sort(bySeverityMessageCount);
2497 for (var idx=0; idx<groupKeys.length; idx++) {
2498 var k = groupKeys[idx][0];
2499 var messages = group[k];
2500 var w = parseInt(k);
2501 var wcolor = SeverityColors[WarnPatternsSeverity[w]];
2502 var description = WarnPatternsDescription[w];
2503 if (description.length == 0)
2504 description = "???";
2505 GlobalAnchor += 1;
2506 result += "<table class='t1'><tr bgcolor='" + wcolor + "'><td>" +
2507 "<button class='bt' id='" + GlobalAnchor + "_mark" +
2508 "' onclick='expand(\\"" + GlobalAnchor + "\\");'>" +
2509 "&#x2295</button> " +
2510 description + " (" + messages.length + ")</td></tr></table>";
2511 result += "<div id='" + GlobalAnchor +
2512 "' style='display:none;'><table class='t1'>";
2513 var c = 0;
2514 messages.sort(compareMessages);
2515 for (var i=0; i<messages.length; i++) {
2516 result += "<tr><td class='c" + c + "'>" +
2517 addURL(WarningMessages[messages[i][2]]) + "</td></tr>";
2518 c = 1 - c;
2519 }
2520 result += "</table></div>";
2521 }
2522 if (result.length > 0) {
2523 return "<br><span style='background-color:" + color + "'><b>" +
2524 header + ": " + totalMessages +
2525 "</b></span><blockquote><table class='t1'>" +
2526 result + "</table></blockquote>";
2527
2528 }
2529 return ""; // empty section
2530 }
2531 function generateSectionsBySeverity() {
2532 var result = "";
2533 var groups = groupWarningsBySeverity();
2534 for (s=0; s<SeverityColors.length; s++) {
2535 result += createWarningSection(SeverityHeaders[s], SeverityColors[s], groups[s]);
2536 }
2537 return result;
2538 }
2539 function generateSectionsByProject() {
2540 var result = "";
2541 var groups = groupWarningsByProject();
2542 for (i=0; i<groups.length; i++) {
2543 result += createWarningSection(ProjectNames[i], 'lightgrey', groups[i]);
2544 }
2545 return result;
2546 }
2547 function groupWarnings(generator) {
2548 GlobalAnchor = 0;
2549 var e = document.getElementById("warning_groups");
2550 e.innerHTML = generator();
2551 }
2552 function groupBySeverity() {
2553 groupWarnings(generateSectionsBySeverity);
2554 }
2555 function groupByProject() {
2556 groupWarnings(generateSectionsByProject);
2557 }
2558"""
2559
2560
2561# Emit a JavaScript const string
2562def emit_const_string(name, value):
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07002563 print('const ' + name + ' = "' + escape_string(value) + '";')
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002564
2565
2566# Emit a JavaScript const integer array.
2567def emit_const_int_array(name, array):
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07002568 print('const ' + name + ' = [')
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002569 for n in array:
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07002570 print(str(n) + ',')
2571 print('];')
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002572
2573
2574# Emit a JavaScript const string array.
2575def emit_const_string_array(name, array):
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07002576 print('const ' + name + ' = [')
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002577 for s in array:
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07002578 print('"' + strip_escape_string(s) + '",')
2579 print('];')
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002580
2581
Chih-Hung Hsiehb2afb632018-07-20 15:36:26 -07002582# Emit a JavaScript const string array for HTML.
2583def emit_const_html_string_array(name, array):
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07002584 print('const ' + name + ' = [')
Chih-Hung Hsiehb2afb632018-07-20 15:36:26 -07002585 for s in array:
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07002586 # Not using html.escape yet, to work for both python 2 and 3,
2587 # until all users switch to python 3.
2588 # pylint:disable=deprecated-method
2589 print('"' + cgi.escape(strip_escape_string(s)) + '",')
2590 print('];')
Chih-Hung Hsiehb2afb632018-07-20 15:36:26 -07002591
2592
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002593# Emit a JavaScript const object array.
2594def emit_const_object_array(name, array):
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07002595 print('const ' + name + ' = [')
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002596 for x in array:
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07002597 print(str(x) + ',')
2598 print('];')
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002599
2600
2601def emit_js_data():
2602 """Dump dynamic HTML page's static JavaScript data."""
2603 emit_const_string('FlagURL', args.url if args.url else '')
2604 emit_const_string('FlagSeparator', args.separator if args.separator else '')
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002605 emit_const_string_array('SeverityColors', Severity.colors)
2606 emit_const_string_array('SeverityHeaders', Severity.headers)
2607 emit_const_string_array('SeverityColumnHeaders', Severity.column_headers)
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002608 emit_const_string_array('ProjectNames', project_names)
2609 emit_const_int_array('WarnPatternsSeverity',
2610 [w['severity'] for w in warn_patterns])
Chih-Hung Hsiehb2afb632018-07-20 15:36:26 -07002611 emit_const_html_string_array('WarnPatternsDescription',
2612 [w['description'] for w in warn_patterns])
2613 emit_const_html_string_array('WarnPatternsOption',
2614 [w['option'] for w in warn_patterns])
2615 emit_const_html_string_array('WarningMessages', warning_messages)
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002616 emit_const_object_array('Warnings', warning_records)
2617
2618draw_table_javascript = """
2619google.charts.load('current', {'packages':['table']});
2620google.charts.setOnLoadCallback(drawTable);
2621function drawTable() {
2622 var data = new google.visualization.DataTable();
2623 data.addColumn('string', StatsHeader[0]);
2624 for (var i=1; i<StatsHeader.length; i++) {
2625 data.addColumn('number', StatsHeader[i]);
2626 }
2627 data.addRows(StatsRows);
2628 for (var i=0; i<StatsRows.length; i++) {
2629 for (var j=0; j<StatsHeader.length; j++) {
2630 data.setProperty(i, j, 'style', 'border:1px solid black;');
2631 }
2632 }
2633 var table = new google.visualization.Table(document.getElementById('stats_table'));
2634 table.draw(data, {allowHtml: true, alternatingRowStyle: true});
2635}
2636"""
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002637
2638
2639def dump_html():
2640 """Dump the html output to stdout."""
2641 dump_html_prologue('Warnings for ' + platform_version + ' - ' +
2642 target_product + ' - ' + target_variant)
2643 dump_stats()
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07002644 print('<br><div id="stats_table"></div><br>')
2645 print('\n<script>')
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002646 emit_js_data()
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07002647 print(scripts_for_warning_groups)
2648 print('</script>')
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002649 emit_buttons()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002650 # Warning messages are grouped by severities or project names.
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07002651 print('<br><div id="warning_groups"></div>')
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002652 if args.byproject:
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07002653 print('<script>groupByProject();</script>')
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002654 else:
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07002655 print('<script>groupBySeverity();</script>')
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002656 dump_fixed()
2657 dump_html_epilogue()
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002658
2659
2660##### Functions to count warnings and dump csv file. #########################
2661
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002662
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002663def description_for_csv(category):
2664 if not category['description']:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002665 return '?'
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002666 return category['description']
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002667
2668
Sam Saccone03aaa7e2017-04-10 15:37:47 -07002669def count_severity(writer, sev, kind):
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002670 """Count warnings of given severity."""
2671 total = 0
2672 for i in warn_patterns:
2673 if i['severity'] == sev and i['members']:
2674 n = len(i['members'])
2675 total += n
Sam Saccone03aaa7e2017-04-10 15:37:47 -07002676 warning = kind + ': ' + description_for_csv(i)
2677 writer.writerow([n, '', warning])
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002678 # print number of warnings for each project, ordered by project name.
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07002679 projects = sorted(i['projects'].keys())
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002680 for p in projects:
Sam Saccone03aaa7e2017-04-10 15:37:47 -07002681 writer.writerow([i['projects'][p], p, warning])
2682 writer.writerow([total, '', kind + ' warnings'])
2683
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002684 return total
2685
2686
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002687# dump number of warnings in csv format to stdout
Sam Saccone03aaa7e2017-04-10 15:37:47 -07002688def dump_csv(writer):
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002689 """Dump number of warnings in csv format to stdout."""
2690 sort_warnings()
2691 total = 0
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002692 for s in Severity.range:
Sam Saccone03aaa7e2017-04-10 15:37:47 -07002693 total += count_severity(writer, s, Severity.column_headers[s])
2694 writer.writerow([total, '', 'All warnings'])
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002695
2696
Meike Baumgärtnerac9d5df2016-09-28 10:48:06 -07002697def main():
Chih-Hung Hsiehf5db8982019-09-23 23:00:09 -07002698 find_android_root()
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07002699 # We must use 'utf-8' codec to parse some non-ASCII code in warnings.
2700 warning_lines = parse_input_file(
2701 io.open(args.buildlog, mode='r', encoding='utf-8'))
Chih-Hung Hsieh76d00652016-11-09 18:19:05 -08002702 parallel_classify_warnings(warning_lines)
Sam Saccone03aaa7e2017-04-10 15:37:47 -07002703 # If a user pases a csv path, save the fileoutput to the path
2704 # If the user also passed gencsv write the output to stdout
2705 # If the user did not pass gencsv flag dump the html report to stdout.
2706 if args.csvpath:
2707 with open(args.csvpath, 'w') as f:
2708 dump_csv(csv.writer(f, lineterminator='\n'))
Meike Baumgärtnerac9d5df2016-09-28 10:48:06 -07002709 if args.gencsv:
Sam Saccone03aaa7e2017-04-10 15:37:47 -07002710 dump_csv(csv.writer(sys.stdout, lineterminator='\n'))
Meike Baumgärtnerac9d5df2016-09-28 10:48:06 -07002711 else:
2712 dump_html()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002713
Meike Baumgärtnerac9d5df2016-09-28 10:48:06 -07002714
2715# Run main function if warn.py is the main program.
2716if __name__ == '__main__':
2717 main()