blob: f0fbfbc80a1a3a127e5efb165ffacad8c8360a93 [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 Hsieh6c0fdbb2016-09-26 10:56:43 -0700197warn_patterns = [
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700198 # pylint:disable=line-too-long,g-inconsistent-quotes
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700199 {'category': 'make', 'severity': Severity.MEDIUM,
200 'description': 'make: overriding commands/ignoring old commands',
201 'patterns': [r".*: warning: overriding commands for target .+",
202 r".*: warning: ignoring old commands for target .+"]},
203 {'category': 'make', 'severity': Severity.HIGH,
204 'description': 'make: LOCAL_CLANG is false',
205 'patterns': [r".*: warning: LOCAL_CLANG is set to false"]},
206 {'category': 'make', 'severity': Severity.HIGH,
207 'description': 'SDK App using platform shared library',
208 'patterns': [r".*: warning: .+ \(.*app:sdk.*\) should not link to .+ \(native:platform\)"]},
209 {'category': 'make', 'severity': Severity.HIGH,
210 'description': 'System module linking to a vendor module',
211 'patterns': [r".*: warning: .+ \(.+\) should not link to .+ \(partition:.+\)"]},
212 {'category': 'make', 'severity': Severity.MEDIUM,
213 'description': 'Invalid SDK/NDK linking',
214 'patterns': [r".*: warning: .+ \(.+\) should not link to .+ \(.+\)"]},
Chih-Hung Hsieh9e9355d2018-06-04 11:32:32 -0700215 {'category': 'make', 'severity': Severity.MEDIUM,
216 'description': 'Duplicate header copy',
217 'patterns': [r".*: warning: Duplicate header copy: .+"]},
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -0700218 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wimplicit-function-declaration',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700219 'description': 'Implicit function declaration',
220 'patterns': [r".*: warning: implicit declaration of function .+",
221 r".*: warning: implicitly declaring library function"]},
222 {'category': 'C/C++', 'severity': Severity.SKIP,
223 'description': 'skip, conflicting types for ...',
224 'patterns': [r".*: warning: conflicting types for '.+'"]},
225 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wtype-limits',
226 'description': 'Expression always evaluates to true or false',
227 'patterns': [r".*: warning: comparison is always .+ due to limited range of data type",
228 r".*: warning: comparison of unsigned .*expression .+ is always true",
229 r".*: warning: comparison of unsigned .*expression .+ is always false"]},
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -0700230 # {'category': 'C/C++', 'severity': Severity.HIGH,
231 # 'description': 'Potential leak of memory, bad free, use after free',
232 # 'patterns': [r".*: warning: Potential leak of memory",
233 # r".*: warning: Potential memory leak",
234 # r".*: warning: Memory allocated by alloca\(\) should not be deallocated",
235 # r".*: warning: Memory allocated by .+ should be deallocated by .+ not .+",
236 # r".*: warning: 'delete' applied to a pointer that was allocated",
237 # r".*: warning: Use of memory after it is freed",
238 # r".*: warning: Argument to .+ is the address of .+ variable",
239 # r".*: warning: Argument to free\(\) is offset by .+ of memory allocated by",
240 # r".*: warning: Attempt to .+ released memory"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700241 {'category': 'C/C++', 'severity': Severity.HIGH,
242 'description': 'Use transient memory for control value',
243 'patterns': [r".*: warning: .+Using such transient memory for the control value is .*dangerous."]},
244 {'category': 'C/C++', 'severity': Severity.HIGH,
245 'description': 'Return address of stack memory',
246 'patterns': [r".*: warning: Address of stack memory .+ returned to caller",
247 r".*: warning: Address of stack memory .+ will be a dangling reference"]},
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -0700248 # {'category': 'C/C++', 'severity': Severity.HIGH,
249 # 'description': 'Problem with vfork',
250 # 'patterns': [r".*: warning: This .+ is prohibited after a successful vfork",
251 # r".*: warning: Call to function '.+' is insecure "]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700252 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': 'infinite-recursion',
253 'description': 'Infinite recursion',
254 'patterns': [r".*: warning: all paths through this function will call itself"]},
255 {'category': 'C/C++', 'severity': Severity.HIGH,
256 'description': 'Potential buffer overflow',
257 'patterns': [r".*: warning: Size argument is greater than .+ the destination buffer",
258 r".*: warning: Potential buffer overflow.",
259 r".*: warning: String copy function overflows destination buffer"]},
260 {'category': 'C/C++', 'severity': Severity.MEDIUM,
261 'description': 'Incompatible pointer types',
262 'patterns': [r".*: warning: assignment from incompatible pointer type",
263 r".*: warning: return from incompatible pointer type",
264 r".*: warning: passing argument [0-9]+ of '.*' from incompatible pointer type",
265 r".*: warning: initialization from incompatible pointer type"]},
266 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-fno-builtin',
267 'description': 'Incompatible declaration of built in function',
268 'patterns': [r".*: warning: incompatible implicit declaration of built-in function .+"]},
269 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wincompatible-library-redeclaration',
270 'description': 'Incompatible redeclaration of library function',
271 'patterns': [r".*: warning: incompatible redeclaration of library function .+"]},
272 {'category': 'C/C++', 'severity': Severity.HIGH,
273 'description': 'Null passed as non-null argument',
274 'patterns': [r".*: warning: Null passed to a callee that requires a non-null"]},
275 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused-parameter',
276 'description': 'Unused parameter',
277 'patterns': [r".*: warning: unused parameter '.*'"]},
278 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused',
Chih-Hung Hsieh9e9355d2018-06-04 11:32:32 -0700279 'description': 'Unused function, variable, label, comparison, etc.',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700280 'patterns': [r".*: warning: '.+' defined but not used",
281 r".*: warning: unused function '.+'",
Chih-Hung Hsieh9e9355d2018-06-04 11:32:32 -0700282 r".*: warning: unused label '.+'",
283 r".*: warning: relational comparison result unused",
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -0700284 r".*: warning: lambda capture .* is not used",
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700285 r".*: warning: private field '.+' is not used",
286 r".*: warning: unused variable '.+'"]},
287 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused-value',
288 'description': 'Statement with no effect or result unused',
289 'patterns': [r".*: warning: statement with no effect",
290 r".*: warning: expression result unused"]},
291 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused-result',
292 'description': 'Ignoreing return value of function',
293 'patterns': [r".*: warning: ignoring return value of function .+Wunused-result"]},
294 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-field-initializers',
295 'description': 'Missing initializer',
296 'patterns': [r".*: warning: missing initializer"]},
297 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wdelete-non-virtual-dtor',
298 'description': 'Need virtual destructor',
299 'patterns': [r".*: warning: delete called .* has virtual functions but non-virtual destructor"]},
300 {'category': 'cont.', 'severity': Severity.SKIP,
301 'description': 'skip, near initialization for ...',
302 'patterns': [r".*: warning: \(near initialization for '.+'\)"]},
303 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wdate-time',
304 'description': 'Expansion of data or time macro',
305 'patterns': [r".*: warning: expansion of date or time macro is not reproducible"]},
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -0700306 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wexpansion-to-defined',
307 'description': 'Macro expansion has undefined behavior',
308 'patterns': [r".*: warning: macro expansion .* has undefined behavior"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700309 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wformat',
310 'description': 'Format string does not match arguments',
311 'patterns': [r".*: warning: format '.+' expects type '.+', but argument [0-9]+ has type '.+'",
312 r".*: warning: more '%' conversions than data arguments",
313 r".*: warning: data argument not used by format string",
314 r".*: warning: incomplete format specifier",
315 r".*: warning: unknown conversion type .* in format",
316 r".*: warning: format .+ expects .+ but argument .+Wformat=",
317 r".*: warning: field precision should have .+ but argument has .+Wformat",
318 r".*: warning: format specifies type .+ but the argument has .*type .+Wformat"]},
319 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wformat-extra-args',
320 'description': 'Too many arguments for format string',
321 'patterns': [r".*: warning: too many arguments for format"]},
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -0700322 {'category': 'C/C++', 'severity': Severity.MEDIUM,
323 'description': 'Too many arguments in call',
324 'patterns': [r".*: warning: too many arguments in call to "]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700325 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wformat-invalid-specifier',
326 'description': 'Invalid format specifier',
327 'patterns': [r".*: warning: invalid .+ specifier '.+'.+format-invalid-specifier"]},
328 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsign-compare',
329 'description': 'Comparison between signed and unsigned',
330 'patterns': [r".*: warning: comparison between signed and unsigned",
331 r".*: warning: comparison of promoted \~unsigned with unsigned",
332 r".*: warning: signed and unsigned type in conditional expression"]},
333 {'category': 'C/C++', 'severity': Severity.MEDIUM,
334 'description': 'Comparison between enum and non-enum',
335 'patterns': [r".*: warning: enumeral and non-enumeral type in conditional expression"]},
336 {'category': 'libpng', 'severity': Severity.MEDIUM,
337 'description': 'libpng: zero area',
338 'patterns': [r".*libpng warning: Ignoring attempt to set cHRM RGB triangle with zero area"]},
339 {'category': 'aapt', 'severity': Severity.MEDIUM,
340 'description': 'aapt: no comment for public symbol',
341 'patterns': [r".*: warning: No comment for public symbol .+"]},
342 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-braces',
343 'description': 'Missing braces around initializer',
344 'patterns': [r".*: warning: missing braces around initializer.*"]},
345 {'category': 'C/C++', 'severity': Severity.HARMLESS,
346 'description': 'No newline at end of file',
347 'patterns': [r".*: warning: no newline at end of file"]},
348 {'category': 'C/C++', 'severity': Severity.HARMLESS,
349 'description': 'Missing space after macro name',
350 'patterns': [r".*: warning: missing whitespace after the macro name"]},
351 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wcast-align',
352 'description': 'Cast increases required alignment',
353 'patterns': [r".*: warning: cast from .* to .* increases required alignment .*"]},
354 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wcast-qual',
355 'description': 'Qualifier discarded',
356 'patterns': [r".*: warning: passing argument [0-9]+ of '.+' discards qualifiers from pointer target type",
357 r".*: warning: assignment discards qualifiers from pointer target type",
358 r".*: warning: passing .+ to parameter of type .+ discards qualifiers",
359 r".*: warning: assigning to .+ from .+ discards qualifiers",
360 r".*: warning: initializing .+ discards qualifiers .+types-discards-qualifiers",
361 r".*: warning: return discards qualifiers from pointer target type"]},
362 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunknown-attributes',
363 'description': 'Unknown attribute',
364 'patterns': [r".*: warning: unknown attribute '.+'"]},
365 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wignored-attributes',
366 'description': 'Attribute ignored',
367 'patterns': [r".*: warning: '_*packed_*' attribute ignored",
368 r".*: warning: attribute declaration must precede definition .+ignored-attributes"]},
369 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wvisibility',
370 'description': 'Visibility problem',
371 'patterns': [r".*: warning: declaration of '.+' will not be visible outside of this function"]},
372 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wattributes',
373 'description': 'Visibility mismatch',
374 'patterns': [r".*: warning: '.+' declared with greater visibility than the type of its field '.+'"]},
375 {'category': 'C/C++', 'severity': Severity.MEDIUM,
376 'description': 'Shift count greater than width of type',
377 'patterns': [r".*: warning: (left|right) shift count >= width of type"]},
378 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wextern-initializer',
379 'description': 'extern <foo> is initialized',
380 'patterns': [r".*: warning: '.+' initialized and declared 'extern'",
381 r".*: warning: 'extern' variable has an initializer"]},
382 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wold-style-declaration',
383 'description': 'Old style declaration',
384 'patterns': [r".*: warning: 'static' is not at beginning of declaration"]},
385 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wreturn-type',
386 'description': 'Missing return value',
387 'patterns': [r".*: warning: control reaches end of non-void function"]},
388 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wimplicit-int',
389 'description': 'Implicit int type',
390 'patterns': [r".*: warning: type specifier missing, defaults to 'int'",
391 r".*: warning: type defaults to 'int' in declaration of '.+'"]},
392 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmain-return-type',
393 'description': 'Main function should return int',
394 'patterns': [r".*: warning: return type of 'main' is not 'int'"]},
395 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wuninitialized',
396 'description': 'Variable may be used uninitialized',
397 'patterns': [r".*: warning: '.+' may be used uninitialized in this function"]},
398 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wuninitialized',
399 'description': 'Variable is used uninitialized',
400 'patterns': [r".*: warning: '.+' is used uninitialized in this function",
401 r".*: warning: variable '.+' is uninitialized when used here"]},
402 {'category': 'ld', 'severity': Severity.MEDIUM, 'option': '-fshort-enums',
403 'description': 'ld: possible enum size mismatch',
404 'patterns': [r".*: warning: .* uses variable-size enums yet the output is to use 32-bit enums; use of enum values across objects may fail"]},
405 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wpointer-sign',
406 'description': 'Pointer targets differ in signedness',
407 'patterns': [r".*: warning: pointer targets in initialization differ in signedness",
408 r".*: warning: pointer targets in assignment differ in signedness",
409 r".*: warning: pointer targets in return differ in signedness",
410 r".*: warning: pointer targets in passing argument [0-9]+ of '.+' differ in signedness"]},
411 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wstrict-overflow',
412 'description': 'Assuming overflow does not occur',
413 'patterns': [r".*: warning: assuming signed overflow does not occur when assuming that .* is always (true|false)"]},
414 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wempty-body',
415 'description': 'Suggest adding braces around empty body',
416 'patterns': [r".*: warning: suggest braces around empty body in an 'if' statement",
417 r".*: warning: empty body in an if-statement",
418 r".*: warning: suggest braces around empty body in an 'else' statement",
419 r".*: warning: empty body in an else-statement"]},
420 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wparentheses',
421 'description': 'Suggest adding parentheses',
422 'patterns': [r".*: warning: suggest explicit braces to avoid ambiguous 'else'",
423 r".*: warning: suggest parentheses around arithmetic in operand of '.+'",
424 r".*: warning: suggest parentheses around comparison in operand of '.+'",
425 r".*: warning: logical not is only applied to the left hand side of this comparison",
426 r".*: warning: using the result of an assignment as a condition without parentheses",
427 r".*: warning: .+ has lower precedence than .+ be evaluated first .+Wparentheses",
428 r".*: warning: suggest parentheses around '.+?' .+ '.+?'",
429 r".*: warning: suggest parentheses around assignment used as truth value"]},
430 {'category': 'C/C++', 'severity': Severity.MEDIUM,
431 'description': 'Static variable used in non-static inline function',
432 'patterns': [r".*: warning: '.+' is static but used in inline function '.+' which is not static"]},
433 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wimplicit int',
434 'description': 'No type or storage class (will default to int)',
435 'patterns': [r".*: warning: data definition has no type or storage class"]},
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -0700436 # {'category': 'C/C++', 'severity': Severity.MEDIUM,
437 # 'description': 'Null pointer',
438 # 'patterns': [r".*: warning: Dereference of null pointer",
439 # r".*: warning: Called .+ pointer is null",
440 # r".*: warning: Forming reference to null pointer",
441 # r".*: warning: Returning null reference",
442 # r".*: warning: Null pointer passed as an argument to a 'nonnull' parameter",
443 # r".*: warning: .+ results in a null pointer dereference",
444 # r".*: warning: Access to .+ results in a dereference of a null pointer",
445 # r".*: warning: Null pointer argument in"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700446 {'category': 'cont.', 'severity': Severity.SKIP,
447 'description': 'skip, parameter name (without types) in function declaration',
448 'patterns': [r".*: warning: parameter names \(without types\) in function declaration"]},
449 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wstrict-aliasing',
450 'description': 'Dereferencing <foo> breaks strict aliasing rules',
451 'patterns': [r".*: warning: dereferencing .* break strict-aliasing rules"]},
452 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wpointer-to-int-cast',
453 'description': 'Cast from pointer to integer of different size',
454 'patterns': [r".*: warning: cast from pointer to integer of different size",
455 r".*: warning: initialization makes pointer from integer without a cast"]},
456 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wint-to-pointer-cast',
457 'description': 'Cast to pointer from integer of different size',
458 'patterns': [r".*: warning: cast to pointer from integer of different size"]},
459 {'category': 'C/C++', 'severity': Severity.MEDIUM,
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -0700460 'description': 'Macro redefined',
461 'patterns': [r".*: warning: '.+' macro redefined"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700462 {'category': 'cont.', 'severity': Severity.SKIP,
463 'description': 'skip, ... location of the previous definition',
464 'patterns': [r".*: warning: this is the location of the previous definition"]},
465 {'category': 'ld', 'severity': Severity.MEDIUM,
466 'description': 'ld: type and size of dynamic symbol are not defined',
467 'patterns': [r".*: warning: type and size of dynamic symbol `.+' are not defined"]},
468 {'category': 'C/C++', 'severity': Severity.MEDIUM,
469 'description': 'Pointer from integer without cast',
470 'patterns': [r".*: warning: assignment makes pointer from integer without a cast"]},
471 {'category': 'C/C++', 'severity': Severity.MEDIUM,
472 'description': 'Pointer from integer without cast',
473 'patterns': [r".*: warning: passing argument [0-9]+ of '.+' makes pointer from integer without a cast"]},
474 {'category': 'C/C++', 'severity': Severity.MEDIUM,
475 'description': 'Integer from pointer without cast',
476 'patterns': [r".*: warning: assignment makes integer from pointer without a cast"]},
477 {'category': 'C/C++', 'severity': Severity.MEDIUM,
478 'description': 'Integer from pointer without cast',
479 'patterns': [r".*: warning: passing argument [0-9]+ of '.+' makes integer from pointer without a cast"]},
480 {'category': 'C/C++', 'severity': Severity.MEDIUM,
481 'description': 'Integer from pointer without cast',
482 'patterns': [r".*: warning: return makes integer from pointer without a cast"]},
483 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunknown-pragmas',
484 'description': 'Ignoring pragma',
485 'patterns': [r".*: warning: ignoring #pragma .+"]},
486 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-W#pragma-messages',
487 'description': 'Pragma warning messages',
488 'patterns': [r".*: warning: .+W#pragma-messages"]},
489 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wclobbered',
490 'description': 'Variable might be clobbered by longjmp or vfork',
491 'patterns': [r".*: warning: variable '.+' might be clobbered by 'longjmp' or 'vfork'"]},
492 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wclobbered',
493 'description': 'Argument might be clobbered by longjmp or vfork',
494 'patterns': [r".*: warning: argument '.+' might be clobbered by 'longjmp' or 'vfork'"]},
495 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wredundant-decls',
496 'description': 'Redundant declaration',
497 'patterns': [r".*: warning: redundant redeclaration of '.+'"]},
498 {'category': 'cont.', 'severity': Severity.SKIP,
499 'description': 'skip, previous declaration ... was here',
500 'patterns': [r".*: warning: previous declaration of '.+' was here"]},
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -0700501 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wswitch-enum',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700502 'description': 'Enum value not handled in switch',
503 'patterns': [r".*: warning: .*enumeration value.* not handled in switch.+Wswitch"]},
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -0700504 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wuser-defined-warnings',
505 'description': 'User defined warnings',
506 'patterns': [r".*: warning: .* \[-Wuser-defined-warnings\]$"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700507 {'category': 'java', 'severity': Severity.MEDIUM, 'option': '-encoding',
508 'description': 'Java: Non-ascii characters used, but ascii encoding specified',
509 'patterns': [r".*: warning: unmappable character for encoding ascii"]},
510 {'category': 'java', 'severity': Severity.MEDIUM,
511 'description': 'Java: Non-varargs call of varargs method with inexact argument type for last parameter',
512 'patterns': [r".*: warning: non-varargs call of varargs method with inexact argument type for last parameter"]},
513 {'category': 'java', 'severity': Severity.MEDIUM,
514 'description': 'Java: Unchecked method invocation',
515 'patterns': [r".*: warning: \[unchecked\] unchecked method invocation: .+ in class .+"]},
516 {'category': 'java', 'severity': Severity.MEDIUM,
517 'description': 'Java: Unchecked conversion',
518 'patterns': [r".*: warning: \[unchecked\] unchecked conversion"]},
519 {'category': 'java', 'severity': Severity.MEDIUM,
520 'description': '_ used as an identifier',
521 'patterns': [r".*: warning: '_' used as an identifier"]},
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -0700522 {'category': 'java', 'severity': Severity.MEDIUM,
523 'description': 'Java: hidden superclass',
524 'patterns': [r".*: warning: .* stripped of .* superclass .* \[HiddenSuperclass\]"]},
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -0700525 {'category': 'java', 'severity': Severity.HIGH,
526 'description': 'Use of internal proprietary API',
527 'patterns': [r".*: warning: .* is internal proprietary API and may be removed"]},
Ian Rogers32bb9bd2016-05-09 23:19:42 -0700528
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800529 # Warnings from Javac
Ian Rogers6e520032016-05-13 08:59:00 -0700530 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700531 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700532 'description': 'Java: Use of deprecated member',
533 'patterns': [r'.*: warning: \[deprecation\] .+']},
534 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700535 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700536 'description': 'Java: Unchecked conversion',
537 'patterns': [r'.*: warning: \[unchecked\] .+']},
Ian Rogers32bb9bd2016-05-09 23:19:42 -0700538
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800539 # Begin warnings generated by Error Prone
540 {'category': 'java',
541 'severity': Severity.LOW,
542 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800543 'Java: Use parameter comments to document ambiguous literals',
544 'patterns': [r".*: warning: \[BooleanParameter\] .+"]},
545 {'category': 'java',
546 'severity': Severity.LOW,
547 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -0700548 'Java: This class\'s name looks like a Type Parameter.',
549 'patterns': [r".*: warning: \[ClassNamedLikeTypeParameter\] .+"]},
550 {'category': 'java',
551 'severity': Severity.LOW,
552 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -0700553 'Java: Field name is CONSTANT_CASE, but field is not static and final',
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800554 'patterns': [r".*: warning: \[ConstantField\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -0700555 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700556 'severity': Severity.LOW,
Ian Rogers6e520032016-05-13 08:59:00 -0700557 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700558 'Java: @Multibinds is a more efficient and declarative mechanism for ensuring that a set multibinding is present in the graph.',
559 'patterns': [r".*: warning: \[EmptySetMultibindingContributions\] .+"]},
560 {'category': 'java',
561 'severity': Severity.LOW,
562 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -0700563 'Java: Prefer assertThrows to ExpectedException',
564 'patterns': [r".*: warning: \[ExpectedExceptionRefactoring\] .+"]},
565 {'category': 'java',
566 'severity': Severity.LOW,
567 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -0700568 'Java: This field is only assigned during initialization; consider making it final',
569 'patterns': [r".*: warning: \[FieldCanBeFinal\] .+"]},
Andreas Gampe2e987af2018-06-08 09:55:41 -0700570 {'category': 'java',
571 'severity': Severity.LOW,
572 'description':
573 'Java: Fields that can be null should be annotated @Nullable',
574 'patterns': [r".*: warning: \[FieldMissingNullable\] .+"]},
575 {'category': 'java',
576 'severity': Severity.LOW,
577 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -0700578 'Java: Refactors uses of the JSR 305 @Immutable to Error Prone\'s annotation',
579 'patterns': [r".*: warning: \[ImmutableRefactoring\] .+"]},
580 {'category': 'java',
581 'severity': Severity.LOW,
582 'description':
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -0700583 u'Java: Use Java\'s utility functional interfaces instead of Function\u003cA, B> for primitive types.',
Andreas Gampecf528ca2018-01-25 11:55:43 -0800584 'patterns': [r".*: warning: \[LambdaFunctionalInterface\] .+"]},
585 {'category': 'java',
586 'severity': Severity.LOW,
587 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800588 'Java: A private method that does not reference the enclosing instance can be static',
589 'patterns': [r".*: warning: \[MethodCanBeStatic\] .+"]},
590 {'category': 'java',
591 'severity': Severity.LOW,
592 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800593 'Java: C-style array declarations should not be used',
594 'patterns': [r".*: warning: \[MixedArrayDimensions\] .+"]},
595 {'category': 'java',
596 'severity': Severity.LOW,
597 'description':
598 'Java: Variable declarations should declare only one variable',
599 'patterns': [r".*: warning: \[MultiVariableDeclaration\] .+"]},
600 {'category': 'java',
601 'severity': Severity.LOW,
602 'description':
603 'Java: Source files should not contain multiple top-level class declarations',
604 'patterns': [r".*: warning: \[MultipleTopLevelClasses\] .+"]},
605 {'category': 'java',
606 'severity': Severity.LOW,
607 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800608 'Java: Avoid having multiple unary operators acting on the same variable in a method call',
609 'patterns': [r".*: warning: \[MultipleUnaryOperatorsInMethodCall\] .+"]},
610 {'category': 'java',
611 'severity': Severity.LOW,
612 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800613 'Java: Package names should match the directory they are declared in',
614 'patterns': [r".*: warning: \[PackageLocation\] .+"]},
615 {'category': 'java',
616 'severity': Severity.LOW,
617 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -0700618 'Java: Non-standard parameter comment; prefer `/* paramName= */ arg`',
Andreas Gampecf528ca2018-01-25 11:55:43 -0800619 'patterns': [r".*: warning: \[ParameterComment\] .+"]},
620 {'category': 'java',
621 'severity': Severity.LOW,
622 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700623 'Java: Method parameters that aren\'t checked for null shouldn\'t be annotated @Nullable',
624 'patterns': [r".*: warning: \[ParameterNotNullable\] .+"]},
625 {'category': 'java',
626 'severity': Severity.LOW,
627 'description':
628 'Java: Add a private constructor to modules that will not be instantiated by Dagger.',
Andreas Gampeb9dc23a2018-06-08 10:11:26 -0700629 'patterns': [r".*: warning: \[PrivateConstructorForNoninstantiableModule\] .+"]},
Andreas Gampe2e987af2018-06-08 09:55:41 -0700630 {'category': 'java',
631 'severity': Severity.LOW,
632 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800633 'Java: Utility classes (only static members) are not designed to be instantiated and should be made noninstantiable with a default constructor.',
634 'patterns': [r".*: warning: \[PrivateConstructorForUtilityClass\] .+"]},
635 {'category': 'java',
636 'severity': Severity.LOW,
637 'description':
638 'Java: Unused imports',
639 'patterns': [r".*: warning: \[RemoveUnusedImports\] .+"]},
640 {'category': 'java',
641 'severity': Severity.LOW,
642 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700643 'Java: Methods that can return null should be annotated @Nullable',
644 'patterns': [r".*: warning: \[ReturnMissingNullable\] .+"]},
645 {'category': 'java',
646 'severity': Severity.LOW,
647 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -0700648 'Java: Scopes on modules have no function and will soon be an error.',
649 'patterns': [r".*: warning: \[ScopeOnModule\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -0800650 {'category': 'java',
651 'severity': Severity.LOW,
652 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -0700653 'Java: The default case of a switch should appear at the end of the last statement group',
654 'patterns': [r".*: warning: \[SwitchDefault\] .+"]},
Andreas Gampe2e987af2018-06-08 09:55:41 -0700655 {'category': 'java',
656 'severity': Severity.LOW,
657 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -0700658 'Java: Prefer assertThrows to @Test(expected=...)',
659 'patterns': [r".*: warning: \[TestExceptionRefactoring\] .+"]},
660 {'category': 'java',
661 'severity': Severity.LOW,
662 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800663 'Java: Unchecked exceptions do not need to be declared in the method signature.',
664 'patterns': [r".*: warning: \[ThrowsUncheckedException\] .+"]},
665 {'category': 'java',
666 'severity': Severity.LOW,
667 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -0700668 'Java: Prefer assertThrows to try/fail',
669 'patterns': [r".*: warning: \[TryFailRefactoring\] .+"]},
670 {'category': 'java',
671 'severity': Severity.LOW,
672 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800673 'Java: Type parameters must be a single letter with an optional numeric suffix, or an UpperCamelCase name followed by the letter \'T\'.',
674 'patterns': [r".*: warning: \[TypeParameterNaming\] .+"]},
675 {'category': 'java',
676 'severity': Severity.LOW,
677 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -0700678 'Java: Constructors and methods with the same name should appear sequentially with no other code in between. Please re-order or re-name methods.',
Andreas Gampecf528ca2018-01-25 11:55:43 -0800679 'patterns': [r".*: warning: \[UngroupedOverloads\] .+"]},
680 {'category': 'java',
681 'severity': Severity.LOW,
682 'description':
683 'Java: Unnecessary call to NullPointerTester#setDefault',
684 'patterns': [r".*: warning: \[UnnecessarySetDefault\] .+"]},
685 {'category': 'java',
686 'severity': Severity.LOW,
687 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800688 'Java: Using static imports for types is unnecessary',
689 'patterns': [r".*: warning: \[UnnecessaryStaticImport\] .+"]},
690 {'category': 'java',
691 'severity': Severity.LOW,
692 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700693 'Java: @Binds is a more efficient and declarative mechanism for delegating a binding.',
694 'patterns': [r".*: warning: \[UseBinds\] .+"]},
695 {'category': 'java',
696 'severity': Severity.LOW,
697 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800698 'Java: Wildcard imports, static or otherwise, should not be used',
699 'patterns': [r".*: warning: \[WildcardImport\] .+"]},
700 {'category': 'java',
Andreas Gampecf528ca2018-01-25 11:55:43 -0800701 'severity': Severity.MEDIUM,
702 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700703 'Java: Method reference is ambiguous',
704 'patterns': [r".*: warning: \[AmbiguousMethodReference\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -0800705 {'category': 'java',
706 'severity': Severity.MEDIUM,
707 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -0700708 'Java: 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.',
709 'patterns': [r".*: warning: \[AnnotateFormatMethod\] .+"]},
710 {'category': 'java',
711 'severity': Severity.MEDIUM,
712 'description':
713 'Java: Annotations should be positioned after Javadocs, but before modifiers..',
714 'patterns': [r".*: warning: \[AnnotationPosition\] .+"]},
715 {'category': 'java',
716 'severity': Severity.MEDIUM,
717 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800718 'Java: Arguments are in the wrong order or could be commented for clarity.',
719 'patterns': [r".*: warning: \[ArgumentSelectionDefectChecker\] .+"]},
720 {'category': 'java',
721 'severity': Severity.MEDIUM,
722 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -0700723 'Java: 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.',
724 'patterns': [r".*: warning: \[ArrayAsKeyOfSetOrMap\] .+"]},
725 {'category': 'java',
726 'severity': Severity.MEDIUM,
727 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800728 'Java: Arguments are swapped in assertEquals-like call',
729 'patterns': [r".*: warning: \[AssertEqualsArgumentOrderChecker\] .+"]},
730 {'category': 'java',
731 'severity': Severity.MEDIUM,
732 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800733 'Java: Assertions may be disabled at runtime and do not guarantee that execution will halt here; consider throwing an exception instead',
734 'patterns': [r".*: warning: \[AssertFalse\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -0700735 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700736 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700737 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -0700738 'Java: The lambda passed to assertThrows should contain exactly one statement',
Andreas Gampeb9dc23a2018-06-08 10:11:26 -0700739 'patterns': [r".*: warning: \[AssertThrowsMultipleStatements\] .+"]},
740 {'category': 'java',
741 'severity': Severity.MEDIUM,
742 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800743 'Java: This assertion throws an AssertionError if it fails, which will be caught by an enclosing try block.',
744 'patterns': [r".*: warning: \[AssertionFailureIgnored\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -0700745 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700746 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700747 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700748 'Java: @AssistedInject and @Inject should not be used on different constructors in the same class.',
749 'patterns': [r".*: warning: \[AssistedInjectAndInjectOnConstructors\] .+"]},
750 {'category': 'java',
751 'severity': Severity.MEDIUM,
752 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -0700753 'Java: Make toString(), hashCode() and equals() final in AutoValue classes, so it is clear to readers that AutoValue is not overriding them',
754 'patterns': [r".*: warning: \[AutoValueFinalMethods\] .+"]},
755 {'category': 'java',
756 'severity': Severity.MEDIUM,
757 'description':
Ian Rogers6e520032016-05-13 08:59:00 -0700758 'Java: Classes that implement Annotation must override equals and hashCode. Consider using AutoAnnotation instead of implementing Annotation by hand.',
759 'patterns': [r".*: warning: \[BadAnnotationImplementation\] .+"]},
760 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700761 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700762 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800763 'Java: Possible sign flip from narrowing conversion',
764 'patterns': [r".*: warning: \[BadComparable\] .+"]},
765 {'category': 'java',
766 'severity': Severity.MEDIUM,
767 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -0700768 'Java: 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.',
769 'patterns': [r".*: warning: \[BadImport\] .+"]},
770 {'category': 'java',
771 'severity': Severity.MEDIUM,
772 'description':
773 'Java: instanceof used in a way that is equivalent to a null check.',
774 'patterns': [r".*: warning: \[BadInstanceof\] .+"]},
775 {'category': 'java',
776 'severity': Severity.MEDIUM,
777 'description':
778 'Java: BigDecimal#equals has surprising behavior: it also compares scale.',
779 'patterns': [r".*: warning: \[BigDecimalEquals\] .+"]},
780 {'category': 'java',
781 'severity': Severity.MEDIUM,
782 'description':
783 'Java: new BigDecimal(double) loses precision in this case.',
Ian Rogers6e520032016-05-13 08:59:00 -0700784 'patterns': [r".*: warning: \[BigDecimalLiteralDouble\] .+"]},
785 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700786 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700787 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700788 'Java: 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.',
789 'patterns': [r".*: warning: \[BinderIdentityRestoredDangerously\] .+"]},
790 {'category': 'java',
791 'severity': Severity.MEDIUM,
792 'description':
793 'Java: This code declares a binding for a common value type without a Qualifier annotation.',
794 'patterns': [r".*: warning: \[BindingToUnqualifiedCommonType\] .+"]},
795 {'category': 'java',
796 'severity': Severity.MEDIUM,
797 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800798 'Java: valueOf or autoboxing provides better time and space performance',
799 'patterns': [r".*: warning: \[BoxedPrimitiveConstructor\] .+"]},
800 {'category': 'java',
801 'severity': Severity.MEDIUM,
802 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -0700803 'Java: ByteBuffer.array() shouldn\'t be called unless ByteBuffer.arrayOffset() is used or if the ByteBuffer was initialized using ByteBuffer.wrap() or ByteBuffer.allocate().',
804 'patterns': [r".*: warning: \[ByteBufferBackingArray\] .+"]},
805 {'category': 'java',
806 'severity': Severity.MEDIUM,
807 'description':
Ian Rogers6e520032016-05-13 08:59:00 -0700808 'Java: Mockito cannot mock final classes',
809 'patterns': [r".*: warning: \[CannotMockFinalClass\] .+"]},
810 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700811 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700812 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800813 'Java: Duration can be expressed more clearly with different units',
814 'patterns': [r".*: warning: \[CanonicalDuration\] .+"]},
815 {'category': 'java',
816 'severity': Severity.MEDIUM,
817 'description':
818 'Java: Logging or rethrowing exceptions should usually be preferred to catching and calling printStackTrace',
819 'patterns': [r".*: warning: \[CatchAndPrintStackTrace\] .+"]},
820 {'category': 'java',
821 'severity': Severity.MEDIUM,
822 'description':
823 'Java: Ignoring exceptions and calling fail() is unnecessary, and makes test output less useful',
824 'patterns': [r".*: warning: \[CatchFail\] .+"]},
825 {'category': 'java',
826 'severity': Severity.MEDIUM,
827 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800828 'Java: Inner class is non-static but does not reference enclosing class',
829 'patterns': [r".*: warning: \[ClassCanBeStatic\] .+"]},
830 {'category': 'java',
831 'severity': Severity.MEDIUM,
832 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800833 'Java: Class.newInstance() bypasses exception checking; prefer getDeclaredConstructor().newInstance()',
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800834 'patterns': [r".*: warning: \[ClassNewInstance\] .+"]},
835 {'category': 'java',
836 'severity': Severity.MEDIUM,
837 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -0700838 'Java: Providing Closeable resources makes their lifecycle unclear',
839 'patterns': [r".*: warning: \[CloseableProvides\] .+"]},
840 {'category': 'java',
841 'severity': Severity.MEDIUM,
842 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800843 'Java: The type of the array parameter of Collection.toArray needs to be compatible with the array type',
844 'patterns': [r".*: warning: \[CollectionToArraySafeParameter\] .+"]},
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800845 {'category': 'java',
846 'severity': Severity.MEDIUM,
847 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800848 'Java: Collector.of() should not use state',
849 'patterns': [r".*: warning: \[CollectorShouldNotUseState\] .+"]},
850 {'category': 'java',
851 'severity': Severity.MEDIUM,
852 'description':
853 'Java: Class should not implement both `Comparable` and `Comparator`',
854 'patterns': [r".*: warning: \[ComparableAndComparator\] .+"]},
855 {'category': 'java',
856 'severity': Severity.MEDIUM,
857 'description':
858 'Java: Constructors should not invoke overridable methods.',
859 'patterns': [r".*: warning: \[ConstructorInvokesOverridable\] .+"]},
860 {'category': 'java',
861 'severity': Severity.MEDIUM,
862 'description':
863 'Java: Constructors should not pass the \'this\' reference out in method invocations, since the object may not be fully constructed.',
864 'patterns': [r".*: warning: \[ConstructorLeaksThis\] .+"]},
865 {'category': 'java',
866 'severity': Severity.MEDIUM,
867 'description':
868 'Java: DateFormat is not thread-safe, and should not be used as a constant field.',
869 'patterns': [r".*: warning: \[DateFormatConstant\] .+"]},
870 {'category': 'java',
871 'severity': Severity.MEDIUM,
872 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -0700873 'Java: 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.',
Andreas Gampecf528ca2018-01-25 11:55:43 -0800874 'patterns': [r".*: warning: \[DefaultCharset\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -0700875 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700876 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700877 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -0700878 'Java: Avoid deprecated Thread methods; read the method\'s javadoc for details.',
879 'patterns': [r".*: warning: \[DeprecatedThreadMethods\] .+"]},
880 {'category': 'java',
881 'severity': Severity.MEDIUM,
882 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -0700883 'Java: Prefer collection factory methods or builders to the double-brace initialization pattern.',
884 'patterns': [r".*: warning: \[DoubleBraceInitialization\] .+"]},
885 {'category': 'java',
886 'severity': Severity.MEDIUM,
887 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700888 'Java: Double-checked locking on non-volatile fields is unsafe',
889 'patterns': [r".*: warning: \[DoubleCheckedLocking\] .+"]},
890 {'category': 'java',
891 'severity': Severity.MEDIUM,
892 'description':
Ian Rogers6e520032016-05-13 08:59:00 -0700893 'Java: Empty top-level type declaration',
894 'patterns': [r".*: warning: \[EmptyTopLevelDeclaration\] .+"]},
895 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700896 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700897 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -0700898 'Java: equals() implementation may throw NullPointerException when given null',
899 'patterns': [r".*: warning: \[EqualsBrokenForNull\] .+"]},
900 {'category': 'java',
901 'severity': Severity.MEDIUM,
902 'description':
903 'Java: Overriding Object#equals in a non-final class by using getClass rather than instanceof breaks substitutability of subclasses.',
904 'patterns': [r".*: warning: \[EqualsGetClass\] .+"]},
905 {'category': 'java',
906 'severity': Severity.MEDIUM,
907 'description':
Ian Rogers6e520032016-05-13 08:59:00 -0700908 'Java: Classes that override equals should also override hashCode.',
909 'patterns': [r".*: warning: \[EqualsHashCode\] .+"]},
910 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700911 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700912 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700913 'Java: An equality test between objects with incompatible types always returns false',
914 'patterns': [r".*: warning: \[EqualsIncompatibleType\] .+"]},
915 {'category': 'java',
916 'severity': Severity.MEDIUM,
917 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -0700918 'Java: The contract of #equals states that it should return false for incompatible types, while this implementation may throw ClassCastException.',
919 'patterns': [r".*: warning: \[EqualsUnsafeCast\] .+"]},
920 {'category': 'java',
921 'severity': Severity.MEDIUM,
922 'description':
923 'Java: Implementing #equals by just comparing hashCodes is fragile. Hashes collide frequently, and this will lead to false positives in #equals.',
924 'patterns': [r".*: warning: \[EqualsUsingHashCode\] .+"]},
925 {'category': 'java',
926 'severity': Severity.MEDIUM,
927 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800928 'Java: Calls to ExpectedException#expect should always be followed by exactly one statement.',
929 'patterns': [r".*: warning: \[ExpectedExceptionChecker\] .+"]},
930 {'category': 'java',
931 'severity': Severity.MEDIUM,
932 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -0700933 'Java: When only using JUnit Assert\'s static methods, you should import statically instead of extending.',
934 'patterns': [r".*: warning: \[ExtendingJUnitAssert\] .+"]},
935 {'category': 'java',
936 'severity': Severity.MEDIUM,
937 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800938 'Java: Switch case may fall through',
939 'patterns': [r".*: warning: \[FallThrough\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -0700940 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700941 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700942 'description':
943 'Java: If you return or throw from a finally, then values returned or thrown from the try-catch block will be ignored. Consider using try-with-resources instead.',
944 'patterns': [r".*: warning: \[Finally\] .+"]},
945 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700946 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700947 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800948 'Java: Use parentheses to make the precedence explicit',
949 'patterns': [r".*: warning: \[FloatCast\] .+"]},
950 {'category': 'java',
951 'severity': Severity.MEDIUM,
952 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -0700953 'Java: 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.',
954 'patterns': [r".*: warning: \[FloatingPointAssertionWithinEpsilon\] .+"]},
955 {'category': 'java',
956 'severity': Severity.MEDIUM,
957 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800958 'Java: Floating point literal loses precision',
959 'patterns': [r".*: warning: \[FloatingPointLiteralPrecision\] .+"]},
960 {'category': 'java',
961 'severity': Severity.MEDIUM,
962 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700963 'Java: Classes extending PreferenceActivity must implement isValidFragment such that it does not unconditionally return true to prevent vulnerability to fragment injection attacks.',
964 'patterns': [r".*: warning: \[FragmentInjection\] .+"]},
965 {'category': 'java',
966 'severity': Severity.MEDIUM,
967 'description':
968 'Java: Subclasses of Fragment must be instantiable via Class#newInstance(): the class must be public, static and have a public nullary constructor',
969 'patterns': [r".*: warning: \[FragmentNotInstantiable\] .+"]},
970 {'category': 'java',
971 'severity': Severity.MEDIUM,
972 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800973 'Java: Overloads will be ambiguous when passing lambda arguments',
974 'patterns': [r".*: warning: \[FunctionalInterfaceClash\] .+"]},
975 {'category': 'java',
976 'severity': Severity.MEDIUM,
977 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800978 'Java: Return value of methods returning Future must be checked. Ignoring returned Futures suppresses exceptions thrown from the code that completes the Future.',
979 'patterns': [r".*: warning: \[FutureReturnValueIgnored\] .+"]},
980 {'category': 'java',
981 'severity': Severity.MEDIUM,
982 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800983 'Java: Calling getClass() on an enum may return a subclass of the enum type',
984 'patterns': [r".*: warning: \[GetClassOnEnum\] .+"]},
985 {'category': 'java',
986 'severity': Severity.MEDIUM,
987 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700988 'Java: Hardcoded reference to /sdcard',
989 'patterns': [r".*: warning: \[HardCodedSdCardPath\] .+"]},
990 {'category': 'java',
991 'severity': Severity.MEDIUM,
992 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800993 'Java: Hiding fields of superclasses may cause confusion and errors',
994 'patterns': [r".*: warning: \[HidingField\] .+"]},
995 {'category': 'java',
996 'severity': Severity.MEDIUM,
997 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700998 'Java: Annotations should always be immutable',
999 'patterns': [r".*: warning: \[ImmutableAnnotationChecker\] .+"]},
1000 {'category': 'java',
1001 'severity': Severity.MEDIUM,
1002 'description':
1003 'Java: Enums should always be immutable',
1004 'patterns': [r".*: warning: \[ImmutableEnumChecker\] .+"]},
1005 {'category': 'java',
1006 'severity': Severity.MEDIUM,
1007 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001008 'Java: This annotation has incompatible modifiers as specified by its @IncompatibleModifiers annotation',
1009 'patterns': [r".*: warning: \[IncompatibleModifiers\] .+"]},
1010 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001011 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001012 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001013 'Java: It is confusing to have a field and a parameter under the same scope that differ only in capitalization.',
1014 'patterns': [r".*: warning: \[InconsistentCapitalization\] .+"]},
1015 {'category': 'java',
1016 'severity': Severity.MEDIUM,
1017 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001018 'Java: Including fields in hashCode which are not compared in equals violates the contract of hashCode.',
1019 'patterns': [r".*: warning: \[InconsistentHashCode\] .+"]},
1020 {'category': 'java',
1021 'severity': Severity.MEDIUM,
1022 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001023 'Java: The ordering of parameters in overloaded methods should be as consistent as possible (when viewed from left to right)',
1024 'patterns': [r".*: warning: \[InconsistentOverloads\] .+"]},
1025 {'category': 'java',
1026 'severity': Severity.MEDIUM,
1027 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001028 'Java: This for loop increments the same variable in the header and in the body',
1029 'patterns': [r".*: warning: \[IncrementInForLoopAndHeader\] .+"]},
1030 {'category': 'java',
1031 'severity': Severity.MEDIUM,
1032 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001033 'Java: Constructors on abstract classes are never directly @Injected, only the constructors of their subclasses can be @Inject\'ed.',
1034 'patterns': [r".*: warning: \[InjectOnConstructorOfAbstractClass\] .+"]},
1035 {'category': 'java',
1036 'severity': Severity.MEDIUM,
1037 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001038 'Java: Please also override int read(byte[], int, int), otherwise multi-byte reads from this input stream are likely to be slow.',
1039 'patterns': [r".*: warning: \[InputStreamSlowMultibyteRead\] .+"]},
1040 {'category': 'java',
1041 'severity': Severity.MEDIUM,
1042 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001043 'Java: Casting inside an if block should be plausibly consistent with the instanceof type',
1044 'patterns': [r".*: warning: \[InstanceOfAndCastMatchWrongType\] .+"]},
1045 {'category': 'java',
1046 'severity': Severity.MEDIUM,
1047 'description':
1048 'Java: Expression of type int may overflow before being assigned to a long',
1049 'patterns': [r".*: warning: \[IntLongMath\] .+"]},
1050 {'category': 'java',
1051 'severity': Severity.MEDIUM,
1052 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001053 'Java: This @param tag doesn\'t refer to a parameter of the method.',
1054 'patterns': [r".*: warning: \[InvalidParam\] .+"]},
1055 {'category': 'java',
1056 'severity': Severity.MEDIUM,
1057 'description':
1058 'Java: This tag is invalid.',
1059 'patterns': [r".*: warning: \[InvalidTag\] .+"]},
1060 {'category': 'java',
1061 'severity': Severity.MEDIUM,
1062 'description':
1063 'Java: The documented method doesn\'t actually throw this checked exception.',
1064 'patterns': [r".*: warning: \[InvalidThrows\] .+"]},
1065 {'category': 'java',
1066 'severity': Severity.MEDIUM,
1067 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001068 'Java: Class should not implement both `Iterable` and `Iterator`',
1069 'patterns': [r".*: warning: \[IterableAndIterator\] .+"]},
1070 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001071 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001072 'description':
1073 'Java: Floating-point comparison without error tolerance',
1074 'patterns': [r".*: warning: \[JUnit3FloatingPointComparisonWithoutDelta\] .+"]},
1075 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001076 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001077 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001078 'Java: Some JUnit4 construct cannot be used in a JUnit3 context. Convert your class to JUnit4 style to use them.',
1079 'patterns': [r".*: warning: \[JUnit4ClassUsedInJUnit3\] .+"]},
1080 {'category': 'java',
1081 'severity': Severity.MEDIUM,
1082 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001083 'Java: Test class inherits from JUnit 3\'s TestCase but has JUnit 4 @Test annotations.',
1084 'patterns': [r".*: warning: \[JUnitAmbiguousTestClass\] .+"]},
1085 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001086 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001087 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001088 'Java: Never reuse class names from java.lang',
1089 'patterns': [r".*: warning: \[JavaLangClash\] .+"]},
1090 {'category': 'java',
1091 'severity': Severity.MEDIUM,
1092 'description':
1093 'Java: Suggests alternatives to obsolete JDK classes.',
1094 'patterns': [r".*: warning: \[JdkObsolete\] .+"]},
1095 {'category': 'java',
1096 'severity': Severity.MEDIUM,
1097 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001098 'Java: Calls to Lock#lock should be immediately followed by a try block which releases the lock.',
1099 'patterns': [r".*: warning: \[LockNotBeforeTry\] .+"]},
1100 {'category': 'java',
1101 'severity': Severity.MEDIUM,
1102 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001103 'Java: Assignment where a boolean expression was expected; use == if this assignment wasn\'t expected or add parentheses for clarity.',
1104 'patterns': [r".*: warning: \[LogicalAssignment\] .+"]},
1105 {'category': 'java',
1106 'severity': Severity.MEDIUM,
1107 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001108 'Java: Math.abs does not always give a positive result. Please consider other methods for positive random numbers.',
1109 'patterns': [r".*: warning: \[MathAbsoluteRandom\] .+"]},
1110 {'category': 'java',
1111 'severity': Severity.MEDIUM,
1112 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001113 'Java: Switches on enum types should either handle all values, or have a default case.',
Ian Rogers6e520032016-05-13 08:59:00 -07001114 'patterns': [r".*: warning: \[MissingCasesInEnumSwitch\] .+"]},
1115 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001116 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001117 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001118 'Java: 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.)',
1119 'patterns': [r".*: warning: \[MissingDefault\] .+"]},
1120 {'category': 'java',
1121 'severity': Severity.MEDIUM,
1122 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001123 'Java: Not calling fail() when expecting an exception masks bugs',
1124 'patterns': [r".*: warning: \[MissingFail\] .+"]},
1125 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001126 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001127 'description':
1128 'Java: method overrides method in supertype; expected @Override',
1129 'patterns': [r".*: warning: \[MissingOverride\] .+"]},
1130 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001131 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001132 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001133 'Java: A collection or proto builder was created, but its values were never accessed.',
1134 'patterns': [r".*: warning: \[ModifiedButNotUsed\] .+"]},
1135 {'category': 'java',
1136 'severity': Severity.MEDIUM,
1137 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001138 'Java: Modifying a collection while iterating over it in a loop may cause a ConcurrentModificationException to be thrown.',
1139 'patterns': [r".*: warning: \[ModifyCollectionInEnhancedForLoop\] .+"]},
1140 {'category': 'java',
1141 'severity': Severity.MEDIUM,
1142 'description':
1143 'Java: Multiple calls to either parallel or sequential are unnecessary and cause confusion.',
1144 'patterns': [r".*: warning: \[MultipleParallelOrSequentialCalls\] .+"]},
1145 {'category': 'java',
1146 'severity': Severity.MEDIUM,
1147 'description':
1148 'Java: Constant field declarations should use the immutable type (such as ImmutableList) instead of the general collection interface type (such as List)',
1149 'patterns': [r".*: warning: \[MutableConstantField\] .+"]},
1150 {'category': 'java',
1151 'severity': Severity.MEDIUM,
1152 'description':
1153 'Java: Method return type should use the immutable type (such as ImmutableList) instead of the general collection interface type (such as List)',
1154 'patterns': [r".*: warning: \[MutableMethodReturnType\] .+"]},
1155 {'category': 'java',
1156 'severity': Severity.MEDIUM,
1157 'description':
1158 'Java: Compound assignments may hide dangerous casts',
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001159 'patterns': [r".*: warning: \[NarrowingCompoundAssignment\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001160 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001161 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001162 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001163 'Java: Nested instanceOf conditions of disjoint types create blocks of code that never execute',
1164 'patterns': [r".*: warning: \[NestedInstanceOfConditions\] .+"]},
1165 {'category': 'java',
1166 'severity': Severity.MEDIUM,
1167 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001168 'Java: Instead of returning a functional type, return the actual type that the returned function would return and use lambdas at use site.',
1169 'patterns': [r".*: warning: \[NoFunctionalReturnType\] .+"]},
1170 {'category': 'java',
1171 'severity': Severity.MEDIUM,
1172 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001173 'Java: This update of a volatile variable is non-atomic',
1174 'patterns': [r".*: warning: \[NonAtomicVolatileUpdate\] .+"]},
1175 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001176 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001177 'description':
1178 'Java: Static import of member uses non-canonical name',
1179 'patterns': [r".*: warning: \[NonCanonicalStaticMemberImport\] .+"]},
1180 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001181 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001182 'description':
1183 'Java: equals method doesn\'t override Object.equals',
1184 'patterns': [r".*: warning: \[NonOverridingEquals\] .+"]},
1185 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001186 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001187 'description':
1188 'Java: Constructors should not be annotated with @Nullable since they cannot return null',
1189 'patterns': [r".*: warning: \[NullableConstructor\] .+"]},
1190 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001191 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001192 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001193 'Java: Dereference of possibly-null value',
1194 'patterns': [r".*: warning: \[NullableDereference\] .+"]},
1195 {'category': 'java',
1196 'severity': Severity.MEDIUM,
1197 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001198 'Java: @Nullable should not be used for primitive types since they cannot be null',
1199 'patterns': [r".*: warning: \[NullablePrimitive\] .+"]},
1200 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001201 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001202 'description':
1203 'Java: void-returning methods should not be annotated with @Nullable, since they cannot return null',
1204 'patterns': [r".*: warning: \[NullableVoid\] .+"]},
1205 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001206 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001207 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001208 'Java: Calling toString on Objects that don\'t override toString() doesn\'t provide useful information',
1209 'patterns': [r".*: warning: \[ObjectToString\] .+"]},
1210 {'category': 'java',
1211 'severity': Severity.MEDIUM,
1212 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001213 'Java: Objects.hashCode(Object o) should not be passed a primitive value',
1214 'patterns': [r".*: warning: \[ObjectsHashCodePrimitive\] .+"]},
1215 {'category': 'java',
1216 'severity': Severity.MEDIUM,
1217 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001218 'Java: Use grouping parenthesis to make the operator precedence explicit',
1219 'patterns': [r".*: warning: \[OperatorPrecedence\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001220 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001221 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001222 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001223 'Java: One should not call optional.get() inside an if statement that checks !optional.isPresent',
1224 'patterns': [r".*: warning: \[OptionalNotPresent\] .+"]},
1225 {'category': 'java',
1226 'severity': Severity.MEDIUM,
1227 'description':
1228 'Java: String literal contains format specifiers, but is not passed to a format method',
1229 'patterns': [r".*: warning: \[OrphanedFormatString\] .+"]},
1230 {'category': 'java',
1231 'severity': Severity.MEDIUM,
1232 'description':
1233 'Java: To return a custom message with a Throwable class, one should override getMessage() instead of toString() for Throwable.',
1234 'patterns': [r".*: warning: \[OverrideThrowableToString\] .+"]},
1235 {'category': 'java',
1236 'severity': Severity.MEDIUM,
1237 'description':
1238 'Java: Varargs doesn\'t agree for overridden method',
1239 'patterns': [r".*: warning: \[Overrides\] .+"]},
1240 {'category': 'java',
1241 'severity': Severity.MEDIUM,
1242 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001243 'Java: This method is not annotated with @Inject, but it overrides a method that is annotated with @com.google.inject.Inject. Guice will inject this method, and it is recommended to annotate it explicitly.',
1244 'patterns': [r".*: warning: \[OverridesGuiceInjectableMethod\] .+"]},
1245 {'category': 'java',
1246 'severity': Severity.MEDIUM,
1247 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001248 'Java: Detects `/* name= */`-style comments on actual parameters where the name doesn\'t match the formal parameter',
1249 'patterns': [r".*: warning: \[ParameterName\] .+"]},
1250 {'category': 'java',
1251 'severity': Severity.MEDIUM,
1252 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001253 'Java: Preconditions only accepts the %s placeholder in error message strings',
1254 'patterns': [r".*: warning: \[PreconditionsInvalidPlaceholder\] .+"]},
1255 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001256 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001257 'description':
1258 'Java: Passing a primitive array to a varargs method is usually wrong',
1259 'patterns': [r".*: warning: \[PrimitiveArrayPassedToVarargsMethod\] .+"]},
1260 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001261 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001262 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001263 'Java: A field on a protocol buffer was set twice in the same chained expression.',
1264 'patterns': [r".*: warning: \[ProtoRedundantSet\] .+"]},
1265 {'category': 'java',
1266 'severity': Severity.MEDIUM,
1267 'description':
1268 'Java: 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.',
1269 'patterns': [r".*: warning: \[ProtosAsKeyOfSetOrMap\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001270 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001271 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001272 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001273 'Java: BugChecker has incorrect ProvidesFix tag, please update',
1274 'patterns': [r".*: warning: \[ProvidesFix\] .+"]},
1275 {'category': 'java',
1276 'severity': Severity.MEDIUM,
1277 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001278 'Java: Qualifiers/Scope annotations on @Inject methods don\'t have any effect. Move the qualifier annotation to the binding location.',
1279 'patterns': [r".*: warning: \[QualifierOrScopeOnInjectMethod\] .+"]},
1280 {'category': 'java',
1281 'severity': Severity.MEDIUM,
1282 'description':
1283 'Java: Injection frameworks currently don\'t understand Qualifiers in TYPE_PARAMETER or TYPE_USE contexts.',
Andreas Gampe2e987af2018-06-08 09:55:41 -07001284 'patterns': [r".*: warning: \[QualifierWithTypeUse\] .+"]},
1285 {'category': 'java',
1286 'severity': Severity.MEDIUM,
1287 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001288 'Java: reachabilityFence should always be called inside a finally block',
1289 'patterns': [r".*: warning: \[ReachabilityFenceUsage\] .+"]},
1290 {'category': 'java',
1291 'severity': Severity.MEDIUM,
1292 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001293 'Java: Thrown exception is a subtype of another',
1294 'patterns': [r".*: warning: \[RedundantThrows\] .+"]},
1295 {'category': 'java',
1296 'severity': Severity.MEDIUM,
1297 'description':
1298 'Java: Comparison using reference equality instead of value equality',
1299 'patterns': [r".*: warning: \[ReferenceEquality\] .+"]},
1300 {'category': 'java',
1301 'severity': Severity.MEDIUM,
1302 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001303 'Java: This annotation is missing required modifiers as specified by its @RequiredModifiers annotation',
1304 'patterns': [r".*: warning: \[RequiredModifiers\] .+"]},
1305 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001306 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001307 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001308 'Java: Void methods should not have a @return tag.',
1309 'patterns': [r".*: warning: \[ReturnFromVoid\] .+"]},
1310 {'category': 'java',
1311 'severity': Severity.MEDIUM,
1312 'description':
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07001313 u'Java: Prefer the short-circuiting boolean operators \u0026\u0026 and || to \u0026 and |.',
Andreas Gampecf528ca2018-01-25 11:55:43 -08001314 'patterns': [r".*: warning: \[ShortCircuitBoolean\] .+"]},
1315 {'category': 'java',
1316 'severity': Severity.MEDIUM,
1317 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001318 'Java: Writes to static fields should not be guarded by instance locks',
1319 'patterns': [r".*: warning: \[StaticGuardedByInstance\] .+"]},
1320 {'category': 'java',
1321 'severity': Severity.MEDIUM,
1322 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001323 'Java: A static variable or method should be qualified with a class name, not expression',
1324 'patterns': [r".*: warning: \[StaticQualifiedUsingExpression\] .+"]},
1325 {'category': 'java',
1326 'severity': Severity.MEDIUM,
1327 'description':
1328 'Java: Streams that encapsulate a closeable resource should be closed using try-with-resources',
1329 'patterns': [r".*: warning: \[StreamResourceLeak\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001330 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001331 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001332 'description':
1333 'Java: String comparison using reference equality instead of value equality',
1334 'patterns': [r".*: warning: \[StringEquality\] .+"]},
1335 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001336 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001337 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001338 'Java: String.split(String) has surprising behavior',
Andreas Gampecf528ca2018-01-25 11:55:43 -08001339 'patterns': [r".*: warning: \[StringSplitter\] .+"]},
1340 {'category': 'java',
1341 'severity': Severity.MEDIUM,
1342 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001343 'Java: SWIG generated code that can\'t call a C++ destructor will leak memory',
1344 'patterns': [r".*: warning: \[SwigMemoryLeak\] .+"]},
1345 {'category': 'java',
1346 'severity': Severity.MEDIUM,
1347 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001348 'Java: Synchronizing on non-final fields is not safe: if the field is ever updated, different threads may end up locking on different objects.',
1349 'patterns': [r".*: warning: \[SynchronizeOnNonFinalField\] .+"]},
1350 {'category': 'java',
1351 'severity': Severity.MEDIUM,
1352 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001353 'Java: Code that contains System.exit() is untestable.',
1354 'patterns': [r".*: warning: \[SystemExitOutsideMain\] .+"]},
1355 {'category': 'java',
1356 'severity': Severity.MEDIUM,
1357 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001358 'Java: Using @Test(expected=...) is discouraged, since the test will pass if *any* statement in the test method throws the expected exception',
1359 'patterns': [r".*: warning: \[TestExceptionChecker\] .+"]},
1360 {'category': 'java',
1361 'severity': Severity.MEDIUM,
1362 'description':
1363 'Java: Thread.join needs to be surrounded by a loop until it succeeds, as in Uninterruptibles.joinUninterruptibly.',
1364 'patterns': [r".*: warning: \[ThreadJoinLoop\] .+"]},
1365 {'category': 'java',
1366 'severity': Severity.MEDIUM,
1367 'description':
1368 'Java: ThreadLocals should be stored in static fields',
1369 'patterns': [r".*: warning: \[ThreadLocalUsage\] .+"]},
1370 {'category': 'java',
1371 'severity': Severity.MEDIUM,
1372 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001373 'Java: Relying on the thread scheduler is discouraged; see Effective Java Item 72 (2nd edition) / 84 (3rd edition).',
1374 'patterns': [r".*: warning: \[ThreadPriorityCheck\] .+"]},
1375 {'category': 'java',
1376 'severity': Severity.MEDIUM,
1377 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001378 'Java: 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.',
1379 'patterns': [r".*: warning: \[ThreeLetterTimeZoneID\] .+"]},
1380 {'category': 'java',
1381 'severity': Severity.MEDIUM,
1382 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001383 'Java: An implementation of Object.toString() should never return null.',
1384 'patterns': [r".*: warning: \[ToStringReturnsNull\] .+"]},
1385 {'category': 'java',
1386 'severity': Severity.MEDIUM,
1387 'description':
1388 'Java: The actual and expected values appear to be swapped, which results in poor assertion failure messages. The actual value should come first.',
1389 'patterns': [r".*: warning: \[TruthAssertExpected\] .+"]},
1390 {'category': 'java',
1391 'severity': Severity.MEDIUM,
1392 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001393 'Java: Truth Library assert is called on a constant.',
1394 'patterns': [r".*: warning: \[TruthConstantAsserts\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001395 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001396 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001397 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001398 'Java: Argument is not compatible with the subject\'s type.',
1399 'patterns': [r".*: warning: \[TruthIncompatibleType\] .+"]},
1400 {'category': 'java',
1401 'severity': Severity.MEDIUM,
1402 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001403 'Java: Type parameter declaration shadows another named type',
1404 'patterns': [r".*: warning: \[TypeNameShadowing\] .+"]},
1405 {'category': 'java',
1406 'severity': Severity.MEDIUM,
1407 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001408 'Java: Type parameter declaration overrides another type parameter already declared',
1409 'patterns': [r".*: warning: \[TypeParameterShadowing\] .+"]},
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001410 {'category': 'java',
1411 'severity': Severity.MEDIUM,
1412 'description':
1413 'Java: Declaring a type parameter that is only used in the return type is a misuse of generics: operations on the type parameter are unchecked, it hides unsafe casts at invocations of the method, and it interacts badly with method overload resolution.',
1414 'patterns': [r".*: warning: \[TypeParameterUnusedInFormals\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001415 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001416 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001417 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001418 'Java: 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.',
Andreas Gampecf528ca2018-01-25 11:55:43 -08001419 'patterns': [r".*: warning: \[URLEqualsHashCode\] .+"]},
1420 {'category': 'java',
1421 'severity': Severity.MEDIUM,
1422 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001423 'Java: Collection, Iterable, Multimap, and Queue do not have well-defined equals behavior',
1424 'patterns': [r".*: warning: \[UndefinedEquals\] .+"]},
1425 {'category': 'java',
1426 'severity': Severity.MEDIUM,
1427 'description':
1428 'Java: Switch handles all enum values: an explicit default case is unnecessary and defeats error checking for non-exhaustive switches.',
Andreas Gampecf528ca2018-01-25 11:55:43 -08001429 'patterns': [r".*: warning: \[UnnecessaryDefaultInEnumSwitch\] .+"]},
1430 {'category': 'java',
1431 'severity': Severity.MEDIUM,
1432 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001433 'Java: Unnecessary use of grouping parentheses',
1434 'patterns': [r".*: warning: \[UnnecessaryParentheses\] .+"]},
1435 {'category': 'java',
1436 'severity': Severity.MEDIUM,
1437 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001438 'Java: Finalizer may run before native code finishes execution',
1439 'patterns': [r".*: warning: \[UnsafeFinalization\] .+"]},
1440 {'category': 'java',
1441 'severity': Severity.MEDIUM,
1442 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001443 'Java: 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.',
1444 'patterns': [r".*: warning: \[UnsafeReflectiveConstructionCast\] .+"]},
1445 {'category': 'java',
1446 'severity': Severity.MEDIUM,
1447 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001448 'Java: Unsynchronized method overrides a synchronized method.',
1449 'patterns': [r".*: warning: \[UnsynchronizedOverridesSynchronized\] .+"]},
1450 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001451 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001452 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001453 'Java: Unused.',
1454 'patterns': [r".*: warning: \[Unused\] .+"]},
1455 {'category': 'java',
1456 'severity': Severity.MEDIUM,
1457 'description':
1458 'Java: 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.',
1459 'patterns': [r".*: warning: \[UnusedException\] .+"]},
1460 {'category': 'java',
1461 'severity': Severity.MEDIUM,
1462 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001463 'Java: Java assert is used in test. For testing purposes Assert.* matchers should be used.',
1464 'patterns': [r".*: warning: \[UseCorrectAssertInTests\] .+"]},
1465 {'category': 'java',
1466 'severity': Severity.MEDIUM,
1467 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001468 'Java: Non-constant variable missing @Var annotation',
1469 'patterns': [r".*: warning: \[Var\] .+"]},
1470 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001471 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001472 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001473 'Java: variableName and type with the same name would refer to the static field instead of the class',
1474 'patterns': [r".*: warning: \[VariableNameSameAsType\] .+"]},
1475 {'category': 'java',
1476 'severity': Severity.MEDIUM,
1477 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001478 'Java: Because of spurious wakeups, Object.wait() and Condition.await() must always be called in a loop',
1479 'patterns': [r".*: warning: \[WaitNotInLoop\] .+"]},
1480 {'category': 'java',
Andreas Gampecf528ca2018-01-25 11:55:43 -08001481 'severity': Severity.MEDIUM,
1482 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001483 'Java: 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.',
1484 'patterns': [r".*: warning: \[WakelockReleasedDangerously\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08001485 {'category': 'java',
1486 'severity': Severity.HIGH,
1487 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001488 'Java: AndroidInjection.inject() should always be invoked before calling super.lifecycleMethod()',
1489 'patterns': [r".*: warning: \[AndroidInjectionBeforeSuper\] .+"]},
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001490 {'category': 'java',
1491 'severity': Severity.HIGH,
1492 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001493 'Java: Use of class, field, or method that is not compatible with legacy Android devices',
1494 'patterns': [r".*: warning: \[AndroidJdkLibsChecker\] .+"]},
1495 {'category': 'java',
1496 'severity': Severity.HIGH,
1497 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001498 'Java: Reference equality used to compare arrays',
1499 'patterns': [r".*: warning: \[ArrayEquals\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001500 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001501 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001502 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001503 'Java: Arrays.fill(Object[], Object) called with incompatible types.',
1504 'patterns': [r".*: warning: \[ArrayFillIncompatibleType\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001505 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001506 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001507 'description':
1508 'Java: hashcode method on array does not hash array contents',
1509 'patterns': [r".*: warning: \[ArrayHashCode\] .+"]},
1510 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001511 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001512 'description':
1513 'Java: Calling toString on an array does not provide useful information',
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001514 'patterns': [r".*: warning: \[ArrayToString\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001515 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001516 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001517 'description':
1518 'Java: Arrays.asList does not autobox primitive arrays, as one might expect.',
1519 'patterns': [r".*: warning: \[ArraysAsListPrimitiveArray\] .+"]},
1520 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001521 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001522 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001523 'Java: @AssistedInject and @Inject cannot be used on the same constructor.',
1524 'patterns': [r".*: warning: \[AssistedInjectAndInjectOnSameConstructor\] .+"]},
1525 {'category': 'java',
1526 'severity': Severity.HIGH,
1527 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001528 'Java: AsyncCallable should not return a null Future, only a Future whose result is null.',
1529 'patterns': [r".*: warning: \[AsyncCallableReturnsNull\] .+"]},
1530 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001531 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001532 'description':
1533 'Java: AsyncFunction should not return a null Future, only a Future whose result is null.',
1534 'patterns': [r".*: warning: \[AsyncFunctionReturnsNull\] .+"]},
1535 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001536 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001537 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001538 'Java: @AutoFactory and @Inject should not be used in the same type.',
1539 'patterns': [r".*: warning: \[AutoFactoryAtInject\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001540 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001541 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001542 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001543 'Java: Arguments to AutoValue constructor are in the wrong order',
1544 'patterns': [r".*: warning: \[AutoValueConstructorOrderChecker\] .+"]},
1545 {'category': 'java',
1546 'severity': Severity.HIGH,
1547 'description':
1548 'Java: Shift by an amount that is out of range',
1549 'patterns': [r".*: warning: \[BadShiftAmount\] .+"]},
Andreas Gampe2e987af2018-06-08 09:55:41 -07001550 {'category': 'java',
1551 'severity': Severity.HIGH,
1552 'description':
1553 'Java: Object serialized in Bundle may have been flattened to base type.',
1554 'patterns': [r".*: warning: \[BundleDeserializationCast\] .+"]},
1555 {'category': 'java',
1556 'severity': Severity.HIGH,
1557 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001558 'Java: The called constructor accepts a parameter with the same name and type as one of its caller\'s parameters, but its caller doesn\'t pass that parameter to it. It\'s likely that it was intended to.',
1559 'patterns': [r".*: warning: \[ChainingConstructorIgnoresParameter\] .+"]},
1560 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001561 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001562 'description':
1563 'Java: Ignored return value of method that is annotated with @CheckReturnValue',
1564 'patterns': [r".*: warning: \[CheckReturnValue\] .+"]},
1565 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001566 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001567 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001568 'Java: The source file name should match the name of the top-level class it contains',
1569 'patterns': [r".*: warning: \[ClassName\] .+"]},
1570 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001571 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001572 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001573 'Java: Incompatible type as argument to Object-accepting Java collections method',
1574 'patterns': [r".*: warning: \[CollectionIncompatibleType\] .+"]},
1575 {'category': 'java',
1576 'severity': Severity.HIGH,
1577 'description':
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07001578 u'Java: Implementing \'Comparable\u003cT>\' where T is not compatible with the implementing class.',
Andreas Gampecf528ca2018-01-25 11:55:43 -08001579 'patterns': [r".*: warning: \[ComparableType\] .+"]},
1580 {'category': 'java',
1581 'severity': Severity.HIGH,
1582 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001583 'Java: this == null is always false, this != null is always true',
1584 'patterns': [r".*: warning: \[ComparingThisWithNull\] .+"]},
1585 {'category': 'java',
1586 'severity': Severity.HIGH,
1587 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001588 'Java: This comparison method violates the contract',
1589 'patterns': [r".*: warning: \[ComparisonContractViolated\] .+"]},
1590 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001591 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001592 'description':
1593 'Java: Comparison to value that is out of range for the compared type',
1594 'patterns': [r".*: warning: \[ComparisonOutOfRange\] .+"]},
1595 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001596 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001597 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001598 'Java: @CompatibleWith\'s value is not a type argument.',
1599 'patterns': [r".*: warning: \[CompatibleWithAnnotationMisuse\] .+"]},
1600 {'category': 'java',
1601 'severity': Severity.HIGH,
1602 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001603 'Java: Non-compile-time constant expression passed to parameter with @CompileTimeConstant type annotation.',
1604 'patterns': [r".*: warning: \[CompileTimeConstant\] .+"]},
1605 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001606 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001607 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001608 'Java: Non-trivial compile time constant boolean expressions shouldn\'t be used.',
1609 'patterns': [r".*: warning: \[ComplexBooleanConstant\] .+"]},
1610 {'category': 'java',
1611 'severity': Severity.HIGH,
1612 'description':
1613 'Java: 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.',
1614 'patterns': [r".*: warning: \[ConditionalExpressionNumericPromotion\] .+"]},
1615 {'category': 'java',
1616 'severity': Severity.HIGH,
1617 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001618 'Java: Compile-time constant expression overflows',
1619 'patterns': [r".*: warning: \[ConstantOverflow\] .+"]},
1620 {'category': 'java',
1621 'severity': Severity.HIGH,
1622 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001623 'Java: Dagger @Provides methods may not return null unless annotated with @Nullable',
1624 'patterns': [r".*: warning: \[DaggerProvidesNull\] .+"]},
1625 {'category': 'java',
1626 'severity': Severity.HIGH,
1627 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001628 'Java: Exception created but not thrown',
1629 'patterns': [r".*: warning: \[DeadException\] .+"]},
1630 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001631 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001632 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001633 'Java: Thread created but not started',
1634 'patterns': [r".*: warning: \[DeadThread\] .+"]},
1635 {'category': 'java',
1636 'severity': Severity.HIGH,
1637 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001638 'Java: Deprecated item is not annotated with @Deprecated',
1639 'patterns': [r".*: warning: \[DepAnn\] .+"]},
1640 {'category': 'java',
1641 'severity': Severity.HIGH,
1642 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001643 'Java: Division by integer literal zero',
1644 'patterns': [r".*: warning: \[DivZero\] .+"]},
1645 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001646 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001647 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001648 'Java: This method should not be called.',
1649 'patterns': [r".*: warning: \[DoNotCall\] .+"]},
1650 {'category': 'java',
1651 'severity': Severity.HIGH,
1652 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001653 'Java: Empty statement after if',
1654 'patterns': [r".*: warning: \[EmptyIf\] .+"]},
1655 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001656 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001657 'description':
1658 'Java: == NaN always returns false; use the isNaN methods instead',
1659 'patterns': [r".*: warning: \[EqualsNaN\] .+"]},
1660 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001661 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001662 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001663 'Java: == must be used in equals method to check equality to itself or an infinite loop will occur.',
1664 'patterns': [r".*: warning: \[EqualsReference\] .+"]},
1665 {'category': 'java',
1666 'severity': Severity.HIGH,
1667 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001668 'Java: Comparing different pairs of fields/getters in an equals implementation is probably a mistake.',
1669 'patterns': [r".*: warning: \[EqualsWrongThing\] .+"]},
1670 {'category': 'java',
1671 'severity': Severity.HIGH,
1672 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001673 'Java: Method annotated @ForOverride must be protected or package-private and only invoked from declaring class, or from an override of the method',
Ian Rogers6e520032016-05-13 08:59:00 -07001674 'patterns': [r".*: warning: \[ForOverride\] .+"]},
1675 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001676 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001677 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001678 'Java: Invalid printf-style format string',
1679 'patterns': [r".*: warning: \[FormatString\] .+"]},
1680 {'category': 'java',
1681 'severity': Severity.HIGH,
1682 'description':
1683 'Java: Invalid format string passed to formatting method.',
1684 'patterns': [r".*: warning: \[FormatStringAnnotation\] .+"]},
1685 {'category': 'java',
1686 'severity': Severity.HIGH,
1687 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001688 'Java: Casting a lambda to this @FunctionalInterface can cause a behavior change from casting to a functional superinterface, which is surprising to users. Prefer decorator methods to this surprising behavior.',
1689 'patterns': [r".*: warning: \[FunctionalInterfaceMethodChanged\] .+"]},
1690 {'category': 'java',
1691 'severity': Severity.HIGH,
1692 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001693 'Java: Futures.getChecked requires a checked exception type with a standard constructor.',
1694 'patterns': [r".*: warning: \[FuturesGetCheckedIllegalExceptionType\] .+"]},
1695 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001696 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001697 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001698 'Java: DoubleMath.fuzzyEquals should never be used in an Object.equals() method',
1699 'patterns': [r".*: warning: \[FuzzyEqualsShouldNotBeUsedInEqualsMethod\] .+"]},
1700 {'category': 'java',
1701 'severity': Severity.HIGH,
1702 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001703 'Java: Calling getClass() on an annotation may return a proxy class',
1704 'patterns': [r".*: warning: \[GetClassOnAnnotation\] .+"]},
1705 {'category': 'java',
1706 'severity': Severity.HIGH,
1707 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001708 'Java: Calling getClass() on an object of type Class returns the Class object for java.lang.Class; you probably meant to operate on the object directly',
1709 'patterns': [r".*: warning: \[GetClassOnClass\] .+"]},
1710 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001711 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001712 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001713 'Java: Checks for unguarded accesses to fields and methods with @GuardedBy annotations',
1714 'patterns': [r".*: warning: \[GuardedBy\] .+"]},
1715 {'category': 'java',
1716 'severity': Severity.HIGH,
1717 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001718 'Java: Scope annotation on implementation class of AssistedInject factory is not allowed',
1719 'patterns': [r".*: warning: \[GuiceAssistedInjectScoping\] .+"]},
1720 {'category': 'java',
1721 'severity': Severity.HIGH,
1722 'description':
1723 'Java: A constructor cannot have two @Assisted parameters of the same type unless they are disambiguated with named @Assisted annotations.',
1724 'patterns': [r".*: warning: \[GuiceAssistedParameters\] .+"]},
1725 {'category': 'java',
1726 'severity': Severity.HIGH,
1727 'description':
1728 'Java: Although Guice allows injecting final fields, doing so is disallowed because the injected value may not be visible to other threads.',
1729 'patterns': [r".*: warning: \[GuiceInjectOnFinalField\] .+"]},
1730 {'category': 'java',
1731 'severity': Severity.HIGH,
1732 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001733 'Java: contains() is a legacy method that is equivalent to containsValue()',
1734 'patterns': [r".*: warning: \[HashtableContains\] .+"]},
1735 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001736 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001737 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001738 'Java: A binary expression where both operands are the same is usually incorrect.',
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001739 'patterns': [r".*: warning: \[IdentityBinaryExpression\] .+"]},
1740 {'category': 'java',
1741 'severity': Severity.HIGH,
1742 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001743 'Java: Type declaration annotated with @Immutable is not immutable',
1744 'patterns': [r".*: warning: \[Immutable\] .+"]},
1745 {'category': 'java',
1746 'severity': Severity.HIGH,
1747 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001748 'Java: Modifying an immutable collection is guaranteed to throw an exception and leave the collection unmodified',
1749 'patterns': [r".*: warning: \[ImmutableModification\] .+"]},
1750 {'category': 'java',
1751 'severity': Severity.HIGH,
1752 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001753 'Java: Passing argument to a generic method with an incompatible type.',
1754 'patterns': [r".*: warning: \[IncompatibleArgumentType\] .+"]},
1755 {'category': 'java',
1756 'severity': Severity.HIGH,
1757 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001758 'Java: The first argument to indexOf is a Unicode code point, and the second is the index to start the search from',
1759 'patterns': [r".*: warning: \[IndexOfChar\] .+"]},
1760 {'category': 'java',
1761 'severity': Severity.HIGH,
1762 'description':
1763 'Java: Conditional expression in varargs call contains array and non-array arguments',
1764 'patterns': [r".*: warning: \[InexactVarargsConditional\] .+"]},
1765 {'category': 'java',
1766 'severity': Severity.HIGH,
1767 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001768 'Java: This method always recurses, and will cause a StackOverflowError',
1769 'patterns': [r".*: warning: \[InfiniteRecursion\] .+"]},
1770 {'category': 'java',
1771 'severity': Severity.HIGH,
1772 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001773 'Java: A scoping annotation\'s Target should include TYPE and METHOD.',
1774 'patterns': [r".*: warning: \[InjectInvalidTargetingOnScopingAnnotation\] .+"]},
1775 {'category': 'java',
1776 'severity': Severity.HIGH,
1777 'description':
1778 'Java: Using more than one qualifier annotation on the same element is not allowed.',
1779 'patterns': [r".*: warning: \[InjectMoreThanOneQualifier\] .+"]},
1780 {'category': 'java',
1781 'severity': Severity.HIGH,
1782 'description':
1783 'Java: A class can be annotated with at most one scope annotation.',
1784 'patterns': [r".*: warning: \[InjectMoreThanOneScopeAnnotationOnClass\] .+"]},
1785 {'category': 'java',
1786 'severity': Severity.HIGH,
1787 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001788 'Java: Members shouldn\'t be annotated with @Inject if constructor is already annotated @Inject',
1789 'patterns': [r".*: warning: \[InjectOnMemberAndConstructor\] .+"]},
1790 {'category': 'java',
1791 'severity': Severity.HIGH,
1792 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001793 'Java: Scope annotation on an interface or abstact class is not allowed',
1794 'patterns': [r".*: warning: \[InjectScopeAnnotationOnInterfaceOrAbstractClass\] .+"]},
1795 {'category': 'java',
1796 'severity': Severity.HIGH,
1797 'description':
1798 'Java: Scoping and qualifier annotations must have runtime retention.',
1799 'patterns': [r".*: warning: \[InjectScopeOrQualifierAnnotationRetention\] .+"]},
1800 {'category': 'java',
1801 'severity': Severity.HIGH,
1802 'description':
1803 'Java: Injected constructors cannot be optional nor have binding annotations',
1804 'patterns': [r".*: warning: \[InjectedConstructorAnnotations\] .+"]},
1805 {'category': 'java',
1806 'severity': Severity.HIGH,
1807 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001808 'Java: A standard cryptographic operation is used in a mode that is prone to vulnerabilities',
1809 'patterns': [r".*: warning: \[InsecureCryptoUsage\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001810 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001811 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001812 'description':
1813 'Java: Invalid syntax used for a regular expression',
1814 'patterns': [r".*: warning: \[InvalidPatternSyntax\] .+"]},
1815 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001816 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001817 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001818 'Java: Invalid time zone identifier. TimeZone.getTimeZone(String) will silently return GMT instead of the time zone you intended.',
1819 'patterns': [r".*: warning: \[InvalidTimeZoneID\] .+"]},
1820 {'category': 'java',
1821 'severity': Severity.HIGH,
1822 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001823 'Java: The argument to Class#isInstance(Object) should not be a Class',
1824 'patterns': [r".*: warning: \[IsInstanceOfClass\] .+"]},
1825 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001826 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001827 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001828 'Java: Log tag too long, cannot exceed 23 characters.',
1829 'patterns': [r".*: warning: \[IsLoggableTagLength\] .+"]},
1830 {'category': 'java',
1831 'severity': Severity.HIGH,
1832 'description':
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07001833 u'Java: Path implements Iterable\u003cPath>; prefer Collection\u003cPath> for clarity',
Andreas Gampecf528ca2018-01-25 11:55:43 -08001834 'patterns': [r".*: warning: \[IterablePathParameter\] .+"]},
1835 {'category': 'java',
1836 'severity': Severity.HIGH,
1837 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001838 'Java: jMock tests must have a @RunWith(JMock.class) annotation, or the Mockery field must have a @Rule JUnit annotation',
1839 'patterns': [r".*: warning: \[JMockTestWithoutRunWithOrRuleAnnotation\] .+"]},
1840 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001841 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001842 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001843 'Java: Test method will not be run; please correct method signature (Should be public, non-static, and method name should begin with "test").',
Ian Rogers6e520032016-05-13 08:59:00 -07001844 'patterns': [r".*: warning: \[JUnit3TestNotRun\] .+"]},
1845 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001846 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001847 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001848 'Java: This method should be static',
1849 'patterns': [r".*: warning: \[JUnit4ClassAnnotationNonStatic\] .+"]},
1850 {'category': 'java',
1851 'severity': Severity.HIGH,
1852 'description':
1853 'Java: setUp() method will not be run; please add JUnit\'s @Before annotation',
Ian Rogers6e520032016-05-13 08:59:00 -07001854 'patterns': [r".*: warning: \[JUnit4SetUpNotRun\] .+"]},
1855 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001856 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001857 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001858 'Java: tearDown() method will not be run; please add JUnit\'s @After annotation',
Ian Rogers6e520032016-05-13 08:59:00 -07001859 'patterns': [r".*: warning: \[JUnit4TearDownNotRun\] .+"]},
1860 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001861 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001862 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001863 'Java: 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.',
Ian Rogers6e520032016-05-13 08:59:00 -07001864 'patterns': [r".*: warning: \[JUnit4TestNotRun\] .+"]},
1865 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001866 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001867 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001868 'Java: An object is tested for reference equality to itself using JUnit library.',
1869 'patterns': [r".*: warning: \[JUnitAssertSameCheck\] .+"]},
1870 {'category': 'java',
1871 'severity': Severity.HIGH,
1872 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001873 'Java: Use of class, field, or method that is not compatible with JDK 7',
1874 'patterns': [r".*: warning: \[Java7ApiChecker\] .+"]},
1875 {'category': 'java',
1876 'severity': Severity.HIGH,
1877 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001878 'Java: Abstract and default methods are not injectable with javax.inject.Inject',
1879 'patterns': [r".*: warning: \[JavaxInjectOnAbstractMethod\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08001880 {'category': 'java',
1881 'severity': Severity.HIGH,
1882 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001883 'Java: @javax.inject.Inject cannot be put on a final field.',
1884 'patterns': [r".*: warning: \[JavaxInjectOnFinalField\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08001885 {'category': 'java',
1886 'severity': Severity.HIGH,
1887 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001888 'Java: This pattern will silently corrupt certain byte sequences from the serialized protocol message. Use ByteString or byte[] directly',
1889 'patterns': [r".*: warning: \[LiteByteStringUtf8\] .+"]},
1890 {'category': 'java',
1891 'severity': Severity.HIGH,
1892 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001893 'Java: This method does not acquire the locks specified by its @LockMethod annotation',
1894 'patterns': [r".*: warning: \[LockMethodChecker\] .+"]},
1895 {'category': 'java',
1896 'severity': Severity.HIGH,
1897 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001898 'Java: Prefer \'L\' to \'l\' for the suffix to long literals',
1899 'patterns': [r".*: warning: \[LongLiteralLowerCaseSuffix\] .+"]},
Andreas Gampe2e987af2018-06-08 09:55:41 -07001900 {'category': 'java',
1901 'severity': Severity.HIGH,
1902 'description':
1903 'Java: Loop condition is never modified in loop body.',
1904 'patterns': [r".*: warning: \[LoopConditionChecker\] .+"]},
1905 {'category': 'java',
1906 'severity': Severity.HIGH,
1907 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001908 'Java: Math.round(Integer) results in truncation',
1909 'patterns': [r".*: warning: \[MathRoundIntLong\] .+"]},
1910 {'category': 'java',
1911 'severity': Severity.HIGH,
1912 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001913 'Java: Certain resources in `android.R.string` have names that do not match their content',
1914 'patterns': [r".*: warning: \[MislabeledAndroidString\] .+"]},
1915 {'category': 'java',
1916 'severity': Severity.HIGH,
1917 'description':
1918 'Java: Overriding method is missing a call to overridden super method',
1919 'patterns': [r".*: warning: \[MissingSuperCall\] .+"]},
1920 {'category': 'java',
1921 'severity': Severity.HIGH,
1922 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001923 'Java: A terminating method call is required for a test helper to have any effect.',
1924 'patterns': [r".*: warning: \[MissingTestCall\] .+"]},
1925 {'category': 'java',
1926 'severity': Severity.HIGH,
1927 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001928 'Java: Use of "YYYY" (week year) in a date pattern without "ww" (week in year). You probably meant to use "yyyy" (year) instead.',
1929 'patterns': [r".*: warning: \[MisusedWeekYear\] .+"]},
1930 {'category': 'java',
1931 'severity': Severity.HIGH,
1932 'description':
1933 'Java: A bug in Mockito will cause this test to fail at runtime with a ClassCastException',
1934 'patterns': [r".*: warning: \[MockitoCast\] .+"]},
1935 {'category': 'java',
1936 'severity': Severity.HIGH,
1937 'description':
1938 'Java: Missing method call for verify(mock) here',
1939 'patterns': [r".*: warning: \[MockitoUsage\] .+"]},
1940 {'category': 'java',
1941 'severity': Severity.HIGH,
1942 'description':
1943 'Java: Using a collection function with itself as the argument.',
1944 'patterns': [r".*: warning: \[ModifyingCollectionWithItself\] .+"]},
1945 {'category': 'java',
1946 'severity': Severity.HIGH,
1947 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001948 'Java: This class has more than one @Inject-annotated constructor. Please remove the @Inject annotation from all but one of them.',
1949 'patterns': [r".*: warning: \[MoreThanOneInjectableConstructor\] .+"]},
1950 {'category': 'java',
1951 'severity': Severity.HIGH,
1952 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001953 'Java: The result of this method must be closed.',
1954 'patterns': [r".*: warning: \[MustBeClosedChecker\] .+"]},
1955 {'category': 'java',
1956 'severity': Severity.HIGH,
1957 'description':
1958 'Java: The first argument to nCopies is the number of copies, and the second is the item to copy',
1959 'patterns': [r".*: warning: \[NCopiesOfChar\] .+"]},
1960 {'category': 'java',
1961 'severity': Severity.HIGH,
1962 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001963 'Java: @NoAllocation was specified on this method, but something was found that would trigger an allocation',
1964 'patterns': [r".*: warning: \[NoAllocation\] .+"]},
1965 {'category': 'java',
1966 'severity': Severity.HIGH,
1967 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001968 'Java: Static import of type uses non-canonical name',
1969 'patterns': [r".*: warning: \[NonCanonicalStaticImport\] .+"]},
1970 {'category': 'java',
1971 'severity': Severity.HIGH,
1972 'description':
1973 'Java: @CompileTimeConstant parameters should be final or effectively final',
1974 'patterns': [r".*: warning: \[NonFinalCompileTimeConstant\] .+"]},
1975 {'category': 'java',
1976 'severity': Severity.HIGH,
1977 'description':
1978 'Java: Calling getAnnotation on an annotation that is not retained at runtime.',
1979 'patterns': [r".*: warning: \[NonRuntimeAnnotation\] .+"]},
1980 {'category': 'java',
1981 'severity': Severity.HIGH,
1982 'description':
1983 'Java: This conditional expression may evaluate to null, which will result in an NPE when the result is unboxed.',
1984 'patterns': [r".*: warning: \[NullTernary\] .+"]},
1985 {'category': 'java',
1986 'severity': Severity.HIGH,
1987 'description':
1988 'Java: Numeric comparison using reference equality instead of value equality',
1989 'patterns': [r".*: warning: \[NumericEquality\] .+"]},
1990 {'category': 'java',
1991 'severity': Severity.HIGH,
1992 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001993 'Java: Comparison using reference equality instead of value equality',
1994 'patterns': [r".*: warning: \[OptionalEquality\] .+"]},
Andreas Gampe2e987af2018-06-08 09:55:41 -07001995 {'category': 'java',
1996 'severity': Severity.HIGH,
1997 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001998 'Java: Annotations cannot be both Scope annotations and Qualifier annotations: this causes confusion when trying to use them.',
1999 'patterns': [r".*: warning: \[OverlappingQualifierAndScopeAnnotation\] .+"]},
2000 {'category': 'java',
2001 'severity': Severity.HIGH,
2002 'description':
2003 'Java: This method is not annotated with @Inject, but it overrides a method that is annotated with @javax.inject.Inject. The method will not be Injected.',
2004 'patterns': [r".*: warning: \[OverridesJavaxInjectableMethod\] .+"]},
Andreas Gampe2e987af2018-06-08 09:55:41 -07002005 {'category': 'java',
2006 'severity': Severity.HIGH,
2007 'description':
2008 'Java: Declaring types inside package-info.java files is very bad form',
2009 'patterns': [r".*: warning: \[PackageInfo\] .+"]},
2010 {'category': 'java',
2011 'severity': Severity.HIGH,
2012 'description':
2013 'Java: Method parameter has wrong package',
2014 'patterns': [r".*: warning: \[ParameterPackage\] .+"]},
2015 {'category': 'java',
2016 'severity': Severity.HIGH,
2017 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07002018 'Java: Detects classes which implement Parcelable but don\'t have CREATOR',
2019 'patterns': [r".*: warning: \[ParcelableCreator\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08002020 {'category': 'java',
2021 'severity': Severity.HIGH,
2022 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07002023 'Java: Literal passed as first argument to Preconditions.checkNotNull() can never be null',
2024 'patterns': [r".*: warning: \[PreconditionsCheckNotNull\] .+"]},
2025 {'category': 'java',
2026 'severity': Severity.HIGH,
2027 'description':
2028 'Java: First argument to `Preconditions.checkNotNull()` is a primitive rather than an object reference',
2029 'patterns': [r".*: warning: \[PreconditionsCheckNotNullPrimitive\] .+"]},
2030 {'category': 'java',
2031 'severity': Severity.HIGH,
2032 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07002033 'Java: Using ::equals or ::isInstance as an incompatible Predicate; the predicate will always return false',
Andreas Gampe2e987af2018-06-08 09:55:41 -07002034 'patterns': [r".*: warning: \[PredicateIncompatibleType\] .+"]},
2035 {'category': 'java',
2036 'severity': Severity.HIGH,
2037 'description':
2038 'Java: 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.',
2039 'patterns': [r".*: warning: \[PrivateSecurityContractProtoAccess\] .+"]},
2040 {'category': 'java',
2041 'severity': Severity.HIGH,
2042 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07002043 'Java: Protobuf fields cannot be null.',
Andreas Gampe2e987af2018-06-08 09:55:41 -07002044 'patterns': [r".*: warning: \[ProtoFieldNullComparison\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08002045 {'category': 'java',
2046 'severity': Severity.HIGH,
2047 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07002048 'Java: Comparing protobuf fields of type String using reference equality',
2049 'patterns': [r".*: warning: \[ProtoStringFieldReferenceEquality\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08002050 {'category': 'java',
2051 'severity': Severity.HIGH,
2052 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07002053 'Java: To get the tag number of a protocol buffer enum, use getNumber() instead.',
2054 'patterns': [r".*: warning: \[ProtocolBufferOrdinal\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08002055 {'category': 'java',
2056 'severity': Severity.HIGH,
2057 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07002058 'Java: @Provides methods need to be declared in a Module to have any effect.',
2059 'patterns': [r".*: warning: \[ProvidesMethodOutsideOfModule\] .+"]},
2060 {'category': 'java',
2061 'severity': Severity.HIGH,
2062 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07002063 'Java: Casting a random number in the range [0.0, 1.0) to an integer or long always results in 0.',
2064 'patterns': [r".*: warning: \[RandomCast\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08002065 {'category': 'java',
2066 'severity': Severity.HIGH,
2067 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07002068 'Java: Use Random.nextInt(int). Random.nextInt() % n can have negative results',
2069 'patterns': [r".*: warning: \[RandomModInteger\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08002070 {'category': 'java',
2071 'severity': Severity.HIGH,
2072 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07002073 'Java: Return value of android.graphics.Rect.intersect() must be checked',
2074 'patterns': [r".*: warning: \[RectIntersectReturnValueIgnored\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08002075 {'category': 'java',
2076 'severity': Severity.HIGH,
2077 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07002078 'Java: Use of method or class annotated with @RestrictTo',
2079 'patterns': [r".*: warning: \[RestrictTo\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08002080 {'category': 'java',
2081 'severity': Severity.HIGH,
2082 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07002083 'Java: Check for non-whitelisted callers to RestrictedApiChecker.',
2084 'patterns': [r".*: warning: \[RestrictedApiChecker\] .+"]},
2085 {'category': 'java',
2086 'severity': Severity.HIGH,
2087 'description':
2088 'Java: Return value of this method must be used',
2089 'patterns': [r".*: warning: \[ReturnValueIgnored\] .+"]},
2090 {'category': 'java',
2091 'severity': Severity.HIGH,
2092 'description':
2093 'Java: Variable assigned to itself',
2094 'patterns': [r".*: warning: \[SelfAssignment\] .+"]},
2095 {'category': 'java',
2096 'severity': Severity.HIGH,
2097 'description':
2098 'Java: An object is compared to itself',
2099 'patterns': [r".*: warning: \[SelfComparison\] .+"]},
2100 {'category': 'java',
2101 'severity': Severity.HIGH,
2102 'description':
2103 'Java: Testing an object for equality with itself will always be true.',
2104 'patterns': [r".*: warning: \[SelfEquals\] .+"]},
2105 {'category': 'java',
2106 'severity': Severity.HIGH,
2107 'description':
2108 'Java: This method must be called with an even number of arguments.',
2109 'patterns': [r".*: warning: \[ShouldHaveEvenArgs\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08002110 {'category': 'java',
2111 'severity': Severity.HIGH,
2112 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07002113 'Java: Comparison of a size >= 0 is always true, did you intend to check for non-emptiness?',
2114 'patterns': [r".*: warning: \[SizeGreaterThanOrEqualsZero\] .+"]},
2115 {'category': 'java',
2116 'severity': Severity.HIGH,
2117 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07002118 'Java: Static and default interface methods are not natively supported on older Android devices. ',
2119 'patterns': [r".*: warning: \[StaticOrDefaultInterfaceMethod\] .+"]},
Andreas Gampe2e987af2018-06-08 09:55:41 -07002120 {'category': 'java',
2121 'severity': Severity.HIGH,
2122 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07002123 'Java: Calling toString on a Stream does not provide useful information',
2124 'patterns': [r".*: warning: \[StreamToString\] .+"]},
Andreas Gampe2e987af2018-06-08 09:55:41 -07002125 {'category': 'java',
2126 'severity': Severity.HIGH,
2127 'description':
2128 'Java: StringBuilder does not have a char constructor; this invokes the int constructor.',
2129 'patterns': [r".*: warning: \[StringBuilderInitWithChar\] .+"]},
2130 {'category': 'java',
2131 'severity': Severity.HIGH,
2132 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07002133 'Java: String.substring(0) returns the original String',
2134 'patterns': [r".*: warning: \[SubstringOfZero\] .+"]},
2135 {'category': 'java',
2136 'severity': Severity.HIGH,
2137 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07002138 'Java: Suppressing "deprecated" is probably a typo for "deprecation"',
2139 'patterns': [r".*: warning: \[SuppressWarningsDeprecated\] .+"]},
2140 {'category': 'java',
2141 'severity': Severity.HIGH,
2142 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07002143 'Java: throwIfUnchecked(knownCheckedException) is a no-op.',
2144 'patterns': [r".*: warning: \[ThrowIfUncheckedKnownChecked\] .+"]},
2145 {'category': 'java',
2146 'severity': Severity.HIGH,
2147 'description':
2148 'Java: Throwing \'null\' always results in a NullPointerException being thrown.',
2149 'patterns': [r".*: warning: \[ThrowNull\] .+"]},
2150 {'category': 'java',
2151 'severity': Severity.HIGH,
2152 'description':
2153 'Java: isEqualTo should not be used to test an object for equality with itself; the assertion will never fail.',
2154 'patterns': [r".*: warning: \[TruthSelfEquals\] .+"]},
2155 {'category': 'java',
2156 'severity': Severity.HIGH,
2157 'description':
2158 'Java: Catching Throwable/Error masks failures from fail() or assert*() in the try block',
2159 'patterns': [r".*: warning: \[TryFailThrowable\] .+"]},
2160 {'category': 'java',
2161 'severity': Severity.HIGH,
2162 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07002163 'Java: Type parameter used as type qualifier',
2164 'patterns': [r".*: warning: \[TypeParameterQualifier\] .+"]},
2165 {'category': 'java',
2166 'severity': Severity.HIGH,
2167 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07002168 'Java: This method does not acquire the locks specified by its @UnlockMethod annotation',
2169 'patterns': [r".*: warning: \[UnlockMethod\] .+"]},
2170 {'category': 'java',
2171 'severity': Severity.HIGH,
2172 'description':
2173 'Java: Non-generic methods should not be invoked with type arguments',
2174 'patterns': [r".*: warning: \[UnnecessaryTypeArgument\] .+"]},
2175 {'category': 'java',
2176 'severity': Severity.HIGH,
2177 'description':
2178 'Java: Instance created but never used',
2179 'patterns': [r".*: warning: \[UnusedAnonymousClass\] .+"]},
2180 {'category': 'java',
2181 'severity': Severity.HIGH,
2182 'description':
2183 'Java: Collection is modified in place, but the result is not used',
2184 'patterns': [r".*: warning: \[UnusedCollectionModifiedInPlace\] .+"]},
2185 {'category': 'java',
2186 'severity': Severity.HIGH,
2187 'description':
2188 'Java: `var` should not be used as a type name.',
2189 'patterns': [r".*: warning: \[VarTypeName\] .+"]},
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08002190
2191 # End warnings generated by Error Prone
Ian Rogers32bb9bd2016-05-09 23:19:42 -07002192
Ian Rogers6e520032016-05-13 08:59:00 -07002193 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002194 'severity': Severity.UNKNOWN,
Ian Rogers6e520032016-05-13 08:59:00 -07002195 'description': 'Java: Unclassified/unrecognized warnings',
2196 'patterns': [r".*: warning: \[.+\] .+"]},
Ian Rogers32bb9bd2016-05-09 23:19:42 -07002197
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002198 {'category': 'aapt', 'severity': Severity.MEDIUM,
2199 'description': 'aapt: No default translation',
2200 'patterns': [r".*: warning: string '.+' has no default translation in .*"]},
2201 {'category': 'aapt', 'severity': Severity.MEDIUM,
2202 'description': 'aapt: Missing default or required localization',
2203 'patterns': [r".*: warning: \*\*\*\* string '.+' has no default or required localization for '.+' in .+"]},
2204 {'category': 'aapt', 'severity': Severity.MEDIUM,
2205 'description': 'aapt: String marked untranslatable, but translation exists',
2206 'patterns': [r".*: warning: string '.+' in .* marked untranslatable but exists in locale '??_??'"]},
2207 {'category': 'aapt', 'severity': Severity.MEDIUM,
2208 'description': 'aapt: empty span in string',
2209 'patterns': [r".*: warning: empty '.+' span found in text '.+"]},
2210 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2211 'description': 'Taking address of temporary',
2212 'patterns': [r".*: warning: taking address of temporary"]},
2213 {'category': 'C/C++', 'severity': Severity.MEDIUM,
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07002214 'description': 'Taking address of packed member',
2215 'patterns': [r".*: warning: taking address of packed member"]},
2216 {'category': 'C/C++', 'severity': Severity.MEDIUM,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002217 'description': 'Possible broken line continuation',
2218 'patterns': [r".*: warning: backslash and newline separated by space"]},
2219 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wundefined-var-template',
2220 'description': 'Undefined variable template',
2221 'patterns': [r".*: warning: instantiation of variable .* no definition is available"]},
2222 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wundefined-inline',
2223 'description': 'Inline function is not defined',
2224 'patterns': [r".*: warning: inline function '.*' is not defined"]},
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -07002225 # {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Warray-bounds',
2226 # 'description': 'Array subscript out of bounds',
2227 # 'patterns': [r".*: warning: array subscript is above array bounds",
2228 # r".*: warning: Array subscript is undefined",
2229 # r".*: warning: array subscript is below array bounds"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002230 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2231 'description': 'Excess elements in initializer',
2232 'patterns': [r".*: warning: excess elements in .+ initializer"]},
2233 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2234 'description': 'Decimal constant is unsigned only in ISO C90',
2235 'patterns': [r".*: warning: this decimal constant is unsigned only in ISO C90"]},
2236 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmain',
2237 'description': 'main is usually a function',
2238 'patterns': [r".*: warning: 'main' is usually a function"]},
2239 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2240 'description': 'Typedef ignored',
2241 'patterns': [r".*: warning: 'typedef' was ignored in this declaration"]},
2242 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Waddress',
2243 'description': 'Address always evaluates to true',
2244 'patterns': [r".*: warning: the address of '.+' will always evaluate as 'true'"]},
2245 {'category': 'C/C++', 'severity': Severity.FIXMENOW,
2246 'description': 'Freeing a non-heap object',
2247 'patterns': [r".*: warning: attempt to free a non-heap object '.+'"]},
2248 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wchar-subscripts',
2249 'description': 'Array subscript has type char',
2250 'patterns': [r".*: warning: array subscript .+ type 'char'.+Wchar-subscripts"]},
2251 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2252 'description': 'Constant too large for type',
2253 'patterns': [r".*: warning: integer constant is too large for '.+' type"]},
2254 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Woverflow',
2255 'description': 'Constant too large for type, truncated',
2256 'patterns': [r".*: warning: large integer implicitly truncated to unsigned type"]},
2257 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Winteger-overflow',
2258 'description': 'Overflow in expression',
2259 'patterns': [r".*: warning: overflow in expression; .*Winteger-overflow"]},
2260 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Woverflow',
2261 'description': 'Overflow in implicit constant conversion',
2262 'patterns': [r".*: warning: overflow in implicit constant conversion"]},
2263 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2264 'description': 'Declaration does not declare anything',
2265 'patterns': [r".*: warning: declaration 'class .+' does not declare anything"]},
2266 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wreorder',
2267 'description': 'Initialization order will be different',
2268 'patterns': [r".*: warning: '.+' will be initialized after",
2269 r".*: warning: field .+ will be initialized after .+Wreorder"]},
2270 {'category': 'cont.', 'severity': Severity.SKIP,
2271 'description': 'skip, ....',
2272 'patterns': [r".*: warning: '.+'"]},
2273 {'category': 'cont.', 'severity': Severity.SKIP,
2274 'description': 'skip, base ...',
2275 'patterns': [r".*: warning: base '.+'"]},
2276 {'category': 'cont.', 'severity': Severity.SKIP,
2277 'description': 'skip, when initialized here',
2278 'patterns': [r".*: warning: when initialized here"]},
2279 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-parameter-type',
2280 'description': 'Parameter type not specified',
2281 'patterns': [r".*: warning: type of '.+' defaults to 'int'"]},
2282 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-declarations',
2283 'description': 'Missing declarations',
2284 'patterns': [r".*: warning: declaration does not declare anything"]},
2285 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-noreturn',
2286 'description': 'Missing noreturn',
2287 'patterns': [r".*: warning: function '.*' could be declared with attribute 'noreturn'"]},
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002288 # pylint:disable=anomalous-backslash-in-string
2289 # TODO(chh): fix the backslash pylint warning.
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002290 {'category': 'gcc', 'severity': Severity.MEDIUM,
2291 'description': 'Invalid option for C file',
2292 'patterns': [r".*: warning: command line option "".+"" is valid for C\+\+\/ObjC\+\+ but not for C"]},
2293 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2294 'description': 'User warning',
2295 'patterns': [r".*: warning: #warning "".+"""]},
2296 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wvexing-parse',
2297 'description': 'Vexing parsing problem',
2298 'patterns': [r".*: warning: empty parentheses interpreted as a function declaration"]},
2299 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wextra',
2300 'description': 'Dereferencing void*',
2301 'patterns': [r".*: warning: dereferencing 'void \*' pointer"]},
2302 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2303 'description': 'Comparison of pointer and integer',
2304 'patterns': [r".*: warning: ordered comparison of pointer with integer zero",
2305 r".*: warning: .*comparison between pointer and integer"]},
2306 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2307 'description': 'Use of error-prone unary operator',
2308 'patterns': [r".*: warning: use of unary operator that may be intended as compound assignment"]},
2309 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wwrite-strings',
2310 'description': 'Conversion of string constant to non-const char*',
2311 'patterns': [r".*: warning: deprecated conversion from string constant to '.+'"]},
2312 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wstrict-prototypes',
2313 'description': 'Function declaration isn''t a prototype',
2314 'patterns': [r".*: warning: function declaration isn't a prototype"]},
2315 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wignored-qualifiers',
2316 'description': 'Type qualifiers ignored on function return value',
2317 'patterns': [r".*: warning: type qualifiers ignored on function return type",
2318 r".*: warning: .+ type qualifier .+ has no effect .+Wignored-qualifiers"]},
2319 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2320 'description': '<foo> declared inside parameter list, scope limited to this definition',
2321 'patterns': [r".*: warning: '.+' declared inside parameter list"]},
2322 {'category': 'cont.', 'severity': Severity.SKIP,
2323 'description': 'skip, its scope is only this ...',
2324 'patterns': [r".*: warning: its scope is only this definition or declaration, which is probably not what you want"]},
2325 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wcomment',
2326 'description': 'Line continuation inside comment',
2327 'patterns': [r".*: warning: multi-line comment"]},
2328 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wcomment',
2329 'description': 'Comment inside comment',
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -07002330 'patterns': [r".*: warning: '.+' within block comment .*-Wcomment"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002331 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wdeprecated-declarations',
2332 'description': 'Deprecated declarations',
2333 'patterns': [r".*: warning: .+ is deprecated.+deprecated-declarations"]},
2334 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wdeprecated-register',
2335 'description': 'Deprecated register',
2336 'patterns': [r".*: warning: 'register' storage class specifier is deprecated"]},
2337 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wpointer-sign',
2338 'description': 'Converts between pointers to integer types with different sign',
2339 'patterns': [r".*: warning: .+ converts between pointers to integer types with different sign"]},
2340 {'category': 'C/C++', 'severity': Severity.HARMLESS,
2341 'description': 'Extra tokens after #endif',
2342 'patterns': [r".*: warning: extra tokens at end of #endif directive"]},
2343 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wenum-compare',
2344 'description': 'Comparison between different enums',
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -07002345 'patterns': [r".*: warning: comparison between '.+' and '.+'.+Wenum-compare",
2346 r".*: warning: comparison of .* enumeration types .*-Wenum-compare-switch"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002347 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wconversion',
2348 'description': 'Conversion may change value',
2349 'patterns': [r".*: warning: converting negative value '.+' to '.+'",
2350 r".*: warning: conversion to '.+' .+ may (alter|change)"]},
2351 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wconversion-null',
2352 'description': 'Converting to non-pointer type from NULL',
2353 'patterns': [r".*: warning: converting to non-pointer type '.+' from NULL"]},
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07002354 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsign-conversion',
2355 'description': 'Implicit sign conversion',
2356 'patterns': [r".*: warning: implicit conversion changes signedness"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002357 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wnull-conversion',
2358 'description': 'Converting NULL to non-pointer type',
2359 'patterns': [r".*: warning: implicit conversion of NULL constant to '.+'"]},
2360 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wnon-literal-null-conversion',
2361 'description': 'Zero used as null pointer',
2362 'patterns': [r".*: warning: expression .* zero treated as a null pointer constant"]},
2363 {'category': 'C/C++', 'severity': Severity.MEDIUM,
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -07002364 'description': 'Implicit conversion changes value or loses precision',
2365 'patterns': [r".*: warning: implicit conversion .* changes value from .* to .*-conversion",
2366 r".*: warning: implicit conversion loses integer precision:"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002367 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2368 'description': 'Passing NULL as non-pointer argument',
2369 'patterns': [r".*: warning: passing NULL to non-pointer argument [0-9]+ of '.+'"]},
2370 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wctor-dtor-privacy',
2371 'description': 'Class seems unusable because of private ctor/dtor',
2372 'patterns': [r".*: warning: all member functions in class '.+' are private"]},
Marco Nelissen594375d2009-07-14 09:04:04 -07002373 # 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 -07002374 {'category': 'C/C++', 'severity': Severity.SKIP, 'option': '-Wctor-dtor-privacy',
2375 'description': 'Class seems unusable because of private ctor/dtor',
2376 'patterns': [r".*: warning: 'class .+' only defines a private destructor and has no friends"]},
2377 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wctor-dtor-privacy',
2378 'description': 'Class seems unusable because of private ctor/dtor',
2379 'patterns': [r".*: warning: 'class .+' only defines private constructors and has no friends"]},
2380 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wgnu-static-float-init',
2381 'description': 'In-class initializer for static const float/double',
2382 'patterns': [r".*: warning: in-class initializer for static data member of .+const (float|double)"]},
2383 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wpointer-arith',
2384 'description': 'void* used in arithmetic',
2385 'patterns': [r".*: warning: pointer of type 'void \*' used in (arithmetic|subtraction)",
2386 r".*: warning: arithmetic on .+ to void is a GNU extension.*Wpointer-arith",
2387 r".*: warning: wrong type argument to increment"]},
2388 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsign-promo',
2389 'description': 'Overload resolution chose to promote from unsigned or enum to signed type',
2390 'patterns': [r".*: warning: passing '.+' chooses '.+' over '.+'.*Wsign-promo"]},
2391 {'category': 'cont.', 'severity': Severity.SKIP,
2392 'description': 'skip, in call to ...',
2393 'patterns': [r".*: warning: in call to '.+'"]},
2394 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wextra',
2395 'description': 'Base should be explicitly initialized in copy constructor',
2396 'patterns': [r".*: warning: base class '.+' should be explicitly initialized in the copy constructor"]},
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -07002397 # {'category': 'C/C++', 'severity': Severity.MEDIUM,
2398 # 'description': 'VLA has zero or negative size',
2399 # 'patterns': [r".*: warning: Declared variable-length array \(VLA\) has .+ size"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002400 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2401 'description': 'Return value from void function',
2402 'patterns': [r".*: warning: 'return' with a value, in function returning void"]},
2403 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'multichar',
2404 'description': 'Multi-character character constant',
2405 'patterns': [r".*: warning: multi-character character constant"]},
2406 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'writable-strings',
2407 'description': 'Conversion from string literal to char*',
2408 'patterns': [r".*: warning: .+ does not allow conversion from string literal to 'char \*'"]},
2409 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wextra-semi',
2410 'description': 'Extra \';\'',
2411 'patterns': [r".*: warning: extra ';' .+extra-semi"]},
2412 {'category': 'C/C++', 'severity': Severity.LOW,
2413 'description': 'Useless specifier',
2414 'patterns': [r".*: warning: useless storage class specifier in empty declaration"]},
2415 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wduplicate-decl-specifier',
2416 'description': 'Duplicate declaration specifier',
2417 'patterns': [r".*: warning: duplicate '.+' declaration specifier"]},
2418 {'category': 'logtags', 'severity': Severity.LOW,
2419 'description': 'Duplicate logtag',
2420 'patterns': [r".*: warning: tag \".+\" \(.+\) duplicated in .+"]},
2421 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'typedef-redefinition',
2422 'description': 'Typedef redefinition',
2423 'patterns': [r".*: warning: redefinition of typedef '.+' is a C11 feature"]},
2424 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'gnu-designator',
2425 'description': 'GNU old-style field designator',
2426 'patterns': [r".*: warning: use of GNU old-style field designator extension"]},
2427 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'missing-field-initializers',
2428 'description': 'Missing field initializers',
2429 'patterns': [r".*: warning: missing field '.+' initializer"]},
2430 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'missing-braces',
2431 'description': 'Missing braces',
2432 'patterns': [r".*: warning: suggest braces around initialization of",
2433 r".*: warning: too many braces around scalar initializer .+Wmany-braces-around-scalar-init",
2434 r".*: warning: braces around scalar initializer"]},
2435 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'sign-compare',
2436 'description': 'Comparison of integers of different signs',
2437 'patterns': [r".*: warning: comparison of integers of different signs.+sign-compare"]},
2438 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'dangling-else',
2439 'description': 'Add braces to avoid dangling else',
2440 'patterns': [r".*: warning: add explicit braces to avoid dangling else"]},
2441 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'initializer-overrides',
2442 'description': 'Initializer overrides prior initialization',
2443 'patterns': [r".*: warning: initializer overrides prior initialization of this subobject"]},
2444 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'self-assign',
2445 'description': 'Assigning value to self',
2446 'patterns': [r".*: warning: explicitly assigning value of .+ to itself"]},
2447 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'gnu-variable-sized-type-not-at-end',
2448 'description': 'GNU extension, variable sized type not at end',
2449 'patterns': [r".*: warning: field '.+' with variable sized type '.+' not at the end of a struct or class"]},
2450 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'tautological-constant-out-of-range-compare',
2451 'description': 'Comparison of constant is always false/true',
2452 'patterns': [r".*: comparison of .+ is always .+Wtautological-constant-out-of-range-compare"]},
2453 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'overloaded-virtual',
2454 'description': 'Hides overloaded virtual function',
2455 'patterns': [r".*: '.+' hides overloaded virtual function"]},
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -07002456 {'category': 'logtags', 'severity': Severity.LOW,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002457 'description': 'Incompatible pointer types',
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -07002458 'patterns': [r".*: warning: incompatible .*pointer types .*-Wincompatible-.*pointer-types"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002459 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'asm-operand-widths',
2460 'description': 'ASM value size does not match register size',
2461 'patterns': [r".*: warning: value size does not match register size specified by the constraint and modifier"]},
2462 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'tautological-compare',
2463 'description': 'Comparison of self is always false',
2464 'patterns': [r".*: self-comparison always evaluates to false"]},
2465 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'constant-logical-operand',
2466 'description': 'Logical op with constant operand',
2467 'patterns': [r".*: use of logical '.+' with constant operand"]},
2468 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'literal-suffix',
2469 'description': 'Needs a space between literal and string macro',
2470 'patterns': [r".*: warning: invalid suffix on literal.+ requires a space .+Wliteral-suffix"]},
2471 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '#warnings',
2472 'description': 'Warnings from #warning',
2473 'patterns': [r".*: warning: .+-W#warnings"]},
2474 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'absolute-value',
2475 'description': 'Using float/int absolute value function with int/float argument',
2476 'patterns': [r".*: warning: using .+ absolute value function .+ when argument is .+ type .+Wabsolute-value",
2477 r".*: warning: absolute value function '.+' given .+ which may cause truncation .+Wabsolute-value"]},
2478 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wc++11-extensions',
2479 'description': 'Using C++11 extensions',
2480 'patterns': [r".*: warning: 'auto' type specifier is a C\+\+11 extension"]},
2481 {'category': 'C/C++', 'severity': Severity.LOW,
2482 'description': 'Refers to implicitly defined namespace',
2483 'patterns': [r".*: warning: using directive refers to implicitly-defined namespace .+"]},
2484 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Winvalid-pp-token',
2485 'description': 'Invalid pp token',
2486 'patterns': [r".*: warning: missing .+Winvalid-pp-token"]},
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07002487 {'category': 'link', 'severity': Severity.LOW,
2488 'description': 'need glibc to link',
2489 'patterns': [r".*: warning: .* requires at runtime .* glibc .* for linking"]},
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07002490
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002491 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2492 'description': 'Operator new returns NULL',
2493 'patterns': [r".*: warning: 'operator new' must not return NULL unless it is declared 'throw\(\)' .+"]},
2494 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wnull-arithmetic',
2495 'description': 'NULL used in arithmetic',
2496 'patterns': [r".*: warning: NULL used in arithmetic",
2497 r".*: warning: comparison between NULL and non-pointer"]},
2498 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'header-guard',
2499 'description': 'Misspelled header guard',
2500 'patterns': [r".*: warning: '.+' is used as a header guard .+ followed by .+ different macro"]},
2501 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'empty-body',
2502 'description': 'Empty loop body',
2503 'patterns': [r".*: warning: .+ loop has empty body"]},
2504 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'enum-conversion',
2505 'description': 'Implicit conversion from enumeration type',
2506 'patterns': [r".*: warning: implicit conversion from enumeration type '.+'"]},
2507 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'switch',
2508 'description': 'case value not in enumerated type',
2509 'patterns': [r".*: warning: case value not in enumerated type '.+'"]},
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -07002510 # {'category': 'C/C++', 'severity': Severity.MEDIUM,
2511 # 'description': 'Undefined result',
2512 # 'patterns': [r".*: warning: The result of .+ is undefined",
2513 # r".*: warning: passing an object that .+ has undefined behavior \[-Wvarargs\]",
2514 # r".*: warning: 'this' pointer cannot be null in well-defined C\+\+ code;",
2515 # r".*: warning: shifting a negative signed value is undefined"]},
2516 # {'category': 'C/C++', 'severity': Severity.MEDIUM,
2517 # 'description': 'Division by zero',
2518 # 'patterns': [r".*: warning: Division by zero"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002519 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2520 'description': 'Use of deprecated method',
2521 'patterns': [r".*: warning: '.+' is deprecated .+"]},
2522 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2523 'description': 'Use of garbage or uninitialized value',
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -07002524 'patterns': [r".*: warning: .+ uninitialized .+\[-Wsometimes-uninitialized\]"]},
2525 # {'category': 'C/C++', 'severity': Severity.MEDIUM,
2526 # 'description': 'Use of garbage or uninitialized value',
2527 # 'patterns': [r".*: warning: .+ is a garbage value",
2528 # r".*: warning: Function call argument is an uninitialized value",
2529 # r".*: warning: Undefined or garbage value returned to caller",
2530 # r".*: warning: Called .+ pointer is.+uninitialized",
2531 # r".*: warning: Called .+ pointer is.+uninitalized", # match a typo in compiler message
2532 # r".*: warning: Use of zero-allocated memory",
2533 # r".*: warning: Dereference of undefined pointer value",
2534 # r".*: warning: Passed-by-value .+ contains uninitialized data",
2535 # r".*: warning: Branch condition evaluates to a garbage value",
2536 # r".*: warning: The .+ of .+ is an uninitialized value.",
2537 # r".*: warning: .+ is used uninitialized whenever .+sometimes-uninitialized",
2538 # r".*: warning: Assigned value is garbage or undefined"]},
2539 # {'category': 'C/C++', 'severity': Severity.MEDIUM,
2540 # 'description': 'Result of malloc type incompatible with sizeof operand type',
2541 # 'patterns': [r".*: warning: Result of '.+' is converted to .+ incompatible with sizeof operand type"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002542 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsizeof-array-argument',
2543 'description': 'Sizeof on array argument',
2544 'patterns': [r".*: warning: sizeof on array function parameter will return"]},
2545 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsizeof-pointer-memacces',
2546 'description': 'Bad argument size of memory access functions',
2547 'patterns': [r".*: warning: .+\[-Wsizeof-pointer-memaccess\]"]},
2548 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2549 'description': 'Return value not checked',
2550 'patterns': [r".*: warning: The return value from .+ is not checked"]},
2551 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2552 'description': 'Possible heap pollution',
2553 'patterns': [r".*: warning: .*Possible heap pollution from .+ type .+"]},
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -07002554 # {'category': 'C/C++', 'severity': Severity.MEDIUM,
2555 # 'description': 'Allocation size of 0 byte',
2556 # 'patterns': [r".*: warning: Call to .+ has an allocation size of 0 byte"]},
2557 # {'category': 'C/C++', 'severity': Severity.MEDIUM,
2558 # 'description': 'Result of malloc type incompatible with sizeof operand type',
2559 # 'patterns': [r".*: warning: Result of '.+' is converted to .+ incompatible with sizeof operand type"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002560 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wfor-loop-analysis',
2561 'description': 'Variable used in loop condition not modified in loop body',
2562 'patterns': [r".*: warning: variable '.+' used in loop condition.*Wfor-loop-analysis"]},
2563 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2564 'description': 'Closing a previously closed file',
2565 'patterns': [r".*: warning: Closing a previously closed file"]},
2566 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunnamed-type-template-args',
2567 'description': 'Unnamed template type argument',
2568 'patterns': [r".*: warning: template argument.+Wunnamed-type-template-args"]},
Chih-Hung Hsiehe1672862018-08-31 16:19:19 -07002569 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wimplicit-fallthrough',
2570 'description': 'Unannotated fall-through between switch labels',
2571 'patterns': [r".*: warning: unannotated fall-through between switch labels.+Wimplicit-fallthrough"]},
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07002572
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002573 {'category': 'C/C++', 'severity': Severity.HARMLESS,
2574 'description': 'Discarded qualifier from pointer target type',
2575 'patterns': [r".*: warning: .+ discards '.+' qualifier from pointer target type"]},
2576 {'category': 'C/C++', 'severity': Severity.HARMLESS,
2577 'description': 'Use snprintf instead of sprintf',
2578 'patterns': [r".*: warning: .*sprintf is often misused; please use snprintf"]},
2579 {'category': 'C/C++', 'severity': Severity.HARMLESS,
2580 'description': 'Unsupported optimizaton flag',
2581 'patterns': [r".*: warning: optimization flag '.+' is not supported"]},
2582 {'category': 'C/C++', 'severity': Severity.HARMLESS,
2583 'description': 'Extra or missing parentheses',
2584 'patterns': [r".*: warning: equality comparison with extraneous parentheses",
2585 r".*: warning: .+ within .+Wlogical-op-parentheses"]},
2586 {'category': 'C/C++', 'severity': Severity.HARMLESS, 'option': 'mismatched-tags',
2587 'description': 'Mismatched class vs struct tags',
2588 'patterns': [r".*: warning: '.+' defined as a .+ here but previously declared as a .+mismatched-tags",
2589 r".*: warning: .+ was previously declared as a .+mismatched-tags"]},
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07002590 {'category': 'FindEmulator', 'severity': Severity.HARMLESS,
2591 'description': 'FindEmulator: No such file or directory',
2592 'patterns': [r".*: warning: FindEmulator: .* No such file or directory"]},
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -07002593 {'category': 'make', 'severity': Severity.HARMLESS,
2594 'description': 'make: unknown installed file',
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07002595 'patterns': [r".*: warning: .*_tests: Unknown installed file for module"]},
2596 {'category': 'make', 'severity': Severity.HARMLESS,
2597 'description': 'unusual tags debug eng',
2598 'patterns': [r".*: warning: .*: unusual tags debug eng"]},
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -07002599 {'category': 'make', 'severity': Severity.MEDIUM,
2600 'description': 'make: please convert to soong',
2601 'patterns': [r".*: warning: .* has been deprecated. Please convert to Soong."]},
Marco Nelissen594375d2009-07-14 09:04:04 -07002602
2603 # 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 -07002604 {'category': 'C/C++', 'severity': Severity.SKIP,
2605 'description': 'skip, ,',
2606 'patterns': [r".*: warning: ,$"]},
2607 {'category': 'C/C++', 'severity': Severity.SKIP,
2608 'description': 'skip,',
2609 'patterns': [r".*: warning: $"]},
2610 {'category': 'C/C++', 'severity': Severity.SKIP,
2611 'description': 'skip, In file included from ...',
2612 'patterns': [r".*: warning: In file included from .+,"]},
Marco Nelissen594375d2009-07-14 09:04:04 -07002613
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07002614 # warnings from clang-tidy
Chih-Hung Hsieh2cd467b2017-11-16 15:42:11 -08002615 group_tidy_warn_pattern('android'),
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -07002616 simple_tidy_warn_pattern('abseil-string-find-startswith'),
Chih-Hung Hsieh9e9355d2018-06-04 11:32:32 -07002617 simple_tidy_warn_pattern('bugprone-argument-comment'),
2618 simple_tidy_warn_pattern('bugprone-copy-constructor-init'),
2619 simple_tidy_warn_pattern('bugprone-fold-init-type'),
2620 simple_tidy_warn_pattern('bugprone-forward-declaration-namespace'),
2621 simple_tidy_warn_pattern('bugprone-forwarding-reference-overload'),
2622 simple_tidy_warn_pattern('bugprone-inaccurate-erase'),
2623 simple_tidy_warn_pattern('bugprone-incorrect-roundings'),
2624 simple_tidy_warn_pattern('bugprone-integer-division'),
2625 simple_tidy_warn_pattern('bugprone-lambda-function-name'),
2626 simple_tidy_warn_pattern('bugprone-macro-parentheses'),
2627 simple_tidy_warn_pattern('bugprone-misplaced-widening-cast'),
2628 simple_tidy_warn_pattern('bugprone-move-forwarding-reference'),
2629 simple_tidy_warn_pattern('bugprone-sizeof-expression'),
2630 simple_tidy_warn_pattern('bugprone-string-constructor'),
2631 simple_tidy_warn_pattern('bugprone-string-integer-assignment'),
2632 simple_tidy_warn_pattern('bugprone-suspicious-enum-usage'),
2633 simple_tidy_warn_pattern('bugprone-suspicious-missing-comma'),
2634 simple_tidy_warn_pattern('bugprone-suspicious-string-compare'),
2635 simple_tidy_warn_pattern('bugprone-suspicious-semicolon'),
2636 simple_tidy_warn_pattern('bugprone-undefined-memory-manipulation'),
2637 simple_tidy_warn_pattern('bugprone-unused-raii'),
2638 simple_tidy_warn_pattern('bugprone-use-after-move'),
2639 group_tidy_warn_pattern('bugprone'),
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07002640 group_tidy_warn_pattern('cert'),
2641 group_tidy_warn_pattern('clang-diagnostic'),
2642 group_tidy_warn_pattern('cppcoreguidelines'),
2643 group_tidy_warn_pattern('llvm'),
2644 simple_tidy_warn_pattern('google-default-arguments'),
2645 simple_tidy_warn_pattern('google-runtime-int'),
2646 simple_tidy_warn_pattern('google-runtime-operator'),
2647 simple_tidy_warn_pattern('google-runtime-references'),
2648 group_tidy_warn_pattern('google-build'),
2649 group_tidy_warn_pattern('google-explicit'),
2650 group_tidy_warn_pattern('google-redability'),
2651 group_tidy_warn_pattern('google-global'),
2652 group_tidy_warn_pattern('google-redability'),
2653 group_tidy_warn_pattern('google-redability'),
2654 group_tidy_warn_pattern('google'),
2655 simple_tidy_warn_pattern('hicpp-explicit-conversions'),
2656 simple_tidy_warn_pattern('hicpp-function-size'),
2657 simple_tidy_warn_pattern('hicpp-invalid-access-moved'),
2658 simple_tidy_warn_pattern('hicpp-member-init'),
2659 simple_tidy_warn_pattern('hicpp-delete-operators'),
2660 simple_tidy_warn_pattern('hicpp-special-member-functions'),
2661 simple_tidy_warn_pattern('hicpp-use-equals-default'),
2662 simple_tidy_warn_pattern('hicpp-use-equals-delete'),
2663 simple_tidy_warn_pattern('hicpp-no-assembler'),
2664 simple_tidy_warn_pattern('hicpp-noexcept-move'),
2665 simple_tidy_warn_pattern('hicpp-use-override'),
2666 group_tidy_warn_pattern('hicpp'),
2667 group_tidy_warn_pattern('modernize'),
2668 group_tidy_warn_pattern('misc'),
2669 simple_tidy_warn_pattern('performance-faster-string-find'),
2670 simple_tidy_warn_pattern('performance-for-range-copy'),
2671 simple_tidy_warn_pattern('performance-implicit-cast-in-loop'),
2672 simple_tidy_warn_pattern('performance-inefficient-string-concatenation'),
2673 simple_tidy_warn_pattern('performance-type-promotion-in-math-fn'),
2674 simple_tidy_warn_pattern('performance-unnecessary-copy-initialization'),
2675 simple_tidy_warn_pattern('performance-unnecessary-value-param'),
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -07002676 simple_tidy_warn_pattern('portability-simd-intrinsics'),
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07002677 group_tidy_warn_pattern('performance'),
2678 group_tidy_warn_pattern('readability'),
2679
2680 # warnings from clang-tidy's clang-analyzer checks
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -07002681 analyzer_high('clang-analyzer-core, null pointer',
2682 [r".*: warning: .+ pointer is null .*\[clang-analyzer-core"]),
2683 analyzer_high('clang-analyzer-core, uninitialized value',
2684 [r".*: warning: .+ uninitialized (value|data) .*\[clang-analyzer-core"]),
2685 analyzer_warn('clang-analyzer-optin.performance.Padding',
2686 [r".*: warning: Excessive padding in '.*'"]),
2687 # analyzer_warn('clang-analyzer Unreachable code',
2688 # [r".*: warning: This statement is never executed.*UnreachableCode"]),
2689 analyzer_warn('clang-analyzer Size of malloc may overflow',
2690 [r".*: warning: .* size of .* may overflow .*MallocOverflow"]),
2691 analyzer_warn('clang-analyzer sozeof() on a pointer type',
2692 [r".*: warning: .*calls sizeof.* on a pointer type.*SizeofPtr"]),
2693 analyzer_warn('clang-analyzer Pointer arithmetic on non-array variables',
2694 [r".*: warning: Pointer arithmetic on non-array variables .*PointerArithm"]),
2695 analyzer_warn('clang-analyzer Subtraction of pointers of different memory chunks',
2696 [r".*: warning: Subtraction of two pointers .*PointerSub"]),
2697 analyzer_warn('clang-analyzer Access out-of-bound array element',
2698 [r".*: warning: Access out-of-bound array element .*ArrayBound"]),
2699 analyzer_warn('clang-analyzer Out of bound memory access',
2700 [r".*: warning: Out of bound memory access .*ArrayBoundV2"]),
2701 analyzer_warn('clang-analyzer Possible lock order reversal',
2702 [r".*: warning: .* Possible lock order reversal.*PthreadLock"]),
2703 analyzer_warn('clang-analyzer call path problems',
2704 [r".*: warning: Call Path : .+"]),
2705 analyzer_warn_check('clang-analyzer-core.CallAndMessage'),
2706 analyzer_high_check('clang-analyzer-core.NonNullParamChecker'),
2707 analyzer_high_check('clang-analyzer-core.NullDereference'),
2708 analyzer_warn_check('clang-analyzer-core.UndefinedBinaryOperatorResult'),
2709 analyzer_warn_check('clang-analyzer-core.DivideZero'),
2710 analyzer_warn_check('clang-analyzer-core.VLASize'),
2711 analyzer_warn_check('clang-analyzer-core.uninitialized.ArraySubscript'),
2712 analyzer_warn_check('clang-analyzer-core.uninitialized.Assign'),
2713 analyzer_warn_check('clang-analyzer-core.uninitialized.UndefReturn'),
2714 analyzer_warn_check('clang-analyzer-cplusplus.Move'),
2715 analyzer_warn_check('clang-analyzer-deadcode.DeadStores'),
2716 analyzer_warn_check('clang-analyzer-optin.cplusplus.UninitializedObject'),
2717 analyzer_warn_check('clang-analyzer-optin.cplusplus.VirtualCall'),
2718 analyzer_warn_check('clang-analyzer-portability.UnixAPI'),
2719 analyzer_warn_check('clang-analyzer-unix.cstring.NullArg'),
2720 analyzer_high_check('clang-analyzer-unix.MallocSizeof'),
2721 analyzer_warn_check('clang-analyzer-valist.Uninitialized'),
2722 analyzer_warn_check('clang-analyzer-valist.Unterminated'),
2723 analyzer_group_check('clang-analyzer-core.uninitialized'),
2724 analyzer_group_check('clang-analyzer-deadcode'),
2725 analyzer_warn_check('clang-analyzer-security.insecureAPI.strcpy'),
2726 analyzer_group_high('clang-analyzer-security.insecureAPI'),
2727 analyzer_group_high('clang-analyzer-security'),
2728 analyzer_group_check('clang-analyzer-unix.Malloc'),
2729 analyzer_group_check('clang-analyzer-unix'),
2730 analyzer_group_check('clang-analyzer'), # catch al
2731
2732 # Assembler warnings
2733 {'category': 'Asm', 'severity': Severity.MEDIUM,
2734 'description': 'Asm: IT instruction is deprecated',
2735 'patterns': [r".*: warning: applying IT instruction .* is deprecated"]},
2736
2737 # NDK warnings
2738 {'category': 'NDK', 'severity': Severity.HIGH,
2739 'description': 'NDK: Generate guard with empty availability, obsoleted',
2740 'patterns': [r".*: warning: .* generate guard with empty availability: obsoleted ="]},
2741
2742 # Protoc warnings
2743 {'category': 'Protoc', 'severity': Severity.MEDIUM,
2744 'description': 'Proto: Enum name colision after strip',
2745 'patterns': [r".*: warning: Enum .* has the same name .* ignore case and strip"]},
2746
2747 # Kotlin warnings
2748 {'category': 'Kotlin', 'severity': Severity.MEDIUM,
2749 'description': 'Kotlin: never used parameter',
2750 'patterns': [r".*: warning: parameter '.*' is never used"]},
2751 {'category': 'Kotlin', 'severity': Severity.MEDIUM,
2752 'description': 'Kotlin: Deprecated in Java',
2753 'patterns': [r".*: warning: '.*' is deprecated. Deprecated in Java"]},
2754 {'category': 'Kotlin', 'severity': Severity.MEDIUM,
2755 'description': 'Kotlin: library has Kotlin runtime',
2756 'patterns': [r".*: warning: library has Kotlin runtime bundled into it",
2757 r".*: warning: some JAR files .* have the Kotlin Runtime library"]},
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07002758
Chih-Hung Hsieha1187072019-09-19 14:49:57 -07002759 # rustc warnings
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -07002760 {'category': 'Rust', 'severity': Severity.HIGH,
2761 'description': 'Rust: Does not derive Copy',
Chih-Hung Hsieha1187072019-09-19 14:49:57 -07002762 'patterns': [r".*: warning: .+ does not derive Copy"]},
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -07002763 {'category': 'Rust', 'severity': Severity.MEDIUM,
2764 'description': 'Rust: Deprecated range pattern',
Chih-Hung Hsieha1187072019-09-19 14:49:57 -07002765 'patterns': [r".*: warning: .+ range patterns are deprecated"]},
Chih-Hung Hsiehd591a5e2019-09-24 11:13:00 -07002766 {'category': 'Rust', 'severity': Severity.MEDIUM,
2767 'description': 'Rust: Deprecated missing explicit \'dyn\'',
Chih-Hung Hsieha1187072019-09-19 14:49:57 -07002768 'patterns': [r".*: warning: .+ without an explicit `dyn` are deprecated"]},
2769
Marco Nelissen594375d2009-07-14 09:04:04 -07002770 # catch-all for warnings this script doesn't know about yet
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002771 {'category': 'C/C++', 'severity': Severity.UNKNOWN,
2772 'description': 'Unclassified/unrecognized warnings',
2773 'patterns': [r".*: warning: .+"]},
Marco Nelissen594375d2009-07-14 09:04:04 -07002774]
2775
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07002776
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002777def project_name_and_pattern(name, pattern):
2778 return [name, '(^|.*/)' + pattern + '/.*: warning:']
2779
2780
2781def simple_project_pattern(pattern):
2782 return project_name_and_pattern(pattern, pattern)
2783
2784
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002785# A list of [project_name, file_path_pattern].
2786# project_name should not contain comma, to be used in CSV output.
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002787project_list = [
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002788 simple_project_pattern('art'),
2789 simple_project_pattern('bionic'),
2790 simple_project_pattern('bootable'),
2791 simple_project_pattern('build'),
2792 simple_project_pattern('cts'),
2793 simple_project_pattern('dalvik'),
2794 simple_project_pattern('developers'),
2795 simple_project_pattern('development'),
2796 simple_project_pattern('device'),
2797 simple_project_pattern('doc'),
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07002798 # match external/google* before external/
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002799 project_name_and_pattern('external/google', 'external/google.*'),
2800 project_name_and_pattern('external/non-google', 'external'),
2801 simple_project_pattern('frameworks/av/camera'),
2802 simple_project_pattern('frameworks/av/cmds'),
2803 simple_project_pattern('frameworks/av/drm'),
2804 simple_project_pattern('frameworks/av/include'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002805 simple_project_pattern('frameworks/av/media/img_utils'),
2806 simple_project_pattern('frameworks/av/media/libcpustats'),
2807 simple_project_pattern('frameworks/av/media/libeffects'),
2808 simple_project_pattern('frameworks/av/media/libmediaplayerservice'),
2809 simple_project_pattern('frameworks/av/media/libmedia'),
2810 simple_project_pattern('frameworks/av/media/libstagefright'),
2811 simple_project_pattern('frameworks/av/media/mtp'),
2812 simple_project_pattern('frameworks/av/media/ndk'),
2813 simple_project_pattern('frameworks/av/media/utils'),
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002814 project_name_and_pattern('frameworks/av/media/Other',
2815 'frameworks/av/media'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002816 simple_project_pattern('frameworks/av/radio'),
2817 simple_project_pattern('frameworks/av/services'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002818 simple_project_pattern('frameworks/av/soundtrigger'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002819 project_name_and_pattern('frameworks/av/Other', 'frameworks/av'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002820 simple_project_pattern('frameworks/base/cmds'),
2821 simple_project_pattern('frameworks/base/core'),
2822 simple_project_pattern('frameworks/base/drm'),
2823 simple_project_pattern('frameworks/base/media'),
2824 simple_project_pattern('frameworks/base/libs'),
2825 simple_project_pattern('frameworks/base/native'),
2826 simple_project_pattern('frameworks/base/packages'),
2827 simple_project_pattern('frameworks/base/rs'),
2828 simple_project_pattern('frameworks/base/services'),
2829 simple_project_pattern('frameworks/base/tests'),
2830 simple_project_pattern('frameworks/base/tools'),
2831 project_name_and_pattern('frameworks/base/Other', 'frameworks/base'),
Stephen Hinesd0aec892016-10-17 15:39:53 -07002832 simple_project_pattern('frameworks/compile/libbcc'),
2833 simple_project_pattern('frameworks/compile/mclinker'),
2834 simple_project_pattern('frameworks/compile/slang'),
2835 project_name_and_pattern('frameworks/compile/Other', 'frameworks/compile'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002836 simple_project_pattern('frameworks/minikin'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002837 simple_project_pattern('frameworks/ml'),
2838 simple_project_pattern('frameworks/native/cmds'),
2839 simple_project_pattern('frameworks/native/include'),
2840 simple_project_pattern('frameworks/native/libs'),
2841 simple_project_pattern('frameworks/native/opengl'),
2842 simple_project_pattern('frameworks/native/services'),
2843 simple_project_pattern('frameworks/native/vulkan'),
2844 project_name_and_pattern('frameworks/native/Other', 'frameworks/native'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002845 simple_project_pattern('frameworks/opt'),
2846 simple_project_pattern('frameworks/rs'),
2847 simple_project_pattern('frameworks/webview'),
2848 simple_project_pattern('frameworks/wilhelm'),
2849 project_name_and_pattern('frameworks/Other', 'frameworks'),
2850 simple_project_pattern('hardware/akm'),
2851 simple_project_pattern('hardware/broadcom'),
2852 simple_project_pattern('hardware/google'),
2853 simple_project_pattern('hardware/intel'),
2854 simple_project_pattern('hardware/interfaces'),
2855 simple_project_pattern('hardware/libhardware'),
2856 simple_project_pattern('hardware/libhardware_legacy'),
2857 simple_project_pattern('hardware/qcom'),
2858 simple_project_pattern('hardware/ril'),
2859 project_name_and_pattern('hardware/Other', 'hardware'),
2860 simple_project_pattern('kernel'),
2861 simple_project_pattern('libcore'),
2862 simple_project_pattern('libnativehelper'),
2863 simple_project_pattern('ndk'),
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002864 # match vendor/unbungled_google/packages before other packages
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002865 simple_project_pattern('unbundled_google'),
2866 simple_project_pattern('packages'),
2867 simple_project_pattern('pdk'),
2868 simple_project_pattern('prebuilts'),
2869 simple_project_pattern('system/bt'),
2870 simple_project_pattern('system/connectivity'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002871 simple_project_pattern('system/core/adb'),
2872 simple_project_pattern('system/core/base'),
2873 simple_project_pattern('system/core/debuggerd'),
2874 simple_project_pattern('system/core/fastboot'),
2875 simple_project_pattern('system/core/fingerprintd'),
2876 simple_project_pattern('system/core/fs_mgr'),
2877 simple_project_pattern('system/core/gatekeeperd'),
2878 simple_project_pattern('system/core/healthd'),
2879 simple_project_pattern('system/core/include'),
2880 simple_project_pattern('system/core/init'),
2881 simple_project_pattern('system/core/libbacktrace'),
2882 simple_project_pattern('system/core/liblog'),
2883 simple_project_pattern('system/core/libpixelflinger'),
2884 simple_project_pattern('system/core/libprocessgroup'),
2885 simple_project_pattern('system/core/libsysutils'),
2886 simple_project_pattern('system/core/logcat'),
2887 simple_project_pattern('system/core/logd'),
2888 simple_project_pattern('system/core/run-as'),
2889 simple_project_pattern('system/core/sdcard'),
2890 simple_project_pattern('system/core/toolbox'),
2891 project_name_and_pattern('system/core/Other', 'system/core'),
2892 simple_project_pattern('system/extras/ANRdaemon'),
2893 simple_project_pattern('system/extras/cpustats'),
2894 simple_project_pattern('system/extras/crypto-perf'),
2895 simple_project_pattern('system/extras/ext4_utils'),
2896 simple_project_pattern('system/extras/f2fs_utils'),
2897 simple_project_pattern('system/extras/iotop'),
2898 simple_project_pattern('system/extras/libfec'),
2899 simple_project_pattern('system/extras/memory_replay'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002900 simple_project_pattern('system/extras/mmap-perf'),
2901 simple_project_pattern('system/extras/multinetwork'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002902 simple_project_pattern('system/extras/procrank'),
2903 simple_project_pattern('system/extras/runconuid'),
2904 simple_project_pattern('system/extras/showmap'),
2905 simple_project_pattern('system/extras/simpleperf'),
2906 simple_project_pattern('system/extras/su'),
2907 simple_project_pattern('system/extras/tests'),
2908 simple_project_pattern('system/extras/verity'),
2909 project_name_and_pattern('system/extras/Other', 'system/extras'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002910 simple_project_pattern('system/gatekeeper'),
2911 simple_project_pattern('system/keymaster'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002912 simple_project_pattern('system/libhidl'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002913 simple_project_pattern('system/libhwbinder'),
2914 simple_project_pattern('system/media'),
2915 simple_project_pattern('system/netd'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002916 simple_project_pattern('system/nvram'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002917 simple_project_pattern('system/security'),
2918 simple_project_pattern('system/sepolicy'),
2919 simple_project_pattern('system/tools'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002920 simple_project_pattern('system/update_engine'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002921 simple_project_pattern('system/vold'),
2922 project_name_and_pattern('system/Other', 'system'),
2923 simple_project_pattern('toolchain'),
2924 simple_project_pattern('test'),
2925 simple_project_pattern('tools'),
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07002926 # match vendor/google* before vendor/
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002927 project_name_and_pattern('vendor/google', 'vendor/google.*'),
2928 project_name_and_pattern('vendor/non-google', 'vendor'),
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07002929 # keep out/obj and other patterns at the end.
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002930 ['out/obj',
2931 '.*/(gen|obj[^/]*)/(include|EXECUTABLES|SHARED_LIBRARIES|'
2932 'STATIC_LIBRARIES|NATIVE_TESTS)/.*: warning:'],
2933 ['other', '.*'] # all other unrecognized patterns
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002934]
2935
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002936project_patterns = []
2937project_names = []
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002938warning_messages = []
2939warning_records = []
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002940
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07002941
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002942def initialize_arrays():
2943 """Complete global arrays before they are used."""
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002944 global project_names, project_patterns
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002945 project_names = [p[0] for p in project_list]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002946 project_patterns = [re.compile(p[1]) for p in project_list]
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002947 for w in warn_patterns:
2948 w['members'] = []
2949 if 'option' not in w:
2950 w['option'] = ''
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002951 # Each warning pattern has a 'projects' dictionary, that
2952 # maps a project name to number of warnings in that project.
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002953 w['projects'] = {}
2954
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002955
2956initialize_arrays()
2957
2958
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -07002959android_root = ''
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002960platform_version = 'unknown'
2961target_product = 'unknown'
2962target_variant = 'unknown'
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002963
2964
2965##### Data and functions to dump html file. ##################################
2966
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002967html_head_scripts = """\
2968 <script type="text/javascript">
2969 function expand(id) {
2970 var e = document.getElementById(id);
2971 var f = document.getElementById(id + "_mark");
2972 if (e.style.display == 'block') {
2973 e.style.display = 'none';
2974 f.innerHTML = '&#x2295';
2975 }
2976 else {
2977 e.style.display = 'block';
2978 f.innerHTML = '&#x2296';
2979 }
2980 };
2981 function expandCollapse(show) {
2982 for (var id = 1; ; id++) {
2983 var e = document.getElementById(id + "");
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07002984 var f = document.getElementById(id + "_mark");
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002985 if (!e || !f) break;
2986 e.style.display = (show ? 'block' : 'none');
2987 f.innerHTML = (show ? '&#x2296' : '&#x2295');
2988 }
2989 };
2990 </script>
2991 <style type="text/css">
2992 th,td{border-collapse:collapse; border:1px solid black;}
2993 .button{color:blue;font-size:110%;font-weight:bolder;}
2994 .bt{color:black;background-color:transparent;border:none;outline:none;
2995 font-size:140%;font-weight:bolder;}
2996 .c0{background-color:#e0e0e0;}
2997 .c1{background-color:#d0d0d0;}
2998 .t1{border-collapse:collapse; width:100%; border:1px solid black;}
2999 </style>
3000 <script src="https://www.gstatic.com/charts/loader.js"></script>
3001"""
Marco Nelissen594375d2009-07-14 09:04:04 -07003002
Marco Nelissen594375d2009-07-14 09:04:04 -07003003
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003004def html_big(param):
3005 return '<font size="+2">' + param + '</font>'
Marco Nelissen594375d2009-07-14 09:04:04 -07003006
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07003007
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003008def dump_html_prologue(title):
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07003009 print('<html>\n<head>')
3010 print('<title>' + title + '</title>')
3011 print(html_head_scripts)
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003012 emit_stats_by_project()
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07003013 print('</head>\n<body>')
3014 print(html_big(title))
3015 print('<p>')
Marco Nelissen594375d2009-07-14 09:04:04 -07003016
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07003017
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003018def dump_html_epilogue():
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07003019 print('</body>\n</head>\n</html>')
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07003020
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003021
3022def sort_warnings():
3023 for i in warn_patterns:
3024 i['members'] = sorted(set(i['members']))
3025
3026
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003027def emit_stats_by_project():
3028 """Dump a google chart table of warnings per project and severity."""
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003029 # warnings[p][s] is number of warnings in project p of severity s.
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07003030 # pylint:disable=g-complex-comprehension
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07003031 warnings = {p: {s: 0 for s in Severity.range} for p in project_names}
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003032 for i in warn_patterns:
3033 s = i['severity']
3034 for p in i['projects']:
3035 warnings[p][s] += i['projects'][p]
3036
3037 # total_by_project[p] is number of warnings in project p.
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07003038 total_by_project = {p: sum(warnings[p][s] for s in Severity.range)
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003039 for p in project_names}
3040
3041 # total_by_severity[s] is number of warnings of severity s.
3042 total_by_severity = {s: sum(warnings[p][s] for p in project_names)
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07003043 for s in Severity.range}
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07003044
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003045 # emit table header
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003046 stats_header = ['Project']
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07003047 for s in Severity.range:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003048 if total_by_severity[s]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003049 stats_header.append("<span style='background-color:{}'>{}</span>".
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07003050 format(Severity.colors[s],
3051 Severity.column_headers[s]))
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003052 stats_header.append('TOTAL')
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07003053
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003054 # emit a row of warning counts per project, skip no-warning projects
3055 total_all_projects = 0
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003056 stats_rows = []
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003057 for p in project_names:
3058 if total_by_project[p]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003059 one_row = [p]
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07003060 for s in Severity.range:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003061 if total_by_severity[s]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003062 one_row.append(warnings[p][s])
3063 one_row.append(total_by_project[p])
3064 stats_rows.append(one_row)
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003065 total_all_projects += total_by_project[p]
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07003066
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003067 # emit a row of warning counts per severity
3068 total_all_severities = 0
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003069 one_row = ['<b>TOTAL</b>']
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07003070 for s in Severity.range:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003071 if total_by_severity[s]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003072 one_row.append(total_by_severity[s])
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003073 total_all_severities += total_by_severity[s]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003074 one_row.append(total_all_projects)
3075 stats_rows.append(one_row)
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07003076 print('<script>')
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003077 emit_const_string_array('StatsHeader', stats_header)
3078 emit_const_object_array('StatsRows', stats_rows)
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07003079 print(draw_table_javascript)
3080 print('</script>')
Marco Nelissen594375d2009-07-14 09:04:04 -07003081
3082
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003083def dump_stats():
3084 """Dump some stats about total number of warnings and such."""
3085 known = 0
3086 skipped = 0
3087 unknown = 0
3088 sort_warnings()
3089 for i in warn_patterns:
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07003090 if i['severity'] == Severity.UNKNOWN:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003091 unknown += len(i['members'])
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07003092 elif i['severity'] == Severity.SKIP:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003093 skipped += len(i['members'])
Ian Rogersf3829732016-05-10 12:06:01 -07003094 else:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003095 known += len(i['members'])
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07003096 print('Number of classified warnings: <b>' + str(known) + '</b><br>')
3097 print('Number of skipped warnings: <b>' + str(skipped) + '</b><br>')
3098 print('Number of unclassified warnings: <b>' + str(unknown) + '</b><br>')
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003099 total = unknown + known + skipped
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003100 extra_msg = ''
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003101 if total < 1000:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003102 extra_msg = ' (low count may indicate incremental build)'
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07003103 print('Total number of warnings: <b>' + str(total) + '</b>' + extra_msg)
Marco Nelissen594375d2009-07-14 09:04:04 -07003104
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07003105
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003106# New base table of warnings, [severity, warn_id, project, warning_message]
3107# Need buttons to show warnings in different grouping options.
3108# (1) Current, group by severity, id for each warning pattern
3109# sort by severity, warn_id, warning_message
3110# (2) Current --byproject, group by severity,
3111# id for each warning pattern + project name
3112# sort by severity, warn_id, project, warning_message
3113# (3) New, group by project + severity,
3114# id for each warning pattern
3115# sort by project, severity, warn_id, warning_message
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003116def emit_buttons():
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07003117 print('<button class="button" onclick="expandCollapse(1);">'
3118 'Expand all warnings</button>\n'
3119 '<button class="button" onclick="expandCollapse(0);">'
3120 'Collapse all warnings</button>\n'
3121 '<button class="button" onclick="groupBySeverity();">'
3122 'Group warnings by severity</button>\n'
3123 '<button class="button" onclick="groupByProject();">'
3124 'Group warnings by project</button><br>')
Marco Nelissen594375d2009-07-14 09:04:04 -07003125
3126
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003127def all_patterns(category):
3128 patterns = ''
3129 for i in category['patterns']:
3130 patterns += i
3131 patterns += ' / '
3132 return patterns
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003133
3134
3135def dump_fixed():
3136 """Show which warnings no longer occur."""
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003137 anchor = 'fixed_warnings'
3138 mark = anchor + '_mark'
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07003139 print('\n<br><p style="background-color:lightblue"><b>'
3140 '<button id="' + mark + '" '
3141 'class="bt" onclick="expand(\'' + anchor + '\');">'
3142 '&#x2295</button> Fixed warnings. '
3143 'No more occurrences. Please consider turning these into '
3144 'errors if possible, before they are reintroduced in to the build'
3145 ':</b></p>')
3146 print('<blockquote>')
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003147 fixed_patterns = []
3148 for i in warn_patterns:
3149 if not i['members']:
3150 fixed_patterns.append(i['description'] + ' (' +
3151 all_patterns(i) + ')')
3152 if i['option']:
3153 fixed_patterns.append(' ' + i['option'])
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07003154 fixed_patterns = sorted(fixed_patterns)
3155 print('<div id="' + anchor + '" style="display:none;"><table>')
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003156 cur_row_class = 0
3157 for text in fixed_patterns:
3158 cur_row_class = 1 - cur_row_class
3159 # remove last '\n'
3160 t = text[:-1] if text[-1] == '\n' else text
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07003161 print('<tr><td class="c' + str(cur_row_class) + '">' + t + '</td></tr>')
3162 print('</table></div>')
3163 print('</blockquote>')
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003164
3165
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003166def find_project_index(line):
3167 for p in range(len(project_patterns)):
3168 if project_patterns[p].match(line):
3169 return p
3170 return -1
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003171
3172
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07003173def classify_one_warning(line, results):
Chih-Hung Hsieh9be27762018-06-07 10:51:47 -07003174 """Classify one warning line."""
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003175 for i in range(len(warn_patterns)):
3176 w = warn_patterns[i]
3177 for cpat in w['compiled_patterns']:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003178 if cpat.match(line):
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003179 p = find_project_index(line)
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07003180 results.append([line, i, p])
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003181 return
3182 else:
3183 # If we end up here, there was a problem parsing the log
3184 # probably caused by 'make -j' mixing the output from
3185 # 2 or more concurrent compiles
3186 pass
Marco Nelissen594375d2009-07-14 09:04:04 -07003187
3188
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07003189def classify_warnings(lines):
3190 results = []
3191 for line in lines:
3192 classify_one_warning(line, results)
Chih-Hung Hsieh76d00652016-11-09 18:19:05 -08003193 # After the main work, ignore all other signals to a child process,
3194 # to avoid bad warning/error messages from the exit clean-up process.
3195 if args.processes > 1:
3196 signal.signal(signal.SIGTERM, lambda *args: sys.exit(-signal.SIGTERM))
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07003197 return results
3198
3199
3200def parallel_classify_warnings(warning_lines):
3201 """Classify all warning lines with num_cpu parallel processes."""
Chih-Hung Hsieh76d00652016-11-09 18:19:05 -08003202 compile_patterns()
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07003203 num_cpu = args.processes
Chih-Hung Hsieh63de3002016-10-28 10:53:34 -07003204 if num_cpu > 1:
3205 groups = [[] for x in range(num_cpu)]
3206 i = 0
3207 for x in warning_lines:
3208 groups[i].append(x)
3209 i = (i + 1) % num_cpu
3210 pool = multiprocessing.Pool(num_cpu)
3211 group_results = pool.map(classify_warnings, groups)
3212 else:
3213 group_results = [classify_warnings(warning_lines)]
3214
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07003215 for result in group_results:
3216 for line, pattern_idx, project_idx in result:
3217 pattern = warn_patterns[pattern_idx]
3218 pattern['members'].append(line)
3219 message_idx = len(warning_messages)
3220 warning_messages.append(line)
3221 warning_records.append([pattern_idx, project_idx, message_idx])
3222 pname = '???' if project_idx < 0 else project_names[project_idx]
3223 # Count warnings by project.
3224 if pname in pattern['projects']:
3225 pattern['projects'][pname] += 1
3226 else:
3227 pattern['projects'][pname] = 1
3228
3229
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003230def compile_patterns():
3231 """Precompiling every pattern speeds up parsing by about 30x."""
3232 for i in warn_patterns:
3233 i['compiled_patterns'] = []
3234 for pat in i['patterns']:
3235 i['compiled_patterns'].append(re.compile(pat))
3236
3237
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -07003238def find_android_root(path):
3239 """Set and return android_root path if it is found."""
3240 global android_root
3241 parts = path.split('/')
3242 for idx in reversed(range(2, len(parts))):
3243 root_path = '/'.join(parts[:idx])
3244 # Android root directory should contain this script.
Colin Crossfdea8932017-12-06 14:38:40 -08003245 if os.path.exists(root_path + '/build/make/tools/warn.py'):
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -07003246 android_root = root_path
3247 return root_path
3248 return ''
3249
3250
3251def remove_android_root_prefix(path):
3252 """Remove android_root prefix from path if it is found."""
3253 if path.startswith(android_root):
3254 return path[1 + len(android_root):]
3255 else:
3256 return path
3257
3258
3259def normalize_path(path):
3260 """Normalize file path relative to android_root."""
3261 # If path is not an absolute path, just normalize it.
3262 path = os.path.normpath(path)
3263 if path[0] != '/':
3264 return path
3265 # Remove known prefix of root path and normalize the suffix.
3266 if android_root or find_android_root(path):
3267 return remove_android_root_prefix(path)
3268 else:
3269 return path
3270
3271
3272def normalize_warning_line(line):
3273 """Normalize file path relative to android_root in a warning line."""
3274 # replace fancy quotes with plain ol' quotes
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07003275 line = re.sub(u'[\u2018\u2019]', '\'', line)
3276 # replace non-ASCII chars to spaces
3277 line = re.sub(u'[^\x00-\x7f]', ' ', line)
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -07003278 line = line.strip()
3279 first_column = line.find(':')
3280 if first_column > 0:
3281 return normalize_path(line[:first_column]) + line[first_column:]
3282 else:
3283 return line
3284
3285
Chih-Hung Hsieh76d00652016-11-09 18:19:05 -08003286def parse_input_file(infile):
Chih-Hung Hsiehef21d142017-04-27 10:25:37 -07003287 """Parse input file, collect parameters and warning lines."""
3288 global android_root
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003289 global platform_version
3290 global target_product
3291 global target_variant
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003292 line_counter = 0
3293
Chih-Hung Hsieha1187072019-09-19 14:49:57 -07003294 # rustc warning messages have two lines that should be combined:
3295 # warning: description
3296 # --> file_path:line_number:column_number
3297 # Some warning messages have no file name:
3298 # warning: macro replacement list ... [bugprone-macro-parentheses]
3299 # Some makefile warning messages have no line number:
3300 # some/path/file.mk: warning: description
3301 # C/C++ compiler warning messages have line and column numbers:
3302 # some/path/file.c:line_number:column_number: warning: description
3303 warning_pattern = re.compile('(^[^ ]*/[^ ]*: warning: .*)|(^warning: .*)')
3304 warning_without_file = re.compile('^warning: .*')
3305 rustc_file_position = re.compile('^[ ]+--> [^ ]*/[^ ]*:[0-9]+:[0-9]+')
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003306
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07003307 # Collect all warnings into the warning_lines set.
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003308 warning_lines = set()
Chih-Hung Hsieha1187072019-09-19 14:49:57 -07003309 prev_warning = ''
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003310 for line in infile:
Chih-Hung Hsieha1187072019-09-19 14:49:57 -07003311 if prev_warning:
3312 if rustc_file_position.match(line):
3313 # must be a rustc warning, combine 2 lines into one warning
3314 line = line.strip().replace('--> ', '') + ': ' + prev_warning
3315 warning_lines.add(normalize_warning_line(line))
3316 prev_warning = ''
3317 continue
3318 # add prev_warning, and then process the current line
3319 prev_warning = 'unknown_source_file: ' + prev_warning
3320 warning_lines.add(normalize_warning_line(prev_warning))
3321 prev_warning = ''
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003322 if warning_pattern.match(line):
Chih-Hung Hsieha1187072019-09-19 14:49:57 -07003323 if warning_without_file.match(line):
3324 # save this line and combine it with the next line
3325 prev_warning = line
3326 else:
3327 warning_lines.add(normalize_warning_line(line))
3328 continue
3329 if line_counter < 100:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003330 # save a little bit of time by only doing this for the first few lines
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003331 line_counter += 1
3332 m = re.search('(?<=^PLATFORM_VERSION=).*', line)
3333 if m is not None:
3334 platform_version = m.group(0)
3335 m = re.search('(?<=^TARGET_PRODUCT=).*', line)
3336 if m is not None:
3337 target_product = m.group(0)
3338 m = re.search('(?<=^TARGET_BUILD_VARIANT=).*', line)
3339 if m is not None:
3340 target_variant = m.group(0)
Chih-Hung Hsiehef21d142017-04-27 10:25:37 -07003341 m = re.search('.* TOP=([^ ]*) .*', line)
3342 if m is not None:
3343 android_root = m.group(1)
Chih-Hung Hsieh76d00652016-11-09 18:19:05 -08003344 return warning_lines
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003345
3346
Chih-Hung Hsieh5722f922016-10-11 15:33:19 -07003347# Return s with escaped backslash and quotation characters.
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003348def escape_string(s):
Chih-Hung Hsieh5722f922016-10-11 15:33:19 -07003349 return s.replace('\\', '\\\\').replace('"', '\\"')
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003350
3351
3352# Return s without trailing '\n' and escape the quotation characters.
3353def strip_escape_string(s):
3354 if not s:
3355 return s
3356 s = s[:-1] if s[-1] == '\n' else s
3357 return escape_string(s)
3358
3359
3360def emit_warning_array(name):
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07003361 print('var warning_{} = ['.format(name))
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003362 for i in range(len(warn_patterns)):
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07003363 print('{},'.format(warn_patterns[i][name]))
3364 print('];')
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003365
3366
3367def emit_warning_arrays():
3368 emit_warning_array('severity')
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07003369 print('var warning_description = [')
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003370 for i in range(len(warn_patterns)):
3371 if warn_patterns[i]['members']:
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07003372 print('"{}",'.format(escape_string(warn_patterns[i]['description'])))
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003373 else:
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07003374 print('"",') # no such warning
3375 print('];')
3376
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003377
3378scripts_for_warning_groups = """
3379 function compareMessages(x1, x2) { // of the same warning type
3380 return (WarningMessages[x1[2]] <= WarningMessages[x2[2]]) ? -1 : 1;
3381 }
3382 function byMessageCount(x1, x2) {
3383 return x2[2] - x1[2]; // reversed order
3384 }
3385 function bySeverityMessageCount(x1, x2) {
3386 // orer by severity first
3387 if (x1[1] != x2[1])
3388 return x1[1] - x2[1];
3389 return byMessageCount(x1, x2);
3390 }
3391 const ParseLinePattern = /^([^ :]+):(\\d+):(.+)/;
3392 function addURL(line) {
3393 if (FlagURL == "") return line;
3394 if (FlagSeparator == "") {
3395 return line.replace(ParseLinePattern,
George Burgess IV169f5f12017-04-21 13:35:52 -07003396 "<a target='_blank' href='" + FlagURL + "/$1'>$1</a>:$2:$3");
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003397 }
3398 return line.replace(ParseLinePattern,
George Burgess IV169f5f12017-04-21 13:35:52 -07003399 "<a target='_blank' href='" + FlagURL + "/$1" + FlagSeparator +
3400 "$2'>$1:$2</a>:$3");
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003401 }
3402 function createArrayOfDictionaries(n) {
3403 var result = [];
3404 for (var i=0; i<n; i++) result.push({});
3405 return result;
3406 }
3407 function groupWarningsBySeverity() {
3408 // groups is an array of dictionaries,
3409 // each dictionary maps from warning type to array of warning messages.
3410 var groups = createArrayOfDictionaries(SeverityColors.length);
3411 for (var i=0; i<Warnings.length; i++) {
3412 var w = Warnings[i][0];
3413 var s = WarnPatternsSeverity[w];
3414 var k = w.toString();
3415 if (!(k in groups[s]))
3416 groups[s][k] = [];
3417 groups[s][k].push(Warnings[i]);
3418 }
3419 return groups;
3420 }
3421 function groupWarningsByProject() {
3422 var groups = createArrayOfDictionaries(ProjectNames.length);
3423 for (var i=0; i<Warnings.length; i++) {
3424 var w = Warnings[i][0];
3425 var p = Warnings[i][1];
3426 var k = w.toString();
3427 if (!(k in groups[p]))
3428 groups[p][k] = [];
3429 groups[p][k].push(Warnings[i]);
3430 }
3431 return groups;
3432 }
3433 var GlobalAnchor = 0;
3434 function createWarningSection(header, color, group) {
3435 var result = "";
3436 var groupKeys = [];
3437 var totalMessages = 0;
3438 for (var k in group) {
3439 totalMessages += group[k].length;
3440 groupKeys.push([k, WarnPatternsSeverity[parseInt(k)], group[k].length]);
3441 }
3442 groupKeys.sort(bySeverityMessageCount);
3443 for (var idx=0; idx<groupKeys.length; idx++) {
3444 var k = groupKeys[idx][0];
3445 var messages = group[k];
3446 var w = parseInt(k);
3447 var wcolor = SeverityColors[WarnPatternsSeverity[w]];
3448 var description = WarnPatternsDescription[w];
3449 if (description.length == 0)
3450 description = "???";
3451 GlobalAnchor += 1;
3452 result += "<table class='t1'><tr bgcolor='" + wcolor + "'><td>" +
3453 "<button class='bt' id='" + GlobalAnchor + "_mark" +
3454 "' onclick='expand(\\"" + GlobalAnchor + "\\");'>" +
3455 "&#x2295</button> " +
3456 description + " (" + messages.length + ")</td></tr></table>";
3457 result += "<div id='" + GlobalAnchor +
3458 "' style='display:none;'><table class='t1'>";
3459 var c = 0;
3460 messages.sort(compareMessages);
3461 for (var i=0; i<messages.length; i++) {
3462 result += "<tr><td class='c" + c + "'>" +
3463 addURL(WarningMessages[messages[i][2]]) + "</td></tr>";
3464 c = 1 - c;
3465 }
3466 result += "</table></div>";
3467 }
3468 if (result.length > 0) {
3469 return "<br><span style='background-color:" + color + "'><b>" +
3470 header + ": " + totalMessages +
3471 "</b></span><blockquote><table class='t1'>" +
3472 result + "</table></blockquote>";
3473
3474 }
3475 return ""; // empty section
3476 }
3477 function generateSectionsBySeverity() {
3478 var result = "";
3479 var groups = groupWarningsBySeverity();
3480 for (s=0; s<SeverityColors.length; s++) {
3481 result += createWarningSection(SeverityHeaders[s], SeverityColors[s], groups[s]);
3482 }
3483 return result;
3484 }
3485 function generateSectionsByProject() {
3486 var result = "";
3487 var groups = groupWarningsByProject();
3488 for (i=0; i<groups.length; i++) {
3489 result += createWarningSection(ProjectNames[i], 'lightgrey', groups[i]);
3490 }
3491 return result;
3492 }
3493 function groupWarnings(generator) {
3494 GlobalAnchor = 0;
3495 var e = document.getElementById("warning_groups");
3496 e.innerHTML = generator();
3497 }
3498 function groupBySeverity() {
3499 groupWarnings(generateSectionsBySeverity);
3500 }
3501 function groupByProject() {
3502 groupWarnings(generateSectionsByProject);
3503 }
3504"""
3505
3506
3507# Emit a JavaScript const string
3508def emit_const_string(name, value):
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07003509 print('const ' + name + ' = "' + escape_string(value) + '";')
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003510
3511
3512# Emit a JavaScript const integer array.
3513def emit_const_int_array(name, array):
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07003514 print('const ' + name + ' = [')
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003515 for n in array:
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07003516 print(str(n) + ',')
3517 print('];')
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003518
3519
3520# Emit a JavaScript const string array.
3521def emit_const_string_array(name, array):
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07003522 print('const ' + name + ' = [')
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003523 for s in array:
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07003524 print('"' + strip_escape_string(s) + '",')
3525 print('];')
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003526
3527
Chih-Hung Hsiehb2afb632018-07-20 15:36:26 -07003528# Emit a JavaScript const string array for HTML.
3529def emit_const_html_string_array(name, array):
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07003530 print('const ' + name + ' = [')
Chih-Hung Hsiehb2afb632018-07-20 15:36:26 -07003531 for s in array:
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07003532 # Not using html.escape yet, to work for both python 2 and 3,
3533 # until all users switch to python 3.
3534 # pylint:disable=deprecated-method
3535 print('"' + cgi.escape(strip_escape_string(s)) + '",')
3536 print('];')
Chih-Hung Hsiehb2afb632018-07-20 15:36:26 -07003537
3538
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003539# Emit a JavaScript const object array.
3540def emit_const_object_array(name, array):
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07003541 print('const ' + name + ' = [')
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003542 for x in array:
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07003543 print(str(x) + ',')
3544 print('];')
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003545
3546
3547def emit_js_data():
3548 """Dump dynamic HTML page's static JavaScript data."""
3549 emit_const_string('FlagURL', args.url if args.url else '')
3550 emit_const_string('FlagSeparator', args.separator if args.separator else '')
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07003551 emit_const_string_array('SeverityColors', Severity.colors)
3552 emit_const_string_array('SeverityHeaders', Severity.headers)
3553 emit_const_string_array('SeverityColumnHeaders', Severity.column_headers)
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003554 emit_const_string_array('ProjectNames', project_names)
3555 emit_const_int_array('WarnPatternsSeverity',
3556 [w['severity'] for w in warn_patterns])
Chih-Hung Hsiehb2afb632018-07-20 15:36:26 -07003557 emit_const_html_string_array('WarnPatternsDescription',
3558 [w['description'] for w in warn_patterns])
3559 emit_const_html_string_array('WarnPatternsOption',
3560 [w['option'] for w in warn_patterns])
3561 emit_const_html_string_array('WarningMessages', warning_messages)
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003562 emit_const_object_array('Warnings', warning_records)
3563
3564draw_table_javascript = """
3565google.charts.load('current', {'packages':['table']});
3566google.charts.setOnLoadCallback(drawTable);
3567function drawTable() {
3568 var data = new google.visualization.DataTable();
3569 data.addColumn('string', StatsHeader[0]);
3570 for (var i=1; i<StatsHeader.length; i++) {
3571 data.addColumn('number', StatsHeader[i]);
3572 }
3573 data.addRows(StatsRows);
3574 for (var i=0; i<StatsRows.length; i++) {
3575 for (var j=0; j<StatsHeader.length; j++) {
3576 data.setProperty(i, j, 'style', 'border:1px solid black;');
3577 }
3578 }
3579 var table = new google.visualization.Table(document.getElementById('stats_table'));
3580 table.draw(data, {allowHtml: true, alternatingRowStyle: true});
3581}
3582"""
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003583
3584
3585def dump_html():
3586 """Dump the html output to stdout."""
3587 dump_html_prologue('Warnings for ' + platform_version + ' - ' +
3588 target_product + ' - ' + target_variant)
3589 dump_stats()
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07003590 print('<br><div id="stats_table"></div><br>')
3591 print('\n<script>')
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003592 emit_js_data()
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07003593 print(scripts_for_warning_groups)
3594 print('</script>')
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003595 emit_buttons()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003596 # Warning messages are grouped by severities or project names.
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07003597 print('<br><div id="warning_groups"></div>')
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003598 if args.byproject:
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07003599 print('<script>groupByProject();</script>')
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003600 else:
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07003601 print('<script>groupBySeverity();</script>')
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003602 dump_fixed()
3603 dump_html_epilogue()
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07003604
3605
3606##### Functions to count warnings and dump csv file. #########################
3607
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07003608
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003609def description_for_csv(category):
3610 if not category['description']:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003611 return '?'
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003612 return category['description']
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07003613
3614
Sam Saccone03aaa7e2017-04-10 15:37:47 -07003615def count_severity(writer, sev, kind):
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003616 """Count warnings of given severity."""
3617 total = 0
3618 for i in warn_patterns:
3619 if i['severity'] == sev and i['members']:
3620 n = len(i['members'])
3621 total += n
Sam Saccone03aaa7e2017-04-10 15:37:47 -07003622 warning = kind + ': ' + description_for_csv(i)
3623 writer.writerow([n, '', warning])
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003624 # print number of warnings for each project, ordered by project name.
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07003625 projects = sorted(i['projects'].keys())
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003626 for p in projects:
Sam Saccone03aaa7e2017-04-10 15:37:47 -07003627 writer.writerow([i['projects'][p], p, warning])
3628 writer.writerow([total, '', kind + ' warnings'])
3629
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003630 return total
3631
3632
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003633# dump number of warnings in csv format to stdout
Sam Saccone03aaa7e2017-04-10 15:37:47 -07003634def dump_csv(writer):
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003635 """Dump number of warnings in csv format to stdout."""
3636 sort_warnings()
3637 total = 0
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07003638 for s in Severity.range:
Sam Saccone03aaa7e2017-04-10 15:37:47 -07003639 total += count_severity(writer, s, Severity.column_headers[s])
3640 writer.writerow([total, '', 'All warnings'])
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003641
3642
Meike Baumgärtnerac9d5df2016-09-28 10:48:06 -07003643def main():
Chih-Hung Hsieh9018ea42019-06-14 15:33:18 -07003644 # We must use 'utf-8' codec to parse some non-ASCII code in warnings.
3645 warning_lines = parse_input_file(
3646 io.open(args.buildlog, mode='r', encoding='utf-8'))
Chih-Hung Hsieh76d00652016-11-09 18:19:05 -08003647 parallel_classify_warnings(warning_lines)
Sam Saccone03aaa7e2017-04-10 15:37:47 -07003648 # If a user pases a csv path, save the fileoutput to the path
3649 # If the user also passed gencsv write the output to stdout
3650 # If the user did not pass gencsv flag dump the html report to stdout.
3651 if args.csvpath:
3652 with open(args.csvpath, 'w') as f:
3653 dump_csv(csv.writer(f, lineterminator='\n'))
Meike Baumgärtnerac9d5df2016-09-28 10:48:06 -07003654 if args.gencsv:
Sam Saccone03aaa7e2017-04-10 15:37:47 -07003655 dump_csv(csv.writer(sys.stdout, lineterminator='\n'))
Meike Baumgärtnerac9d5df2016-09-28 10:48:06 -07003656 else:
3657 dump_html()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003658
Meike Baumgärtnerac9d5df2016-09-28 10:48:06 -07003659
3660# Run main function if warn.py is the main program.
3661if __name__ == '__main__':
3662 main()