blob: 89f4778951ba46d2d27a428709730e9cc3bc6a7e [file] [log] [blame]
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001#!/usr/bin/python
Marco Nelissen8e201962010-03-10 16:16:02 -08002# This file uses the following encoding: utf-8
Marco Nelissen594375d2009-07-14 09:04:04 -07003
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07004"""Grep warnings messages and output HTML tables or warning counts in CSV.
5
6Default is to output warnings in HTML tables grouped by warning severity.
7Use option --byproject to output tables grouped by source file projects.
8Use option --gencsv to output warning counts in CSV format.
9"""
10
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -070011# List of important data structures and functions in this script.
12#
13# To parse and keep warning message in the input file:
14# severity: classification of message severity
15# severity.range [0, 1, ... last_severity_level]
16# severity.colors for header background
17# severity.column_headers for the warning count table
18# severity.headers for warning message tables
19# warn_patterns:
20# warn_patterns[w]['category'] tool that issued the warning, not used now
21# warn_patterns[w]['description'] table heading
22# warn_patterns[w]['members'] matched warnings from input
23# warn_patterns[w]['option'] compiler flag to control the warning
24# warn_patterns[w]['patterns'] regular expressions to match warnings
25# warn_patterns[w]['projects'][p] number of warnings of pattern w in p
26# warn_patterns[w]['severity'] severity level
27# project_list[p][0] project name
28# project_list[p][1] regular expression to match a project path
29# project_patterns[p] re.compile(project_list[p][1])
30# project_names[p] project_list[p][0]
31# warning_messages array of each warning message, without source url
32# warning_records array of [idx to warn_patterns,
33# idx to project_names,
34# idx to warning_messages]
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -070035# android_root
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -070036# platform_version
37# target_product
38# target_variant
39# compile_patterns, parse_input_file
40#
41# To emit html page of warning messages:
42# flags: --byproject, --url, --separator
43# Old stuff for static html components:
44# html_script_style: static html scripts and styles
45# htmlbig:
46# dump_stats, dump_html_prologue, dump_html_epilogue:
47# emit_buttons:
48# dump_fixed
49# sort_warnings:
50# emit_stats_by_project:
51# all_patterns,
52# findproject, classify_warning
53# dump_html
54#
55# New dynamic HTML page's static JavaScript data:
56# Some data are copied from Python to JavaScript, to generate HTML elements.
57# FlagURL args.url
58# FlagSeparator args.separator
59# SeverityColors: severity.colors
60# SeverityHeaders: severity.headers
61# SeverityColumnHeaders: severity.column_headers
62# ProjectNames: project_names, or project_list[*][0]
63# WarnPatternsSeverity: warn_patterns[*]['severity']
64# WarnPatternsDescription: warn_patterns[*]['description']
65# WarnPatternsOption: warn_patterns[*]['option']
66# WarningMessages: warning_messages
67# Warnings: warning_records
68# StatsHeader: warning count table header row
69# StatsRows: array of warning count table rows
70#
71# New dynamic HTML page's dynamic JavaScript data:
72#
73# New dynamic HTML related function to emit data:
74# escape_string, strip_escape_string, emit_warning_arrays
75# emit_js_data():
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -070076
Ian Rogersf3829732016-05-10 12:06:01 -070077import argparse
Sam Saccone03aaa7e2017-04-10 15:37:47 -070078import csv
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -070079import multiprocessing
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -070080import os
Marco Nelissen594375d2009-07-14 09:04:04 -070081import re
Chih-Hung Hsieh76d00652016-11-09 18:19:05 -080082import signal
83import sys
Marco Nelissen594375d2009-07-14 09:04:04 -070084
Ian Rogersf3829732016-05-10 12:06:01 -070085parser = argparse.ArgumentParser(description='Convert a build log into HTML')
Sam Saccone03aaa7e2017-04-10 15:37:47 -070086parser.add_argument('--csvpath',
87 help='Save CSV warning file to the passed absolute path',
88 default=None)
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -070089parser.add_argument('--gencsv',
90 help='Generate a CSV file with number of various warnings',
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -070091 action='store_true',
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -070092 default=False)
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -070093parser.add_argument('--byproject',
94 help='Separate warnings in HTML output by project names',
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -070095 action='store_true',
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -070096 default=False)
Ian Rogersf3829732016-05-10 12:06:01 -070097parser.add_argument('--url',
98 help='Root URL of an Android source code tree prefixed '
99 'before files in warnings')
100parser.add_argument('--separator',
101 help='Separator between the end of a URL and the line '
102 'number argument. e.g. #')
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -0700103parser.add_argument('--processes',
104 type=int,
105 default=multiprocessing.cpu_count(),
106 help='Number of parallel processes to process warnings')
Ian Rogersf3829732016-05-10 12:06:01 -0700107parser.add_argument(dest='buildlog', metavar='build.log',
108 help='Path to build.log file')
109args = parser.parse_args()
Marco Nelissen594375d2009-07-14 09:04:04 -0700110
Marco Nelissen594375d2009-07-14 09:04:04 -0700111
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700112class Severity(object):
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700113 """Severity levels and attributes."""
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -0700114 # numbered by dump order
115 FIXMENOW = 0
116 HIGH = 1
117 MEDIUM = 2
118 LOW = 3
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -0700119 ANALYZER = 4
120 TIDY = 5
121 HARMLESS = 6
122 UNKNOWN = 7
123 SKIP = 8
124 range = range(SKIP + 1)
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700125 attributes = [
126 # pylint:disable=bad-whitespace
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700127 ['fuchsia', 'FixNow', 'Critical warnings, fix me now'],
128 ['red', 'High', 'High severity warnings'],
129 ['orange', 'Medium', 'Medium severity warnings'],
130 ['yellow', 'Low', 'Low severity warnings'],
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -0700131 ['hotpink', 'Analyzer', 'Clang-Analyzer warnings'],
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700132 ['peachpuff', 'Tidy', 'Clang-Tidy warnings'],
133 ['limegreen', 'Harmless', 'Harmless warnings'],
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -0700134 ['lightblue', 'Unknown', 'Unknown warnings'],
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700135 ['grey', 'Unhandled', 'Unhandled warnings']
136 ]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -0700137 colors = [a[0] for a in attributes]
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700138 column_headers = [a[1] for a in attributes]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -0700139 headers = [a[2] for a in attributes]
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700140
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -0700141
142def tidy_warn_pattern(description, pattern):
143 return {
144 'category': 'C/C++',
145 'severity': Severity.TIDY,
146 'description': 'clang-tidy ' + description,
147 'patterns': [r'.*: .+\[' + pattern + r'\]$']
148 }
149
150
151def simple_tidy_warn_pattern(description):
152 return tidy_warn_pattern(description, description)
153
154
155def group_tidy_warn_pattern(description):
156 return tidy_warn_pattern(description, description + r'-.+')
157
158
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700159warn_patterns = [
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700160 # pylint:disable=line-too-long,g-inconsistent-quotes
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -0700161 {'category': 'C/C++', 'severity': Severity.ANALYZER,
162 'description': 'clang-analyzer Security warning',
163 'patterns': [r".*: warning: .+\[clang-analyzer-security.*\]"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700164 {'category': 'make', 'severity': Severity.MEDIUM,
165 'description': 'make: overriding commands/ignoring old commands',
166 'patterns': [r".*: warning: overriding commands for target .+",
167 r".*: warning: ignoring old commands for target .+"]},
168 {'category': 'make', 'severity': Severity.HIGH,
169 'description': 'make: LOCAL_CLANG is false',
170 'patterns': [r".*: warning: LOCAL_CLANG is set to false"]},
171 {'category': 'make', 'severity': Severity.HIGH,
172 'description': 'SDK App using platform shared library',
173 'patterns': [r".*: warning: .+ \(.*app:sdk.*\) should not link to .+ \(native:platform\)"]},
174 {'category': 'make', 'severity': Severity.HIGH,
175 'description': 'System module linking to a vendor module',
176 'patterns': [r".*: warning: .+ \(.+\) should not link to .+ \(partition:.+\)"]},
177 {'category': 'make', 'severity': Severity.MEDIUM,
178 'description': 'Invalid SDK/NDK linking',
179 'patterns': [r".*: warning: .+ \(.+\) should not link to .+ \(.+\)"]},
Chih-Hung Hsieh9e9355d2018-06-04 11:32:32 -0700180 {'category': 'make', 'severity': Severity.MEDIUM,
181 'description': 'Duplicate header copy',
182 'patterns': [r".*: warning: Duplicate header copy: .+"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700183 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wimplicit-function-declaration',
184 'description': 'Implicit function declaration',
185 'patterns': [r".*: warning: implicit declaration of function .+",
186 r".*: warning: implicitly declaring library function"]},
187 {'category': 'C/C++', 'severity': Severity.SKIP,
188 'description': 'skip, conflicting types for ...',
189 'patterns': [r".*: warning: conflicting types for '.+'"]},
190 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wtype-limits',
191 'description': 'Expression always evaluates to true or false',
192 'patterns': [r".*: warning: comparison is always .+ due to limited range of data type",
193 r".*: warning: comparison of unsigned .*expression .+ is always true",
194 r".*: warning: comparison of unsigned .*expression .+ is always false"]},
195 {'category': 'C/C++', 'severity': Severity.HIGH,
196 'description': 'Potential leak of memory, bad free, use after free',
197 'patterns': [r".*: warning: Potential leak of memory",
198 r".*: warning: Potential memory leak",
199 r".*: warning: Memory allocated by alloca\(\) should not be deallocated",
200 r".*: warning: Memory allocated by .+ should be deallocated by .+ not .+",
201 r".*: warning: 'delete' applied to a pointer that was allocated",
202 r".*: warning: Use of memory after it is freed",
203 r".*: warning: Argument to .+ is the address of .+ variable",
204 r".*: warning: Argument to free\(\) is offset by .+ of memory allocated by",
205 r".*: warning: Attempt to .+ released memory"]},
206 {'category': 'C/C++', 'severity': Severity.HIGH,
207 'description': 'Use transient memory for control value',
208 'patterns': [r".*: warning: .+Using such transient memory for the control value is .*dangerous."]},
209 {'category': 'C/C++', 'severity': Severity.HIGH,
210 'description': 'Return address of stack memory',
211 'patterns': [r".*: warning: Address of stack memory .+ returned to caller",
212 r".*: warning: Address of stack memory .+ will be a dangling reference"]},
213 {'category': 'C/C++', 'severity': Severity.HIGH,
214 'description': 'Problem with vfork',
215 'patterns': [r".*: warning: This .+ is prohibited after a successful vfork",
216 r".*: warning: Call to function '.+' is insecure "]},
217 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': 'infinite-recursion',
218 'description': 'Infinite recursion',
219 'patterns': [r".*: warning: all paths through this function will call itself"]},
220 {'category': 'C/C++', 'severity': Severity.HIGH,
221 'description': 'Potential buffer overflow',
222 'patterns': [r".*: warning: Size argument is greater than .+ the destination buffer",
223 r".*: warning: Potential buffer overflow.",
224 r".*: warning: String copy function overflows destination buffer"]},
225 {'category': 'C/C++', 'severity': Severity.MEDIUM,
226 'description': 'Incompatible pointer types',
227 'patterns': [r".*: warning: assignment from incompatible pointer type",
228 r".*: warning: return from incompatible pointer type",
229 r".*: warning: passing argument [0-9]+ of '.*' from incompatible pointer type",
230 r".*: warning: initialization from incompatible pointer type"]},
231 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-fno-builtin',
232 'description': 'Incompatible declaration of built in function',
233 'patterns': [r".*: warning: incompatible implicit declaration of built-in function .+"]},
234 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wincompatible-library-redeclaration',
235 'description': 'Incompatible redeclaration of library function',
236 'patterns': [r".*: warning: incompatible redeclaration of library function .+"]},
237 {'category': 'C/C++', 'severity': Severity.HIGH,
238 'description': 'Null passed as non-null argument',
239 'patterns': [r".*: warning: Null passed to a callee that requires a non-null"]},
240 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused-parameter',
241 'description': 'Unused parameter',
242 'patterns': [r".*: warning: unused parameter '.*'"]},
243 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused',
Chih-Hung Hsieh9e9355d2018-06-04 11:32:32 -0700244 'description': 'Unused function, variable, label, comparison, etc.',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700245 'patterns': [r".*: warning: '.+' defined but not used",
246 r".*: warning: unused function '.+'",
Chih-Hung Hsieh9e9355d2018-06-04 11:32:32 -0700247 r".*: warning: unused label '.+'",
248 r".*: warning: relational comparison result unused",
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -0700249 r".*: warning: lambda capture .* is not used",
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700250 r".*: warning: private field '.+' is not used",
251 r".*: warning: unused variable '.+'"]},
252 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused-value',
253 'description': 'Statement with no effect or result unused',
254 'patterns': [r".*: warning: statement with no effect",
255 r".*: warning: expression result unused"]},
256 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused-result',
257 'description': 'Ignoreing return value of function',
258 'patterns': [r".*: warning: ignoring return value of function .+Wunused-result"]},
259 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-field-initializers',
260 'description': 'Missing initializer',
261 'patterns': [r".*: warning: missing initializer"]},
262 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wdelete-non-virtual-dtor',
263 'description': 'Need virtual destructor',
264 'patterns': [r".*: warning: delete called .* has virtual functions but non-virtual destructor"]},
265 {'category': 'cont.', 'severity': Severity.SKIP,
266 'description': 'skip, near initialization for ...',
267 'patterns': [r".*: warning: \(near initialization for '.+'\)"]},
268 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wdate-time',
269 'description': 'Expansion of data or time macro',
270 'patterns': [r".*: warning: expansion of date or time macro is not reproducible"]},
271 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wformat',
272 'description': 'Format string does not match arguments',
273 'patterns': [r".*: warning: format '.+' expects type '.+', but argument [0-9]+ has type '.+'",
274 r".*: warning: more '%' conversions than data arguments",
275 r".*: warning: data argument not used by format string",
276 r".*: warning: incomplete format specifier",
277 r".*: warning: unknown conversion type .* in format",
278 r".*: warning: format .+ expects .+ but argument .+Wformat=",
279 r".*: warning: field precision should have .+ but argument has .+Wformat",
280 r".*: warning: format specifies type .+ but the argument has .*type .+Wformat"]},
281 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wformat-extra-args',
282 'description': 'Too many arguments for format string',
283 'patterns': [r".*: warning: too many arguments for format"]},
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -0700284 {'category': 'C/C++', 'severity': Severity.MEDIUM,
285 'description': 'Too many arguments in call',
286 'patterns': [r".*: warning: too many arguments in call to "]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700287 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wformat-invalid-specifier',
288 'description': 'Invalid format specifier',
289 'patterns': [r".*: warning: invalid .+ specifier '.+'.+format-invalid-specifier"]},
290 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsign-compare',
291 'description': 'Comparison between signed and unsigned',
292 'patterns': [r".*: warning: comparison between signed and unsigned",
293 r".*: warning: comparison of promoted \~unsigned with unsigned",
294 r".*: warning: signed and unsigned type in conditional expression"]},
295 {'category': 'C/C++', 'severity': Severity.MEDIUM,
296 'description': 'Comparison between enum and non-enum',
297 'patterns': [r".*: warning: enumeral and non-enumeral type in conditional expression"]},
298 {'category': 'libpng', 'severity': Severity.MEDIUM,
299 'description': 'libpng: zero area',
300 'patterns': [r".*libpng warning: Ignoring attempt to set cHRM RGB triangle with zero area"]},
301 {'category': 'aapt', 'severity': Severity.MEDIUM,
302 'description': 'aapt: no comment for public symbol',
303 'patterns': [r".*: warning: No comment for public symbol .+"]},
304 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-braces',
305 'description': 'Missing braces around initializer',
306 'patterns': [r".*: warning: missing braces around initializer.*"]},
307 {'category': 'C/C++', 'severity': Severity.HARMLESS,
308 'description': 'No newline at end of file',
309 'patterns': [r".*: warning: no newline at end of file"]},
310 {'category': 'C/C++', 'severity': Severity.HARMLESS,
311 'description': 'Missing space after macro name',
312 'patterns': [r".*: warning: missing whitespace after the macro name"]},
313 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wcast-align',
314 'description': 'Cast increases required alignment',
315 'patterns': [r".*: warning: cast from .* to .* increases required alignment .*"]},
316 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wcast-qual',
317 'description': 'Qualifier discarded',
318 'patterns': [r".*: warning: passing argument [0-9]+ of '.+' discards qualifiers from pointer target type",
319 r".*: warning: assignment discards qualifiers from pointer target type",
320 r".*: warning: passing .+ to parameter of type .+ discards qualifiers",
321 r".*: warning: assigning to .+ from .+ discards qualifiers",
322 r".*: warning: initializing .+ discards qualifiers .+types-discards-qualifiers",
323 r".*: warning: return discards qualifiers from pointer target type"]},
324 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunknown-attributes',
325 'description': 'Unknown attribute',
326 'patterns': [r".*: warning: unknown attribute '.+'"]},
327 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wignored-attributes',
328 'description': 'Attribute ignored',
329 'patterns': [r".*: warning: '_*packed_*' attribute ignored",
330 r".*: warning: attribute declaration must precede definition .+ignored-attributes"]},
331 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wvisibility',
332 'description': 'Visibility problem',
333 'patterns': [r".*: warning: declaration of '.+' will not be visible outside of this function"]},
334 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wattributes',
335 'description': 'Visibility mismatch',
336 'patterns': [r".*: warning: '.+' declared with greater visibility than the type of its field '.+'"]},
337 {'category': 'C/C++', 'severity': Severity.MEDIUM,
338 'description': 'Shift count greater than width of type',
339 'patterns': [r".*: warning: (left|right) shift count >= width of type"]},
340 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wextern-initializer',
341 'description': 'extern <foo> is initialized',
342 'patterns': [r".*: warning: '.+' initialized and declared 'extern'",
343 r".*: warning: 'extern' variable has an initializer"]},
344 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wold-style-declaration',
345 'description': 'Old style declaration',
346 'patterns': [r".*: warning: 'static' is not at beginning of declaration"]},
347 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wreturn-type',
348 'description': 'Missing return value',
349 'patterns': [r".*: warning: control reaches end of non-void function"]},
350 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wimplicit-int',
351 'description': 'Implicit int type',
352 'patterns': [r".*: warning: type specifier missing, defaults to 'int'",
353 r".*: warning: type defaults to 'int' in declaration of '.+'"]},
354 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmain-return-type',
355 'description': 'Main function should return int',
356 'patterns': [r".*: warning: return type of 'main' is not 'int'"]},
357 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wuninitialized',
358 'description': 'Variable may be used uninitialized',
359 'patterns': [r".*: warning: '.+' may be used uninitialized in this function"]},
360 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wuninitialized',
361 'description': 'Variable is used uninitialized',
362 'patterns': [r".*: warning: '.+' is used uninitialized in this function",
363 r".*: warning: variable '.+' is uninitialized when used here"]},
364 {'category': 'ld', 'severity': Severity.MEDIUM, 'option': '-fshort-enums',
365 'description': 'ld: possible enum size mismatch',
366 'patterns': [r".*: warning: .* uses variable-size enums yet the output is to use 32-bit enums; use of enum values across objects may fail"]},
367 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wpointer-sign',
368 'description': 'Pointer targets differ in signedness',
369 'patterns': [r".*: warning: pointer targets in initialization differ in signedness",
370 r".*: warning: pointer targets in assignment differ in signedness",
371 r".*: warning: pointer targets in return differ in signedness",
372 r".*: warning: pointer targets in passing argument [0-9]+ of '.+' differ in signedness"]},
373 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wstrict-overflow',
374 'description': 'Assuming overflow does not occur',
375 'patterns': [r".*: warning: assuming signed overflow does not occur when assuming that .* is always (true|false)"]},
376 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wempty-body',
377 'description': 'Suggest adding braces around empty body',
378 'patterns': [r".*: warning: suggest braces around empty body in an 'if' statement",
379 r".*: warning: empty body in an if-statement",
380 r".*: warning: suggest braces around empty body in an 'else' statement",
381 r".*: warning: empty body in an else-statement"]},
382 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wparentheses',
383 'description': 'Suggest adding parentheses',
384 'patterns': [r".*: warning: suggest explicit braces to avoid ambiguous 'else'",
385 r".*: warning: suggest parentheses around arithmetic in operand of '.+'",
386 r".*: warning: suggest parentheses around comparison in operand of '.+'",
387 r".*: warning: logical not is only applied to the left hand side of this comparison",
388 r".*: warning: using the result of an assignment as a condition without parentheses",
389 r".*: warning: .+ has lower precedence than .+ be evaluated first .+Wparentheses",
390 r".*: warning: suggest parentheses around '.+?' .+ '.+?'",
391 r".*: warning: suggest parentheses around assignment used as truth value"]},
392 {'category': 'C/C++', 'severity': Severity.MEDIUM,
393 'description': 'Static variable used in non-static inline function',
394 'patterns': [r".*: warning: '.+' is static but used in inline function '.+' which is not static"]},
395 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wimplicit int',
396 'description': 'No type or storage class (will default to int)',
397 'patterns': [r".*: warning: data definition has no type or storage class"]},
398 {'category': 'C/C++', 'severity': Severity.MEDIUM,
399 'description': 'Null pointer',
400 'patterns': [r".*: warning: Dereference of null pointer",
401 r".*: warning: Called .+ pointer is null",
402 r".*: warning: Forming reference to null pointer",
403 r".*: warning: Returning null reference",
404 r".*: warning: Null pointer passed as an argument to a 'nonnull' parameter",
405 r".*: warning: .+ results in a null pointer dereference",
406 r".*: warning: Access to .+ results in a dereference of a null pointer",
407 r".*: warning: Null pointer argument in"]},
408 {'category': 'cont.', 'severity': Severity.SKIP,
409 'description': 'skip, parameter name (without types) in function declaration',
410 'patterns': [r".*: warning: parameter names \(without types\) in function declaration"]},
411 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wstrict-aliasing',
412 'description': 'Dereferencing <foo> breaks strict aliasing rules',
413 'patterns': [r".*: warning: dereferencing .* break strict-aliasing rules"]},
414 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wpointer-to-int-cast',
415 'description': 'Cast from pointer to integer of different size',
416 'patterns': [r".*: warning: cast from pointer to integer of different size",
417 r".*: warning: initialization makes pointer from integer without a cast"]},
418 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wint-to-pointer-cast',
419 'description': 'Cast to pointer from integer of different size',
420 'patterns': [r".*: warning: cast to pointer from integer of different size"]},
421 {'category': 'C/C++', 'severity': Severity.MEDIUM,
422 'description': 'Symbol redefined',
423 'patterns': [r".*: warning: "".+"" redefined"]},
424 {'category': 'cont.', 'severity': Severity.SKIP,
425 'description': 'skip, ... location of the previous definition',
426 'patterns': [r".*: warning: this is the location of the previous definition"]},
427 {'category': 'ld', 'severity': Severity.MEDIUM,
428 'description': 'ld: type and size of dynamic symbol are not defined',
429 'patterns': [r".*: warning: type and size of dynamic symbol `.+' are not defined"]},
430 {'category': 'C/C++', 'severity': Severity.MEDIUM,
431 'description': 'Pointer from integer without cast',
432 'patterns': [r".*: warning: assignment makes pointer from integer without a cast"]},
433 {'category': 'C/C++', 'severity': Severity.MEDIUM,
434 'description': 'Pointer from integer without cast',
435 'patterns': [r".*: warning: passing argument [0-9]+ of '.+' makes pointer from integer without a cast"]},
436 {'category': 'C/C++', 'severity': Severity.MEDIUM,
437 'description': 'Integer from pointer without cast',
438 'patterns': [r".*: warning: assignment makes integer from pointer without a cast"]},
439 {'category': 'C/C++', 'severity': Severity.MEDIUM,
440 'description': 'Integer from pointer without cast',
441 'patterns': [r".*: warning: passing argument [0-9]+ of '.+' makes integer from pointer without a cast"]},
442 {'category': 'C/C++', 'severity': Severity.MEDIUM,
443 'description': 'Integer from pointer without cast',
444 'patterns': [r".*: warning: return makes integer from pointer without a cast"]},
445 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunknown-pragmas',
446 'description': 'Ignoring pragma',
447 'patterns': [r".*: warning: ignoring #pragma .+"]},
448 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-W#pragma-messages',
449 'description': 'Pragma warning messages',
450 'patterns': [r".*: warning: .+W#pragma-messages"]},
451 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wclobbered',
452 'description': 'Variable might be clobbered by longjmp or vfork',
453 'patterns': [r".*: warning: variable '.+' might be clobbered by 'longjmp' or 'vfork'"]},
454 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wclobbered',
455 'description': 'Argument might be clobbered by longjmp or vfork',
456 'patterns': [r".*: warning: argument '.+' might be clobbered by 'longjmp' or 'vfork'"]},
457 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wredundant-decls',
458 'description': 'Redundant declaration',
459 'patterns': [r".*: warning: redundant redeclaration of '.+'"]},
460 {'category': 'cont.', 'severity': Severity.SKIP,
461 'description': 'skip, previous declaration ... was here',
462 'patterns': [r".*: warning: previous declaration of '.+' was here"]},
463 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wswitch-enum',
464 'description': 'Enum value not handled in switch',
465 'patterns': [r".*: warning: .*enumeration value.* not handled in switch.+Wswitch"]},
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -0700466 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wuser-defined-warnings',
467 'description': 'User defined warnings',
468 'patterns': [r".*: warning: .* \[-Wuser-defined-warnings\]$"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700469 {'category': 'java', 'severity': Severity.MEDIUM, 'option': '-encoding',
470 'description': 'Java: Non-ascii characters used, but ascii encoding specified',
471 'patterns': [r".*: warning: unmappable character for encoding ascii"]},
472 {'category': 'java', 'severity': Severity.MEDIUM,
473 'description': 'Java: Non-varargs call of varargs method with inexact argument type for last parameter',
474 'patterns': [r".*: warning: non-varargs call of varargs method with inexact argument type for last parameter"]},
475 {'category': 'java', 'severity': Severity.MEDIUM,
476 'description': 'Java: Unchecked method invocation',
477 'patterns': [r".*: warning: \[unchecked\] unchecked method invocation: .+ in class .+"]},
478 {'category': 'java', 'severity': Severity.MEDIUM,
479 'description': 'Java: Unchecked conversion',
480 'patterns': [r".*: warning: \[unchecked\] unchecked conversion"]},
481 {'category': 'java', 'severity': Severity.MEDIUM,
482 'description': '_ used as an identifier',
483 'patterns': [r".*: warning: '_' used as an identifier"]},
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -0700484 {'category': 'java', 'severity': Severity.HIGH,
485 'description': 'Use of internal proprietary API',
486 'patterns': [r".*: warning: .* is internal proprietary API and may be removed"]},
Ian Rogers32bb9bd2016-05-09 23:19:42 -0700487
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800488 # Warnings from Javac
Ian Rogers6e520032016-05-13 08:59:00 -0700489 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700490 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700491 'description': 'Java: Use of deprecated member',
492 'patterns': [r'.*: warning: \[deprecation\] .+']},
493 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700494 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700495 'description': 'Java: Unchecked conversion',
496 'patterns': [r'.*: warning: \[unchecked\] .+']},
Ian Rogers32bb9bd2016-05-09 23:19:42 -0700497
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800498 # Begin warnings generated by Error Prone
499 {'category': 'java',
500 'severity': Severity.LOW,
501 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800502 'Java: Use parameter comments to document ambiguous literals',
503 'patterns': [r".*: warning: \[BooleanParameter\] .+"]},
504 {'category': 'java',
505 'severity': Severity.LOW,
506 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -0700507 'Java: Field name is CONSTANT_CASE, but field is not static and final',
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800508 'patterns': [r".*: warning: \[ConstantField\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -0700509 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700510 'severity': Severity.LOW,
Ian Rogers6e520032016-05-13 08:59:00 -0700511 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700512 'Java: @Multibinds is a more efficient and declarative mechanism for ensuring that a set multibinding is present in the graph.',
513 'patterns': [r".*: warning: \[EmptySetMultibindingContributions\] .+"]},
514 {'category': 'java',
515 'severity': Severity.LOW,
516 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -0700517 'Java: This field is only assigned during initialization; consider making it final',
518 'patterns': [r".*: warning: \[FieldCanBeFinal\] .+"]},
Andreas Gampe2e987af2018-06-08 09:55:41 -0700519 {'category': 'java',
520 'severity': Severity.LOW,
521 'description':
522 'Java: Fields that can be null should be annotated @Nullable',
523 'patterns': [r".*: warning: \[FieldMissingNullable\] .+"]},
524 {'category': 'java',
525 'severity': Severity.LOW,
526 'description':
Chih-Hung Hsieh9be27762018-06-07 10:51:47 -0700527 r'Java: Use Java\'s utility functional interfaces instead of Function\u003cA, B> for primitive types.',
Andreas Gampecf528ca2018-01-25 11:55:43 -0800528 'patterns': [r".*: warning: \[LambdaFunctionalInterface\] .+"]},
529 {'category': 'java',
530 'severity': Severity.LOW,
531 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800532 'Java: A private method that does not reference the enclosing instance can be static',
533 'patterns': [r".*: warning: \[MethodCanBeStatic\] .+"]},
534 {'category': 'java',
535 'severity': Severity.LOW,
536 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800537 'Java: C-style array declarations should not be used',
538 'patterns': [r".*: warning: \[MixedArrayDimensions\] .+"]},
539 {'category': 'java',
540 'severity': Severity.LOW,
541 'description':
542 'Java: Variable declarations should declare only one variable',
543 'patterns': [r".*: warning: \[MultiVariableDeclaration\] .+"]},
544 {'category': 'java',
545 'severity': Severity.LOW,
546 'description':
547 'Java: Source files should not contain multiple top-level class declarations',
548 'patterns': [r".*: warning: \[MultipleTopLevelClasses\] .+"]},
549 {'category': 'java',
550 'severity': Severity.LOW,
551 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800552 'Java: Avoid having multiple unary operators acting on the same variable in a method call',
553 'patterns': [r".*: warning: \[MultipleUnaryOperatorsInMethodCall\] .+"]},
554 {'category': 'java',
555 'severity': Severity.LOW,
556 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800557 'Java: Package names should match the directory they are declared in',
558 'patterns': [r".*: warning: \[PackageLocation\] .+"]},
559 {'category': 'java',
560 'severity': Severity.LOW,
561 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800562 'Java: Non-standard parameter comment; prefer `/*paramName=*/ arg`',
563 'patterns': [r".*: warning: \[ParameterComment\] .+"]},
564 {'category': 'java',
565 'severity': Severity.LOW,
566 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700567 'Java: Method parameters that aren\'t checked for null shouldn\'t be annotated @Nullable',
568 'patterns': [r".*: warning: \[ParameterNotNullable\] .+"]},
569 {'category': 'java',
570 'severity': Severity.LOW,
571 'description':
572 'Java: Add a private constructor to modules that will not be instantiated by Dagger.',
Andreas Gampeb9dc23a2018-06-08 10:11:26 -0700573 'patterns': [r".*: warning: \[PrivateConstructorForNoninstantiableModule\] .+"]},
Andreas Gampe2e987af2018-06-08 09:55:41 -0700574 {'category': 'java',
575 'severity': Severity.LOW,
576 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800577 'Java: Utility classes (only static members) are not designed to be instantiated and should be made noninstantiable with a default constructor.',
578 'patterns': [r".*: warning: \[PrivateConstructorForUtilityClass\] .+"]},
579 {'category': 'java',
580 'severity': Severity.LOW,
581 'description':
582 'Java: Unused imports',
583 'patterns': [r".*: warning: \[RemoveUnusedImports\] .+"]},
584 {'category': 'java',
585 'severity': Severity.LOW,
586 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700587 'Java: Methods that can return null should be annotated @Nullable',
588 'patterns': [r".*: warning: \[ReturnMissingNullable\] .+"]},
589 {'category': 'java',
590 'severity': Severity.LOW,
591 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -0700592 'Java: Scopes on modules have no function and will soon be an error.',
593 'patterns': [r".*: warning: \[ScopeOnModule\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -0800594 {'category': 'java',
595 'severity': Severity.LOW,
596 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -0700597 'Java: The default case of a switch should appear at the end of the last statement group',
598 'patterns': [r".*: warning: \[SwitchDefault\] .+"]},
Andreas Gampe2e987af2018-06-08 09:55:41 -0700599 {'category': 'java',
600 'severity': Severity.LOW,
601 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800602 'Java: Unchecked exceptions do not need to be declared in the method signature.',
603 'patterns': [r".*: warning: \[ThrowsUncheckedException\] .+"]},
604 {'category': 'java',
605 'severity': Severity.LOW,
606 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800607 'Java: Type parameters must be a single letter with an optional numeric suffix, or an UpperCamelCase name followed by the letter \'T\'.',
608 'patterns': [r".*: warning: \[TypeParameterNaming\] .+"]},
609 {'category': 'java',
610 'severity': Severity.LOW,
611 'description':
612 'Java: Constructors and methods with the same name should appear sequentially with no other code in between',
613 'patterns': [r".*: warning: \[UngroupedOverloads\] .+"]},
614 {'category': 'java',
615 'severity': Severity.LOW,
616 'description':
617 'Java: Unnecessary call to NullPointerTester#setDefault',
618 'patterns': [r".*: warning: \[UnnecessarySetDefault\] .+"]},
619 {'category': 'java',
620 'severity': Severity.LOW,
621 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800622 'Java: Using static imports for types is unnecessary',
623 'patterns': [r".*: warning: \[UnnecessaryStaticImport\] .+"]},
624 {'category': 'java',
625 'severity': Severity.LOW,
626 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700627 'Java: @Binds is a more efficient and declarative mechanism for delegating a binding.',
628 'patterns': [r".*: warning: \[UseBinds\] .+"]},
629 {'category': 'java',
630 'severity': Severity.LOW,
631 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800632 'Java: Wildcard imports, static or otherwise, should not be used',
633 'patterns': [r".*: warning: \[WildcardImport\] .+"]},
634 {'category': 'java',
Andreas Gampecf528ca2018-01-25 11:55:43 -0800635 'severity': Severity.MEDIUM,
636 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700637 'Java: Method reference is ambiguous',
638 'patterns': [r".*: warning: \[AmbiguousMethodReference\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -0800639 {'category': 'java',
640 'severity': Severity.MEDIUM,
641 'description':
642 'Java: Arguments are in the wrong order or could be commented for clarity.',
643 'patterns': [r".*: warning: \[ArgumentSelectionDefectChecker\] .+"]},
644 {'category': 'java',
645 'severity': Severity.MEDIUM,
646 'description':
647 'Java: Arguments are swapped in assertEquals-like call',
648 'patterns': [r".*: warning: \[AssertEqualsArgumentOrderChecker\] .+"]},
649 {'category': 'java',
650 'severity': Severity.MEDIUM,
651 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800652 'Java: Assertions may be disabled at runtime and do not guarantee that execution will halt here; consider throwing an exception instead',
653 'patterns': [r".*: warning: \[AssertFalse\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -0700654 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700655 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700656 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -0700657 'Java: The lambda passed to assertThows should contain exactly one statement',
658 'patterns': [r".*: warning: \[AssertThrowsMultipleStatements\] .+"]},
659 {'category': 'java',
660 'severity': Severity.MEDIUM,
661 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800662 'Java: This assertion throws an AssertionError if it fails, which will be caught by an enclosing try block.',
663 'patterns': [r".*: warning: \[AssertionFailureIgnored\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -0700664 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700665 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700666 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700667 'Java: @AssistedInject and @Inject should not be used on different constructors in the same class.',
668 'patterns': [r".*: warning: \[AssistedInjectAndInjectOnConstructors\] .+"]},
669 {'category': 'java',
670 'severity': Severity.MEDIUM,
671 'description':
Ian Rogers6e520032016-05-13 08:59:00 -0700672 'Java: Classes that implement Annotation must override equals and hashCode. Consider using AutoAnnotation instead of implementing Annotation by hand.',
673 'patterns': [r".*: warning: \[BadAnnotationImplementation\] .+"]},
674 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700675 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700676 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800677 'Java: Possible sign flip from narrowing conversion',
678 'patterns': [r".*: warning: \[BadComparable\] .+"]},
679 {'category': 'java',
680 'severity': Severity.MEDIUM,
681 'description':
Ian Rogers6e520032016-05-13 08:59:00 -0700682 'Java: BigDecimal(double) and BigDecimal.valueOf(double) may lose precision, prefer BigDecimal(String) or BigDecimal(long)',
683 'patterns': [r".*: warning: \[BigDecimalLiteralDouble\] .+"]},
684 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700685 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700686 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700687 '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.',
688 'patterns': [r".*: warning: \[BinderIdentityRestoredDangerously\] .+"]},
689 {'category': 'java',
690 'severity': Severity.MEDIUM,
691 'description':
692 'Java: This code declares a binding for a common value type without a Qualifier annotation.',
693 'patterns': [r".*: warning: \[BindingToUnqualifiedCommonType\] .+"]},
694 {'category': 'java',
695 'severity': Severity.MEDIUM,
696 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800697 'Java: valueOf or autoboxing provides better time and space performance',
698 'patterns': [r".*: warning: \[BoxedPrimitiveConstructor\] .+"]},
699 {'category': 'java',
700 'severity': Severity.MEDIUM,
701 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -0700702 'Java: ByteBuffer.array() shouldn\'t be called unless ByteBuffer.arrayOffset() is used or if the ByteBuffer was initialized using ByteBuffer.wrap() or ByteBuffer.allocate().',
703 'patterns': [r".*: warning: \[ByteBufferBackingArray\] .+"]},
704 {'category': 'java',
705 'severity': Severity.MEDIUM,
706 'description':
Ian Rogers6e520032016-05-13 08:59:00 -0700707 'Java: Mockito cannot mock final classes',
708 'patterns': [r".*: warning: \[CannotMockFinalClass\] .+"]},
709 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700710 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700711 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800712 'Java: Duration can be expressed more clearly with different units',
713 'patterns': [r".*: warning: \[CanonicalDuration\] .+"]},
714 {'category': 'java',
715 'severity': Severity.MEDIUM,
716 'description':
717 'Java: Logging or rethrowing exceptions should usually be preferred to catching and calling printStackTrace',
718 'patterns': [r".*: warning: \[CatchAndPrintStackTrace\] .+"]},
719 {'category': 'java',
720 'severity': Severity.MEDIUM,
721 'description':
722 'Java: Ignoring exceptions and calling fail() is unnecessary, and makes test output less useful',
723 'patterns': [r".*: warning: \[CatchFail\] .+"]},
724 {'category': 'java',
725 'severity': Severity.MEDIUM,
726 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800727 'Java: Inner class is non-static but does not reference enclosing class',
728 'patterns': [r".*: warning: \[ClassCanBeStatic\] .+"]},
729 {'category': 'java',
730 'severity': Severity.MEDIUM,
731 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800732 'Java: Class.newInstance() bypasses exception checking; prefer getDeclaredConstructor().newInstance()',
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800733 'patterns': [r".*: warning: \[ClassNewInstance\] .+"]},
734 {'category': 'java',
735 'severity': Severity.MEDIUM,
736 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800737 'Java: The type of the array parameter of Collection.toArray needs to be compatible with the array type',
738 'patterns': [r".*: warning: \[CollectionToArraySafeParameter\] .+"]},
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800739 {'category': 'java',
740 'severity': Severity.MEDIUM,
741 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800742 'Java: Collector.of() should not use state',
743 'patterns': [r".*: warning: \[CollectorShouldNotUseState\] .+"]},
744 {'category': 'java',
745 'severity': Severity.MEDIUM,
746 'description':
747 'Java: Class should not implement both `Comparable` and `Comparator`',
748 'patterns': [r".*: warning: \[ComparableAndComparator\] .+"]},
749 {'category': 'java',
750 'severity': Severity.MEDIUM,
751 'description':
752 'Java: Constructors should not invoke overridable methods.',
753 'patterns': [r".*: warning: \[ConstructorInvokesOverridable\] .+"]},
754 {'category': 'java',
755 'severity': Severity.MEDIUM,
756 'description':
757 'Java: Constructors should not pass the \'this\' reference out in method invocations, since the object may not be fully constructed.',
758 'patterns': [r".*: warning: \[ConstructorLeaksThis\] .+"]},
759 {'category': 'java',
760 'severity': Severity.MEDIUM,
761 'description':
762 'Java: DateFormat is not thread-safe, and should not be used as a constant field.',
763 'patterns': [r".*: warning: \[DateFormatConstant\] .+"]},
764 {'category': 'java',
765 'severity': Severity.MEDIUM,
766 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -0700767 '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 -0800768 'patterns': [r".*: warning: \[DefaultCharset\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -0700769 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700770 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700771 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -0700772 'Java: Prefer collection factory methods or builders to the double-brace initialization pattern.',
773 'patterns': [r".*: warning: \[DoubleBraceInitialization\] .+"]},
774 {'category': 'java',
775 'severity': Severity.MEDIUM,
776 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700777 'Java: Double-checked locking on non-volatile fields is unsafe',
778 'patterns': [r".*: warning: \[DoubleCheckedLocking\] .+"]},
779 {'category': 'java',
780 'severity': Severity.MEDIUM,
781 'description':
Ian Rogers6e520032016-05-13 08:59:00 -0700782 'Java: Empty top-level type declaration',
783 'patterns': [r".*: warning: \[EmptyTopLevelDeclaration\] .+"]},
784 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700785 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700786 'description':
787 'Java: Classes that override equals should also override hashCode.',
788 'patterns': [r".*: warning: \[EqualsHashCode\] .+"]},
789 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700790 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700791 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700792 'Java: An equality test between objects with incompatible types always returns false',
793 'patterns': [r".*: warning: \[EqualsIncompatibleType\] .+"]},
794 {'category': 'java',
795 'severity': Severity.MEDIUM,
796 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800797 'Java: Calls to ExpectedException#expect should always be followed by exactly one statement.',
798 'patterns': [r".*: warning: \[ExpectedExceptionChecker\] .+"]},
799 {'category': 'java',
800 'severity': Severity.MEDIUM,
801 'description':
802 'Java: Switch case may fall through',
803 'patterns': [r".*: warning: \[FallThrough\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -0700804 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700805 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700806 'description':
807 'Java: 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.',
808 'patterns': [r".*: warning: \[Finally\] .+"]},
809 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700810 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700811 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800812 'Java: Use parentheses to make the precedence explicit',
813 'patterns': [r".*: warning: \[FloatCast\] .+"]},
814 {'category': 'java',
815 'severity': Severity.MEDIUM,
816 'description':
817 'Java: Floating point literal loses precision',
818 'patterns': [r".*: warning: \[FloatingPointLiteralPrecision\] .+"]},
819 {'category': 'java',
820 'severity': Severity.MEDIUM,
821 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700822 'Java: Classes extending PreferenceActivity must implement isValidFragment such that it does not unconditionally return true to prevent vulnerability to fragment injection attacks.',
823 'patterns': [r".*: warning: \[FragmentInjection\] .+"]},
824 {'category': 'java',
825 'severity': Severity.MEDIUM,
826 'description':
827 'Java: Subclasses of Fragment must be instantiable via Class#newInstance(): the class must be public, static and have a public nullary constructor',
828 'patterns': [r".*: warning: \[FragmentNotInstantiable\] .+"]},
829 {'category': 'java',
830 'severity': Severity.MEDIUM,
831 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800832 'Java: Overloads will be ambiguous when passing lambda arguments',
833 'patterns': [r".*: warning: \[FunctionalInterfaceClash\] .+"]},
834 {'category': 'java',
835 'severity': Severity.MEDIUM,
836 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800837 'Java: Return value of methods returning Future must be checked. Ignoring returned Futures suppresses exceptions thrown from the code that completes the Future.',
838 'patterns': [r".*: warning: \[FutureReturnValueIgnored\] .+"]},
839 {'category': 'java',
840 'severity': Severity.MEDIUM,
841 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800842 'Java: Calling getClass() on an enum may return a subclass of the enum type',
843 'patterns': [r".*: warning: \[GetClassOnEnum\] .+"]},
844 {'category': 'java',
845 'severity': Severity.MEDIUM,
846 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700847 'Java: Hardcoded reference to /sdcard',
848 'patterns': [r".*: warning: \[HardCodedSdCardPath\] .+"]},
849 {'category': 'java',
850 'severity': Severity.MEDIUM,
851 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800852 'Java: Hiding fields of superclasses may cause confusion and errors',
853 'patterns': [r".*: warning: \[HidingField\] .+"]},
854 {'category': 'java',
855 'severity': Severity.MEDIUM,
856 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700857 'Java: Annotations should always be immutable',
858 'patterns': [r".*: warning: \[ImmutableAnnotationChecker\] .+"]},
859 {'category': 'java',
860 'severity': Severity.MEDIUM,
861 'description':
862 'Java: Enums should always be immutable',
863 'patterns': [r".*: warning: \[ImmutableEnumChecker\] .+"]},
864 {'category': 'java',
865 'severity': Severity.MEDIUM,
866 'description':
Ian Rogers6e520032016-05-13 08:59:00 -0700867 'Java: This annotation has incompatible modifiers as specified by its @IncompatibleModifiers annotation',
868 'patterns': [r".*: warning: \[IncompatibleModifiers\] .+"]},
869 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700870 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700871 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -0700872 'Java: It is confusing to have a field and a parameter under the same scope that differ only in capitalization.',
873 'patterns': [r".*: warning: \[InconsistentCapitalization\] .+"]},
874 {'category': 'java',
875 'severity': Severity.MEDIUM,
876 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700877 'Java: The ordering of parameters in overloaded methods should be as consistent as possible (when viewed from left to right)',
878 'patterns': [r".*: warning: \[InconsistentOverloads\] .+"]},
879 {'category': 'java',
880 'severity': Severity.MEDIUM,
881 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800882 'Java: This for loop increments the same variable in the header and in the body',
883 'patterns': [r".*: warning: \[IncrementInForLoopAndHeader\] .+"]},
884 {'category': 'java',
885 'severity': Severity.MEDIUM,
886 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700887 'Java: Constructors on abstract classes are never directly @Injected, only the constructors of their subclasses can be @Inject\'ed.',
888 'patterns': [r".*: warning: \[InjectOnConstructorOfAbstractClass\] .+"]},
889 {'category': 'java',
890 'severity': Severity.MEDIUM,
891 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800892 'Java: Please also override int read(byte[], int, int), otherwise multi-byte reads from this input stream are likely to be slow.',
893 'patterns': [r".*: warning: \[InputStreamSlowMultibyteRead\] .+"]},
894 {'category': 'java',
895 'severity': Severity.MEDIUM,
896 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800897 'Java: Casting inside an if block should be plausibly consistent with the instanceof type',
898 'patterns': [r".*: warning: \[InstanceOfAndCastMatchWrongType\] .+"]},
899 {'category': 'java',
900 'severity': Severity.MEDIUM,
901 'description':
902 'Java: Expression of type int may overflow before being assigned to a long',
903 'patterns': [r".*: warning: \[IntLongMath\] .+"]},
904 {'category': 'java',
905 'severity': Severity.MEDIUM,
906 'description':
Ian Rogers6e520032016-05-13 08:59:00 -0700907 'Java: Class should not implement both `Iterable` and `Iterator`',
908 'patterns': [r".*: warning: \[IterableAndIterator\] .+"]},
909 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700910 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700911 'description':
912 'Java: Floating-point comparison without error tolerance',
913 'patterns': [r".*: warning: \[JUnit3FloatingPointComparisonWithoutDelta\] .+"]},
914 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700915 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700916 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800917 'Java: Some JUnit4 construct cannot be used in a JUnit3 context. Convert your class to JUnit4 style to use them.',
918 'patterns': [r".*: warning: \[JUnit4ClassUsedInJUnit3\] .+"]},
919 {'category': 'java',
920 'severity': Severity.MEDIUM,
921 'description':
Ian Rogers6e520032016-05-13 08:59:00 -0700922 'Java: Test class inherits from JUnit 3\'s TestCase but has JUnit 4 @Test annotations.',
923 'patterns': [r".*: warning: \[JUnitAmbiguousTestClass\] .+"]},
924 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700925 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700926 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800927 'Java: Never reuse class names from java.lang',
928 'patterns': [r".*: warning: \[JavaLangClash\] .+"]},
929 {'category': 'java',
930 'severity': Severity.MEDIUM,
931 'description':
932 'Java: Suggests alternatives to obsolete JDK classes.',
933 'patterns': [r".*: warning: \[JdkObsolete\] .+"]},
934 {'category': 'java',
935 'severity': Severity.MEDIUM,
936 'description':
937 'Java: Assignment where a boolean expression was expected; use == if this assignment wasn\'t expected or add parentheses for clarity.',
938 'patterns': [r".*: warning: \[LogicalAssignment\] .+"]},
939 {'category': 'java',
940 'severity': Severity.MEDIUM,
941 'description':
942 'Java: Switches on enum types should either handle all values, or have a default case.',
Ian Rogers6e520032016-05-13 08:59:00 -0700943 'patterns': [r".*: warning: \[MissingCasesInEnumSwitch\] .+"]},
944 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700945 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700946 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800947 '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.)',
948 'patterns': [r".*: warning: \[MissingDefault\] .+"]},
949 {'category': 'java',
950 'severity': Severity.MEDIUM,
951 'description':
Ian Rogers6e520032016-05-13 08:59:00 -0700952 'Java: Not calling fail() when expecting an exception masks bugs',
953 'patterns': [r".*: warning: \[MissingFail\] .+"]},
954 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700955 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700956 'description':
957 'Java: method overrides method in supertype; expected @Override',
958 'patterns': [r".*: warning: \[MissingOverride\] .+"]},
959 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700960 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700961 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800962 'Java: Modifying a collection while iterating over it in a loop may cause a ConcurrentModificationException to be thrown.',
963 'patterns': [r".*: warning: \[ModifyCollectionInEnhancedForLoop\] .+"]},
964 {'category': 'java',
965 'severity': Severity.MEDIUM,
966 'description':
967 'Java: Multiple calls to either parallel or sequential are unnecessary and cause confusion.',
968 'patterns': [r".*: warning: \[MultipleParallelOrSequentialCalls\] .+"]},
969 {'category': 'java',
970 'severity': Severity.MEDIUM,
971 'description':
972 'Java: Constant field declarations should use the immutable type (such as ImmutableList) instead of the general collection interface type (such as List)',
973 'patterns': [r".*: warning: \[MutableConstantField\] .+"]},
974 {'category': 'java',
975 'severity': Severity.MEDIUM,
976 'description':
977 'Java: Method return type should use the immutable type (such as ImmutableList) instead of the general collection interface type (such as List)',
978 'patterns': [r".*: warning: \[MutableMethodReturnType\] .+"]},
979 {'category': 'java',
980 'severity': Severity.MEDIUM,
981 'description':
982 'Java: Compound assignments may hide dangerous casts',
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800983 'patterns': [r".*: warning: \[NarrowingCompoundAssignment\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -0700984 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700985 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700986 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800987 'Java: Nested instanceOf conditions of disjoint types create blocks of code that never execute',
988 'patterns': [r".*: warning: \[NestedInstanceOfConditions\] .+"]},
989 {'category': 'java',
990 'severity': Severity.MEDIUM,
991 'description':
Ian Rogers6e520032016-05-13 08:59:00 -0700992 'Java: This update of a volatile variable is non-atomic',
993 'patterns': [r".*: warning: \[NonAtomicVolatileUpdate\] .+"]},
994 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700995 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700996 'description':
997 'Java: Static import of member uses non-canonical name',
998 'patterns': [r".*: warning: \[NonCanonicalStaticMemberImport\] .+"]},
999 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001000 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001001 'description':
1002 'Java: equals method doesn\'t override Object.equals',
1003 'patterns': [r".*: warning: \[NonOverridingEquals\] .+"]},
1004 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001005 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001006 'description':
1007 'Java: Constructors should not be annotated with @Nullable since they cannot return null',
1008 'patterns': [r".*: warning: \[NullableConstructor\] .+"]},
1009 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001010 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001011 'description':
1012 'Java: @Nullable should not be used for primitive types since they cannot be null',
1013 'patterns': [r".*: warning: \[NullablePrimitive\] .+"]},
1014 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001015 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001016 'description':
1017 'Java: void-returning methods should not be annotated with @Nullable, since they cannot return null',
1018 'patterns': [r".*: warning: \[NullableVoid\] .+"]},
1019 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001020 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001021 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001022 'Java: Calling toString on Objects that don\'t override toString() doesn\'t provide useful information',
1023 'patterns': [r".*: warning: \[ObjectToString\] .+"]},
1024 {'category': 'java',
1025 'severity': Severity.MEDIUM,
1026 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001027 'Java: Use grouping parenthesis to make the operator precedence explicit',
1028 'patterns': [r".*: warning: \[OperatorPrecedence\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001029 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001030 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001031 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001032 'Java: One should not call optional.get() inside an if statement that checks !optional.isPresent',
1033 'patterns': [r".*: warning: \[OptionalNotPresent\] .+"]},
1034 {'category': 'java',
1035 'severity': Severity.MEDIUM,
1036 'description':
1037 'Java: String literal contains format specifiers, but is not passed to a format method',
1038 'patterns': [r".*: warning: \[OrphanedFormatString\] .+"]},
1039 {'category': 'java',
1040 'severity': Severity.MEDIUM,
1041 'description':
1042 'Java: To return a custom message with a Throwable class, one should override getMessage() instead of toString() for Throwable.',
1043 'patterns': [r".*: warning: \[OverrideThrowableToString\] .+"]},
1044 {'category': 'java',
1045 'severity': Severity.MEDIUM,
1046 'description':
1047 'Java: Varargs doesn\'t agree for overridden method',
1048 'patterns': [r".*: warning: \[Overrides\] .+"]},
1049 {'category': 'java',
1050 'severity': Severity.MEDIUM,
1051 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001052 '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.',
1053 'patterns': [r".*: warning: \[OverridesGuiceInjectableMethod\] .+"]},
1054 {'category': 'java',
1055 'severity': Severity.MEDIUM,
1056 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001057 'Java: Detects `/* name= */`-style comments on actual parameters where the name doesn\'t match the formal parameter',
1058 'patterns': [r".*: warning: \[ParameterName\] .+"]},
1059 {'category': 'java',
1060 'severity': Severity.MEDIUM,
1061 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001062 'Java: Preconditions only accepts the %s placeholder in error message strings',
1063 'patterns': [r".*: warning: \[PreconditionsInvalidPlaceholder\] .+"]},
1064 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001065 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001066 'description':
1067 'Java: Passing a primitive array to a varargs method is usually wrong',
1068 'patterns': [r".*: warning: \[PrimitiveArrayPassedToVarargsMethod\] .+"]},
1069 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001070 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001071 'description':
1072 'Java: Protobuf fields cannot be null, so this check is redundant',
1073 'patterns': [r".*: warning: \[ProtoFieldPreconditionsCheckNotNull\] .+"]},
1074 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001075 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001076 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001077 'Java: BugChecker has incorrect ProvidesFix tag, please update',
1078 'patterns': [r".*: warning: \[ProvidesFix\] .+"]},
1079 {'category': 'java',
1080 'severity': Severity.MEDIUM,
1081 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001082 'Java: Qualifiers/Scope annotations on @Inject methods don\'t have any effect. Move the qualifier annotation to the binding location.',
1083 'patterns': [r".*: warning: \[QualifierOrScopeOnInjectMethod\] .+"]},
1084 {'category': 'java',
1085 'severity': Severity.MEDIUM,
1086 'description':
1087 'Java: Injection frameworks currently don\'t understand Qualifiers in TYPE_PARAMETER or TYPE_USE contexts.',
Andreas Gampe2e987af2018-06-08 09:55:41 -07001088 'patterns': [r".*: warning: \[QualifierWithTypeUse\] .+"]},
1089 {'category': 'java',
1090 'severity': Severity.MEDIUM,
1091 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001092 'Java: reachabilityFence should always be called inside a finally block',
1093 'patterns': [r".*: warning: \[ReachabilityFenceUsage\] .+"]},
1094 {'category': 'java',
1095 'severity': Severity.MEDIUM,
1096 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001097 'Java: Thrown exception is a subtype of another',
1098 'patterns': [r".*: warning: \[RedundantThrows\] .+"]},
1099 {'category': 'java',
1100 'severity': Severity.MEDIUM,
1101 'description':
1102 'Java: Comparison using reference equality instead of value equality',
1103 'patterns': [r".*: warning: \[ReferenceEquality\] .+"]},
1104 {'category': 'java',
1105 'severity': Severity.MEDIUM,
1106 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001107 'Java: This annotation is missing required modifiers as specified by its @RequiredModifiers annotation',
1108 'patterns': [r".*: warning: \[RequiredModifiers\] .+"]},
1109 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001110 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001111 'description':
Chih-Hung Hsieh9be27762018-06-07 10:51:47 -07001112 r'Java: Prefer the short-circuiting boolean operators \u0026\u0026 and || to \u0026 and |.',
Andreas Gampecf528ca2018-01-25 11:55:43 -08001113 'patterns': [r".*: warning: \[ShortCircuitBoolean\] .+"]},
1114 {'category': 'java',
1115 'severity': Severity.MEDIUM,
1116 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001117 'Java: Writes to static fields should not be guarded by instance locks',
1118 'patterns': [r".*: warning: \[StaticGuardedByInstance\] .+"]},
1119 {'category': 'java',
1120 'severity': Severity.MEDIUM,
1121 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001122 'Java: A static variable or method should be qualified with a class name, not expression',
1123 'patterns': [r".*: warning: \[StaticQualifiedUsingExpression\] .+"]},
1124 {'category': 'java',
1125 'severity': Severity.MEDIUM,
1126 'description':
1127 'Java: Streams that encapsulate a closeable resource should be closed using try-with-resources',
1128 'patterns': [r".*: warning: \[StreamResourceLeak\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001129 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001130 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001131 'description':
1132 'Java: String comparison using reference equality instead of value equality',
1133 'patterns': [r".*: warning: \[StringEquality\] .+"]},
1134 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001135 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001136 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001137 'Java: String.split(String) has surprising behavior',
Andreas Gampecf528ca2018-01-25 11:55:43 -08001138 'patterns': [r".*: warning: \[StringSplitter\] .+"]},
1139 {'category': 'java',
1140 'severity': Severity.MEDIUM,
1141 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001142 'Java: Synchronizing on non-final fields is not safe: if the field is ever updated, different threads may end up locking on different objects.',
1143 'patterns': [r".*: warning: \[SynchronizeOnNonFinalField\] .+"]},
1144 {'category': 'java',
1145 'severity': Severity.MEDIUM,
1146 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001147 'Java: Using @Test(expected=...) is discouraged, since the test will pass if *any* statement in the test method throws the expected exception',
1148 'patterns': [r".*: warning: \[TestExceptionChecker\] .+"]},
1149 {'category': 'java',
1150 'severity': Severity.MEDIUM,
1151 'description':
1152 'Java: Thread.join needs to be surrounded by a loop until it succeeds, as in Uninterruptibles.joinUninterruptibly.',
1153 'patterns': [r".*: warning: \[ThreadJoinLoop\] .+"]},
1154 {'category': 'java',
1155 'severity': Severity.MEDIUM,
1156 'description':
1157 'Java: ThreadLocals should be stored in static fields',
1158 'patterns': [r".*: warning: \[ThreadLocalUsage\] .+"]},
1159 {'category': 'java',
1160 'severity': Severity.MEDIUM,
1161 'description':
1162 '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.',
1163 'patterns': [r".*: warning: \[ThreeLetterTimeZoneID\] .+"]},
1164 {'category': 'java',
1165 'severity': Severity.MEDIUM,
1166 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001167 'Java: Truth Library assert is called on a constant.',
1168 'patterns': [r".*: warning: \[TruthConstantAsserts\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001169 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001170 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001171 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001172 'Java: Argument is not compatible with the subject\'s type.',
1173 'patterns': [r".*: warning: \[TruthIncompatibleType\] .+"]},
1174 {'category': 'java',
1175 'severity': Severity.MEDIUM,
1176 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001177 'Java: Type parameter declaration overrides another type parameter already declared',
1178 'patterns': [r".*: warning: \[TypeParameterShadowing\] .+"]},
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001179 {'category': 'java',
1180 'severity': Severity.MEDIUM,
1181 'description':
1182 '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.',
1183 'patterns': [r".*: warning: \[TypeParameterUnusedInFormals\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001184 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001185 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001186 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001187 '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 -08001188 'patterns': [r".*: warning: \[URLEqualsHashCode\] .+"]},
1189 {'category': 'java',
1190 'severity': Severity.MEDIUM,
1191 'description':
1192 'Java: Switch handles all enum values; an explicit default case is unnecessary and defeats error checking for non-exhaustive switches.',
1193 'patterns': [r".*: warning: \[UnnecessaryDefaultInEnumSwitch\] .+"]},
1194 {'category': 'java',
1195 'severity': Severity.MEDIUM,
1196 'description':
1197 'Java: Finalizer may run before native code finishes execution',
1198 'patterns': [r".*: warning: \[UnsafeFinalization\] .+"]},
1199 {'category': 'java',
1200 'severity': Severity.MEDIUM,
1201 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001202 'Java: Unsynchronized method overrides a synchronized method.',
1203 'patterns': [r".*: warning: \[UnsynchronizedOverridesSynchronized\] .+"]},
1204 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001205 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001206 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001207 'Java: Java assert is used in test. For testing purposes Assert.* matchers should be used.',
1208 'patterns': [r".*: warning: \[UseCorrectAssertInTests\] .+"]},
1209 {'category': 'java',
1210 'severity': Severity.MEDIUM,
1211 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001212 'Java: Non-constant variable missing @Var annotation',
1213 'patterns': [r".*: warning: \[Var\] .+"]},
1214 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001215 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001216 'description':
1217 'Java: Because of spurious wakeups, Object.wait() and Condition.await() must always be called in a loop',
1218 'patterns': [r".*: warning: \[WaitNotInLoop\] .+"]},
1219 {'category': 'java',
Andreas Gampecf528ca2018-01-25 11:55:43 -08001220 'severity': Severity.MEDIUM,
1221 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001222 '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.',
1223 'patterns': [r".*: warning: \[WakelockReleasedDangerously\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08001224 {'category': 'java',
1225 'severity': Severity.HIGH,
1226 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001227 'Java: AndroidInjection.inject() should always be invoked before calling super.lifecycleMethod()',
1228 'patterns': [r".*: warning: \[AndroidInjectionBeforeSuper\] .+"]},
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001229 {'category': 'java',
1230 'severity': Severity.HIGH,
1231 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001232 'Java: Reference equality used to compare arrays',
1233 'patterns': [r".*: warning: \[ArrayEquals\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001234 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001235 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001236 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001237 'Java: Arrays.fill(Object[], Object) called with incompatible types.',
1238 'patterns': [r".*: warning: \[ArrayFillIncompatibleType\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001239 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001240 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001241 'description':
1242 'Java: hashcode method on array does not hash array contents',
1243 'patterns': [r".*: warning: \[ArrayHashCode\] .+"]},
1244 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001245 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001246 'description':
1247 'Java: Calling toString on an array does not provide useful information',
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001248 'patterns': [r".*: warning: \[ArrayToString\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001249 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001250 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001251 'description':
1252 'Java: Arrays.asList does not autobox primitive arrays, as one might expect.',
1253 'patterns': [r".*: warning: \[ArraysAsListPrimitiveArray\] .+"]},
1254 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001255 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001256 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001257 'Java: @AssistedInject and @Inject cannot be used on the same constructor.',
1258 'patterns': [r".*: warning: \[AssistedInjectAndInjectOnSameConstructor\] .+"]},
1259 {'category': 'java',
1260 'severity': Severity.HIGH,
1261 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001262 'Java: AsyncCallable should not return a null Future, only a Future whose result is null.',
1263 'patterns': [r".*: warning: \[AsyncCallableReturnsNull\] .+"]},
1264 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001265 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001266 'description':
1267 'Java: AsyncFunction should not return a null Future, only a Future whose result is null.',
1268 'patterns': [r".*: warning: \[AsyncFunctionReturnsNull\] .+"]},
1269 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001270 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001271 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001272 'Java: @AutoFactory and @Inject should not be used in the same type.',
1273 'patterns': [r".*: warning: \[AutoFactoryAtInject\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001274 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001275 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001276 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001277 'Java: Arguments to AutoValue constructor are in the wrong order',
1278 'patterns': [r".*: warning: \[AutoValueConstructorOrderChecker\] .+"]},
1279 {'category': 'java',
1280 'severity': Severity.HIGH,
1281 'description':
1282 'Java: Shift by an amount that is out of range',
1283 'patterns': [r".*: warning: \[BadShiftAmount\] .+"]},
Andreas Gampe2e987af2018-06-08 09:55:41 -07001284 {'category': 'java',
1285 'severity': Severity.HIGH,
1286 'description':
1287 'Java: Object serialized in Bundle may have been flattened to base type.',
1288 'patterns': [r".*: warning: \[BundleDeserializationCast\] .+"]},
1289 {'category': 'java',
1290 'severity': Severity.HIGH,
1291 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001292 '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.',
1293 'patterns': [r".*: warning: \[ChainingConstructorIgnoresParameter\] .+"]},
1294 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001295 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001296 'description':
1297 'Java: Ignored return value of method that is annotated with @CheckReturnValue',
1298 'patterns': [r".*: warning: \[CheckReturnValue\] .+"]},
1299 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001300 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001301 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001302 'Java: The source file name should match the name of the top-level class it contains',
1303 'patterns': [r".*: warning: \[ClassName\] .+"]},
1304 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001305 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001306 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001307 'Java: Incompatible type as argument to Object-accepting Java collections method',
1308 'patterns': [r".*: warning: \[CollectionIncompatibleType\] .+"]},
1309 {'category': 'java',
1310 'severity': Severity.HIGH,
1311 'description':
Chih-Hung Hsieh9be27762018-06-07 10:51:47 -07001312 r'Java: Implementing \'Comparable\u003cT>\' where T is not compatible with the implementing class.',
Andreas Gampecf528ca2018-01-25 11:55:43 -08001313 'patterns': [r".*: warning: \[ComparableType\] .+"]},
1314 {'category': 'java',
1315 'severity': Severity.HIGH,
1316 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001317 'Java: This comparison method violates the contract',
1318 'patterns': [r".*: warning: \[ComparisonContractViolated\] .+"]},
1319 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001320 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001321 'description':
1322 'Java: Comparison to value that is out of range for the compared type',
1323 'patterns': [r".*: warning: \[ComparisonOutOfRange\] .+"]},
1324 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001325 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001326 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001327 'Java: @CompatibleWith\'s value is not a type argument.',
1328 'patterns': [r".*: warning: \[CompatibleWithAnnotationMisuse\] .+"]},
1329 {'category': 'java',
1330 'severity': Severity.HIGH,
1331 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001332 'Java: Non-compile-time constant expression passed to parameter with @CompileTimeConstant type annotation.',
1333 'patterns': [r".*: warning: \[CompileTimeConstant\] .+"]},
1334 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001335 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001336 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001337 'Java: Non-trivial compile time constant boolean expressions shouldn\'t be used.',
1338 'patterns': [r".*: warning: \[ComplexBooleanConstant\] .+"]},
1339 {'category': 'java',
1340 'severity': Severity.HIGH,
1341 'description':
1342 '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.',
1343 'patterns': [r".*: warning: \[ConditionalExpressionNumericPromotion\] .+"]},
1344 {'category': 'java',
1345 'severity': Severity.HIGH,
1346 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001347 'Java: Compile-time constant expression overflows',
1348 'patterns': [r".*: warning: \[ConstantOverflow\] .+"]},
1349 {'category': 'java',
1350 'severity': Severity.HIGH,
1351 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001352 'Java: Dagger @Provides methods may not return null unless annotated with @Nullable',
1353 'patterns': [r".*: warning: \[DaggerProvidesNull\] .+"]},
1354 {'category': 'java',
1355 'severity': Severity.HIGH,
1356 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001357 'Java: Exception created but not thrown',
1358 'patterns': [r".*: warning: \[DeadException\] .+"]},
1359 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001360 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001361 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001362 'Java: Thread created but not started',
1363 'patterns': [r".*: warning: \[DeadThread\] .+"]},
1364 {'category': 'java',
1365 'severity': Severity.HIGH,
1366 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001367 'Java: Deprecated item is not annotated with @Deprecated',
1368 'patterns': [r".*: warning: \[DepAnn\] .+"]},
1369 {'category': 'java',
1370 'severity': Severity.HIGH,
1371 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001372 'Java: Division by integer literal zero',
1373 'patterns': [r".*: warning: \[DivZero\] .+"]},
1374 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001375 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001376 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001377 'Java: This method should not be called.',
1378 'patterns': [r".*: warning: \[DoNotCall\] .+"]},
1379 {'category': 'java',
1380 'severity': Severity.HIGH,
1381 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001382 'Java: Empty statement after if',
1383 'patterns': [r".*: warning: \[EmptyIf\] .+"]},
1384 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001385 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001386 'description':
1387 'Java: == NaN always returns false; use the isNaN methods instead',
1388 'patterns': [r".*: warning: \[EqualsNaN\] .+"]},
1389 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001390 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001391 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001392 'Java: == must be used in equals method to check equality to itself or an infinite loop will occur.',
1393 'patterns': [r".*: warning: \[EqualsReference\] .+"]},
1394 {'category': 'java',
1395 'severity': Severity.HIGH,
1396 'description':
1397 '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 -07001398 'patterns': [r".*: warning: \[ForOverride\] .+"]},
1399 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001400 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001401 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001402 'Java: Invalid printf-style format string',
1403 'patterns': [r".*: warning: \[FormatString\] .+"]},
1404 {'category': 'java',
1405 'severity': Severity.HIGH,
1406 'description':
1407 'Java: Invalid format string passed to formatting method.',
1408 'patterns': [r".*: warning: \[FormatStringAnnotation\] .+"]},
1409 {'category': 'java',
1410 'severity': Severity.HIGH,
1411 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001412 '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.',
1413 'patterns': [r".*: warning: \[FunctionalInterfaceMethodChanged\] .+"]},
1414 {'category': 'java',
1415 'severity': Severity.HIGH,
1416 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001417 'Java: Futures.getChecked requires a checked exception type with a standard constructor.',
1418 'patterns': [r".*: warning: \[FuturesGetCheckedIllegalExceptionType\] .+"]},
1419 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001420 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001421 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001422 'Java: DoubleMath.fuzzyEquals should never be used in an Object.equals() method',
1423 'patterns': [r".*: warning: \[FuzzyEqualsShouldNotBeUsedInEqualsMethod\] .+"]},
1424 {'category': 'java',
1425 'severity': Severity.HIGH,
1426 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001427 'Java: Calling getClass() on an annotation may return a proxy class',
1428 'patterns': [r".*: warning: \[GetClassOnAnnotation\] .+"]},
1429 {'category': 'java',
1430 'severity': Severity.HIGH,
1431 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001432 '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',
1433 'patterns': [r".*: warning: \[GetClassOnClass\] .+"]},
1434 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001435 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001436 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001437 'Java: Checks for unguarded accesses to fields and methods with @GuardedBy annotations',
1438 'patterns': [r".*: warning: \[GuardedBy\] .+"]},
1439 {'category': 'java',
1440 'severity': Severity.HIGH,
1441 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001442 'Java: Scope annotation on implementation class of AssistedInject factory is not allowed',
1443 'patterns': [r".*: warning: \[GuiceAssistedInjectScoping\] .+"]},
1444 {'category': 'java',
1445 'severity': Severity.HIGH,
1446 'description':
1447 'Java: A constructor cannot have two @Assisted parameters of the same type unless they are disambiguated with named @Assisted annotations.',
1448 'patterns': [r".*: warning: \[GuiceAssistedParameters\] .+"]},
1449 {'category': 'java',
1450 'severity': Severity.HIGH,
1451 'description':
1452 'Java: Although Guice allows injecting final fields, doing so is disallowed because the injected value may not be visible to other threads.',
1453 'patterns': [r".*: warning: \[GuiceInjectOnFinalField\] .+"]},
1454 {'category': 'java',
1455 'severity': Severity.HIGH,
1456 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001457 'Java: contains() is a legacy method that is equivalent to containsValue()',
1458 'patterns': [r".*: warning: \[HashtableContains\] .+"]},
1459 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001460 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001461 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001462 'Java: A binary expression where both operands are the same is usually incorrect.',
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001463 'patterns': [r".*: warning: \[IdentityBinaryExpression\] .+"]},
1464 {'category': 'java',
1465 'severity': Severity.HIGH,
1466 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001467 'Java: Type declaration annotated with @Immutable is not immutable',
1468 'patterns': [r".*: warning: \[Immutable\] .+"]},
1469 {'category': 'java',
1470 'severity': Severity.HIGH,
1471 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001472 'Java: Modifying an immutable collection is guaranteed to throw an exception and leave the collection unmodified',
1473 'patterns': [r".*: warning: \[ImmutableModification\] .+"]},
1474 {'category': 'java',
1475 'severity': Severity.HIGH,
1476 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001477 'Java: Passing argument to a generic method with an incompatible type.',
1478 'patterns': [r".*: warning: \[IncompatibleArgumentType\] .+"]},
1479 {'category': 'java',
1480 'severity': Severity.HIGH,
1481 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001482 'Java: The first argument to indexOf is a Unicode code point, and the second is the index to start the search from',
1483 'patterns': [r".*: warning: \[IndexOfChar\] .+"]},
1484 {'category': 'java',
1485 'severity': Severity.HIGH,
1486 'description':
1487 'Java: Conditional expression in varargs call contains array and non-array arguments',
1488 'patterns': [r".*: warning: \[InexactVarargsConditional\] .+"]},
1489 {'category': 'java',
1490 'severity': Severity.HIGH,
1491 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001492 'Java: This method always recurses, and will cause a StackOverflowError',
1493 'patterns': [r".*: warning: \[InfiniteRecursion\] .+"]},
1494 {'category': 'java',
1495 'severity': Severity.HIGH,
1496 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001497 'Java: A scoping annotation\'s Target should include TYPE and METHOD.',
1498 'patterns': [r".*: warning: \[InjectInvalidTargetingOnScopingAnnotation\] .+"]},
1499 {'category': 'java',
1500 'severity': Severity.HIGH,
1501 'description':
1502 'Java: Using more than one qualifier annotation on the same element is not allowed.',
1503 'patterns': [r".*: warning: \[InjectMoreThanOneQualifier\] .+"]},
1504 {'category': 'java',
1505 'severity': Severity.HIGH,
1506 'description':
1507 'Java: A class can be annotated with at most one scope annotation.',
1508 'patterns': [r".*: warning: \[InjectMoreThanOneScopeAnnotationOnClass\] .+"]},
1509 {'category': 'java',
1510 'severity': Severity.HIGH,
1511 'description':
1512 'Java: Scope annotation on an interface or abstact class is not allowed',
1513 'patterns': [r".*: warning: \[InjectScopeAnnotationOnInterfaceOrAbstractClass\] .+"]},
1514 {'category': 'java',
1515 'severity': Severity.HIGH,
1516 'description':
1517 'Java: Scoping and qualifier annotations must have runtime retention.',
1518 'patterns': [r".*: warning: \[InjectScopeOrQualifierAnnotationRetention\] .+"]},
1519 {'category': 'java',
1520 'severity': Severity.HIGH,
1521 'description':
1522 'Java: Injected constructors cannot be optional nor have binding annotations',
1523 'patterns': [r".*: warning: \[InjectedConstructorAnnotations\] .+"]},
1524 {'category': 'java',
1525 'severity': Severity.HIGH,
1526 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001527 'Java: A standard cryptographic operation is used in a mode that is prone to vulnerabilities',
1528 'patterns': [r".*: warning: \[InsecureCryptoUsage\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001529 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001530 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001531 'description':
1532 'Java: Invalid syntax used for a regular expression',
1533 'patterns': [r".*: warning: \[InvalidPatternSyntax\] .+"]},
1534 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001535 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001536 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001537 'Java: Invalid time zone identifier. TimeZone.getTimeZone(String) will silently return GMT instead of the time zone you intended.',
1538 'patterns': [r".*: warning: \[InvalidTimeZoneID\] .+"]},
1539 {'category': 'java',
1540 'severity': Severity.HIGH,
1541 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001542 'Java: The argument to Class#isInstance(Object) should not be a Class',
1543 'patterns': [r".*: warning: \[IsInstanceOfClass\] .+"]},
1544 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001545 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001546 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001547 'Java: Log tag too long, cannot exceed 23 characters.',
1548 'patterns': [r".*: warning: \[IsLoggableTagLength\] .+"]},
1549 {'category': 'java',
1550 'severity': Severity.HIGH,
1551 'description':
Chih-Hung Hsieh9be27762018-06-07 10:51:47 -07001552 r'Java: Path implements Iterable\u003cPath>; prefer Collection\u003cPath> for clarity',
Andreas Gampecf528ca2018-01-25 11:55:43 -08001553 'patterns': [r".*: warning: \[IterablePathParameter\] .+"]},
1554 {'category': 'java',
1555 'severity': Severity.HIGH,
1556 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001557 'Java: jMock tests must have a @RunWith(JMock.class) annotation, or the Mockery field must have a @Rule JUnit annotation',
1558 'patterns': [r".*: warning: \[JMockTestWithoutRunWithOrRuleAnnotation\] .+"]},
1559 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001560 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001561 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001562 '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 -07001563 'patterns': [r".*: warning: \[JUnit3TestNotRun\] .+"]},
1564 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001565 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001566 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001567 'Java: This method should be static',
1568 'patterns': [r".*: warning: \[JUnit4ClassAnnotationNonStatic\] .+"]},
1569 {'category': 'java',
1570 'severity': Severity.HIGH,
1571 'description':
1572 'Java: setUp() method will not be run; please add JUnit\'s @Before annotation',
Ian Rogers6e520032016-05-13 08:59:00 -07001573 'patterns': [r".*: warning: \[JUnit4SetUpNotRun\] .+"]},
1574 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001575 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001576 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001577 'Java: tearDown() method will not be run; please add JUnit\'s @After annotation',
Ian Rogers6e520032016-05-13 08:59:00 -07001578 'patterns': [r".*: warning: \[JUnit4TearDownNotRun\] .+"]},
1579 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001580 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001581 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001582 '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 -07001583 'patterns': [r".*: warning: \[JUnit4TestNotRun\] .+"]},
1584 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001585 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001586 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001587 'Java: An object is tested for reference equality to itself using JUnit library.',
1588 'patterns': [r".*: warning: \[JUnitAssertSameCheck\] .+"]},
1589 {'category': 'java',
1590 'severity': Severity.HIGH,
1591 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001592 'Java: Abstract and default methods are not injectable with javax.inject.Inject',
1593 'patterns': [r".*: warning: \[JavaxInjectOnAbstractMethod\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08001594 {'category': 'java',
1595 'severity': Severity.HIGH,
1596 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001597 'Java: @javax.inject.Inject cannot be put on a final field.',
1598 'patterns': [r".*: warning: \[JavaxInjectOnFinalField\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08001599 {'category': 'java',
1600 'severity': Severity.HIGH,
1601 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001602 'Java: This pattern will silently corrupt certain byte sequences from the serialized protocol message. Use ByteString or byte[] directly',
1603 'patterns': [r".*: warning: \[LiteByteStringUtf8\] .+"]},
1604 {'category': 'java',
1605 'severity': Severity.HIGH,
1606 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001607 'Java: This method does not acquire the locks specified by its @LockMethod annotation',
1608 'patterns': [r".*: warning: \[LockMethodChecker\] .+"]},
1609 {'category': 'java',
1610 'severity': Severity.HIGH,
1611 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001612 'Java: Prefer \'L\' to \'l\' for the suffix to long literals',
1613 'patterns': [r".*: warning: \[LongLiteralLowerCaseSuffix\] .+"]},
Andreas Gampe2e987af2018-06-08 09:55:41 -07001614 {'category': 'java',
1615 'severity': Severity.HIGH,
1616 'description':
1617 'Java: Loop condition is never modified in loop body.',
1618 'patterns': [r".*: warning: \[LoopConditionChecker\] .+"]},
1619 {'category': 'java',
1620 'severity': Severity.HIGH,
1621 'description':
1622 'Java: Certain resources in `android.R.string` have names that do not match their content',
1623 'patterns': [r".*: warning: \[MislabeledAndroidString\] .+"]},
1624 {'category': 'java',
1625 'severity': Severity.HIGH,
1626 'description':
1627 'Java: Overriding method is missing a call to overridden super method',
1628 'patterns': [r".*: warning: \[MissingSuperCall\] .+"]},
1629 {'category': 'java',
1630 'severity': Severity.HIGH,
1631 'description':
1632 'Java: Use of "YYYY" (week year) in a date pattern without "ww" (week in year). You probably meant to use "yyyy" (year) instead.',
1633 'patterns': [r".*: warning: \[MisusedWeekYear\] .+"]},
1634 {'category': 'java',
1635 'severity': Severity.HIGH,
1636 'description':
1637 'Java: A bug in Mockito will cause this test to fail at runtime with a ClassCastException',
1638 'patterns': [r".*: warning: \[MockitoCast\] .+"]},
1639 {'category': 'java',
1640 'severity': Severity.HIGH,
1641 'description':
1642 'Java: Missing method call for verify(mock) here',
1643 'patterns': [r".*: warning: \[MockitoUsage\] .+"]},
1644 {'category': 'java',
1645 'severity': Severity.HIGH,
1646 'description':
1647 'Java: Using a collection function with itself as the argument.',
1648 'patterns': [r".*: warning: \[ModifyingCollectionWithItself\] .+"]},
1649 {'category': 'java',
1650 'severity': Severity.HIGH,
1651 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001652 'Java: This class has more than one @Inject-annotated constructor. Please remove the @Inject annotation from all but one of them.',
1653 'patterns': [r".*: warning: \[MoreThanOneInjectableConstructor\] .+"]},
1654 {'category': 'java',
1655 'severity': Severity.HIGH,
1656 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001657 'Java: The result of this method must be closed.',
1658 'patterns': [r".*: warning: \[MustBeClosedChecker\] .+"]},
1659 {'category': 'java',
1660 'severity': Severity.HIGH,
1661 'description':
1662 'Java: The first argument to nCopies is the number of copies, and the second is the item to copy',
1663 'patterns': [r".*: warning: \[NCopiesOfChar\] .+"]},
1664 {'category': 'java',
1665 'severity': Severity.HIGH,
1666 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001667 'Java: @NoAllocation was specified on this method, but something was found that would trigger an allocation',
1668 'patterns': [r".*: warning: \[NoAllocation\] .+"]},
1669 {'category': 'java',
1670 'severity': Severity.HIGH,
1671 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001672 'Java: Static import of type uses non-canonical name',
1673 'patterns': [r".*: warning: \[NonCanonicalStaticImport\] .+"]},
1674 {'category': 'java',
1675 'severity': Severity.HIGH,
1676 'description':
1677 'Java: @CompileTimeConstant parameters should be final or effectively final',
1678 'patterns': [r".*: warning: \[NonFinalCompileTimeConstant\] .+"]},
1679 {'category': 'java',
1680 'severity': Severity.HIGH,
1681 'description':
1682 'Java: Calling getAnnotation on an annotation that is not retained at runtime.',
1683 'patterns': [r".*: warning: \[NonRuntimeAnnotation\] .+"]},
1684 {'category': 'java',
1685 'severity': Severity.HIGH,
1686 'description':
1687 'Java: This conditional expression may evaluate to null, which will result in an NPE when the result is unboxed.',
1688 'patterns': [r".*: warning: \[NullTernary\] .+"]},
1689 {'category': 'java',
1690 'severity': Severity.HIGH,
1691 'description':
1692 'Java: Numeric comparison using reference equality instead of value equality',
1693 'patterns': [r".*: warning: \[NumericEquality\] .+"]},
1694 {'category': 'java',
1695 'severity': Severity.HIGH,
1696 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001697 'Java: Comparison using reference equality instead of value equality',
1698 'patterns': [r".*: warning: \[OptionalEquality\] .+"]},
Andreas Gampe2e987af2018-06-08 09:55:41 -07001699 {'category': 'java',
1700 'severity': Severity.HIGH,
1701 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001702 'Java: Annotations cannot be both Scope annotations and Qualifier annotations: this causes confusion when trying to use them.',
1703 'patterns': [r".*: warning: \[OverlappingQualifierAndScopeAnnotation\] .+"]},
1704 {'category': 'java',
1705 'severity': Severity.HIGH,
1706 'description':
1707 '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.',
1708 'patterns': [r".*: warning: \[OverridesJavaxInjectableMethod\] .+"]},
Andreas Gampe2e987af2018-06-08 09:55:41 -07001709 {'category': 'java',
1710 'severity': Severity.HIGH,
1711 'description':
1712 'Java: Declaring types inside package-info.java files is very bad form',
1713 'patterns': [r".*: warning: \[PackageInfo\] .+"]},
1714 {'category': 'java',
1715 'severity': Severity.HIGH,
1716 'description':
1717 'Java: Method parameter has wrong package',
1718 'patterns': [r".*: warning: \[ParameterPackage\] .+"]},
1719 {'category': 'java',
1720 'severity': Severity.HIGH,
1721 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001722 'Java: Detects classes which implement Parcelable but don\'t have CREATOR',
1723 'patterns': [r".*: warning: \[ParcelableCreator\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08001724 {'category': 'java',
1725 'severity': Severity.HIGH,
1726 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001727 'Java: Literal passed as first argument to Preconditions.checkNotNull() can never be null',
1728 'patterns': [r".*: warning: \[PreconditionsCheckNotNull\] .+"]},
1729 {'category': 'java',
1730 'severity': Severity.HIGH,
1731 'description':
1732 'Java: First argument to `Preconditions.checkNotNull()` is a primitive rather than an object reference',
1733 'patterns': [r".*: warning: \[PreconditionsCheckNotNullPrimitive\] .+"]},
1734 {'category': 'java',
1735 'severity': Severity.HIGH,
1736 'description':
1737 'Java: Using ::equals as an incompatible Predicate; the predicate will always return false',
1738 'patterns': [r".*: warning: \[PredicateIncompatibleType\] .+"]},
1739 {'category': 'java',
1740 'severity': Severity.HIGH,
1741 'description':
1742 '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.',
1743 'patterns': [r".*: warning: \[PrivateSecurityContractProtoAccess\] .+"]},
1744 {'category': 'java',
1745 'severity': Severity.HIGH,
1746 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001747 'Java: Protobuf fields cannot be null',
1748 'patterns': [r".*: warning: \[ProtoFieldNullComparison\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08001749 {'category': 'java',
1750 'severity': Severity.HIGH,
1751 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001752 'Java: Comparing protobuf fields of type String using reference equality',
1753 'patterns': [r".*: warning: \[ProtoStringFieldReferenceEquality\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08001754 {'category': 'java',
1755 'severity': Severity.HIGH,
1756 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001757 'Java: To get the tag number of a protocol buffer enum, use getNumber() instead.',
1758 'patterns': [r".*: warning: \[ProtocolBufferOrdinal\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08001759 {'category': 'java',
1760 'severity': Severity.HIGH,
1761 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001762 'Java: @Provides methods need to be declared in a Module to have any effect.',
1763 'patterns': [r".*: warning: \[ProvidesMethodOutsideOfModule\] .+"]},
1764 {'category': 'java',
1765 'severity': Severity.HIGH,
1766 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001767 'Java: Casting a random number in the range [0.0, 1.0) to an integer or long always results in 0.',
1768 'patterns': [r".*: warning: \[RandomCast\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08001769 {'category': 'java',
1770 'severity': Severity.HIGH,
1771 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001772 'Java: Use Random.nextInt(int). Random.nextInt() % n can have negative results',
1773 'patterns': [r".*: warning: \[RandomModInteger\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08001774 {'category': 'java',
1775 'severity': Severity.HIGH,
1776 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001777 'Java: Return value of android.graphics.Rect.intersect() must be checked',
1778 'patterns': [r".*: warning: \[RectIntersectReturnValueIgnored\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08001779 {'category': 'java',
1780 'severity': Severity.HIGH,
1781 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001782 'Java: Use of method or class annotated with @RestrictTo',
1783 'patterns': [r".*: warning: \[RestrictTo\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08001784 {'category': 'java',
1785 'severity': Severity.HIGH,
1786 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001787 'Java: Check for non-whitelisted callers to RestrictedApiChecker.',
1788 'patterns': [r".*: warning: \[RestrictedApiChecker\] .+"]},
1789 {'category': 'java',
1790 'severity': Severity.HIGH,
1791 'description':
1792 'Java: Return value of this method must be used',
1793 'patterns': [r".*: warning: \[ReturnValueIgnored\] .+"]},
1794 {'category': 'java',
1795 'severity': Severity.HIGH,
1796 'description':
1797 'Java: Variable assigned to itself',
1798 'patterns': [r".*: warning: \[SelfAssignment\] .+"]},
1799 {'category': 'java',
1800 'severity': Severity.HIGH,
1801 'description':
1802 'Java: An object is compared to itself',
1803 'patterns': [r".*: warning: \[SelfComparison\] .+"]},
1804 {'category': 'java',
1805 'severity': Severity.HIGH,
1806 'description':
1807 'Java: Testing an object for equality with itself will always be true.',
1808 'patterns': [r".*: warning: \[SelfEquals\] .+"]},
1809 {'category': 'java',
1810 'severity': Severity.HIGH,
1811 'description':
1812 'Java: This method must be called with an even number of arguments.',
1813 'patterns': [r".*: warning: \[ShouldHaveEvenArgs\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08001814 {'category': 'java',
1815 'severity': Severity.HIGH,
1816 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001817 'Java: Comparison of a size >= 0 is always true, did you intend to check for non-emptiness?',
1818 'patterns': [r".*: warning: \[SizeGreaterThanOrEqualsZero\] .+"]},
1819 {'category': 'java',
1820 'severity': Severity.HIGH,
1821 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001822 'Java: Static and default interface methods are not natively supported on older Android devices. ',
1823 'patterns': [r".*: warning: \[StaticOrDefaultInterfaceMethod\] .+"]},
Andreas Gampe2e987af2018-06-08 09:55:41 -07001824 {'category': 'java',
1825 'severity': Severity.HIGH,
1826 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001827 'Java: Calling toString on a Stream does not provide useful information',
1828 'patterns': [r".*: warning: \[StreamToString\] .+"]},
Andreas Gampe2e987af2018-06-08 09:55:41 -07001829 {'category': 'java',
1830 'severity': Severity.HIGH,
1831 'description':
1832 'Java: StringBuilder does not have a char constructor; this invokes the int constructor.',
1833 'patterns': [r".*: warning: \[StringBuilderInitWithChar\] .+"]},
1834 {'category': 'java',
1835 'severity': Severity.HIGH,
1836 'description':
1837 'Java: Suppressing "deprecated" is probably a typo for "deprecation"',
1838 'patterns': [r".*: warning: \[SuppressWarningsDeprecated\] .+"]},
1839 {'category': 'java',
1840 'severity': Severity.HIGH,
1841 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001842 'Java: throwIfUnchecked(knownCheckedException) is a no-op.',
1843 'patterns': [r".*: warning: \[ThrowIfUncheckedKnownChecked\] .+"]},
1844 {'category': 'java',
1845 'severity': Severity.HIGH,
1846 'description':
1847 'Java: Throwing \'null\' always results in a NullPointerException being thrown.',
1848 'patterns': [r".*: warning: \[ThrowNull\] .+"]},
1849 {'category': 'java',
1850 'severity': Severity.HIGH,
1851 'description':
1852 'Java: isEqualTo should not be used to test an object for equality with itself; the assertion will never fail.',
1853 'patterns': [r".*: warning: \[TruthSelfEquals\] .+"]},
1854 {'category': 'java',
1855 'severity': Severity.HIGH,
1856 'description':
1857 'Java: Catching Throwable/Error masks failures from fail() or assert*() in the try block',
1858 'patterns': [r".*: warning: \[TryFailThrowable\] .+"]},
1859 {'category': 'java',
1860 'severity': Severity.HIGH,
1861 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001862 'Java: Type parameter used as type qualifier',
1863 'patterns': [r".*: warning: \[TypeParameterQualifier\] .+"]},
1864 {'category': 'java',
1865 'severity': Severity.HIGH,
1866 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001867 'Java: This method does not acquire the locks specified by its @UnlockMethod annotation',
1868 'patterns': [r".*: warning: \[UnlockMethod\] .+"]},
1869 {'category': 'java',
1870 'severity': Severity.HIGH,
1871 'description':
1872 'Java: Non-generic methods should not be invoked with type arguments',
1873 'patterns': [r".*: warning: \[UnnecessaryTypeArgument\] .+"]},
1874 {'category': 'java',
1875 'severity': Severity.HIGH,
1876 'description':
1877 'Java: Instance created but never used',
1878 'patterns': [r".*: warning: \[UnusedAnonymousClass\] .+"]},
1879 {'category': 'java',
1880 'severity': Severity.HIGH,
1881 'description':
1882 'Java: Collection is modified in place, but the result is not used',
1883 'patterns': [r".*: warning: \[UnusedCollectionModifiedInPlace\] .+"]},
1884 {'category': 'java',
1885 'severity': Severity.HIGH,
1886 'description':
1887 'Java: `var` should not be used as a type name.',
1888 'patterns': [r".*: warning: \[VarTypeName\] .+"]},
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001889
1890 # End warnings generated by Error Prone
Ian Rogers32bb9bd2016-05-09 23:19:42 -07001891
Ian Rogers6e520032016-05-13 08:59:00 -07001892 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001893 'severity': Severity.UNKNOWN,
Ian Rogers6e520032016-05-13 08:59:00 -07001894 'description': 'Java: Unclassified/unrecognized warnings',
1895 'patterns': [r".*: warning: \[.+\] .+"]},
Ian Rogers32bb9bd2016-05-09 23:19:42 -07001896
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001897 {'category': 'aapt', 'severity': Severity.MEDIUM,
1898 'description': 'aapt: No default translation',
1899 'patterns': [r".*: warning: string '.+' has no default translation in .*"]},
1900 {'category': 'aapt', 'severity': Severity.MEDIUM,
1901 'description': 'aapt: Missing default or required localization',
1902 'patterns': [r".*: warning: \*\*\*\* string '.+' has no default or required localization for '.+' in .+"]},
1903 {'category': 'aapt', 'severity': Severity.MEDIUM,
1904 'description': 'aapt: String marked untranslatable, but translation exists',
1905 'patterns': [r".*: warning: string '.+' in .* marked untranslatable but exists in locale '??_??'"]},
1906 {'category': 'aapt', 'severity': Severity.MEDIUM,
1907 'description': 'aapt: empty span in string',
1908 'patterns': [r".*: warning: empty '.+' span found in text '.+"]},
1909 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1910 'description': 'Taking address of temporary',
1911 'patterns': [r".*: warning: taking address of temporary"]},
1912 {'category': 'C/C++', 'severity': Severity.MEDIUM,
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07001913 'description': 'Taking address of packed member',
1914 'patterns': [r".*: warning: taking address of packed member"]},
1915 {'category': 'C/C++', 'severity': Severity.MEDIUM,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001916 'description': 'Possible broken line continuation',
1917 'patterns': [r".*: warning: backslash and newline separated by space"]},
1918 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wundefined-var-template',
1919 'description': 'Undefined variable template',
1920 'patterns': [r".*: warning: instantiation of variable .* no definition is available"]},
1921 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wundefined-inline',
1922 'description': 'Inline function is not defined',
1923 'patterns': [r".*: warning: inline function '.*' is not defined"]},
1924 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Warray-bounds',
1925 'description': 'Array subscript out of bounds',
1926 'patterns': [r".*: warning: array subscript is above array bounds",
1927 r".*: warning: Array subscript is undefined",
1928 r".*: warning: array subscript is below array bounds"]},
1929 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1930 'description': 'Excess elements in initializer',
1931 'patterns': [r".*: warning: excess elements in .+ initializer"]},
1932 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1933 'description': 'Decimal constant is unsigned only in ISO C90',
1934 'patterns': [r".*: warning: this decimal constant is unsigned only in ISO C90"]},
1935 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmain',
1936 'description': 'main is usually a function',
1937 'patterns': [r".*: warning: 'main' is usually a function"]},
1938 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1939 'description': 'Typedef ignored',
1940 'patterns': [r".*: warning: 'typedef' was ignored in this declaration"]},
1941 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Waddress',
1942 'description': 'Address always evaluates to true',
1943 'patterns': [r".*: warning: the address of '.+' will always evaluate as 'true'"]},
1944 {'category': 'C/C++', 'severity': Severity.FIXMENOW,
1945 'description': 'Freeing a non-heap object',
1946 'patterns': [r".*: warning: attempt to free a non-heap object '.+'"]},
1947 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wchar-subscripts',
1948 'description': 'Array subscript has type char',
1949 'patterns': [r".*: warning: array subscript .+ type 'char'.+Wchar-subscripts"]},
1950 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1951 'description': 'Constant too large for type',
1952 'patterns': [r".*: warning: integer constant is too large for '.+' type"]},
1953 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Woverflow',
1954 'description': 'Constant too large for type, truncated',
1955 'patterns': [r".*: warning: large integer implicitly truncated to unsigned type"]},
1956 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Winteger-overflow',
1957 'description': 'Overflow in expression',
1958 'patterns': [r".*: warning: overflow in expression; .*Winteger-overflow"]},
1959 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Woverflow',
1960 'description': 'Overflow in implicit constant conversion',
1961 'patterns': [r".*: warning: overflow in implicit constant conversion"]},
1962 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1963 'description': 'Declaration does not declare anything',
1964 'patterns': [r".*: warning: declaration 'class .+' does not declare anything"]},
1965 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wreorder',
1966 'description': 'Initialization order will be different',
1967 'patterns': [r".*: warning: '.+' will be initialized after",
1968 r".*: warning: field .+ will be initialized after .+Wreorder"]},
1969 {'category': 'cont.', 'severity': Severity.SKIP,
1970 'description': 'skip, ....',
1971 'patterns': [r".*: warning: '.+'"]},
1972 {'category': 'cont.', 'severity': Severity.SKIP,
1973 'description': 'skip, base ...',
1974 'patterns': [r".*: warning: base '.+'"]},
1975 {'category': 'cont.', 'severity': Severity.SKIP,
1976 'description': 'skip, when initialized here',
1977 'patterns': [r".*: warning: when initialized here"]},
1978 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-parameter-type',
1979 'description': 'Parameter type not specified',
1980 'patterns': [r".*: warning: type of '.+' defaults to 'int'"]},
1981 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-declarations',
1982 'description': 'Missing declarations',
1983 'patterns': [r".*: warning: declaration does not declare anything"]},
1984 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-noreturn',
1985 'description': 'Missing noreturn',
1986 'patterns': [r".*: warning: function '.*' could be declared with attribute 'noreturn'"]},
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001987 # pylint:disable=anomalous-backslash-in-string
1988 # TODO(chh): fix the backslash pylint warning.
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001989 {'category': 'gcc', 'severity': Severity.MEDIUM,
1990 'description': 'Invalid option for C file',
1991 'patterns': [r".*: warning: command line option "".+"" is valid for C\+\+\/ObjC\+\+ but not for C"]},
1992 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1993 'description': 'User warning',
1994 'patterns': [r".*: warning: #warning "".+"""]},
1995 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wvexing-parse',
1996 'description': 'Vexing parsing problem',
1997 'patterns': [r".*: warning: empty parentheses interpreted as a function declaration"]},
1998 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wextra',
1999 'description': 'Dereferencing void*',
2000 'patterns': [r".*: warning: dereferencing 'void \*' pointer"]},
2001 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2002 'description': 'Comparison of pointer and integer',
2003 'patterns': [r".*: warning: ordered comparison of pointer with integer zero",
2004 r".*: warning: .*comparison between pointer and integer"]},
2005 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2006 'description': 'Use of error-prone unary operator',
2007 'patterns': [r".*: warning: use of unary operator that may be intended as compound assignment"]},
2008 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wwrite-strings',
2009 'description': 'Conversion of string constant to non-const char*',
2010 'patterns': [r".*: warning: deprecated conversion from string constant to '.+'"]},
2011 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wstrict-prototypes',
2012 'description': 'Function declaration isn''t a prototype',
2013 'patterns': [r".*: warning: function declaration isn't a prototype"]},
2014 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wignored-qualifiers',
2015 'description': 'Type qualifiers ignored on function return value',
2016 'patterns': [r".*: warning: type qualifiers ignored on function return type",
2017 r".*: warning: .+ type qualifier .+ has no effect .+Wignored-qualifiers"]},
2018 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2019 'description': '<foo> declared inside parameter list, scope limited to this definition',
2020 'patterns': [r".*: warning: '.+' declared inside parameter list"]},
2021 {'category': 'cont.', 'severity': Severity.SKIP,
2022 'description': 'skip, its scope is only this ...',
2023 'patterns': [r".*: warning: its scope is only this definition or declaration, which is probably not what you want"]},
2024 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wcomment',
2025 'description': 'Line continuation inside comment',
2026 'patterns': [r".*: warning: multi-line comment"]},
2027 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wcomment',
2028 'description': 'Comment inside comment',
2029 'patterns': [r".*: warning: "".+"" within comment"]},
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07002030 # Warning "value stored is never read" could be from clang-tidy or clang static analyzer.
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002031 {'category': 'C/C++', 'severity': Severity.ANALYZER,
2032 'description': 'clang-analyzer Value stored is never read',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002033 'patterns': [r".*: warning: Value stored to .+ is never read.*clang-analyzer-deadcode.DeadStores"]},
2034 {'category': 'C/C++', 'severity': Severity.LOW,
2035 'description': 'Value stored is never read',
2036 'patterns': [r".*: warning: Value stored to .+ is never read"]},
2037 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wdeprecated-declarations',
2038 'description': 'Deprecated declarations',
2039 'patterns': [r".*: warning: .+ is deprecated.+deprecated-declarations"]},
2040 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wdeprecated-register',
2041 'description': 'Deprecated register',
2042 'patterns': [r".*: warning: 'register' storage class specifier is deprecated"]},
2043 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wpointer-sign',
2044 'description': 'Converts between pointers to integer types with different sign',
2045 'patterns': [r".*: warning: .+ converts between pointers to integer types with different sign"]},
2046 {'category': 'C/C++', 'severity': Severity.HARMLESS,
2047 'description': 'Extra tokens after #endif',
2048 'patterns': [r".*: warning: extra tokens at end of #endif directive"]},
2049 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wenum-compare',
2050 'description': 'Comparison between different enums',
2051 'patterns': [r".*: warning: comparison between '.+' and '.+'.+Wenum-compare"]},
2052 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wconversion',
2053 'description': 'Conversion may change value',
2054 'patterns': [r".*: warning: converting negative value '.+' to '.+'",
2055 r".*: warning: conversion to '.+' .+ may (alter|change)"]},
2056 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wconversion-null',
2057 'description': 'Converting to non-pointer type from NULL',
2058 'patterns': [r".*: warning: converting to non-pointer type '.+' from NULL"]},
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07002059 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsign-conversion',
2060 'description': 'Implicit sign conversion',
2061 'patterns': [r".*: warning: implicit conversion changes signedness"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002062 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wnull-conversion',
2063 'description': 'Converting NULL to non-pointer type',
2064 'patterns': [r".*: warning: implicit conversion of NULL constant to '.+'"]},
2065 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wnon-literal-null-conversion',
2066 'description': 'Zero used as null pointer',
2067 'patterns': [r".*: warning: expression .* zero treated as a null pointer constant"]},
2068 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2069 'description': 'Implicit conversion changes value',
2070 'patterns': [r".*: warning: implicit conversion .* changes value from .* to .*-conversion"]},
2071 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2072 'description': 'Passing NULL as non-pointer argument',
2073 'patterns': [r".*: warning: passing NULL to non-pointer argument [0-9]+ of '.+'"]},
2074 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wctor-dtor-privacy',
2075 'description': 'Class seems unusable because of private ctor/dtor',
2076 'patterns': [r".*: warning: all member functions in class '.+' are private"]},
Marco Nelissen594375d2009-07-14 09:04:04 -07002077 # 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 -07002078 {'category': 'C/C++', 'severity': Severity.SKIP, 'option': '-Wctor-dtor-privacy',
2079 'description': 'Class seems unusable because of private ctor/dtor',
2080 'patterns': [r".*: warning: 'class .+' only defines a private destructor and has no friends"]},
2081 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wctor-dtor-privacy',
2082 'description': 'Class seems unusable because of private ctor/dtor',
2083 'patterns': [r".*: warning: 'class .+' only defines private constructors and has no friends"]},
2084 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wgnu-static-float-init',
2085 'description': 'In-class initializer for static const float/double',
2086 'patterns': [r".*: warning: in-class initializer for static data member of .+const (float|double)"]},
2087 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wpointer-arith',
2088 'description': 'void* used in arithmetic',
2089 'patterns': [r".*: warning: pointer of type 'void \*' used in (arithmetic|subtraction)",
2090 r".*: warning: arithmetic on .+ to void is a GNU extension.*Wpointer-arith",
2091 r".*: warning: wrong type argument to increment"]},
2092 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsign-promo',
2093 'description': 'Overload resolution chose to promote from unsigned or enum to signed type',
2094 'patterns': [r".*: warning: passing '.+' chooses '.+' over '.+'.*Wsign-promo"]},
2095 {'category': 'cont.', 'severity': Severity.SKIP,
2096 'description': 'skip, in call to ...',
2097 'patterns': [r".*: warning: in call to '.+'"]},
2098 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wextra',
2099 'description': 'Base should be explicitly initialized in copy constructor',
2100 'patterns': [r".*: warning: base class '.+' should be explicitly initialized in the copy constructor"]},
2101 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2102 'description': 'VLA has zero or negative size',
2103 'patterns': [r".*: warning: Declared variable-length array \(VLA\) has .+ size"]},
2104 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2105 'description': 'Return value from void function',
2106 'patterns': [r".*: warning: 'return' with a value, in function returning void"]},
2107 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'multichar',
2108 'description': 'Multi-character character constant',
2109 'patterns': [r".*: warning: multi-character character constant"]},
2110 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'writable-strings',
2111 'description': 'Conversion from string literal to char*',
2112 'patterns': [r".*: warning: .+ does not allow conversion from string literal to 'char \*'"]},
2113 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wextra-semi',
2114 'description': 'Extra \';\'',
2115 'patterns': [r".*: warning: extra ';' .+extra-semi"]},
2116 {'category': 'C/C++', 'severity': Severity.LOW,
2117 'description': 'Useless specifier',
2118 'patterns': [r".*: warning: useless storage class specifier in empty declaration"]},
2119 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wduplicate-decl-specifier',
2120 'description': 'Duplicate declaration specifier',
2121 'patterns': [r".*: warning: duplicate '.+' declaration specifier"]},
2122 {'category': 'logtags', 'severity': Severity.LOW,
2123 'description': 'Duplicate logtag',
2124 'patterns': [r".*: warning: tag \".+\" \(.+\) duplicated in .+"]},
2125 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'typedef-redefinition',
2126 'description': 'Typedef redefinition',
2127 'patterns': [r".*: warning: redefinition of typedef '.+' is a C11 feature"]},
2128 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'gnu-designator',
2129 'description': 'GNU old-style field designator',
2130 'patterns': [r".*: warning: use of GNU old-style field designator extension"]},
2131 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'missing-field-initializers',
2132 'description': 'Missing field initializers',
2133 'patterns': [r".*: warning: missing field '.+' initializer"]},
2134 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'missing-braces',
2135 'description': 'Missing braces',
2136 'patterns': [r".*: warning: suggest braces around initialization of",
2137 r".*: warning: too many braces around scalar initializer .+Wmany-braces-around-scalar-init",
2138 r".*: warning: braces around scalar initializer"]},
2139 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'sign-compare',
2140 'description': 'Comparison of integers of different signs',
2141 'patterns': [r".*: warning: comparison of integers of different signs.+sign-compare"]},
2142 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'dangling-else',
2143 'description': 'Add braces to avoid dangling else',
2144 'patterns': [r".*: warning: add explicit braces to avoid dangling else"]},
2145 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'initializer-overrides',
2146 'description': 'Initializer overrides prior initialization',
2147 'patterns': [r".*: warning: initializer overrides prior initialization of this subobject"]},
2148 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'self-assign',
2149 'description': 'Assigning value to self',
2150 'patterns': [r".*: warning: explicitly assigning value of .+ to itself"]},
2151 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'gnu-variable-sized-type-not-at-end',
2152 'description': 'GNU extension, variable sized type not at end',
2153 'patterns': [r".*: warning: field '.+' with variable sized type '.+' not at the end of a struct or class"]},
2154 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'tautological-constant-out-of-range-compare',
2155 'description': 'Comparison of constant is always false/true',
2156 'patterns': [r".*: comparison of .+ is always .+Wtautological-constant-out-of-range-compare"]},
2157 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'overloaded-virtual',
2158 'description': 'Hides overloaded virtual function',
2159 'patterns': [r".*: '.+' hides overloaded virtual function"]},
2160 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'incompatible-pointer-types',
2161 'description': 'Incompatible pointer types',
2162 'patterns': [r".*: warning: incompatible pointer types .+Wincompatible-pointer-types"]},
2163 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'asm-operand-widths',
2164 'description': 'ASM value size does not match register size',
2165 'patterns': [r".*: warning: value size does not match register size specified by the constraint and modifier"]},
2166 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'tautological-compare',
2167 'description': 'Comparison of self is always false',
2168 'patterns': [r".*: self-comparison always evaluates to false"]},
2169 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'constant-logical-operand',
2170 'description': 'Logical op with constant operand',
2171 'patterns': [r".*: use of logical '.+' with constant operand"]},
2172 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'literal-suffix',
2173 'description': 'Needs a space between literal and string macro',
2174 'patterns': [r".*: warning: invalid suffix on literal.+ requires a space .+Wliteral-suffix"]},
2175 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '#warnings',
2176 'description': 'Warnings from #warning',
2177 'patterns': [r".*: warning: .+-W#warnings"]},
2178 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'absolute-value',
2179 'description': 'Using float/int absolute value function with int/float argument',
2180 'patterns': [r".*: warning: using .+ absolute value function .+ when argument is .+ type .+Wabsolute-value",
2181 r".*: warning: absolute value function '.+' given .+ which may cause truncation .+Wabsolute-value"]},
2182 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wc++11-extensions',
2183 'description': 'Using C++11 extensions',
2184 'patterns': [r".*: warning: 'auto' type specifier is a C\+\+11 extension"]},
2185 {'category': 'C/C++', 'severity': Severity.LOW,
2186 'description': 'Refers to implicitly defined namespace',
2187 'patterns': [r".*: warning: using directive refers to implicitly-defined namespace .+"]},
2188 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Winvalid-pp-token',
2189 'description': 'Invalid pp token',
2190 'patterns': [r".*: warning: missing .+Winvalid-pp-token"]},
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07002191 {'category': 'link', 'severity': Severity.LOW,
2192 'description': 'need glibc to link',
2193 'patterns': [r".*: warning: .* requires at runtime .* glibc .* for linking"]},
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07002194
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002195 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2196 'description': 'Operator new returns NULL',
2197 'patterns': [r".*: warning: 'operator new' must not return NULL unless it is declared 'throw\(\)' .+"]},
2198 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wnull-arithmetic',
2199 'description': 'NULL used in arithmetic',
2200 'patterns': [r".*: warning: NULL used in arithmetic",
2201 r".*: warning: comparison between NULL and non-pointer"]},
2202 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'header-guard',
2203 'description': 'Misspelled header guard',
2204 'patterns': [r".*: warning: '.+' is used as a header guard .+ followed by .+ different macro"]},
2205 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'empty-body',
2206 'description': 'Empty loop body',
2207 'patterns': [r".*: warning: .+ loop has empty body"]},
2208 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'enum-conversion',
2209 'description': 'Implicit conversion from enumeration type',
2210 'patterns': [r".*: warning: implicit conversion from enumeration type '.+'"]},
2211 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'switch',
2212 'description': 'case value not in enumerated type',
2213 'patterns': [r".*: warning: case value not in enumerated type '.+'"]},
2214 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2215 'description': 'Undefined result',
2216 'patterns': [r".*: warning: The result of .+ is undefined",
2217 r".*: warning: passing an object that .+ has undefined behavior \[-Wvarargs\]",
2218 r".*: warning: 'this' pointer cannot be null in well-defined C\+\+ code;",
2219 r".*: warning: shifting a negative signed value is undefined"]},
2220 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2221 'description': 'Division by zero',
2222 'patterns': [r".*: warning: Division by zero"]},
2223 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2224 'description': 'Use of deprecated method',
2225 'patterns': [r".*: warning: '.+' is deprecated .+"]},
2226 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2227 'description': 'Use of garbage or uninitialized value',
2228 'patterns': [r".*: warning: .+ is a garbage value",
2229 r".*: warning: Function call argument is an uninitialized value",
2230 r".*: warning: Undefined or garbage value returned to caller",
2231 r".*: warning: Called .+ pointer is.+uninitialized",
2232 r".*: warning: Called .+ pointer is.+uninitalized", # match a typo in compiler message
2233 r".*: warning: Use of zero-allocated memory",
2234 r".*: warning: Dereference of undefined pointer value",
2235 r".*: warning: Passed-by-value .+ contains uninitialized data",
2236 r".*: warning: Branch condition evaluates to a garbage value",
2237 r".*: warning: The .+ of .+ is an uninitialized value.",
2238 r".*: warning: .+ is used uninitialized whenever .+sometimes-uninitialized",
2239 r".*: warning: Assigned value is garbage or undefined"]},
2240 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2241 'description': 'Result of malloc type incompatible with sizeof operand type',
2242 'patterns': [r".*: warning: Result of '.+' is converted to .+ incompatible with sizeof operand type"]},
2243 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsizeof-array-argument',
2244 'description': 'Sizeof on array argument',
2245 'patterns': [r".*: warning: sizeof on array function parameter will return"]},
2246 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsizeof-pointer-memacces',
2247 'description': 'Bad argument size of memory access functions',
2248 'patterns': [r".*: warning: .+\[-Wsizeof-pointer-memaccess\]"]},
2249 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2250 'description': 'Return value not checked',
2251 'patterns': [r".*: warning: The return value from .+ is not checked"]},
2252 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2253 'description': 'Possible heap pollution',
2254 'patterns': [r".*: warning: .*Possible heap pollution from .+ type .+"]},
2255 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2256 'description': 'Allocation size of 0 byte',
2257 'patterns': [r".*: warning: Call to .+ has an allocation size of 0 byte"]},
2258 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2259 'description': 'Result of malloc type incompatible with sizeof operand type',
2260 'patterns': [r".*: warning: Result of '.+' is converted to .+ incompatible with sizeof operand type"]},
2261 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wfor-loop-analysis',
2262 'description': 'Variable used in loop condition not modified in loop body',
2263 'patterns': [r".*: warning: variable '.+' used in loop condition.*Wfor-loop-analysis"]},
2264 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2265 'description': 'Closing a previously closed file',
2266 'patterns': [r".*: warning: Closing a previously closed file"]},
2267 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunnamed-type-template-args',
2268 'description': 'Unnamed template type argument',
2269 'patterns': [r".*: warning: template argument.+Wunnamed-type-template-args"]},
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07002270
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002271 {'category': 'C/C++', 'severity': Severity.HARMLESS,
2272 'description': 'Discarded qualifier from pointer target type',
2273 'patterns': [r".*: warning: .+ discards '.+' qualifier from pointer target type"]},
2274 {'category': 'C/C++', 'severity': Severity.HARMLESS,
2275 'description': 'Use snprintf instead of sprintf',
2276 'patterns': [r".*: warning: .*sprintf is often misused; please use snprintf"]},
2277 {'category': 'C/C++', 'severity': Severity.HARMLESS,
2278 'description': 'Unsupported optimizaton flag',
2279 'patterns': [r".*: warning: optimization flag '.+' is not supported"]},
2280 {'category': 'C/C++', 'severity': Severity.HARMLESS,
2281 'description': 'Extra or missing parentheses',
2282 'patterns': [r".*: warning: equality comparison with extraneous parentheses",
2283 r".*: warning: .+ within .+Wlogical-op-parentheses"]},
2284 {'category': 'C/C++', 'severity': Severity.HARMLESS, 'option': 'mismatched-tags',
2285 'description': 'Mismatched class vs struct tags',
2286 'patterns': [r".*: warning: '.+' defined as a .+ here but previously declared as a .+mismatched-tags",
2287 r".*: warning: .+ was previously declared as a .+mismatched-tags"]},
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07002288 {'category': 'FindEmulator', 'severity': Severity.HARMLESS,
2289 'description': 'FindEmulator: No such file or directory',
2290 'patterns': [r".*: warning: FindEmulator: .* No such file or directory"]},
2291 {'category': 'google_tests', 'severity': Severity.HARMLESS,
2292 'description': 'google_tests: unknown installed file',
2293 'patterns': [r".*: warning: .*_tests: Unknown installed file for module"]},
2294 {'category': 'make', 'severity': Severity.HARMLESS,
2295 'description': 'unusual tags debug eng',
2296 'patterns': [r".*: warning: .*: unusual tags debug eng"]},
Marco Nelissen594375d2009-07-14 09:04:04 -07002297
2298 # 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 -07002299 {'category': 'C/C++', 'severity': Severity.SKIP,
2300 'description': 'skip, ,',
2301 'patterns': [r".*: warning: ,$"]},
2302 {'category': 'C/C++', 'severity': Severity.SKIP,
2303 'description': 'skip,',
2304 'patterns': [r".*: warning: $"]},
2305 {'category': 'C/C++', 'severity': Severity.SKIP,
2306 'description': 'skip, In file included from ...',
2307 'patterns': [r".*: warning: In file included from .+,"]},
Marco Nelissen594375d2009-07-14 09:04:04 -07002308
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07002309 # warnings from clang-tidy
Chih-Hung Hsieh2cd467b2017-11-16 15:42:11 -08002310 group_tidy_warn_pattern('android'),
Chih-Hung Hsieh9e9355d2018-06-04 11:32:32 -07002311 simple_tidy_warn_pattern('bugprone-argument-comment'),
2312 simple_tidy_warn_pattern('bugprone-copy-constructor-init'),
2313 simple_tidy_warn_pattern('bugprone-fold-init-type'),
2314 simple_tidy_warn_pattern('bugprone-forward-declaration-namespace'),
2315 simple_tidy_warn_pattern('bugprone-forwarding-reference-overload'),
2316 simple_tidy_warn_pattern('bugprone-inaccurate-erase'),
2317 simple_tidy_warn_pattern('bugprone-incorrect-roundings'),
2318 simple_tidy_warn_pattern('bugprone-integer-division'),
2319 simple_tidy_warn_pattern('bugprone-lambda-function-name'),
2320 simple_tidy_warn_pattern('bugprone-macro-parentheses'),
2321 simple_tidy_warn_pattern('bugprone-misplaced-widening-cast'),
2322 simple_tidy_warn_pattern('bugprone-move-forwarding-reference'),
2323 simple_tidy_warn_pattern('bugprone-sizeof-expression'),
2324 simple_tidy_warn_pattern('bugprone-string-constructor'),
2325 simple_tidy_warn_pattern('bugprone-string-integer-assignment'),
2326 simple_tidy_warn_pattern('bugprone-suspicious-enum-usage'),
2327 simple_tidy_warn_pattern('bugprone-suspicious-missing-comma'),
2328 simple_tidy_warn_pattern('bugprone-suspicious-string-compare'),
2329 simple_tidy_warn_pattern('bugprone-suspicious-semicolon'),
2330 simple_tidy_warn_pattern('bugprone-undefined-memory-manipulation'),
2331 simple_tidy_warn_pattern('bugprone-unused-raii'),
2332 simple_tidy_warn_pattern('bugprone-use-after-move'),
2333 group_tidy_warn_pattern('bugprone'),
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07002334 group_tidy_warn_pattern('cert'),
2335 group_tidy_warn_pattern('clang-diagnostic'),
2336 group_tidy_warn_pattern('cppcoreguidelines'),
2337 group_tidy_warn_pattern('llvm'),
2338 simple_tidy_warn_pattern('google-default-arguments'),
2339 simple_tidy_warn_pattern('google-runtime-int'),
2340 simple_tidy_warn_pattern('google-runtime-operator'),
2341 simple_tidy_warn_pattern('google-runtime-references'),
2342 group_tidy_warn_pattern('google-build'),
2343 group_tidy_warn_pattern('google-explicit'),
2344 group_tidy_warn_pattern('google-redability'),
2345 group_tidy_warn_pattern('google-global'),
2346 group_tidy_warn_pattern('google-redability'),
2347 group_tidy_warn_pattern('google-redability'),
2348 group_tidy_warn_pattern('google'),
2349 simple_tidy_warn_pattern('hicpp-explicit-conversions'),
2350 simple_tidy_warn_pattern('hicpp-function-size'),
2351 simple_tidy_warn_pattern('hicpp-invalid-access-moved'),
2352 simple_tidy_warn_pattern('hicpp-member-init'),
2353 simple_tidy_warn_pattern('hicpp-delete-operators'),
2354 simple_tidy_warn_pattern('hicpp-special-member-functions'),
2355 simple_tidy_warn_pattern('hicpp-use-equals-default'),
2356 simple_tidy_warn_pattern('hicpp-use-equals-delete'),
2357 simple_tidy_warn_pattern('hicpp-no-assembler'),
2358 simple_tidy_warn_pattern('hicpp-noexcept-move'),
2359 simple_tidy_warn_pattern('hicpp-use-override'),
2360 group_tidy_warn_pattern('hicpp'),
2361 group_tidy_warn_pattern('modernize'),
2362 group_tidy_warn_pattern('misc'),
2363 simple_tidy_warn_pattern('performance-faster-string-find'),
2364 simple_tidy_warn_pattern('performance-for-range-copy'),
2365 simple_tidy_warn_pattern('performance-implicit-cast-in-loop'),
2366 simple_tidy_warn_pattern('performance-inefficient-string-concatenation'),
2367 simple_tidy_warn_pattern('performance-type-promotion-in-math-fn'),
2368 simple_tidy_warn_pattern('performance-unnecessary-copy-initialization'),
2369 simple_tidy_warn_pattern('performance-unnecessary-value-param'),
2370 group_tidy_warn_pattern('performance'),
2371 group_tidy_warn_pattern('readability'),
2372
2373 # warnings from clang-tidy's clang-analyzer checks
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002374 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002375 'description': 'clang-analyzer Unreachable code',
2376 'patterns': [r".*: warning: This statement is never executed.*UnreachableCode"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002377 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002378 'description': 'clang-analyzer Size of malloc may overflow',
2379 'patterns': [r".*: warning: .* size of .* may overflow .*MallocOverflow"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002380 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002381 'description': 'clang-analyzer Stream pointer might be NULL',
2382 'patterns': [r".*: warning: Stream pointer might be NULL .*unix.Stream"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002383 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002384 'description': 'clang-analyzer Opened file never closed',
2385 'patterns': [r".*: warning: Opened File never closed.*unix.Stream"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002386 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002387 'description': 'clang-analyzer sozeof() on a pointer type',
2388 'patterns': [r".*: warning: .*calls sizeof.* on a pointer type.*SizeofPtr"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002389 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002390 'description': 'clang-analyzer Pointer arithmetic on non-array variables',
2391 'patterns': [r".*: warning: Pointer arithmetic on non-array variables .*PointerArithm"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002392 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002393 'description': 'clang-analyzer Subtraction of pointers of different memory chunks',
2394 'patterns': [r".*: warning: Subtraction of two pointers .*PointerSub"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002395 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002396 'description': 'clang-analyzer Access out-of-bound array element',
2397 'patterns': [r".*: warning: Access out-of-bound array element .*ArrayBound"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002398 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002399 'description': 'clang-analyzer Out of bound memory access',
2400 'patterns': [r".*: warning: Out of bound memory access .*ArrayBoundV2"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002401 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002402 'description': 'clang-analyzer Possible lock order reversal',
2403 'patterns': [r".*: warning: .* Possible lock order reversal.*PthreadLock"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002404 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002405 'description': 'clang-analyzer Argument is a pointer to uninitialized value',
2406 'patterns': [r".*: warning: .* argument is a pointer to uninitialized value .*CallAndMessage"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002407 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002408 'description': 'clang-analyzer cast to struct',
2409 'patterns': [r".*: warning: Casting a non-structure type to a structure type .*CastToStruct"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002410 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002411 'description': 'clang-analyzer call path problems',
2412 'patterns': [r".*: warning: Call Path : .+"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002413 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07002414 'description': 'clang-analyzer excessive padding',
2415 'patterns': [r".*: warning: Excessive padding in '.*'"]},
2416 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002417 'description': 'clang-analyzer other',
2418 'patterns': [r".*: .+\[clang-analyzer-.+\]$",
2419 r".*: Call Path : .+$"]},
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07002420
Marco Nelissen594375d2009-07-14 09:04:04 -07002421 # catch-all for warnings this script doesn't know about yet
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002422 {'category': 'C/C++', 'severity': Severity.UNKNOWN,
2423 'description': 'Unclassified/unrecognized warnings',
2424 'patterns': [r".*: warning: .+"]},
Marco Nelissen594375d2009-07-14 09:04:04 -07002425]
2426
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07002427
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002428def project_name_and_pattern(name, pattern):
2429 return [name, '(^|.*/)' + pattern + '/.*: warning:']
2430
2431
2432def simple_project_pattern(pattern):
2433 return project_name_and_pattern(pattern, pattern)
2434
2435
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002436# A list of [project_name, file_path_pattern].
2437# project_name should not contain comma, to be used in CSV output.
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002438project_list = [
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002439 simple_project_pattern('art'),
2440 simple_project_pattern('bionic'),
2441 simple_project_pattern('bootable'),
2442 simple_project_pattern('build'),
2443 simple_project_pattern('cts'),
2444 simple_project_pattern('dalvik'),
2445 simple_project_pattern('developers'),
2446 simple_project_pattern('development'),
2447 simple_project_pattern('device'),
2448 simple_project_pattern('doc'),
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07002449 # match external/google* before external/
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002450 project_name_and_pattern('external/google', 'external/google.*'),
2451 project_name_and_pattern('external/non-google', 'external'),
2452 simple_project_pattern('frameworks/av/camera'),
2453 simple_project_pattern('frameworks/av/cmds'),
2454 simple_project_pattern('frameworks/av/drm'),
2455 simple_project_pattern('frameworks/av/include'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002456 simple_project_pattern('frameworks/av/media/img_utils'),
2457 simple_project_pattern('frameworks/av/media/libcpustats'),
2458 simple_project_pattern('frameworks/av/media/libeffects'),
2459 simple_project_pattern('frameworks/av/media/libmediaplayerservice'),
2460 simple_project_pattern('frameworks/av/media/libmedia'),
2461 simple_project_pattern('frameworks/av/media/libstagefright'),
2462 simple_project_pattern('frameworks/av/media/mtp'),
2463 simple_project_pattern('frameworks/av/media/ndk'),
2464 simple_project_pattern('frameworks/av/media/utils'),
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002465 project_name_and_pattern('frameworks/av/media/Other',
2466 'frameworks/av/media'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002467 simple_project_pattern('frameworks/av/radio'),
2468 simple_project_pattern('frameworks/av/services'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002469 simple_project_pattern('frameworks/av/soundtrigger'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002470 project_name_and_pattern('frameworks/av/Other', 'frameworks/av'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002471 simple_project_pattern('frameworks/base/cmds'),
2472 simple_project_pattern('frameworks/base/core'),
2473 simple_project_pattern('frameworks/base/drm'),
2474 simple_project_pattern('frameworks/base/media'),
2475 simple_project_pattern('frameworks/base/libs'),
2476 simple_project_pattern('frameworks/base/native'),
2477 simple_project_pattern('frameworks/base/packages'),
2478 simple_project_pattern('frameworks/base/rs'),
2479 simple_project_pattern('frameworks/base/services'),
2480 simple_project_pattern('frameworks/base/tests'),
2481 simple_project_pattern('frameworks/base/tools'),
2482 project_name_and_pattern('frameworks/base/Other', 'frameworks/base'),
Stephen Hinesd0aec892016-10-17 15:39:53 -07002483 simple_project_pattern('frameworks/compile/libbcc'),
2484 simple_project_pattern('frameworks/compile/mclinker'),
2485 simple_project_pattern('frameworks/compile/slang'),
2486 project_name_and_pattern('frameworks/compile/Other', 'frameworks/compile'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002487 simple_project_pattern('frameworks/minikin'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002488 simple_project_pattern('frameworks/ml'),
2489 simple_project_pattern('frameworks/native/cmds'),
2490 simple_project_pattern('frameworks/native/include'),
2491 simple_project_pattern('frameworks/native/libs'),
2492 simple_project_pattern('frameworks/native/opengl'),
2493 simple_project_pattern('frameworks/native/services'),
2494 simple_project_pattern('frameworks/native/vulkan'),
2495 project_name_and_pattern('frameworks/native/Other', 'frameworks/native'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002496 simple_project_pattern('frameworks/opt'),
2497 simple_project_pattern('frameworks/rs'),
2498 simple_project_pattern('frameworks/webview'),
2499 simple_project_pattern('frameworks/wilhelm'),
2500 project_name_and_pattern('frameworks/Other', 'frameworks'),
2501 simple_project_pattern('hardware/akm'),
2502 simple_project_pattern('hardware/broadcom'),
2503 simple_project_pattern('hardware/google'),
2504 simple_project_pattern('hardware/intel'),
2505 simple_project_pattern('hardware/interfaces'),
2506 simple_project_pattern('hardware/libhardware'),
2507 simple_project_pattern('hardware/libhardware_legacy'),
2508 simple_project_pattern('hardware/qcom'),
2509 simple_project_pattern('hardware/ril'),
2510 project_name_and_pattern('hardware/Other', 'hardware'),
2511 simple_project_pattern('kernel'),
2512 simple_project_pattern('libcore'),
2513 simple_project_pattern('libnativehelper'),
2514 simple_project_pattern('ndk'),
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002515 # match vendor/unbungled_google/packages before other packages
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002516 simple_project_pattern('unbundled_google'),
2517 simple_project_pattern('packages'),
2518 simple_project_pattern('pdk'),
2519 simple_project_pattern('prebuilts'),
2520 simple_project_pattern('system/bt'),
2521 simple_project_pattern('system/connectivity'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002522 simple_project_pattern('system/core/adb'),
2523 simple_project_pattern('system/core/base'),
2524 simple_project_pattern('system/core/debuggerd'),
2525 simple_project_pattern('system/core/fastboot'),
2526 simple_project_pattern('system/core/fingerprintd'),
2527 simple_project_pattern('system/core/fs_mgr'),
2528 simple_project_pattern('system/core/gatekeeperd'),
2529 simple_project_pattern('system/core/healthd'),
2530 simple_project_pattern('system/core/include'),
2531 simple_project_pattern('system/core/init'),
2532 simple_project_pattern('system/core/libbacktrace'),
2533 simple_project_pattern('system/core/liblog'),
2534 simple_project_pattern('system/core/libpixelflinger'),
2535 simple_project_pattern('system/core/libprocessgroup'),
2536 simple_project_pattern('system/core/libsysutils'),
2537 simple_project_pattern('system/core/logcat'),
2538 simple_project_pattern('system/core/logd'),
2539 simple_project_pattern('system/core/run-as'),
2540 simple_project_pattern('system/core/sdcard'),
2541 simple_project_pattern('system/core/toolbox'),
2542 project_name_and_pattern('system/core/Other', 'system/core'),
2543 simple_project_pattern('system/extras/ANRdaemon'),
2544 simple_project_pattern('system/extras/cpustats'),
2545 simple_project_pattern('system/extras/crypto-perf'),
2546 simple_project_pattern('system/extras/ext4_utils'),
2547 simple_project_pattern('system/extras/f2fs_utils'),
2548 simple_project_pattern('system/extras/iotop'),
2549 simple_project_pattern('system/extras/libfec'),
2550 simple_project_pattern('system/extras/memory_replay'),
2551 simple_project_pattern('system/extras/micro_bench'),
2552 simple_project_pattern('system/extras/mmap-perf'),
2553 simple_project_pattern('system/extras/multinetwork'),
2554 simple_project_pattern('system/extras/perfprofd'),
2555 simple_project_pattern('system/extras/procrank'),
2556 simple_project_pattern('system/extras/runconuid'),
2557 simple_project_pattern('system/extras/showmap'),
2558 simple_project_pattern('system/extras/simpleperf'),
2559 simple_project_pattern('system/extras/su'),
2560 simple_project_pattern('system/extras/tests'),
2561 simple_project_pattern('system/extras/verity'),
2562 project_name_and_pattern('system/extras/Other', 'system/extras'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002563 simple_project_pattern('system/gatekeeper'),
2564 simple_project_pattern('system/keymaster'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002565 simple_project_pattern('system/libhidl'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002566 simple_project_pattern('system/libhwbinder'),
2567 simple_project_pattern('system/media'),
2568 simple_project_pattern('system/netd'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002569 simple_project_pattern('system/nvram'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002570 simple_project_pattern('system/security'),
2571 simple_project_pattern('system/sepolicy'),
2572 simple_project_pattern('system/tools'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002573 simple_project_pattern('system/update_engine'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002574 simple_project_pattern('system/vold'),
2575 project_name_and_pattern('system/Other', 'system'),
2576 simple_project_pattern('toolchain'),
2577 simple_project_pattern('test'),
2578 simple_project_pattern('tools'),
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07002579 # match vendor/google* before vendor/
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002580 project_name_and_pattern('vendor/google', 'vendor/google.*'),
2581 project_name_and_pattern('vendor/non-google', 'vendor'),
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07002582 # keep out/obj and other patterns at the end.
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002583 ['out/obj',
2584 '.*/(gen|obj[^/]*)/(include|EXECUTABLES|SHARED_LIBRARIES|'
2585 'STATIC_LIBRARIES|NATIVE_TESTS)/.*: warning:'],
2586 ['other', '.*'] # all other unrecognized patterns
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002587]
2588
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002589project_patterns = []
2590project_names = []
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002591warning_messages = []
2592warning_records = []
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002593
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07002594
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002595def initialize_arrays():
2596 """Complete global arrays before they are used."""
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002597 global project_names, project_patterns
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002598 project_names = [p[0] for p in project_list]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002599 project_patterns = [re.compile(p[1]) for p in project_list]
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002600 for w in warn_patterns:
2601 w['members'] = []
2602 if 'option' not in w:
2603 w['option'] = ''
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002604 # Each warning pattern has a 'projects' dictionary, that
2605 # maps a project name to number of warnings in that project.
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002606 w['projects'] = {}
2607
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002608
2609initialize_arrays()
2610
2611
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -07002612android_root = ''
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002613platform_version = 'unknown'
2614target_product = 'unknown'
2615target_variant = 'unknown'
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002616
2617
2618##### Data and functions to dump html file. ##################################
2619
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002620html_head_scripts = """\
2621 <script type="text/javascript">
2622 function expand(id) {
2623 var e = document.getElementById(id);
2624 var f = document.getElementById(id + "_mark");
2625 if (e.style.display == 'block') {
2626 e.style.display = 'none';
2627 f.innerHTML = '&#x2295';
2628 }
2629 else {
2630 e.style.display = 'block';
2631 f.innerHTML = '&#x2296';
2632 }
2633 };
2634 function expandCollapse(show) {
2635 for (var id = 1; ; id++) {
2636 var e = document.getElementById(id + "");
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07002637 var f = document.getElementById(id + "_mark");
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002638 if (!e || !f) break;
2639 e.style.display = (show ? 'block' : 'none');
2640 f.innerHTML = (show ? '&#x2296' : '&#x2295');
2641 }
2642 };
2643 </script>
2644 <style type="text/css">
2645 th,td{border-collapse:collapse; border:1px solid black;}
2646 .button{color:blue;font-size:110%;font-weight:bolder;}
2647 .bt{color:black;background-color:transparent;border:none;outline:none;
2648 font-size:140%;font-weight:bolder;}
2649 .c0{background-color:#e0e0e0;}
2650 .c1{background-color:#d0d0d0;}
2651 .t1{border-collapse:collapse; width:100%; border:1px solid black;}
2652 </style>
2653 <script src="https://www.gstatic.com/charts/loader.js"></script>
2654"""
Marco Nelissen594375d2009-07-14 09:04:04 -07002655
Marco Nelissen594375d2009-07-14 09:04:04 -07002656
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002657def html_big(param):
2658 return '<font size="+2">' + param + '</font>'
Marco Nelissen594375d2009-07-14 09:04:04 -07002659
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07002660
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002661def dump_html_prologue(title):
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002662 print '<html>\n<head>'
2663 print '<title>' + title + '</title>'
2664 print html_head_scripts
2665 emit_stats_by_project()
2666 print '</head>\n<body>'
2667 print html_big(title)
2668 print '<p>'
Marco Nelissen594375d2009-07-14 09:04:04 -07002669
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002670
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002671def dump_html_epilogue():
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002672 print '</body>\n</head>\n</html>'
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07002673
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002674
2675def sort_warnings():
2676 for i in warn_patterns:
2677 i['members'] = sorted(set(i['members']))
2678
2679
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002680def emit_stats_by_project():
2681 """Dump a google chart table of warnings per project and severity."""
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002682 # warnings[p][s] is number of warnings in project p of severity s.
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002683 warnings = {p: {s: 0 for s in Severity.range} for p in project_names}
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002684 for i in warn_patterns:
2685 s = i['severity']
2686 for p in i['projects']:
2687 warnings[p][s] += i['projects'][p]
2688
2689 # total_by_project[p] is number of warnings in project p.
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002690 total_by_project = {p: sum(warnings[p][s] for s in Severity.range)
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002691 for p in project_names}
2692
2693 # total_by_severity[s] is number of warnings of severity s.
2694 total_by_severity = {s: sum(warnings[p][s] for p in project_names)
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002695 for s in Severity.range}
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07002696
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002697 # emit table header
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002698 stats_header = ['Project']
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002699 for s in Severity.range:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002700 if total_by_severity[s]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002701 stats_header.append("<span style='background-color:{}'>{}</span>".
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002702 format(Severity.colors[s],
2703 Severity.column_headers[s]))
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002704 stats_header.append('TOTAL')
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07002705
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002706 # emit a row of warning counts per project, skip no-warning projects
2707 total_all_projects = 0
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002708 stats_rows = []
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002709 for p in project_names:
2710 if total_by_project[p]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002711 one_row = [p]
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002712 for s in Severity.range:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002713 if total_by_severity[s]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002714 one_row.append(warnings[p][s])
2715 one_row.append(total_by_project[p])
2716 stats_rows.append(one_row)
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002717 total_all_projects += total_by_project[p]
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07002718
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002719 # emit a row of warning counts per severity
2720 total_all_severities = 0
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002721 one_row = ['<b>TOTAL</b>']
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002722 for s in Severity.range:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002723 if total_by_severity[s]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002724 one_row.append(total_by_severity[s])
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002725 total_all_severities += total_by_severity[s]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002726 one_row.append(total_all_projects)
2727 stats_rows.append(one_row)
2728 print '<script>'
2729 emit_const_string_array('StatsHeader', stats_header)
2730 emit_const_object_array('StatsRows', stats_rows)
2731 print draw_table_javascript
2732 print '</script>'
Marco Nelissen594375d2009-07-14 09:04:04 -07002733
2734
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002735def dump_stats():
2736 """Dump some stats about total number of warnings and such."""
2737 known = 0
2738 skipped = 0
2739 unknown = 0
2740 sort_warnings()
2741 for i in warn_patterns:
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002742 if i['severity'] == Severity.UNKNOWN:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002743 unknown += len(i['members'])
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002744 elif i['severity'] == Severity.SKIP:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002745 skipped += len(i['members'])
Ian Rogersf3829732016-05-10 12:06:01 -07002746 else:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002747 known += len(i['members'])
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002748 print 'Number of classified warnings: <b>' + str(known) + '</b><br>'
2749 print 'Number of skipped warnings: <b>' + str(skipped) + '</b><br>'
2750 print 'Number of unclassified warnings: <b>' + str(unknown) + '</b><br>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002751 total = unknown + known + skipped
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002752 extra_msg = ''
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002753 if total < 1000:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002754 extra_msg = ' (low count may indicate incremental build)'
2755 print 'Total number of warnings: <b>' + str(total) + '</b>' + extra_msg
Marco Nelissen594375d2009-07-14 09:04:04 -07002756
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07002757
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002758# New base table of warnings, [severity, warn_id, project, warning_message]
2759# Need buttons to show warnings in different grouping options.
2760# (1) Current, group by severity, id for each warning pattern
2761# sort by severity, warn_id, warning_message
2762# (2) Current --byproject, group by severity,
2763# id for each warning pattern + project name
2764# sort by severity, warn_id, project, warning_message
2765# (3) New, group by project + severity,
2766# id for each warning pattern
2767# sort by project, severity, warn_id, warning_message
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002768def emit_buttons():
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002769 print ('<button class="button" onclick="expandCollapse(1);">'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002770 'Expand all warnings</button>\n'
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002771 '<button class="button" onclick="expandCollapse(0);">'
2772 'Collapse all warnings</button>\n'
2773 '<button class="button" onclick="groupBySeverity();">'
2774 'Group warnings by severity</button>\n'
2775 '<button class="button" onclick="groupByProject();">'
2776 'Group warnings by project</button><br>')
Marco Nelissen594375d2009-07-14 09:04:04 -07002777
2778
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002779def all_patterns(category):
2780 patterns = ''
2781 for i in category['patterns']:
2782 patterns += i
2783 patterns += ' / '
2784 return patterns
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002785
2786
2787def dump_fixed():
2788 """Show which warnings no longer occur."""
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002789 anchor = 'fixed_warnings'
2790 mark = anchor + '_mark'
2791 print ('\n<br><p style="background-color:lightblue"><b>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002792 '<button id="' + mark + '" '
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002793 'class="bt" onclick="expand(\'' + anchor + '\');">'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002794 '&#x2295</button> Fixed warnings. '
2795 'No more occurrences. Please consider turning these into '
2796 'errors if possible, before they are reintroduced in to the build'
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002797 ':</b></p>')
2798 print '<blockquote>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002799 fixed_patterns = []
2800 for i in warn_patterns:
2801 if not i['members']:
2802 fixed_patterns.append(i['description'] + ' (' +
2803 all_patterns(i) + ')')
2804 if i['option']:
2805 fixed_patterns.append(' ' + i['option'])
2806 fixed_patterns.sort()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002807 print '<div id="' + anchor + '" style="display:none;"><table>'
2808 cur_row_class = 0
2809 for text in fixed_patterns:
2810 cur_row_class = 1 - cur_row_class
2811 # remove last '\n'
2812 t = text[:-1] if text[-1] == '\n' else text
2813 print '<tr><td class="c' + str(cur_row_class) + '">' + t + '</td></tr>'
2814 print '</table></div>'
2815 print '</blockquote>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002816
2817
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002818def find_project_index(line):
2819 for p in range(len(project_patterns)):
2820 if project_patterns[p].match(line):
2821 return p
2822 return -1
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002823
2824
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002825def classify_one_warning(line, results):
Chih-Hung Hsieh9be27762018-06-07 10:51:47 -07002826 """Classify one warning line."""
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002827 for i in range(len(warn_patterns)):
2828 w = warn_patterns[i]
2829 for cpat in w['compiled_patterns']:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002830 if cpat.match(line):
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002831 p = find_project_index(line)
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002832 results.append([line, i, p])
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002833 return
2834 else:
2835 # If we end up here, there was a problem parsing the log
2836 # probably caused by 'make -j' mixing the output from
2837 # 2 or more concurrent compiles
2838 pass
Marco Nelissen594375d2009-07-14 09:04:04 -07002839
2840
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002841def classify_warnings(lines):
2842 results = []
2843 for line in lines:
2844 classify_one_warning(line, results)
Chih-Hung Hsieh76d00652016-11-09 18:19:05 -08002845 # After the main work, ignore all other signals to a child process,
2846 # to avoid bad warning/error messages from the exit clean-up process.
2847 if args.processes > 1:
2848 signal.signal(signal.SIGTERM, lambda *args: sys.exit(-signal.SIGTERM))
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002849 return results
2850
2851
2852def parallel_classify_warnings(warning_lines):
2853 """Classify all warning lines with num_cpu parallel processes."""
Chih-Hung Hsieh76d00652016-11-09 18:19:05 -08002854 compile_patterns()
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002855 num_cpu = args.processes
Chih-Hung Hsieh63de3002016-10-28 10:53:34 -07002856 if num_cpu > 1:
2857 groups = [[] for x in range(num_cpu)]
2858 i = 0
2859 for x in warning_lines:
2860 groups[i].append(x)
2861 i = (i + 1) % num_cpu
2862 pool = multiprocessing.Pool(num_cpu)
2863 group_results = pool.map(classify_warnings, groups)
2864 else:
2865 group_results = [classify_warnings(warning_lines)]
2866
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002867 for result in group_results:
2868 for line, pattern_idx, project_idx in result:
2869 pattern = warn_patterns[pattern_idx]
2870 pattern['members'].append(line)
2871 message_idx = len(warning_messages)
2872 warning_messages.append(line)
2873 warning_records.append([pattern_idx, project_idx, message_idx])
2874 pname = '???' if project_idx < 0 else project_names[project_idx]
2875 # Count warnings by project.
2876 if pname in pattern['projects']:
2877 pattern['projects'][pname] += 1
2878 else:
2879 pattern['projects'][pname] = 1
2880
2881
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002882def compile_patterns():
2883 """Precompiling every pattern speeds up parsing by about 30x."""
2884 for i in warn_patterns:
2885 i['compiled_patterns'] = []
2886 for pat in i['patterns']:
2887 i['compiled_patterns'].append(re.compile(pat))
2888
2889
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -07002890def find_android_root(path):
2891 """Set and return android_root path if it is found."""
2892 global android_root
2893 parts = path.split('/')
2894 for idx in reversed(range(2, len(parts))):
2895 root_path = '/'.join(parts[:idx])
2896 # Android root directory should contain this script.
Colin Crossfdea8932017-12-06 14:38:40 -08002897 if os.path.exists(root_path + '/build/make/tools/warn.py'):
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -07002898 android_root = root_path
2899 return root_path
2900 return ''
2901
2902
2903def remove_android_root_prefix(path):
2904 """Remove android_root prefix from path if it is found."""
2905 if path.startswith(android_root):
2906 return path[1 + len(android_root):]
2907 else:
2908 return path
2909
2910
2911def normalize_path(path):
2912 """Normalize file path relative to android_root."""
2913 # If path is not an absolute path, just normalize it.
2914 path = os.path.normpath(path)
2915 if path[0] != '/':
2916 return path
2917 # Remove known prefix of root path and normalize the suffix.
2918 if android_root or find_android_root(path):
2919 return remove_android_root_prefix(path)
2920 else:
2921 return path
2922
2923
2924def normalize_warning_line(line):
2925 """Normalize file path relative to android_root in a warning line."""
2926 # replace fancy quotes with plain ol' quotes
2927 line = line.replace('‘', "'")
2928 line = line.replace('’', "'")
2929 line = line.strip()
2930 first_column = line.find(':')
2931 if first_column > 0:
2932 return normalize_path(line[:first_column]) + line[first_column:]
2933 else:
2934 return line
2935
2936
Chih-Hung Hsieh76d00652016-11-09 18:19:05 -08002937def parse_input_file(infile):
Chih-Hung Hsiehef21d142017-04-27 10:25:37 -07002938 """Parse input file, collect parameters and warning lines."""
2939 global android_root
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002940 global platform_version
2941 global target_product
2942 global target_variant
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002943 line_counter = 0
2944
Chih-Hung Hsieh5722f922016-10-11 15:33:19 -07002945 # handle only warning messages with a file path
2946 warning_pattern = re.compile('^[^ ]*/[^ ]*: warning: .*')
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002947
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002948 # Collect all warnings into the warning_lines set.
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002949 warning_lines = set()
2950 for line in infile:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002951 if warning_pattern.match(line):
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -07002952 line = normalize_warning_line(line)
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002953 warning_lines.add(line)
Chih-Hung Hsieh655c5422017-06-07 15:52:13 -07002954 elif line_counter < 100:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002955 # save a little bit of time by only doing this for the first few lines
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002956 line_counter += 1
2957 m = re.search('(?<=^PLATFORM_VERSION=).*', line)
2958 if m is not None:
2959 platform_version = m.group(0)
2960 m = re.search('(?<=^TARGET_PRODUCT=).*', line)
2961 if m is not None:
2962 target_product = m.group(0)
2963 m = re.search('(?<=^TARGET_BUILD_VARIANT=).*', line)
2964 if m is not None:
2965 target_variant = m.group(0)
Chih-Hung Hsiehef21d142017-04-27 10:25:37 -07002966 m = re.search('.* TOP=([^ ]*) .*', line)
2967 if m is not None:
2968 android_root = m.group(1)
Chih-Hung Hsieh76d00652016-11-09 18:19:05 -08002969 return warning_lines
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002970
2971
Chih-Hung Hsieh5722f922016-10-11 15:33:19 -07002972# Return s with escaped backslash and quotation characters.
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002973def escape_string(s):
Chih-Hung Hsieh5722f922016-10-11 15:33:19 -07002974 return s.replace('\\', '\\\\').replace('"', '\\"')
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002975
2976
2977# Return s without trailing '\n' and escape the quotation characters.
2978def strip_escape_string(s):
2979 if not s:
2980 return s
2981 s = s[:-1] if s[-1] == '\n' else s
2982 return escape_string(s)
2983
2984
2985def emit_warning_array(name):
2986 print 'var warning_{} = ['.format(name)
2987 for i in range(len(warn_patterns)):
2988 print '{},'.format(warn_patterns[i][name])
2989 print '];'
2990
2991
2992def emit_warning_arrays():
2993 emit_warning_array('severity')
2994 print 'var warning_description = ['
2995 for i in range(len(warn_patterns)):
2996 if warn_patterns[i]['members']:
2997 print '"{}",'.format(escape_string(warn_patterns[i]['description']))
2998 else:
2999 print '"",' # no such warning
3000 print '];'
3001
3002scripts_for_warning_groups = """
3003 function compareMessages(x1, x2) { // of the same warning type
3004 return (WarningMessages[x1[2]] <= WarningMessages[x2[2]]) ? -1 : 1;
3005 }
3006 function byMessageCount(x1, x2) {
3007 return x2[2] - x1[2]; // reversed order
3008 }
3009 function bySeverityMessageCount(x1, x2) {
3010 // orer by severity first
3011 if (x1[1] != x2[1])
3012 return x1[1] - x2[1];
3013 return byMessageCount(x1, x2);
3014 }
3015 const ParseLinePattern = /^([^ :]+):(\\d+):(.+)/;
3016 function addURL(line) {
3017 if (FlagURL == "") return line;
3018 if (FlagSeparator == "") {
3019 return line.replace(ParseLinePattern,
George Burgess IV169f5f12017-04-21 13:35:52 -07003020 "<a target='_blank' href='" + FlagURL + "/$1'>$1</a>:$2:$3");
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003021 }
3022 return line.replace(ParseLinePattern,
George Burgess IV169f5f12017-04-21 13:35:52 -07003023 "<a target='_blank' href='" + FlagURL + "/$1" + FlagSeparator +
3024 "$2'>$1:$2</a>:$3");
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003025 }
3026 function createArrayOfDictionaries(n) {
3027 var result = [];
3028 for (var i=0; i<n; i++) result.push({});
3029 return result;
3030 }
3031 function groupWarningsBySeverity() {
3032 // groups is an array of dictionaries,
3033 // each dictionary maps from warning type to array of warning messages.
3034 var groups = createArrayOfDictionaries(SeverityColors.length);
3035 for (var i=0; i<Warnings.length; i++) {
3036 var w = Warnings[i][0];
3037 var s = WarnPatternsSeverity[w];
3038 var k = w.toString();
3039 if (!(k in groups[s]))
3040 groups[s][k] = [];
3041 groups[s][k].push(Warnings[i]);
3042 }
3043 return groups;
3044 }
3045 function groupWarningsByProject() {
3046 var groups = createArrayOfDictionaries(ProjectNames.length);
3047 for (var i=0; i<Warnings.length; i++) {
3048 var w = Warnings[i][0];
3049 var p = Warnings[i][1];
3050 var k = w.toString();
3051 if (!(k in groups[p]))
3052 groups[p][k] = [];
3053 groups[p][k].push(Warnings[i]);
3054 }
3055 return groups;
3056 }
3057 var GlobalAnchor = 0;
3058 function createWarningSection(header, color, group) {
3059 var result = "";
3060 var groupKeys = [];
3061 var totalMessages = 0;
3062 for (var k in group) {
3063 totalMessages += group[k].length;
3064 groupKeys.push([k, WarnPatternsSeverity[parseInt(k)], group[k].length]);
3065 }
3066 groupKeys.sort(bySeverityMessageCount);
3067 for (var idx=0; idx<groupKeys.length; idx++) {
3068 var k = groupKeys[idx][0];
3069 var messages = group[k];
3070 var w = parseInt(k);
3071 var wcolor = SeverityColors[WarnPatternsSeverity[w]];
3072 var description = WarnPatternsDescription[w];
3073 if (description.length == 0)
3074 description = "???";
3075 GlobalAnchor += 1;
3076 result += "<table class='t1'><tr bgcolor='" + wcolor + "'><td>" +
3077 "<button class='bt' id='" + GlobalAnchor + "_mark" +
3078 "' onclick='expand(\\"" + GlobalAnchor + "\\");'>" +
3079 "&#x2295</button> " +
3080 description + " (" + messages.length + ")</td></tr></table>";
3081 result += "<div id='" + GlobalAnchor +
3082 "' style='display:none;'><table class='t1'>";
3083 var c = 0;
3084 messages.sort(compareMessages);
3085 for (var i=0; i<messages.length; i++) {
3086 result += "<tr><td class='c" + c + "'>" +
3087 addURL(WarningMessages[messages[i][2]]) + "</td></tr>";
3088 c = 1 - c;
3089 }
3090 result += "</table></div>";
3091 }
3092 if (result.length > 0) {
3093 return "<br><span style='background-color:" + color + "'><b>" +
3094 header + ": " + totalMessages +
3095 "</b></span><blockquote><table class='t1'>" +
3096 result + "</table></blockquote>";
3097
3098 }
3099 return ""; // empty section
3100 }
3101 function generateSectionsBySeverity() {
3102 var result = "";
3103 var groups = groupWarningsBySeverity();
3104 for (s=0; s<SeverityColors.length; s++) {
3105 result += createWarningSection(SeverityHeaders[s], SeverityColors[s], groups[s]);
3106 }
3107 return result;
3108 }
3109 function generateSectionsByProject() {
3110 var result = "";
3111 var groups = groupWarningsByProject();
3112 for (i=0; i<groups.length; i++) {
3113 result += createWarningSection(ProjectNames[i], 'lightgrey', groups[i]);
3114 }
3115 return result;
3116 }
3117 function groupWarnings(generator) {
3118 GlobalAnchor = 0;
3119 var e = document.getElementById("warning_groups");
3120 e.innerHTML = generator();
3121 }
3122 function groupBySeverity() {
3123 groupWarnings(generateSectionsBySeverity);
3124 }
3125 function groupByProject() {
3126 groupWarnings(generateSectionsByProject);
3127 }
3128"""
3129
3130
3131# Emit a JavaScript const string
3132def emit_const_string(name, value):
3133 print 'const ' + name + ' = "' + escape_string(value) + '";'
3134
3135
3136# Emit a JavaScript const integer array.
3137def emit_const_int_array(name, array):
3138 print 'const ' + name + ' = ['
3139 for n in array:
3140 print str(n) + ','
3141 print '];'
3142
3143
3144# Emit a JavaScript const string array.
3145def emit_const_string_array(name, array):
3146 print 'const ' + name + ' = ['
3147 for s in array:
3148 print '"' + strip_escape_string(s) + '",'
3149 print '];'
3150
3151
3152# Emit a JavaScript const object array.
3153def emit_const_object_array(name, array):
3154 print 'const ' + name + ' = ['
3155 for x in array:
3156 print str(x) + ','
3157 print '];'
3158
3159
3160def emit_js_data():
3161 """Dump dynamic HTML page's static JavaScript data."""
3162 emit_const_string('FlagURL', args.url if args.url else '')
3163 emit_const_string('FlagSeparator', args.separator if args.separator else '')
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07003164 emit_const_string_array('SeverityColors', Severity.colors)
3165 emit_const_string_array('SeverityHeaders', Severity.headers)
3166 emit_const_string_array('SeverityColumnHeaders', Severity.column_headers)
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003167 emit_const_string_array('ProjectNames', project_names)
3168 emit_const_int_array('WarnPatternsSeverity',
3169 [w['severity'] for w in warn_patterns])
3170 emit_const_string_array('WarnPatternsDescription',
3171 [w['description'] for w in warn_patterns])
3172 emit_const_string_array('WarnPatternsOption',
3173 [w['option'] for w in warn_patterns])
3174 emit_const_string_array('WarningMessages', warning_messages)
3175 emit_const_object_array('Warnings', warning_records)
3176
3177draw_table_javascript = """
3178google.charts.load('current', {'packages':['table']});
3179google.charts.setOnLoadCallback(drawTable);
3180function drawTable() {
3181 var data = new google.visualization.DataTable();
3182 data.addColumn('string', StatsHeader[0]);
3183 for (var i=1; i<StatsHeader.length; i++) {
3184 data.addColumn('number', StatsHeader[i]);
3185 }
3186 data.addRows(StatsRows);
3187 for (var i=0; i<StatsRows.length; i++) {
3188 for (var j=0; j<StatsHeader.length; j++) {
3189 data.setProperty(i, j, 'style', 'border:1px solid black;');
3190 }
3191 }
3192 var table = new google.visualization.Table(document.getElementById('stats_table'));
3193 table.draw(data, {allowHtml: true, alternatingRowStyle: true});
3194}
3195"""
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003196
3197
3198def dump_html():
3199 """Dump the html output to stdout."""
3200 dump_html_prologue('Warnings for ' + platform_version + ' - ' +
3201 target_product + ' - ' + target_variant)
3202 dump_stats()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003203 print '<br><div id="stats_table"></div><br>'
3204 print '\n<script>'
3205 emit_js_data()
3206 print scripts_for_warning_groups
3207 print '</script>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003208 emit_buttons()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003209 # Warning messages are grouped by severities or project names.
3210 print '<br><div id="warning_groups"></div>'
3211 if args.byproject:
3212 print '<script>groupByProject();</script>'
3213 else:
3214 print '<script>groupBySeverity();</script>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003215 dump_fixed()
3216 dump_html_epilogue()
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07003217
3218
3219##### Functions to count warnings and dump csv file. #########################
3220
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07003221
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003222def description_for_csv(category):
3223 if not category['description']:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003224 return '?'
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003225 return category['description']
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07003226
3227
Sam Saccone03aaa7e2017-04-10 15:37:47 -07003228def count_severity(writer, sev, kind):
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003229 """Count warnings of given severity."""
3230 total = 0
3231 for i in warn_patterns:
3232 if i['severity'] == sev and i['members']:
3233 n = len(i['members'])
3234 total += n
Sam Saccone03aaa7e2017-04-10 15:37:47 -07003235 warning = kind + ': ' + description_for_csv(i)
3236 writer.writerow([n, '', warning])
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003237 # print number of warnings for each project, ordered by project name.
3238 projects = i['projects'].keys()
3239 projects.sort()
3240 for p in projects:
Sam Saccone03aaa7e2017-04-10 15:37:47 -07003241 writer.writerow([i['projects'][p], p, warning])
3242 writer.writerow([total, '', kind + ' warnings'])
3243
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003244 return total
3245
3246
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003247# dump number of warnings in csv format to stdout
Sam Saccone03aaa7e2017-04-10 15:37:47 -07003248def dump_csv(writer):
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003249 """Dump number of warnings in csv format to stdout."""
3250 sort_warnings()
3251 total = 0
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07003252 for s in Severity.range:
Sam Saccone03aaa7e2017-04-10 15:37:47 -07003253 total += count_severity(writer, s, Severity.column_headers[s])
3254 writer.writerow([total, '', 'All warnings'])
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003255
3256
Meike Baumgärtnerac9d5df2016-09-28 10:48:06 -07003257def main():
Chih-Hung Hsieh76d00652016-11-09 18:19:05 -08003258 warning_lines = parse_input_file(open(args.buildlog, 'r'))
3259 parallel_classify_warnings(warning_lines)
Sam Saccone03aaa7e2017-04-10 15:37:47 -07003260 # If a user pases a csv path, save the fileoutput to the path
3261 # If the user also passed gencsv write the output to stdout
3262 # If the user did not pass gencsv flag dump the html report to stdout.
3263 if args.csvpath:
3264 with open(args.csvpath, 'w') as f:
3265 dump_csv(csv.writer(f, lineterminator='\n'))
Meike Baumgärtnerac9d5df2016-09-28 10:48:06 -07003266 if args.gencsv:
Sam Saccone03aaa7e2017-04-10 15:37:47 -07003267 dump_csv(csv.writer(sys.stdout, lineterminator='\n'))
Meike Baumgärtnerac9d5df2016-09-28 10:48:06 -07003268 else:
3269 dump_html()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003270
Meike Baumgärtnerac9d5df2016-09-28 10:48:06 -07003271
3272# Run main function if warn.py is the main program.
3273if __name__ == '__main__':
3274 main()