blob: 2208d6df7117efb3a442ccae575546f1bd97b5a1 [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':
502 'Java: @Multibinds is a more efficient and declarative mechanism for ensuring that a set multibinding is present in the graph.',
503 'patterns': [r".*: warning: \[EmptySetMultibindingContributions\] .+"]},
504 {'category': 'java',
505 'severity': Severity.LOW,
506 'description':
507 'Java: Add a private constructor to modules that will not be instantiated by Dagger.',
508 'patterns': [r".*: warning: \[PrivateConstructorForNoninstantiableModuleTest\] .+"]},
509 {'category': 'java',
510 'severity': Severity.LOW,
511 'description':
512 'Java: @Binds is a more efficient and declarative mechanism for delegating a binding.',
513 'patterns': [r".*: warning: \[UseBinds\] .+"]},
514 {'category': 'java',
515 'severity': Severity.LOW,
516 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800517 'Java: Fields that can be null should be annotated @Nullable',
518 'patterns': [r".*: warning: \[FieldMissingNullable\] .+"]},
519 {'category': 'java',
520 'severity': Severity.LOW,
521 'description':
522 'Java: Method parameters that aren\'t checked for null shouldn\'t be annotated @Nullable',
523 'patterns': [r".*: warning: \[ParameterNotNullable\] .+"]},
524 {'category': 'java',
525 'severity': Severity.LOW,
526 'description':
527 'Java: Methods that can return null should be annotated @Nullable',
528 'patterns': [r".*: warning: \[ReturnMissingNullable\] .+"]},
529 {'category': 'java',
530 'severity': Severity.LOW,
531 'description':
532 'Java: Use parameter comments to document ambiguous literals',
533 'patterns': [r".*: warning: \[BooleanParameter\] .+"]},
534 {'category': 'java',
535 'severity': Severity.LOW,
536 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800537 'Java: Field name is CONSTANT CASE, but field is not static and final',
538 'patterns': [r".*: warning: \[ConstantField\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -0700539 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700540 'severity': Severity.LOW,
Ian Rogers6e520032016-05-13 08:59:00 -0700541 'description':
542 'Java: Deprecated item is not annotated with @Deprecated',
543 'patterns': [r".*: warning: \[DepAnn\] .+"]},
544 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700545 'severity': Severity.LOW,
Ian Rogers6e520032016-05-13 08:59:00 -0700546 'description':
Chih-Hung Hsieh9be27762018-06-07 10:51:47 -0700547 r'Java: Use Java\'s utility functional interfaces instead of Function\u003cA, B> for primitive types.',
Andreas Gampecf528ca2018-01-25 11:55:43 -0800548 'patterns': [r".*: warning: \[LambdaFunctionalInterface\] .+"]},
549 {'category': 'java',
550 'severity': Severity.LOW,
551 'description':
Ian Rogers6e520032016-05-13 08:59:00 -0700552 'Java: Prefer \'L\' to \'l\' for the suffix to long literals',
553 'patterns': [r".*: warning: \[LongLiteralLowerCaseSuffix\] .+"]},
554 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700555 'severity': Severity.LOW,
Ian Rogers6e520032016-05-13 08:59:00 -0700556 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800557 'Java: A private method that does not reference the enclosing instance can be static',
558 'patterns': [r".*: warning: \[MethodCanBeStatic\] .+"]},
559 {'category': 'java',
560 'severity': Severity.LOW,
561 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800562 'Java: C-style array declarations should not be used',
563 'patterns': [r".*: warning: \[MixedArrayDimensions\] .+"]},
564 {'category': 'java',
565 'severity': Severity.LOW,
566 'description':
567 'Java: Variable declarations should declare only one variable',
568 'patterns': [r".*: warning: \[MultiVariableDeclaration\] .+"]},
569 {'category': 'java',
570 'severity': Severity.LOW,
571 'description':
572 'Java: Source files should not contain multiple top-level class declarations',
573 'patterns': [r".*: warning: \[MultipleTopLevelClasses\] .+"]},
574 {'category': 'java',
575 'severity': Severity.LOW,
576 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800577 'Java: Avoid having multiple unary operators acting on the same variable in a method call',
578 'patterns': [r".*: warning: \[MultipleUnaryOperatorsInMethodCall\] .+"]},
579 {'category': 'java',
580 'severity': Severity.LOW,
581 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800582 'Java: Package names should match the directory they are declared in',
583 'patterns': [r".*: warning: \[PackageLocation\] .+"]},
584 {'category': 'java',
585 'severity': Severity.LOW,
586 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800587 'Java: Non-standard parameter comment; prefer `/*paramName=*/ arg`',
588 'patterns': [r".*: warning: \[ParameterComment\] .+"]},
589 {'category': 'java',
590 'severity': Severity.LOW,
591 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800592 'Java: Utility classes (only static members) are not designed to be instantiated and should be made noninstantiable with a default constructor.',
593 'patterns': [r".*: warning: \[PrivateConstructorForUtilityClass\] .+"]},
594 {'category': 'java',
595 'severity': Severity.LOW,
596 'description':
597 'Java: Unused imports',
598 'patterns': [r".*: warning: \[RemoveUnusedImports\] .+"]},
599 {'category': 'java',
600 'severity': Severity.LOW,
601 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800602 'Java: The default case of a switch should appear at the end of the last statement group',
603 'patterns': [r".*: warning: \[SwitchDefault\] .+"]},
604 {'category': 'java',
605 'severity': Severity.LOW,
606 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800607 'Java: Unchecked exceptions do not need to be declared in the method signature.',
608 'patterns': [r".*: warning: \[ThrowsUncheckedException\] .+"]},
609 {'category': 'java',
610 'severity': Severity.LOW,
611 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800612 'Java: Type parameters must be a single letter with an optional numeric suffix, or an UpperCamelCase name followed by the letter \'T\'.',
613 'patterns': [r".*: warning: \[TypeParameterNaming\] .+"]},
614 {'category': 'java',
615 'severity': Severity.LOW,
616 'description':
617 'Java: Constructors and methods with the same name should appear sequentially with no other code in between',
618 'patterns': [r".*: warning: \[UngroupedOverloads\] .+"]},
619 {'category': 'java',
620 'severity': Severity.LOW,
621 'description':
622 'Java: Unnecessary call to NullPointerTester#setDefault',
623 'patterns': [r".*: warning: \[UnnecessarySetDefault\] .+"]},
624 {'category': 'java',
625 'severity': Severity.LOW,
626 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800627 'Java: Using static imports for types is unnecessary',
628 'patterns': [r".*: warning: \[UnnecessaryStaticImport\] .+"]},
629 {'category': 'java',
630 'severity': Severity.LOW,
631 'description':
632 '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.LOW,
636 'description':
637 'Java: ',
638 'patterns': [r".*: warning: \[RemoveFieldPrefixes\] .+"]},
639 {'category': 'java',
640 'severity': Severity.LOW,
641 'description':
642 'Java: Prefer assertThrows to ExpectedException',
643 'patterns': [r".*: warning: \[ExpectedExceptionMigration\] .+"]},
644 {'category': 'java',
645 'severity': Severity.LOW,
646 'description':
647 'Java: Logger instances are not constants -- they are mutable and have side effects -- and should not be named using CONSTANT CASE',
648 'patterns': [r".*: warning: \[LoggerVariableCase\] .+"]},
649 {'category': 'java',
650 'severity': Severity.LOW,
651 'description':
652 'Java: Prefer assertThrows to @Test(expected=...)',
653 'patterns': [r".*: warning: \[TestExceptionMigration\] .+"]},
654 {'category': 'java',
655 'severity': Severity.MEDIUM,
656 'description':
657 'Java: Public fields must be final.',
658 'patterns': [r".*: warning: \[NonFinalPublicFields\] .+"]},
659 {'category': 'java',
660 'severity': Severity.MEDIUM,
661 'description':
662 'Java: Private fields that are only assigned in the initializer should be made final.',
663 'patterns': [r".*: warning: \[PrivateFieldsNotAssigned\] .+"]},
664 {'category': 'java',
665 'severity': Severity.MEDIUM,
666 'description':
667 'Java: Lists returned by methods should be immutable.',
668 'patterns': [r".*: warning: \[ReturnedListNotImmutable\] .+"]},
669 {'category': 'java',
670 'severity': Severity.MEDIUM,
671 'description':
672 'Java: Parameters to log methods should not be generated by a call to String.format() or MessageFormat.format().',
673 'patterns': [r".*: warning: \[SaferLoggerFormat\] .+"]},
674 {'category': 'java',
675 'severity': Severity.MEDIUM,
676 'description':
677 'Java: Parameters to log methods should not be generated by a call to toString(); see b/22986665.',
678 'patterns': [r".*: warning: \[SaferLoggerToString\] .+"]},
679 {'category': 'java',
680 'severity': Severity.MEDIUM,
681 'description':
682 '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.',
683 'patterns': [r".*: warning: \[BinderIdentityRestoredDangerously\] .+"]},
684 {'category': 'java',
685 'severity': Severity.MEDIUM,
686 'description':
687 'Java: Classes extending PreferenceActivity must implement isValidFragment such that it does not unconditionally return true to prevent vulnerability to fragment injection attacks.',
688 'patterns': [r".*: warning: \[FragmentInjection\] .+"]},
689 {'category': 'java',
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800690 'severity': Severity.MEDIUM,
691 'description':
692 'Java: Subclasses of Fragment must be instantiable via Class#newInstance(): the class must be public, static and have a public nullary constructor',
693 'patterns': [r".*: warning: \[FragmentNotInstantiable\] .+"]},
694 {'category': 'java',
695 'severity': Severity.MEDIUM,
696 'description':
697 'Java: Hardcoded reference to /sdcard',
698 'patterns': [r".*: warning: \[HardCodedSdCardPath\] .+"]},
699 {'category': 'java',
700 'severity': Severity.MEDIUM,
701 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800702 '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.',
703 'patterns': [r".*: warning: \[WakelockReleasedDangerously\] .+"]},
704 {'category': 'java',
705 'severity': Severity.MEDIUM,
706 'description':
707 'Java: Arguments are in the wrong order or could be commented for clarity.',
708 'patterns': [r".*: warning: \[ArgumentSelectionDefectChecker\] .+"]},
709 {'category': 'java',
710 'severity': Severity.MEDIUM,
711 'description':
712 'Java: Arguments are swapped in assertEquals-like call',
713 'patterns': [r".*: warning: \[AssertEqualsArgumentOrderChecker\] .+"]},
714 {'category': 'java',
715 'severity': Severity.MEDIUM,
716 'description':
717 'Java: An equality test between objects with incompatible types always returns false',
718 'patterns': [r".*: warning: \[EqualsIncompatibleType\] .+"]},
719 {'category': 'java',
720 'severity': Severity.MEDIUM,
721 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800722 'Java: @AssistedInject and @Inject should not be used on different constructors in the same class.',
723 'patterns': [r".*: warning: \[AssistedInjectAndInjectOnConstructors\] .+"]},
724 {'category': 'java',
725 'severity': Severity.MEDIUM,
726 'description':
727 'Java: Constructors on abstract classes are never directly @Injected, only the constructors of their subclasses can be @Inject\'ed.',
728 'patterns': [r".*: warning: \[InjectOnConstructorOfAbstractClass\] .+"]},
729 {'category': 'java',
730 'severity': Severity.MEDIUM,
731 'description':
732 'Java: Injection frameworks currently don\'t understand Qualifiers in TYPE PARAMETER or TYPE USE contexts.',
733 'patterns': [r".*: warning: \[QualifierWithTypeUse\] .+"]},
734 {'category': 'java',
735 'severity': Severity.MEDIUM,
736 'description':
737 'Java: This code declares a binding for a common value type without a Qualifier annotation.',
738 'patterns': [r".*: warning: \[BindingToUnqualifiedCommonType\] .+"]},
739 {'category': 'java',
740 'severity': Severity.MEDIUM,
741 'description':
742 '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.',
743 'patterns': [r".*: warning: \[OverridesGuiceInjectableMethod\] .+"]},
744 {'category': 'java',
745 'severity': Severity.MEDIUM,
746 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800747 'Java: The ordering of parameters in overloaded methods should be as consistent as possible (when viewed from left to right)',
748 'patterns': [r".*: warning: \[InconsistentOverloads\] .+"]},
749 {'category': 'java',
750 'severity': Severity.MEDIUM,
751 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800752 'Java: Double-checked locking on non-volatile fields is unsafe',
753 'patterns': [r".*: warning: \[DoubleCheckedLocking\] .+"]},
754 {'category': 'java',
755 'severity': Severity.MEDIUM,
756 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800757 'Java: Annotations should always be immutable',
758 'patterns': [r".*: warning: \[ImmutableAnnotationChecker\] .+"]},
759 {'category': 'java',
760 'severity': Severity.MEDIUM,
761 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800762 'Java: Enums should always be immutable',
763 'patterns': [r".*: warning: \[ImmutableEnumChecker\] .+"]},
764 {'category': 'java',
765 'severity': Severity.MEDIUM,
766 'description':
767 'Java: Writes to static fields should not be guarded by instance locks',
768 'patterns': [r".*: warning: \[StaticGuardedByInstance\] .+"]},
769 {'category': 'java',
770 'severity': Severity.MEDIUM,
771 'description':
772 'Java: Synchronizing on non-final fields is not safe: if the field is ever updated, different threads may end up locking on different objects.',
773 'patterns': [r".*: warning: \[SynchronizeOnNonFinalField\] .+"]},
774 {'category': 'java',
775 'severity': Severity.MEDIUM,
776 'description':
777 'Java: Method reference is ambiguous',
778 'patterns': [r".*: warning: \[AmbiguousMethodReference\] .+"]},
779 {'category': 'java',
780 'severity': Severity.MEDIUM,
781 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800782 'Java: Assertions may be disabled at runtime and do not guarantee that execution will halt here; consider throwing an exception instead',
783 'patterns': [r".*: warning: \[AssertFalse\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -0700784 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700785 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700786 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800787 'Java: This assertion throws an AssertionError if it fails, which will be caught by an enclosing try block.',
788 'patterns': [r".*: warning: \[AssertionFailureIgnored\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -0700789 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700790 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700791 'description':
792 'Java: Classes that implement Annotation must override equals and hashCode. Consider using AutoAnnotation instead of implementing Annotation by hand.',
793 'patterns': [r".*: warning: \[BadAnnotationImplementation\] .+"]},
794 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700795 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700796 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800797 'Java: Possible sign flip from narrowing conversion',
798 'patterns': [r".*: warning: \[BadComparable\] .+"]},
799 {'category': 'java',
800 'severity': Severity.MEDIUM,
801 'description':
Ian Rogers6e520032016-05-13 08:59:00 -0700802 'Java: BigDecimal(double) and BigDecimal.valueOf(double) may lose precision, prefer BigDecimal(String) or BigDecimal(long)',
803 'patterns': [r".*: warning: \[BigDecimalLiteralDouble\] .+"]},
804 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700805 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700806 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800807 'Java: valueOf or autoboxing provides better time and space performance',
808 'patterns': [r".*: warning: \[BoxedPrimitiveConstructor\] .+"]},
809 {'category': 'java',
810 'severity': Severity.MEDIUM,
811 'description':
Ian Rogers6e520032016-05-13 08:59:00 -0700812 'Java: Mockito cannot mock final classes',
813 'patterns': [r".*: warning: \[CannotMockFinalClass\] .+"]},
814 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700815 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700816 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800817 'Java: Duration can be expressed more clearly with different units',
818 'patterns': [r".*: warning: \[CanonicalDuration\] .+"]},
819 {'category': 'java',
820 'severity': Severity.MEDIUM,
821 'description':
822 'Java: Logging or rethrowing exceptions should usually be preferred to catching and calling printStackTrace',
823 'patterns': [r".*: warning: \[CatchAndPrintStackTrace\] .+"]},
824 {'category': 'java',
825 'severity': Severity.MEDIUM,
826 'description':
827 'Java: Ignoring exceptions and calling fail() is unnecessary, and makes test output less useful',
828 'patterns': [r".*: warning: \[CatchFail\] .+"]},
829 {'category': 'java',
830 'severity': Severity.MEDIUM,
831 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800832 'Java: Inner class is non-static but does not reference enclosing class',
833 'patterns': [r".*: warning: \[ClassCanBeStatic\] .+"]},
834 {'category': 'java',
835 'severity': Severity.MEDIUM,
836 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800837 'Java: Class.newInstance() bypasses exception checking; prefer getDeclaredConstructor().newInstance()',
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800838 'patterns': [r".*: warning: \[ClassNewInstance\] .+"]},
839 {'category': 'java',
840 'severity': Severity.MEDIUM,
841 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800842 'Java: The type of the array parameter of Collection.toArray needs to be compatible with the array type',
843 'patterns': [r".*: warning: \[CollectionToArraySafeParameter\] .+"]},
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800844 {'category': 'java',
845 'severity': Severity.MEDIUM,
846 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800847 'Java: Collector.of() should not use state',
848 'patterns': [r".*: warning: \[CollectorShouldNotUseState\] .+"]},
849 {'category': 'java',
850 'severity': Severity.MEDIUM,
851 'description':
852 'Java: Class should not implement both `Comparable` and `Comparator`',
853 'patterns': [r".*: warning: \[ComparableAndComparator\] .+"]},
854 {'category': 'java',
855 'severity': Severity.MEDIUM,
856 'description':
857 'Java: Constructors should not invoke overridable methods.',
858 'patterns': [r".*: warning: \[ConstructorInvokesOverridable\] .+"]},
859 {'category': 'java',
860 'severity': Severity.MEDIUM,
861 'description':
862 'Java: Constructors should not pass the \'this\' reference out in method invocations, since the object may not be fully constructed.',
863 'patterns': [r".*: warning: \[ConstructorLeaksThis\] .+"]},
864 {'category': 'java',
865 'severity': Severity.MEDIUM,
866 'description':
867 'Java: DateFormat is not thread-safe, and should not be used as a constant field.',
868 'patterns': [r".*: warning: \[DateFormatConstant\] .+"]},
869 {'category': 'java',
870 'severity': Severity.MEDIUM,
871 'description':
872 'Java: Implicit use of the platform default charset, which can result in differing behavior between JVM executions or incorrect behavior if the encoding of the data source doesn\'t match expectations.',
873 'patterns': [r".*: warning: \[DefaultCharset\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -0700874 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700875 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700876 'description':
877 'Java: Empty top-level type declaration',
878 'patterns': [r".*: warning: \[EmptyTopLevelDeclaration\] .+"]},
879 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700880 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700881 'description':
882 'Java: Classes that override equals should also override hashCode.',
883 'patterns': [r".*: warning: \[EqualsHashCode\] .+"]},
884 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700885 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700886 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800887 'Java: Calls to ExpectedException#expect should always be followed by exactly one statement.',
888 'patterns': [r".*: warning: \[ExpectedExceptionChecker\] .+"]},
889 {'category': 'java',
890 'severity': Severity.MEDIUM,
891 'description':
892 'Java: Switch case may fall through',
893 'patterns': [r".*: warning: \[FallThrough\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -0700894 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700895 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700896 'description':
897 '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.',
898 'patterns': [r".*: warning: \[Finally\] .+"]},
899 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700900 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700901 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800902 'Java: Use parentheses to make the precedence explicit',
903 'patterns': [r".*: warning: \[FloatCast\] .+"]},
904 {'category': 'java',
905 'severity': Severity.MEDIUM,
906 'description':
907 'Java: Floating point literal loses precision',
908 'patterns': [r".*: warning: \[FloatingPointLiteralPrecision\] .+"]},
909 {'category': 'java',
910 'severity': Severity.MEDIUM,
911 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800912 'Java: Overloads will be ambiguous when passing lambda arguments',
913 'patterns': [r".*: warning: \[FunctionalInterfaceClash\] .+"]},
914 {'category': 'java',
915 'severity': Severity.MEDIUM,
916 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800917 'Java: Return value of methods returning Future must be checked. Ignoring returned Futures suppresses exceptions thrown from the code that completes the Future.',
918 'patterns': [r".*: warning: \[FutureReturnValueIgnored\] .+"]},
919 {'category': 'java',
920 'severity': Severity.MEDIUM,
921 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800922 'Java: Calling getClass() on an enum may return a subclass of the enum type',
923 'patterns': [r".*: warning: \[GetClassOnEnum\] .+"]},
924 {'category': 'java',
925 'severity': Severity.MEDIUM,
926 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800927 'Java: Hiding fields of superclasses may cause confusion and errors',
928 'patterns': [r".*: warning: \[HidingField\] .+"]},
929 {'category': 'java',
930 'severity': Severity.MEDIUM,
931 'description':
Ian Rogers6e520032016-05-13 08:59:00 -0700932 'Java: This annotation has incompatible modifiers as specified by its @IncompatibleModifiers annotation',
933 'patterns': [r".*: warning: \[IncompatibleModifiers\] .+"]},
934 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700935 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700936 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800937 'Java: This for loop increments the same variable in the header and in the body',
938 'patterns': [r".*: warning: \[IncrementInForLoopAndHeader\] .+"]},
939 {'category': 'java',
940 'severity': Severity.MEDIUM,
941 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800942 'Java: Please also override int read(byte[], int, int), otherwise multi-byte reads from this input stream are likely to be slow.',
943 'patterns': [r".*: warning: \[InputStreamSlowMultibyteRead\] .+"]},
944 {'category': 'java',
945 'severity': Severity.MEDIUM,
946 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800947 'Java: Casting inside an if block should be plausibly consistent with the instanceof type',
948 'patterns': [r".*: warning: \[InstanceOfAndCastMatchWrongType\] .+"]},
949 {'category': 'java',
950 'severity': Severity.MEDIUM,
951 'description':
952 'Java: Expression of type int may overflow before being assigned to a long',
953 'patterns': [r".*: warning: \[IntLongMath\] .+"]},
954 {'category': 'java',
955 'severity': Severity.MEDIUM,
956 'description':
Ian Rogers6e520032016-05-13 08:59:00 -0700957 'Java: Class should not implement both `Iterable` and `Iterator`',
958 'patterns': [r".*: warning: \[IterableAndIterator\] .+"]},
959 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700960 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700961 'description':
962 'Java: Floating-point comparison without error tolerance',
963 'patterns': [r".*: warning: \[JUnit3FloatingPointComparisonWithoutDelta\] .+"]},
964 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700965 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700966 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800967 'Java: Some JUnit4 construct cannot be used in a JUnit3 context. Convert your class to JUnit4 style to use them.',
968 'patterns': [r".*: warning: \[JUnit4ClassUsedInJUnit3\] .+"]},
969 {'category': 'java',
970 'severity': Severity.MEDIUM,
971 'description':
Ian Rogers6e520032016-05-13 08:59:00 -0700972 'Java: Test class inherits from JUnit 3\'s TestCase but has JUnit 4 @Test annotations.',
973 'patterns': [r".*: warning: \[JUnitAmbiguousTestClass\] .+"]},
974 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700975 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700976 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800977 'Java: Never reuse class names from java.lang',
978 'patterns': [r".*: warning: \[JavaLangClash\] .+"]},
979 {'category': 'java',
980 'severity': Severity.MEDIUM,
981 'description':
982 'Java: Suggests alternatives to obsolete JDK classes.',
983 'patterns': [r".*: warning: \[JdkObsolete\] .+"]},
984 {'category': 'java',
985 'severity': Severity.MEDIUM,
986 'description':
987 'Java: Assignment where a boolean expression was expected; use == if this assignment wasn\'t expected or add parentheses for clarity.',
988 'patterns': [r".*: warning: \[LogicalAssignment\] .+"]},
989 {'category': 'java',
990 'severity': Severity.MEDIUM,
991 'description':
992 'Java: Switches on enum types should either handle all values, or have a default case.',
Ian Rogers6e520032016-05-13 08:59:00 -0700993 'patterns': [r".*: warning: \[MissingCasesInEnumSwitch\] .+"]},
994 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700995 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700996 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800997 '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.)',
998 'patterns': [r".*: warning: \[MissingDefault\] .+"]},
999 {'category': 'java',
1000 'severity': Severity.MEDIUM,
1001 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001002 'Java: Not calling fail() when expecting an exception masks bugs',
1003 'patterns': [r".*: warning: \[MissingFail\] .+"]},
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: method overrides method in supertype; expected @Override',
1008 'patterns': [r".*: warning: \[MissingOverride\] .+"]},
1009 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001010 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001011 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001012 'Java: Modifying a collection while iterating over it in a loop may cause a ConcurrentModificationException to be thrown.',
1013 'patterns': [r".*: warning: \[ModifyCollectionInEnhancedForLoop\] .+"]},
1014 {'category': 'java',
1015 'severity': Severity.MEDIUM,
1016 'description':
1017 'Java: Multiple calls to either parallel or sequential are unnecessary and cause confusion.',
1018 'patterns': [r".*: warning: \[MultipleParallelOrSequentialCalls\] .+"]},
1019 {'category': 'java',
1020 'severity': Severity.MEDIUM,
1021 'description':
1022 'Java: Constant field declarations should use the immutable type (such as ImmutableList) instead of the general collection interface type (such as List)',
1023 'patterns': [r".*: warning: \[MutableConstantField\] .+"]},
1024 {'category': 'java',
1025 'severity': Severity.MEDIUM,
1026 'description':
1027 'Java: Method return type should use the immutable type (such as ImmutableList) instead of the general collection interface type (such as List)',
1028 'patterns': [r".*: warning: \[MutableMethodReturnType\] .+"]},
1029 {'category': 'java',
1030 'severity': Severity.MEDIUM,
1031 'description':
1032 'Java: Compound assignments may hide dangerous casts',
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001033 'patterns': [r".*: warning: \[NarrowingCompoundAssignment\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001034 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001035 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001036 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001037 'Java: Nested instanceOf conditions of disjoint types create blocks of code that never execute',
1038 'patterns': [r".*: warning: \[NestedInstanceOfConditions\] .+"]},
1039 {'category': 'java',
1040 'severity': Severity.MEDIUM,
1041 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001042 'Java: This update of a volatile variable is non-atomic',
1043 'patterns': [r".*: warning: \[NonAtomicVolatileUpdate\] .+"]},
1044 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001045 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001046 'description':
1047 'Java: Static import of member uses non-canonical name',
1048 'patterns': [r".*: warning: \[NonCanonicalStaticMemberImport\] .+"]},
1049 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001050 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001051 'description':
1052 'Java: equals method doesn\'t override Object.equals',
1053 'patterns': [r".*: warning: \[NonOverridingEquals\] .+"]},
1054 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001055 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001056 'description':
1057 'Java: Constructors should not be annotated with @Nullable since they cannot return null',
1058 'patterns': [r".*: warning: \[NullableConstructor\] .+"]},
1059 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001060 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001061 'description':
1062 'Java: @Nullable should not be used for primitive types since they cannot be null',
1063 'patterns': [r".*: warning: \[NullablePrimitive\] .+"]},
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: void-returning methods should not be annotated with @Nullable, since they cannot return null',
1068 'patterns': [r".*: warning: \[NullableVoid\] .+"]},
1069 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001070 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001071 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001072 'Java: Use grouping parenthesis to make the operator precedence explicit',
1073 'patterns': [r".*: warning: \[OperatorPrecedence\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001074 {'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: One should not call optional.get() inside an if statement that checks !optional.isPresent',
1078 'patterns': [r".*: warning: \[OptionalNotPresent\] .+"]},
1079 {'category': 'java',
1080 'severity': Severity.MEDIUM,
1081 'description':
1082 'Java: String literal contains format specifiers, but is not passed to a format method',
1083 'patterns': [r".*: warning: \[OrphanedFormatString\] .+"]},
1084 {'category': 'java',
1085 'severity': Severity.MEDIUM,
1086 'description':
1087 'Java: To return a custom message with a Throwable class, one should override getMessage() instead of toString() for Throwable.',
1088 'patterns': [r".*: warning: \[OverrideThrowableToString\] .+"]},
1089 {'category': 'java',
1090 'severity': Severity.MEDIUM,
1091 'description':
1092 'Java: Varargs doesn\'t agree for overridden method',
1093 'patterns': [r".*: warning: \[Overrides\] .+"]},
1094 {'category': 'java',
1095 'severity': Severity.MEDIUM,
1096 'description':
1097 'Java: Detects `/* name= */`-style comments on actual parameters where the name doesn\'t match the formal parameter',
1098 'patterns': [r".*: warning: \[ParameterName\] .+"]},
1099 {'category': 'java',
1100 'severity': Severity.MEDIUM,
1101 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001102 'Java: Preconditions only accepts the %s placeholder in error message strings',
1103 'patterns': [r".*: warning: \[PreconditionsInvalidPlaceholder\] .+"]},
1104 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001105 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001106 'description':
1107 'Java: Passing a primitive array to a varargs method is usually wrong',
1108 'patterns': [r".*: warning: \[PrimitiveArrayPassedToVarargsMethod\] .+"]},
1109 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001110 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001111 'description':
1112 'Java: Protobuf fields cannot be null, so this check is redundant',
1113 'patterns': [r".*: warning: \[ProtoFieldPreconditionsCheckNotNull\] .+"]},
1114 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001115 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001116 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001117 'Java: BugChecker has incorrect ProvidesFix tag, please update',
1118 'patterns': [r".*: warning: \[ProvidesFix\] .+"]},
1119 {'category': 'java',
1120 'severity': Severity.MEDIUM,
1121 'description':
1122 'Java: reachabilityFence should always be called inside a finally block',
1123 'patterns': [r".*: warning: \[ReachabilityFenceUsage\] .+"]},
1124 {'category': 'java',
1125 'severity': Severity.MEDIUM,
1126 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001127 'Java: Thrown exception is a subtype of another',
1128 'patterns': [r".*: warning: \[RedundantThrows\] .+"]},
1129 {'category': 'java',
1130 'severity': Severity.MEDIUM,
1131 'description':
1132 'Java: Comparison using reference equality instead of value equality',
1133 'patterns': [r".*: warning: \[ReferenceEquality\] .+"]},
1134 {'category': 'java',
1135 'severity': Severity.MEDIUM,
1136 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001137 'Java: This annotation is missing required modifiers as specified by its @RequiredModifiers annotation',
1138 'patterns': [r".*: warning: \[RequiredModifiers\] .+"]},
1139 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001140 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001141 'description':
Chih-Hung Hsieh9be27762018-06-07 10:51:47 -07001142 r'Java: Prefer the short-circuiting boolean operators \u0026\u0026 and || to \u0026 and |.',
Andreas Gampecf528ca2018-01-25 11:55:43 -08001143 'patterns': [r".*: warning: \[ShortCircuitBoolean\] .+"]},
1144 {'category': 'java',
1145 'severity': Severity.MEDIUM,
1146 'description':
1147 'Java: A static variable or method should be qualified with a class name, not expression',
1148 'patterns': [r".*: warning: \[StaticQualifiedUsingExpression\] .+"]},
1149 {'category': 'java',
1150 'severity': Severity.MEDIUM,
1151 'description':
1152 'Java: Streams that encapsulate a closeable resource should be closed using try-with-resources',
1153 'patterns': [r".*: warning: \[StreamResourceLeak\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001154 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001155 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001156 'description':
1157 'Java: String comparison using reference equality instead of value equality',
1158 'patterns': [r".*: warning: \[StringEquality\] .+"]},
1159 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001160 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001161 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001162 'Java: String.split should never take only a single argument; it has surprising behavior',
1163 'patterns': [r".*: warning: \[StringSplit\] .+"]},
1164 {'category': 'java',
1165 'severity': Severity.MEDIUM,
1166 'description':
1167 'Java: Prefer Splitter to String.split',
1168 'patterns': [r".*: warning: \[StringSplitter\] .+"]},
1169 {'category': 'java',
1170 'severity': Severity.MEDIUM,
1171 'description':
1172 'Java: Using @Test(expected=...) is discouraged, since the test will pass if *any* statement in the test method throws the expected exception',
1173 'patterns': [r".*: warning: \[TestExceptionChecker\] .+"]},
1174 {'category': 'java',
1175 'severity': Severity.MEDIUM,
1176 'description':
1177 'Java: Thread.join needs to be surrounded by a loop until it succeeds, as in Uninterruptibles.joinUninterruptibly.',
1178 'patterns': [r".*: warning: \[ThreadJoinLoop\] .+"]},
1179 {'category': 'java',
1180 'severity': Severity.MEDIUM,
1181 'description':
1182 'Java: ThreadLocals should be stored in static fields',
1183 'patterns': [r".*: warning: \[ThreadLocalUsage\] .+"]},
1184 {'category': 'java',
1185 'severity': Severity.MEDIUM,
1186 'description':
1187 '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.',
1188 'patterns': [r".*: warning: \[ThreeLetterTimeZoneID\] .+"]},
1189 {'category': 'java',
1190 'severity': Severity.MEDIUM,
1191 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001192 'Java: Truth Library assert is called on a constant.',
1193 'patterns': [r".*: warning: \[TruthConstantAsserts\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001194 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001195 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001196 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001197 'Java: Type parameter declaration overrides another type parameter already declared',
1198 'patterns': [r".*: warning: \[TypeParameterShadowing\] .+"]},
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001199 {'category': 'java',
1200 'severity': Severity.MEDIUM,
1201 'description':
1202 '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.',
1203 'patterns': [r".*: warning: \[TypeParameterUnusedInFormals\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001204 {'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: Creation of a Set/HashSet/HashMap of java.net.URL. equals() and hashCode() of java.net.URL class make blocking internet connections.',
1208 'patterns': [r".*: warning: \[URLEqualsHashCode\] .+"]},
1209 {'category': 'java',
1210 'severity': Severity.MEDIUM,
1211 'description':
1212 'Java: Switch handles all enum values; an explicit default case is unnecessary and defeats error checking for non-exhaustive switches.',
1213 'patterns': [r".*: warning: \[UnnecessaryDefaultInEnumSwitch\] .+"]},
1214 {'category': 'java',
1215 'severity': Severity.MEDIUM,
1216 'description':
1217 'Java: Finalizer may run before native code finishes execution',
1218 'patterns': [r".*: warning: \[UnsafeFinalization\] .+"]},
1219 {'category': 'java',
1220 'severity': Severity.MEDIUM,
1221 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001222 'Java: Unsynchronized method overrides a synchronized method.',
1223 'patterns': [r".*: warning: \[UnsynchronizedOverridesSynchronized\] .+"]},
1224 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001225 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001226 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001227 'Java: Java assert is used in test. For testing purposes Assert.* matchers should be used.',
1228 'patterns': [r".*: warning: \[UseCorrectAssertInTests\] .+"]},
1229 {'category': 'java',
1230 'severity': Severity.MEDIUM,
1231 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001232 'Java: Non-constant variable missing @Var annotation',
1233 'patterns': [r".*: warning: \[Var\] .+"]},
1234 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001235 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001236 'description':
1237 'Java: Because of spurious wakeups, Object.wait() and Condition.await() must always be called in a loop',
1238 'patterns': [r".*: warning: \[WaitNotInLoop\] .+"]},
1239 {'category': 'java',
Andreas Gampecf528ca2018-01-25 11:55:43 -08001240 'severity': Severity.MEDIUM,
1241 'description':
1242 'Java: Pluggable Type checker internal error',
1243 'patterns': [r".*: warning: \[PluggableTypeChecker\] .+"]},
1244 {'category': 'java',
1245 'severity': Severity.MEDIUM,
1246 'description':
1247 'Java: Invalid message format-style format specifier ({0}), expected printf-style (%s)',
1248 'patterns': [r".*: warning: \[FloggerMessageFormat\] .+"]},
1249 {'category': 'java',
1250 'severity': Severity.MEDIUM,
1251 'description':
1252 'Java: Logger level check is already implied in the log() call. An explicit at[Level]().isEnabled() check is redundant.',
1253 'patterns': [r".*: warning: \[FloggerRedundantIsEnabled\] .+"]},
1254 {'category': 'java',
1255 'severity': Severity.MEDIUM,
1256 'description':
1257 'Java: Calling withCause(Throwable) with an inline allocated Throwable is discouraged. Consider using withStackTrace(StackSize) instead, and specifying a reduced stack size (e.g. SMALL, MEDIUM or LARGE) instead of FULL, to improve performance.',
1258 'patterns': [r".*: warning: \[FloggerWithCause\] .+"]},
1259 {'category': 'java',
1260 'severity': Severity.MEDIUM,
1261 'description':
1262 'Java: Use withCause to associate Exceptions with log statements',
1263 'patterns': [r".*: warning: \[FloggerWithoutCause\] .+"]},
1264 {'category': 'java',
1265 'severity': Severity.MEDIUM,
1266 'description':
1267 'Java: No bug exists to track an ignored test',
1268 'patterns': [r".*: warning: \[IgnoredTestWithoutBug\] .+"]},
1269 {'category': 'java',
1270 'severity': Severity.MEDIUM,
1271 'description':
1272 'Java: @Ignore is preferred to @Suppress for JUnit4 tests. @Suppress may silently fail in JUnit4 (that is, tests may run anyway.)',
1273 'patterns': [r".*: warning: \[JUnit4SuppressWithoutIgnore\] .+"]},
1274 {'category': 'java',
1275 'severity': Severity.MEDIUM,
1276 'description':
1277 'Java: Medium and large test classes should document why they are medium or large',
1278 'patterns': [r".*: warning: \[JUnit4TestAttributeMissing\] .+"]},
1279 {'category': 'java',
1280 'severity': Severity.MEDIUM,
1281 'description':
1282 'Java: java.net.IDN implements the older IDNA2003 standard. Prefer com.google.i18n.Idn, which implements the newer UTS #46 standard',
1283 'patterns': [r".*: warning: \[JavaNetIdn\] .+"]},
1284 {'category': 'java',
1285 'severity': Severity.MEDIUM,
1286 'description':
1287 'Java: Consider requiring strict parsing on JodaDurationFlag instances. Before adjusting existing flags, check the documentation and your existing configuration to avoid crashes!',
1288 'patterns': [r".*: warning: \[JodaDurationFlagStrictParsing\] .+"]},
1289 {'category': 'java',
1290 'severity': Severity.MEDIUM,
1291 'description':
1292 'Java: Logging an exception and throwing it (or a new exception) for the same exceptional situation is an anti-pattern.',
1293 'patterns': [r".*: warning: \[LogAndThrow\] .+"]},
1294 {'category': 'java',
1295 'severity': Severity.MEDIUM,
1296 'description':
1297 'Java: FormattingLogger uses wrong or mismatched format string',
1298 'patterns': [r".*: warning: \[MisusedFormattingLogger\] .+"]},
1299 {'category': 'java',
1300 'severity': Severity.MEDIUM,
1301 'description':
1302 'Java: Flags should be final',
1303 'patterns': [r".*: warning: \[NonFinalFlag\] .+"]},
1304 {'category': 'java',
1305 'severity': Severity.MEDIUM,
1306 'description':
1307 'Java: Reading a flag from a static field or initializer block will cause it to always receive the default value and will cause an IllegalFlagStateException if the flag is ever set.',
1308 'patterns': [r".*: warning: \[StaticFlagUsage\] .+"]},
1309 {'category': 'java',
1310 'severity': Severity.MEDIUM,
1311 'description':
1312 'Java: Apps must use BuildCompat.isAtLeastO to check whether they\'re running on Android O',
1313 'patterns': [r".*: warning: \[UnsafeSdkVersionCheck\] .+"]},
1314 {'category': 'java',
1315 'severity': Severity.HIGH,
1316 'description':
1317 'Java: Logging tag cannot be longer than 23 characters.',
1318 'patterns': [r".*: warning: \[LogTagLength\] .+"]},
1319 {'category': 'java',
1320 'severity': Severity.HIGH,
1321 'description':
1322 'Java: Relative class name passed to ComponentName constructor',
1323 'patterns': [r".*: warning: \[RelativeComponentName\] .+"]},
1324 {'category': 'java',
1325 'severity': Severity.HIGH,
1326 'description':
1327 'Java: Explicitly enumerate all cases in switch statements for certain enum types.',
1328 'patterns': [r".*: warning: \[EnumerateAllCasesInEnumSwitch\] .+"]},
1329 {'category': 'java',
1330 'severity': Severity.HIGH,
1331 'description':
1332 'Java: Do not call assumeTrue(tester.getExperimentValueFor(...)). Use @RequireEndToEndTestExperiment instead.',
1333 'patterns': [r".*: warning: \[JUnitAssumeExperiment\] .+"]},
1334 {'category': 'java',
1335 'severity': Severity.HIGH,
1336 'description':
1337 'Java: The accessed field or method is not visible here. Note that the default production visibility for @VisibleForTesting is Visibility.PRIVATE.',
1338 'patterns': [r".*: warning: \[VisibleForTestingChecker\] .+"]},
1339 {'category': 'java',
1340 'severity': Severity.HIGH,
1341 'description':
1342 'Java: Detects errors encountered building Error Prone plugins',
1343 'patterns': [r".*: warning: \[ErrorPronePluginCorrectness\] .+"]},
1344 {'category': 'java',
1345 'severity': Severity.HIGH,
1346 'description':
Chih-Hung Hsieh9be27762018-06-07 10:51:47 -07001347 r'Java: Parcelable CREATOR fields should be Creator\u003cT>',
Andreas Gampecf528ca2018-01-25 11:55:43 -08001348 'patterns': [r".*: warning: \[ParcelableCreatorType\] .+"]},
1349 {'category': 'java',
1350 'severity': Severity.HIGH,
1351 'description':
1352 'Java: Enforce reflected Parcelables are kept by Proguard',
1353 'patterns': [r".*: warning: \[ReflectedParcelable\] .+"]},
1354 {'category': 'java',
1355 'severity': Severity.HIGH,
1356 'description':
1357 'Java: Any class that extends IntentService should have @Nullable notation on method onHandleIntent(@Nullable Intent intent) and handle the case if intent is null.',
1358 'patterns': [r".*: warning: \[OnHandleIntentNullableChecker\] .+"]},
1359 {'category': 'java',
1360 'severity': Severity.HIGH,
1361 'description':
1362 'Java: In many cases, randomUUID is not necessary, and it slows the performance, which can be quite severe especially when this operation happens at start up time. Consider replacing it with cheaper alternatives, like object.hashCode() or IdGenerator.INSTANCE.getRandomId()',
1363 'patterns': [r".*: warning: \[UUIDChecker\] .+"]},
1364 {'category': 'java',
1365 'severity': Severity.HIGH,
1366 'description':
1367 'Java: DynamicActivity.findViewById(int) is slow and should not be used inside View.onDraw(Canvas)!',
1368 'patterns': [r".*: warning: \[NoFindViewByIdInOnDrawChecker\] .+"]},
1369 {'category': 'java',
1370 'severity': Severity.HIGH,
1371 'description':
1372 'Java: Passing Throwable/Exception argument to the message format L.x(). Calling L.w(tag, message, ex) instead of L.w(tag, ex, message)',
1373 'patterns': [r".*: warning: \[WrongThrowableArgumentInLogChecker\] .+"]},
1374 {'category': 'java',
1375 'severity': Severity.HIGH,
1376 'description':
1377 'Java: New splicers are disallowed on paths that are being Libsearched',
1378 'patterns': [r".*: warning: \[BlacklistedSplicerPathChecker\] .+"]},
1379 {'category': 'java',
1380 'severity': Severity.HIGH,
1381 'description':
1382 'Java: Object serialized in Bundle may have been flattened to base type.',
1383 'patterns': [r".*: warning: \[BundleDeserializationCast\] .+"]},
1384 {'category': 'java',
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001385 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001386 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001387 'Java: Log tag too long, cannot exceed 23 characters.',
1388 'patterns': [r".*: warning: \[IsLoggableTagLength\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001389 {'category': 'java',
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001390 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001391 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001392 'Java: Certain resources in `android.R.string` have names that do not match their content',
1393 'patterns': [r".*: warning: \[MislabeledAndroidString\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001394 {'category': 'java',
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001395 'severity': Severity.HIGH,
1396 'description':
1397 'Java: Return value of android.graphics.Rect.intersect() must be checked',
1398 'patterns': [r".*: warning: \[RectIntersectReturnValueIgnored\] .+"]},
1399 {'category': 'java',
1400 'severity': Severity.HIGH,
1401 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001402 'Java: Incompatible type as argument to Object-accepting Java collections method',
1403 'patterns': [r".*: warning: \[CollectionIncompatibleType\] .+"]},
1404 {'category': 'java',
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001405 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001406 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001407 'Java: @CompatibleWith\'s value is not a type argument.',
1408 'patterns': [r".*: warning: \[CompatibleWithAnnotationMisuse\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001409 {'category': 'java',
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001410 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001411 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001412 'Java: Passing argument to a generic method with an incompatible type.',
1413 'patterns': [r".*: warning: \[IncompatibleArgumentType\] .+"]},
1414 {'category': 'java',
1415 'severity': Severity.HIGH,
1416 'description':
1417 'Java: Invalid printf-style format string',
1418 'patterns': [r".*: warning: \[FormatString\] .+"]},
1419 {'category': 'java',
1420 'severity': Severity.HIGH,
1421 'description':
1422 'Java: Invalid format string passed to formatting method.',
1423 'patterns': [r".*: warning: \[FormatStringAnnotation\] .+"]},
1424 {'category': 'java',
1425 'severity': Severity.HIGH,
1426 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001427 'Java: Checks for unguarded accesses to fields and methods with @GuardedBy annotations',
Andreas Gampe7f494c12018-01-17 21:20:36 -08001428 'patterns': [r".*: warning: \[GuardedBy\] .+"]},
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001429 {'category': 'java',
1430 'severity': Severity.HIGH,
1431 'description':
1432 'Java: Type declaration annotated with @Immutable is not immutable',
1433 'patterns': [r".*: warning: \[Immutable\] .+"]},
1434 {'category': 'java',
1435 'severity': Severity.HIGH,
1436 'description':
1437 'Java: This method does not acquire the locks specified by its @LockMethod annotation',
1438 'patterns': [r".*: warning: \[LockMethodChecker\] .+"]},
1439 {'category': 'java',
1440 'severity': Severity.HIGH,
1441 'description':
1442 'Java: This method does not acquire the locks specified by its @UnlockMethod annotation',
1443 'patterns': [r".*: warning: \[UnlockMethod\] .+"]},
1444 {'category': 'java',
1445 'severity': Severity.HIGH,
1446 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001447 'Java: Reference equality used to compare arrays',
1448 'patterns': [r".*: warning: \[ArrayEquals\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001449 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001450 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001451 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001452 'Java: Arrays.fill(Object[], Object) called with incompatible types.',
1453 'patterns': [r".*: warning: \[ArrayFillIncompatibleType\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001454 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001455 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001456 'description':
1457 'Java: hashcode method on array does not hash array contents',
1458 'patterns': [r".*: warning: \[ArrayHashCode\] .+"]},
1459 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001460 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001461 'description':
1462 'Java: Calling toString on an array does not provide useful information',
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001463 'patterns': [r".*: warning: \[ArrayToString\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001464 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001465 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001466 'description':
1467 'Java: Arrays.asList does not autobox primitive arrays, as one might expect.',
1468 'patterns': [r".*: warning: \[ArraysAsListPrimitiveArray\] .+"]},
1469 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001470 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001471 'description':
1472 'Java: AsyncCallable should not return a null Future, only a Future whose result is null.',
1473 'patterns': [r".*: warning: \[AsyncCallableReturnsNull\] .+"]},
1474 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001475 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001476 'description':
1477 'Java: AsyncFunction should not return a null Future, only a Future whose result is null.',
1478 'patterns': [r".*: warning: \[AsyncFunctionReturnsNull\] .+"]},
1479 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001480 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001481 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001482 'Java: Shift by an amount that is out of range',
1483 'patterns': [r".*: warning: \[BadShiftAmount\] .+"]},
1484 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001485 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001486 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001487 '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.',
1488 'patterns': [r".*: warning: \[ChainingConstructorIgnoresParameter\] .+"]},
1489 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001490 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001491 'description':
1492 'Java: Ignored return value of method that is annotated with @CheckReturnValue',
1493 'patterns': [r".*: warning: \[CheckReturnValue\] .+"]},
1494 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001495 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001496 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001497 'Java: The source file name should match the name of the top-level class it contains',
1498 'patterns': [r".*: warning: \[ClassName\] .+"]},
1499 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001500 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001501 'description':
Chih-Hung Hsieh9be27762018-06-07 10:51:47 -07001502 r'Java: Implementing \'Comparable\u003cT>\' where T is not compatible with the implementing class.',
Andreas Gampecf528ca2018-01-25 11:55:43 -08001503 'patterns': [r".*: warning: \[ComparableType\] .+"]},
1504 {'category': 'java',
1505 'severity': Severity.HIGH,
1506 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001507 'Java: This comparison method violates the contract',
1508 'patterns': [r".*: warning: \[ComparisonContractViolated\] .+"]},
1509 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001510 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001511 'description':
1512 'Java: Comparison to value that is out of range for the compared type',
1513 'patterns': [r".*: warning: \[ComparisonOutOfRange\] .+"]},
1514 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001515 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001516 'description':
1517 'Java: Non-compile-time constant expression passed to parameter with @CompileTimeConstant type annotation.',
1518 'patterns': [r".*: warning: \[CompileTimeConstant\] .+"]},
1519 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001520 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001521 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001522 'Java: Non-trivial compile time constant boolean expressions shouldn\'t be used.',
1523 'patterns': [r".*: warning: \[ComplexBooleanConstant\] .+"]},
1524 {'category': 'java',
1525 'severity': Severity.HIGH,
1526 'description':
1527 '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.',
1528 'patterns': [r".*: warning: \[ConditionalExpressionNumericPromotion\] .+"]},
1529 {'category': 'java',
1530 'severity': Severity.HIGH,
1531 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001532 'Java: Compile-time constant expression overflows',
1533 'patterns': [r".*: warning: \[ConstantOverflow\] .+"]},
1534 {'category': 'java',
1535 'severity': Severity.HIGH,
1536 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001537 'Java: Exception created but not thrown',
1538 'patterns': [r".*: warning: \[DeadException\] .+"]},
1539 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001540 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001541 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001542 'Java: Thread created but not started',
1543 'patterns': [r".*: warning: \[DeadThread\] .+"]},
1544 {'category': 'java',
1545 'severity': Severity.HIGH,
1546 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001547 'Java: Division by integer literal zero',
1548 'patterns': [r".*: warning: \[DivZero\] .+"]},
1549 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001550 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001551 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001552 'Java: This method should not be called.',
1553 'patterns': [r".*: warning: \[DoNotCall\] .+"]},
1554 {'category': 'java',
1555 'severity': Severity.HIGH,
1556 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001557 'Java: Empty statement after if',
1558 'patterns': [r".*: warning: \[EmptyIf\] .+"]},
1559 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001560 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001561 'description':
1562 'Java: == NaN always returns false; use the isNaN methods instead',
1563 'patterns': [r".*: warning: \[EqualsNaN\] .+"]},
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: == must be used in equals method to check equality to itself or an infinite loop will occur.',
1568 'patterns': [r".*: warning: \[EqualsReference\] .+"]},
1569 {'category': 'java',
1570 'severity': Severity.HIGH,
1571 'description':
1572 '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 -07001573 'patterns': [r".*: warning: \[ForOverride\] .+"]},
1574 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001575 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001576 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001577 '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.',
1578 'patterns': [r".*: warning: \[FunctionalInterfaceMethodChanged\] .+"]},
1579 {'category': 'java',
1580 'severity': Severity.HIGH,
1581 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001582 'Java: Futures.getChecked requires a checked exception type with a standard constructor.',
1583 'patterns': [r".*: warning: \[FuturesGetCheckedIllegalExceptionType\] .+"]},
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: DoubleMath.fuzzyEquals should never be used in an Object.equals() method',
1588 'patterns': [r".*: warning: \[FuzzyEqualsShouldNotBeUsedInEqualsMethod\] .+"]},
1589 {'category': 'java',
1590 'severity': Severity.HIGH,
1591 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001592 'Java: Calling getClass() on an annotation may return a proxy class',
1593 'patterns': [r".*: warning: \[GetClassOnAnnotation\] .+"]},
1594 {'category': 'java',
1595 'severity': Severity.HIGH,
1596 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001597 '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',
1598 'patterns': [r".*: warning: \[GetClassOnClass\] .+"]},
1599 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001600 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001601 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001602 'Java: contains() is a legacy method that is equivalent to containsValue()',
1603 'patterns': [r".*: warning: \[HashtableContains\] .+"]},
1604 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001605 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001606 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001607 'Java: A binary expression where both operands are the same is usually incorrect.',
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001608 'patterns': [r".*: warning: \[IdentityBinaryExpression\] .+"]},
1609 {'category': 'java',
1610 'severity': Severity.HIGH,
1611 'description':
1612 'Java: Modifying an immutable collection is guaranteed to throw an exception and leave the collection unmodified',
1613 'patterns': [r".*: warning: \[ImmutableModification\] .+"]},
1614 {'category': 'java',
1615 'severity': Severity.HIGH,
1616 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001617 'Java: The first argument to indexOf is a Unicode code point, and the second is the index to start the search from',
1618 'patterns': [r".*: warning: \[IndexOfChar\] .+"]},
1619 {'category': 'java',
1620 'severity': Severity.HIGH,
1621 'description':
1622 'Java: Conditional expression in varargs call contains array and non-array arguments',
1623 'patterns': [r".*: warning: \[InexactVarargsConditional\] .+"]},
1624 {'category': 'java',
1625 'severity': Severity.HIGH,
1626 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001627 'Java: This method always recurses, and will cause a StackOverflowError',
1628 'patterns': [r".*: warning: \[InfiniteRecursion\] .+"]},
1629 {'category': 'java',
1630 'severity': Severity.HIGH,
1631 'description':
1632 'Java: A standard cryptographic operation is used in a mode that is prone to vulnerabilities',
1633 'patterns': [r".*: warning: \[InsecureCryptoUsage\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001634 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001635 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001636 'description':
1637 'Java: Invalid syntax used for a regular expression',
1638 'patterns': [r".*: warning: \[InvalidPatternSyntax\] .+"]},
1639 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001640 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001641 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001642 'Java: Invalid time zone identifier. TimeZone.getTimeZone(String) will silently return GMT instead of the time zone you intended.',
1643 'patterns': [r".*: warning: \[InvalidTimeZoneID\] .+"]},
1644 {'category': 'java',
1645 'severity': Severity.HIGH,
1646 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001647 'Java: The argument to Class#isInstance(Object) should not be a Class',
1648 'patterns': [r".*: warning: \[IsInstanceOfClass\] .+"]},
1649 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001650 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001651 'description':
Chih-Hung Hsieh9be27762018-06-07 10:51:47 -07001652 r'Java: Path implements Iterable\u003cPath>; prefer Collection\u003cPath> for clarity',
Andreas Gampecf528ca2018-01-25 11:55:43 -08001653 'patterns': [r".*: warning: \[IterablePathParameter\] .+"]},
1654 {'category': 'java',
1655 'severity': Severity.HIGH,
1656 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001657 'Java: jMock tests must have a @RunWith(JMock.class) annotation, or the Mockery field must have a @Rule JUnit annotation',
1658 'patterns': [r".*: warning: \[JMockTestWithoutRunWithOrRuleAnnotation\] .+"]},
1659 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001660 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001661 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001662 '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 -07001663 'patterns': [r".*: warning: \[JUnit3TestNotRun\] .+"]},
1664 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001665 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001666 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001667 'Java: This method should be static',
1668 'patterns': [r".*: warning: \[JUnit4ClassAnnotationNonStatic\] .+"]},
1669 {'category': 'java',
1670 'severity': Severity.HIGH,
1671 'description':
1672 'Java: setUp() method will not be run; please add JUnit\'s @Before annotation',
Ian Rogers6e520032016-05-13 08:59:00 -07001673 'patterns': [r".*: warning: \[JUnit4SetUpNotRun\] .+"]},
1674 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001675 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001676 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001677 'Java: tearDown() method will not be run; please add JUnit\'s @After annotation',
Ian Rogers6e520032016-05-13 08:59:00 -07001678 'patterns': [r".*: warning: \[JUnit4TearDownNotRun\] .+"]},
1679 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001680 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001681 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001682 'Java: This looks like a test method but is not run; please add @Test or @Ignore, or, if this is a helper method, reduce its visibility.',
Ian Rogers6e520032016-05-13 08:59:00 -07001683 'patterns': [r".*: warning: \[JUnit4TestNotRun\] .+"]},
1684 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001685 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001686 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001687 'Java: An object is tested for reference equality to itself using JUnit library.',
1688 'patterns': [r".*: warning: \[JUnitAssertSameCheck\] .+"]},
1689 {'category': 'java',
1690 'severity': Severity.HIGH,
1691 'description':
1692 'Java: This pattern will silently corrupt certain byte sequences from the serialized protocol message. Use ByteString or byte[] directly',
1693 'patterns': [r".*: warning: \[LiteByteStringUtf8\] .+"]},
1694 {'category': 'java',
1695 'severity': Severity.HIGH,
1696 'description':
1697 'Java: Loop condition is never modified in loop body.',
1698 'patterns': [r".*: warning: \[LoopConditionChecker\] .+"]},
1699 {'category': 'java',
1700 'severity': Severity.HIGH,
1701 'description':
1702 'Java: Overriding method is missing a call to overridden super method',
1703 'patterns': [r".*: warning: \[MissingSuperCall\] .+"]},
1704 {'category': 'java',
1705 'severity': Severity.HIGH,
1706 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001707 'Java: Use of "YYYY" (week year) in a date pattern without "ww" (week in year). You probably meant to use "yyyy" (year) instead.',
1708 'patterns': [r".*: warning: \[MisusedWeekYear\] .+"]},
1709 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001710 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001711 'description':
1712 'Java: A bug in Mockito will cause this test to fail at runtime with a ClassCastException',
1713 'patterns': [r".*: warning: \[MockitoCast\] .+"]},
1714 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001715 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001716 'description':
1717 'Java: Missing method call for verify(mock) here',
1718 'patterns': [r".*: warning: \[MockitoUsage\] .+"]},
1719 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001720 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001721 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001722 'Java: Using a collection function with itself as the argument.',
Ian Rogers6e520032016-05-13 08:59:00 -07001723 'patterns': [r".*: warning: \[ModifyingCollectionWithItself\] .+"]},
1724 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001725 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001726 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001727 'Java: The result of this method must be closed.',
1728 'patterns': [r".*: warning: \[MustBeClosedChecker\] .+"]},
1729 {'category': 'java',
1730 'severity': Severity.HIGH,
1731 'description':
1732 'Java: The first argument to nCopies is the number of copies, and the second is the item to copy',
1733 'patterns': [r".*: warning: \[NCopiesOfChar\] .+"]},
1734 {'category': 'java',
1735 'severity': Severity.HIGH,
1736 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001737 'Java: @NoAllocation was specified on this method, but something was found that would trigger an allocation',
1738 'patterns': [r".*: warning: \[NoAllocation\] .+"]},
1739 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001740 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001741 'description':
1742 'Java: Static import of type uses non-canonical name',
1743 'patterns': [r".*: warning: \[NonCanonicalStaticImport\] .+"]},
1744 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001745 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001746 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001747 'Java: @CompileTimeConstant parameters should be final or effectively final',
Ian Rogers6e520032016-05-13 08:59:00 -07001748 'patterns': [r".*: warning: \[NonFinalCompileTimeConstant\] .+"]},
1749 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001750 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001751 'description':
1752 'Java: Calling getAnnotation on an annotation that is not retained at runtime.',
1753 'patterns': [r".*: warning: \[NonRuntimeAnnotation\] .+"]},
1754 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001755 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001756 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001757 'Java: This conditional expression may evaluate to null, which will result in an NPE when the result is unboxed.',
1758 'patterns': [r".*: warning: \[NullTernary\] .+"]},
1759 {'category': 'java',
1760 'severity': Severity.HIGH,
1761 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001762 'Java: Numeric comparison using reference equality instead of value equality',
1763 'patterns': [r".*: warning: \[NumericEquality\] .+"]},
1764 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001765 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001766 'description':
1767 'Java: Comparison using reference equality instead of value equality',
1768 'patterns': [r".*: warning: \[OptionalEquality\] .+"]},
1769 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001770 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001771 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001772 'Java: Declaring types inside package-info.java files is very bad form',
1773 'patterns': [r".*: warning: \[PackageInfo\] .+"]},
1774 {'category': 'java',
1775 'severity': Severity.HIGH,
1776 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001777 'Java: Literal passed as first argument to Preconditions.checkNotNull() can never be null',
1778 'patterns': [r".*: warning: \[PreconditionsCheckNotNull\] .+"]},
1779 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001780 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001781 'description':
1782 'Java: First argument to `Preconditions.checkNotNull()` is a primitive rather than an object reference',
1783 'patterns': [r".*: warning: \[PreconditionsCheckNotNullPrimitive\] .+"]},
1784 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001785 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001786 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001787 'Java: Using ::equals as an incompatible Predicate; the predicate will always return false',
1788 'patterns': [r".*: warning: \[PredicateIncompatibleType\] .+"]},
1789 {'category': 'java',
1790 'severity': Severity.HIGH,
1791 'description':
1792 '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.',
1793 'patterns': [r".*: warning: \[PrivateSecurityContractProtoAccess\] .+"]},
1794 {'category': 'java',
1795 'severity': Severity.HIGH,
1796 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001797 'Java: Protobuf fields cannot be null',
1798 'patterns': [r".*: warning: \[ProtoFieldNullComparison\] .+"]},
1799 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001800 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001801 'description':
1802 'Java: Comparing protobuf fields of type String using reference equality',
1803 'patterns': [r".*: warning: \[ProtoStringFieldReferenceEquality\] .+"]},
1804 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001805 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001806 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001807 'Java: To get the tag number of a protocol buffer enum, use getNumber() instead.',
1808 'patterns': [r".*: warning: \[ProtocolBufferOrdinal\] .+"]},
1809 {'category': 'java',
1810 'severity': Severity.HIGH,
1811 'description':
1812 'Java: Casting a random number in the range [0.0, 1.0) to an integer or long always results in 0.',
1813 'patterns': [r".*: warning: \[RandomCast\] .+"]},
1814 {'category': 'java',
1815 'severity': Severity.HIGH,
1816 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001817 'Java: Use Random.nextInt(int). Random.nextInt() % n can have negative results',
1818 'patterns': [r".*: warning: \[RandomModInteger\] .+"]},
1819 {'category': 'java',
1820 'severity': Severity.HIGH,
1821 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001822 'Java: Check for non-whitelisted callers to RestrictedApiChecker.',
1823 'patterns': [r".*: warning: \[RestrictedApiChecker\] .+"]},
1824 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001825 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001826 'description':
1827 'Java: Return value of this method must be used',
1828 'patterns': [r".*: warning: \[ReturnValueIgnored\] .+"]},
1829 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001830 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001831 'description':
1832 'Java: Variable assigned to itself',
1833 'patterns': [r".*: warning: \[SelfAssignment\] .+"]},
1834 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001835 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001836 'description':
1837 'Java: An object is compared to itself',
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001838 'patterns': [r".*: warning: \[SelfComparison\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001839 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001840 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001841 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001842 'Java: Testing an object for equality with itself will always be true.',
1843 'patterns': [r".*: warning: \[SelfEquals\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001844 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001845 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001846 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001847 'Java: This method must be called with an even number of arguments.',
1848 'patterns': [r".*: warning: \[ShouldHaveEvenArgs\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001849 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001850 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001851 'description':
1852 'Java: Comparison of a size >= 0 is always true, did you intend to check for non-emptiness?',
1853 'patterns': [r".*: warning: \[SizeGreaterThanOrEqualsZero\] .+"]},
1854 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001855 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001856 'description':
1857 'Java: Calling toString on a Stream does not provide useful information',
1858 'patterns': [r".*: warning: \[StreamToString\] .+"]},
1859 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001860 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001861 'description':
1862 'Java: StringBuilder does not have a char constructor; this invokes the int constructor.',
1863 'patterns': [r".*: warning: \[StringBuilderInitWithChar\] .+"]},
1864 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001865 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001866 'description':
1867 'Java: Suppressing "deprecated" is probably a typo for "deprecation"',
1868 'patterns': [r".*: warning: \[SuppressWarningsDeprecated\] .+"]},
1869 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001870 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001871 'description':
1872 'Java: throwIfUnchecked(knownCheckedException) is a no-op.',
1873 'patterns': [r".*: warning: \[ThrowIfUncheckedKnownChecked\] .+"]},
1874 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001875 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001876 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001877 'Java: Throwing \'null\' always results in a NullPointerException being thrown.',
1878 'patterns': [r".*: warning: \[ThrowNull\] .+"]},
1879 {'category': 'java',
1880 'severity': Severity.HIGH,
1881 'description':
1882 'Java: isEqualTo should not be used to test an object for equality with itself; the assertion will never fail.',
1883 'patterns': [r".*: warning: \[TruthSelfEquals\] .+"]},
1884 {'category': 'java',
1885 'severity': Severity.HIGH,
1886 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001887 'Java: Catching Throwable/Error masks failures from fail() or assert*() in the try block',
1888 'patterns': [r".*: warning: \[TryFailThrowable\] .+"]},
1889 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001890 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001891 'description':
1892 'Java: Type parameter used as type qualifier',
1893 'patterns': [r".*: warning: \[TypeParameterQualifier\] .+"]},
1894 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001895 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001896 'description':
1897 'Java: Non-generic methods should not be invoked with type arguments',
1898 'patterns': [r".*: warning: \[UnnecessaryTypeArgument\] .+"]},
1899 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001900 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001901 'description':
1902 'Java: Instance created but never used',
1903 'patterns': [r".*: warning: \[UnusedAnonymousClass\] .+"]},
1904 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001905 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001906 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001907 'Java: Collection is modified in place, but the result is not used',
1908 'patterns': [r".*: warning: \[UnusedCollectionModifiedInPlace\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001909 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001910 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001911 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001912 'Java: `var` should not be used as a type name.',
1913 'patterns': [r".*: warning: \[VarTypeName\] .+"]},
1914 {'category': 'java',
1915 'severity': Severity.HIGH,
1916 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001917 'Java: Method parameter has wrong package',
1918 'patterns': [r".*: warning: \[ParameterPackage\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08001919 {'category': 'java',
1920 'severity': Severity.HIGH,
1921 'description':
1922 'Java: Type declaration annotated with @ThreadSafe is not thread safe',
1923 'patterns': [r".*: warning: \[ThreadSafe\] .+"]},
1924 {'category': 'java',
1925 'severity': Severity.HIGH,
1926 'description':
1927 'Java: Use of class, field, or method that is not compatible with legacy Android devices',
1928 'patterns': [r".*: warning: \[AndroidApiChecker\] .+"]},
1929 {'category': 'java',
1930 'severity': Severity.HIGH,
1931 'description':
1932 'Java: Invalid use of Flogger format string',
1933 'patterns': [r".*: warning: \[AndroidFloggerFormatString\] .+"]},
1934 {'category': 'java',
1935 'severity': Severity.HIGH,
1936 'description':
1937 'Java: Use TunnelException.getCauseAs(Class) instead of casting the result of TunnelException.getCause().',
1938 'patterns': [r".*: warning: \[DoNotCastTunnelExceptionCause\] .+"]},
1939 {'category': 'java',
1940 'severity': Severity.HIGH,
1941 'description':
1942 'Java: Identifies undesirable mocks.',
1943 'patterns': [r".*: warning: \[DoNotMock_ForJavaBuilder\] .+"]},
1944 {'category': 'java',
1945 'severity': Severity.HIGH,
1946 'description':
1947 'Java: Duration Flag should NOT have units in the variable name or the @FlagSpec\'s name or altName field.',
1948 'patterns': [r".*: warning: \[DurationFlagWithUnits\] .+"]},
1949 {'category': 'java',
1950 'severity': Severity.HIGH,
1951 'description':
1952 'Java: Duration.get() only works with SECONDS or NANOS.',
1953 'patterns': [r".*: warning: \[DurationGetTemporalUnit\] .+"]},
1954 {'category': 'java',
1955 'severity': Severity.HIGH,
1956 'description':
1957 'Java: Invalid printf-style format string',
1958 'patterns': [r".*: warning: \[FloggerFormatString\] .+"]},
1959 {'category': 'java',
1960 'severity': Severity.HIGH,
1961 'description':
1962 'Java: Test class may not be run because it is missing a @RunWith annotation',
1963 'patterns': [r".*: warning: \[JUnit4RunWithMissing\] .+"]},
1964 {'category': 'java',
1965 'severity': Severity.HIGH,
1966 'description':
1967 'Java: Use of class, field, or method that is not compatible with JDK 7',
1968 'patterns': [r".*: warning: \[Java7ApiChecker\] .+"]},
1969 {'category': 'java',
1970 'severity': Severity.HIGH,
1971 'description':
1972 'Java: Use of java.time.Duration.withNanos(int) is not allowed.',
1973 'patterns': [r".*: warning: \[JavaDurationWithNanos\] .+"]},
1974 {'category': 'java',
1975 'severity': Severity.HIGH,
1976 'description':
1977 'Java: Use of java.time.Duration.withSeconds(long) is not allowed.',
1978 'patterns': [r".*: warning: \[JavaDurationWithSeconds\] .+"]},
1979 {'category': 'java',
1980 'severity': Severity.HIGH,
1981 'description':
1982 'Java: java.time APIs that silently use the default system time-zone are not allowed.',
1983 'patterns': [r".*: warning: \[JavaTimeDefaultTimeZone\] .+"]},
1984 {'category': 'java',
1985 'severity': Severity.HIGH,
1986 'description':
1987 'Java: Use of new Duration(long) is not allowed. Please use Duration.millis(long) instead.',
1988 'patterns': [r".*: warning: \[JodaDurationConstructor\] .+"]},
1989 {'category': 'java',
1990 'severity': Severity.HIGH,
1991 'description':
1992 'Java: Use of duration.withMillis(long) is not allowed. Please use Duration.millis(long) instead.',
1993 'patterns': [r".*: warning: \[JodaDurationWithMillis\] .+"]},
1994 {'category': 'java',
1995 'severity': Severity.HIGH,
1996 'description':
1997 'Java: Use of instant.withMillis(long) is not allowed. Please use new Instant(long) instead.',
1998 'patterns': [r".*: warning: \[JodaInstantWithMillis\] .+"]},
1999 {'category': 'java',
2000 'severity': Severity.HIGH,
2001 'description':
Chih-Hung Hsieh9be27762018-06-07 10:51:47 -07002002 r'Java: Use of JodaTime\'s type.plus(long) or type.minus(long) is not allowed (where \u003ctype> = {Duration,Instant,DateTime,DateMidnight}). Please use type.plus(Duration.millis(long)) or type.minus(Duration.millis(long)) instead.',
Andreas Gampecf528ca2018-01-25 11:55:43 -08002003 'patterns': [r".*: warning: \[JodaPlusMinusLong\] .+"]},
2004 {'category': 'java',
2005 'severity': Severity.HIGH,
2006 'description':
2007 'Java: Changing JodaTime\'s current time is not allowed in non-testonly code.',
2008 'patterns': [r".*: warning: \[JodaSetCurrentMillis\] .+"]},
2009 {'category': 'java',
2010 'severity': Severity.HIGH,
2011 'description':
2012 'Java: Use of Joda-Time\'s DateTime.toDateTime(), Duration.toDuration(), Instant.toInstant(), Interval.toInterval(), and Period.toPeriod() are not allowed.',
2013 'patterns': [r".*: warning: \[JodaToSelf\] .+"]},
2014 {'category': 'java',
2015 'severity': Severity.HIGH,
2016 'description':
Chih-Hung Hsieh9be27762018-06-07 10:51:47 -07002017 r'Java: Use of JodaTime\'s type.withDurationAdded(long, int) (where \u003ctype> = {Duration,Instant,DateTime}). Please use type.withDurationAdded(Duration.millis(long), int) instead.',
Andreas Gampecf528ca2018-01-25 11:55:43 -08002018 'patterns': [r".*: warning: \[JodaWithDurationAddedLong\] .+"]},
2019 {'category': 'java',
2020 'severity': Severity.HIGH,
2021 'description':
2022 'Java: LanguageCode comparison using reference equality instead of value equality',
2023 'patterns': [r".*: warning: \[LanguageCodeEquality\] .+"]},
2024 {'category': 'java',
2025 'severity': Severity.HIGH,
2026 'description':
2027 'Java: The zero argument toString is not part of the Localizable interface and likely is just the java Object toString. You probably want to call toString(Locale).',
2028 'patterns': [r".*: warning: \[LocalizableWrongToString\] .+"]},
2029 {'category': 'java',
2030 'severity': Severity.HIGH,
2031 'description':
2032 'Java: Period.get() only works with YEARS, MONTHS, or DAYS.',
2033 'patterns': [r".*: warning: \[PeriodGetTemporalUnit\] .+"]},
2034 {'category': 'java',
2035 'severity': Severity.HIGH,
2036 'description':
2037 'Java: Return value of methods returning Promise must be checked. Ignoring returned Promises suppresses exceptions thrown from the code that completes the Promises.',
2038 'patterns': [r".*: warning: \[PromiseReturnValueIgnored\] .+"]},
2039 {'category': 'java',
2040 'severity': Severity.HIGH,
2041 'description':
2042 'Java: When returning a Promise, use thenChain() instead of then()',
2043 'patterns': [r".*: warning: \[PromiseThenReturningPromise\] .+"]},
2044 {'category': 'java',
2045 'severity': Severity.HIGH,
2046 'description':
2047 'Java: Streams.iterating() is unsafe for use except in the header of a for-each loop; please see its Javadoc for details.',
2048 'patterns': [r".*: warning: \[StreamsIteratingNotInLoop\] .+"]},
2049 {'category': 'java',
2050 'severity': Severity.HIGH,
2051 'description':
2052 'Java: TemporalAccessor.get() only works for certain values of ChronoField.',
2053 'patterns': [r".*: warning: \[TemporalAccessorGetChronoField\] .+"]},
2054 {'category': 'java',
2055 'severity': Severity.HIGH,
2056 'description':
2057 'Java: Try-with-resources is not supported in this code, use try/finally instead',
2058 'patterns': [r".*: warning: \[TryWithResources\] .+"]},
2059 {'category': 'java',
2060 'severity': Severity.HIGH,
2061 'description':
2062 'Java: Adds checkOrThrow calls where needed',
2063 'patterns': [r".*: warning: \[AddCheckOrThrow\] .+"]},
2064 {'category': 'java',
2065 'severity': Severity.HIGH,
2066 'description':
2067 'Java: Equality on Nano protos (== or .equals) might not be the same in Lite',
2068 'patterns': [r".*: warning: \[ForbidNanoEquality\] .+"]},
2069 {'category': 'java',
2070 'severity': Severity.HIGH,
2071 'description':
2072 'Java: Submessages of a proto cannot be mutated',
2073 'patterns': [r".*: warning: \[ForbidSubmessageMutation\] .+"]},
2074 {'category': 'java',
2075 'severity': Severity.HIGH,
2076 'description':
2077 'Java: Repeated fields on proto messages cannot be directly referenced',
2078 'patterns': [r".*: warning: \[NanoUnsafeRepeatedFieldUsage\] .+"]},
2079 {'category': 'java',
2080 'severity': Severity.HIGH,
2081 'description':
2082 'Java: Requires that non-@enum int assignments to @enum ints is wrapped in a checkOrThrow',
2083 'patterns': [r".*: warning: \[RequireCheckOrThrow\] .+"]},
2084 {'category': 'java',
2085 'severity': Severity.HIGH,
2086 'description':
2087 'Java: Assignments into repeated field elements must be sequential',
2088 'patterns': [r".*: warning: \[RequireSequentialRepeatedFields\] .+"]},
2089 {'category': 'java',
2090 'severity': Severity.HIGH,
2091 'description':
2092 'Java: Future.get in Google Now Producers code',
2093 'patterns': [r".*: warning: \[FutureGetInNowProducers\] .+"]},
2094 {'category': 'java',
2095 'severity': Severity.HIGH,
2096 'description':
2097 'Java: @SimpleEnum applied to non-enum type',
2098 'patterns': [r".*: warning: \[SimpleEnumUsage\] .+"]},
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08002099
2100 # End warnings generated by Error Prone
Ian Rogers32bb9bd2016-05-09 23:19:42 -07002101
Ian Rogers6e520032016-05-13 08:59:00 -07002102 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002103 'severity': Severity.UNKNOWN,
Ian Rogers6e520032016-05-13 08:59:00 -07002104 'description': 'Java: Unclassified/unrecognized warnings',
2105 'patterns': [r".*: warning: \[.+\] .+"]},
Ian Rogers32bb9bd2016-05-09 23:19:42 -07002106
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002107 {'category': 'aapt', 'severity': Severity.MEDIUM,
2108 'description': 'aapt: No default translation',
2109 'patterns': [r".*: warning: string '.+' has no default translation in .*"]},
2110 {'category': 'aapt', 'severity': Severity.MEDIUM,
2111 'description': 'aapt: Missing default or required localization',
2112 'patterns': [r".*: warning: \*\*\*\* string '.+' has no default or required localization for '.+' in .+"]},
2113 {'category': 'aapt', 'severity': Severity.MEDIUM,
2114 'description': 'aapt: String marked untranslatable, but translation exists',
2115 'patterns': [r".*: warning: string '.+' in .* marked untranslatable but exists in locale '??_??'"]},
2116 {'category': 'aapt', 'severity': Severity.MEDIUM,
2117 'description': 'aapt: empty span in string',
2118 'patterns': [r".*: warning: empty '.+' span found in text '.+"]},
2119 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2120 'description': 'Taking address of temporary',
2121 'patterns': [r".*: warning: taking address of temporary"]},
2122 {'category': 'C/C++', 'severity': Severity.MEDIUM,
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07002123 'description': 'Taking address of packed member',
2124 'patterns': [r".*: warning: taking address of packed member"]},
2125 {'category': 'C/C++', 'severity': Severity.MEDIUM,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002126 'description': 'Possible broken line continuation',
2127 'patterns': [r".*: warning: backslash and newline separated by space"]},
2128 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wundefined-var-template',
2129 'description': 'Undefined variable template',
2130 'patterns': [r".*: warning: instantiation of variable .* no definition is available"]},
2131 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wundefined-inline',
2132 'description': 'Inline function is not defined',
2133 'patterns': [r".*: warning: inline function '.*' is not defined"]},
2134 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Warray-bounds',
2135 'description': 'Array subscript out of bounds',
2136 'patterns': [r".*: warning: array subscript is above array bounds",
2137 r".*: warning: Array subscript is undefined",
2138 r".*: warning: array subscript is below array bounds"]},
2139 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2140 'description': 'Excess elements in initializer',
2141 'patterns': [r".*: warning: excess elements in .+ initializer"]},
2142 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2143 'description': 'Decimal constant is unsigned only in ISO C90',
2144 'patterns': [r".*: warning: this decimal constant is unsigned only in ISO C90"]},
2145 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmain',
2146 'description': 'main is usually a function',
2147 'patterns': [r".*: warning: 'main' is usually a function"]},
2148 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2149 'description': 'Typedef ignored',
2150 'patterns': [r".*: warning: 'typedef' was ignored in this declaration"]},
2151 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Waddress',
2152 'description': 'Address always evaluates to true',
2153 'patterns': [r".*: warning: the address of '.+' will always evaluate as 'true'"]},
2154 {'category': 'C/C++', 'severity': Severity.FIXMENOW,
2155 'description': 'Freeing a non-heap object',
2156 'patterns': [r".*: warning: attempt to free a non-heap object '.+'"]},
2157 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wchar-subscripts',
2158 'description': 'Array subscript has type char',
2159 'patterns': [r".*: warning: array subscript .+ type 'char'.+Wchar-subscripts"]},
2160 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2161 'description': 'Constant too large for type',
2162 'patterns': [r".*: warning: integer constant is too large for '.+' type"]},
2163 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Woverflow',
2164 'description': 'Constant too large for type, truncated',
2165 'patterns': [r".*: warning: large integer implicitly truncated to unsigned type"]},
2166 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Winteger-overflow',
2167 'description': 'Overflow in expression',
2168 'patterns': [r".*: warning: overflow in expression; .*Winteger-overflow"]},
2169 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Woverflow',
2170 'description': 'Overflow in implicit constant conversion',
2171 'patterns': [r".*: warning: overflow in implicit constant conversion"]},
2172 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2173 'description': 'Declaration does not declare anything',
2174 'patterns': [r".*: warning: declaration 'class .+' does not declare anything"]},
2175 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wreorder',
2176 'description': 'Initialization order will be different',
2177 'patterns': [r".*: warning: '.+' will be initialized after",
2178 r".*: warning: field .+ will be initialized after .+Wreorder"]},
2179 {'category': 'cont.', 'severity': Severity.SKIP,
2180 'description': 'skip, ....',
2181 'patterns': [r".*: warning: '.+'"]},
2182 {'category': 'cont.', 'severity': Severity.SKIP,
2183 'description': 'skip, base ...',
2184 'patterns': [r".*: warning: base '.+'"]},
2185 {'category': 'cont.', 'severity': Severity.SKIP,
2186 'description': 'skip, when initialized here',
2187 'patterns': [r".*: warning: when initialized here"]},
2188 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-parameter-type',
2189 'description': 'Parameter type not specified',
2190 'patterns': [r".*: warning: type of '.+' defaults to 'int'"]},
2191 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-declarations',
2192 'description': 'Missing declarations',
2193 'patterns': [r".*: warning: declaration does not declare anything"]},
2194 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-noreturn',
2195 'description': 'Missing noreturn',
2196 'patterns': [r".*: warning: function '.*' could be declared with attribute 'noreturn'"]},
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002197 # pylint:disable=anomalous-backslash-in-string
2198 # TODO(chh): fix the backslash pylint warning.
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002199 {'category': 'gcc', 'severity': Severity.MEDIUM,
2200 'description': 'Invalid option for C file',
2201 'patterns': [r".*: warning: command line option "".+"" is valid for C\+\+\/ObjC\+\+ but not for C"]},
2202 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2203 'description': 'User warning',
2204 'patterns': [r".*: warning: #warning "".+"""]},
2205 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wvexing-parse',
2206 'description': 'Vexing parsing problem',
2207 'patterns': [r".*: warning: empty parentheses interpreted as a function declaration"]},
2208 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wextra',
2209 'description': 'Dereferencing void*',
2210 'patterns': [r".*: warning: dereferencing 'void \*' pointer"]},
2211 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2212 'description': 'Comparison of pointer and integer',
2213 'patterns': [r".*: warning: ordered comparison of pointer with integer zero",
2214 r".*: warning: .*comparison between pointer and integer"]},
2215 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2216 'description': 'Use of error-prone unary operator',
2217 'patterns': [r".*: warning: use of unary operator that may be intended as compound assignment"]},
2218 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wwrite-strings',
2219 'description': 'Conversion of string constant to non-const char*',
2220 'patterns': [r".*: warning: deprecated conversion from string constant to '.+'"]},
2221 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wstrict-prototypes',
2222 'description': 'Function declaration isn''t a prototype',
2223 'patterns': [r".*: warning: function declaration isn't a prototype"]},
2224 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wignored-qualifiers',
2225 'description': 'Type qualifiers ignored on function return value',
2226 'patterns': [r".*: warning: type qualifiers ignored on function return type",
2227 r".*: warning: .+ type qualifier .+ has no effect .+Wignored-qualifiers"]},
2228 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2229 'description': '<foo> declared inside parameter list, scope limited to this definition',
2230 'patterns': [r".*: warning: '.+' declared inside parameter list"]},
2231 {'category': 'cont.', 'severity': Severity.SKIP,
2232 'description': 'skip, its scope is only this ...',
2233 'patterns': [r".*: warning: its scope is only this definition or declaration, which is probably not what you want"]},
2234 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wcomment',
2235 'description': 'Line continuation inside comment',
2236 'patterns': [r".*: warning: multi-line comment"]},
2237 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wcomment',
2238 'description': 'Comment inside comment',
2239 'patterns': [r".*: warning: "".+"" within comment"]},
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07002240 # Warning "value stored is never read" could be from clang-tidy or clang static analyzer.
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002241 {'category': 'C/C++', 'severity': Severity.ANALYZER,
2242 'description': 'clang-analyzer Value stored is never read',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002243 'patterns': [r".*: warning: Value stored to .+ is never read.*clang-analyzer-deadcode.DeadStores"]},
2244 {'category': 'C/C++', 'severity': Severity.LOW,
2245 'description': 'Value stored is never read',
2246 'patterns': [r".*: warning: Value stored to .+ is never read"]},
2247 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wdeprecated-declarations',
2248 'description': 'Deprecated declarations',
2249 'patterns': [r".*: warning: .+ is deprecated.+deprecated-declarations"]},
2250 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wdeprecated-register',
2251 'description': 'Deprecated register',
2252 'patterns': [r".*: warning: 'register' storage class specifier is deprecated"]},
2253 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wpointer-sign',
2254 'description': 'Converts between pointers to integer types with different sign',
2255 'patterns': [r".*: warning: .+ converts between pointers to integer types with different sign"]},
2256 {'category': 'C/C++', 'severity': Severity.HARMLESS,
2257 'description': 'Extra tokens after #endif',
2258 'patterns': [r".*: warning: extra tokens at end of #endif directive"]},
2259 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wenum-compare',
2260 'description': 'Comparison between different enums',
2261 'patterns': [r".*: warning: comparison between '.+' and '.+'.+Wenum-compare"]},
2262 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wconversion',
2263 'description': 'Conversion may change value',
2264 'patterns': [r".*: warning: converting negative value '.+' to '.+'",
2265 r".*: warning: conversion to '.+' .+ may (alter|change)"]},
2266 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wconversion-null',
2267 'description': 'Converting to non-pointer type from NULL',
2268 'patterns': [r".*: warning: converting to non-pointer type '.+' from NULL"]},
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07002269 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsign-conversion',
2270 'description': 'Implicit sign conversion',
2271 'patterns': [r".*: warning: implicit conversion changes signedness"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002272 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wnull-conversion',
2273 'description': 'Converting NULL to non-pointer type',
2274 'patterns': [r".*: warning: implicit conversion of NULL constant to '.+'"]},
2275 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wnon-literal-null-conversion',
2276 'description': 'Zero used as null pointer',
2277 'patterns': [r".*: warning: expression .* zero treated as a null pointer constant"]},
2278 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2279 'description': 'Implicit conversion changes value',
2280 'patterns': [r".*: warning: implicit conversion .* changes value from .* to .*-conversion"]},
2281 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2282 'description': 'Passing NULL as non-pointer argument',
2283 'patterns': [r".*: warning: passing NULL to non-pointer argument [0-9]+ of '.+'"]},
2284 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wctor-dtor-privacy',
2285 'description': 'Class seems unusable because of private ctor/dtor',
2286 'patterns': [r".*: warning: all member functions in class '.+' are private"]},
Marco Nelissen594375d2009-07-14 09:04:04 -07002287 # 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 -07002288 {'category': 'C/C++', 'severity': Severity.SKIP, 'option': '-Wctor-dtor-privacy',
2289 'description': 'Class seems unusable because of private ctor/dtor',
2290 'patterns': [r".*: warning: 'class .+' only defines a private destructor and has no friends"]},
2291 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wctor-dtor-privacy',
2292 'description': 'Class seems unusable because of private ctor/dtor',
2293 'patterns': [r".*: warning: 'class .+' only defines private constructors and has no friends"]},
2294 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wgnu-static-float-init',
2295 'description': 'In-class initializer for static const float/double',
2296 'patterns': [r".*: warning: in-class initializer for static data member of .+const (float|double)"]},
2297 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wpointer-arith',
2298 'description': 'void* used in arithmetic',
2299 'patterns': [r".*: warning: pointer of type 'void \*' used in (arithmetic|subtraction)",
2300 r".*: warning: arithmetic on .+ to void is a GNU extension.*Wpointer-arith",
2301 r".*: warning: wrong type argument to increment"]},
2302 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsign-promo',
2303 'description': 'Overload resolution chose to promote from unsigned or enum to signed type',
2304 'patterns': [r".*: warning: passing '.+' chooses '.+' over '.+'.*Wsign-promo"]},
2305 {'category': 'cont.', 'severity': Severity.SKIP,
2306 'description': 'skip, in call to ...',
2307 'patterns': [r".*: warning: in call to '.+'"]},
2308 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wextra',
2309 'description': 'Base should be explicitly initialized in copy constructor',
2310 'patterns': [r".*: warning: base class '.+' should be explicitly initialized in the copy constructor"]},
2311 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2312 'description': 'VLA has zero or negative size',
2313 'patterns': [r".*: warning: Declared variable-length array \(VLA\) has .+ size"]},
2314 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2315 'description': 'Return value from void function',
2316 'patterns': [r".*: warning: 'return' with a value, in function returning void"]},
2317 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'multichar',
2318 'description': 'Multi-character character constant',
2319 'patterns': [r".*: warning: multi-character character constant"]},
2320 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'writable-strings',
2321 'description': 'Conversion from string literal to char*',
2322 'patterns': [r".*: warning: .+ does not allow conversion from string literal to 'char \*'"]},
2323 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wextra-semi',
2324 'description': 'Extra \';\'',
2325 'patterns': [r".*: warning: extra ';' .+extra-semi"]},
2326 {'category': 'C/C++', 'severity': Severity.LOW,
2327 'description': 'Useless specifier',
2328 'patterns': [r".*: warning: useless storage class specifier in empty declaration"]},
2329 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wduplicate-decl-specifier',
2330 'description': 'Duplicate declaration specifier',
2331 'patterns': [r".*: warning: duplicate '.+' declaration specifier"]},
2332 {'category': 'logtags', 'severity': Severity.LOW,
2333 'description': 'Duplicate logtag',
2334 'patterns': [r".*: warning: tag \".+\" \(.+\) duplicated in .+"]},
2335 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'typedef-redefinition',
2336 'description': 'Typedef redefinition',
2337 'patterns': [r".*: warning: redefinition of typedef '.+' is a C11 feature"]},
2338 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'gnu-designator',
2339 'description': 'GNU old-style field designator',
2340 'patterns': [r".*: warning: use of GNU old-style field designator extension"]},
2341 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'missing-field-initializers',
2342 'description': 'Missing field initializers',
2343 'patterns': [r".*: warning: missing field '.+' initializer"]},
2344 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'missing-braces',
2345 'description': 'Missing braces',
2346 'patterns': [r".*: warning: suggest braces around initialization of",
2347 r".*: warning: too many braces around scalar initializer .+Wmany-braces-around-scalar-init",
2348 r".*: warning: braces around scalar initializer"]},
2349 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'sign-compare',
2350 'description': 'Comparison of integers of different signs',
2351 'patterns': [r".*: warning: comparison of integers of different signs.+sign-compare"]},
2352 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'dangling-else',
2353 'description': 'Add braces to avoid dangling else',
2354 'patterns': [r".*: warning: add explicit braces to avoid dangling else"]},
2355 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'initializer-overrides',
2356 'description': 'Initializer overrides prior initialization',
2357 'patterns': [r".*: warning: initializer overrides prior initialization of this subobject"]},
2358 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'self-assign',
2359 'description': 'Assigning value to self',
2360 'patterns': [r".*: warning: explicitly assigning value of .+ to itself"]},
2361 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'gnu-variable-sized-type-not-at-end',
2362 'description': 'GNU extension, variable sized type not at end',
2363 'patterns': [r".*: warning: field '.+' with variable sized type '.+' not at the end of a struct or class"]},
2364 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'tautological-constant-out-of-range-compare',
2365 'description': 'Comparison of constant is always false/true',
2366 'patterns': [r".*: comparison of .+ is always .+Wtautological-constant-out-of-range-compare"]},
2367 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'overloaded-virtual',
2368 'description': 'Hides overloaded virtual function',
2369 'patterns': [r".*: '.+' hides overloaded virtual function"]},
2370 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'incompatible-pointer-types',
2371 'description': 'Incompatible pointer types',
2372 'patterns': [r".*: warning: incompatible pointer types .+Wincompatible-pointer-types"]},
2373 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'asm-operand-widths',
2374 'description': 'ASM value size does not match register size',
2375 'patterns': [r".*: warning: value size does not match register size specified by the constraint and modifier"]},
2376 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'tautological-compare',
2377 'description': 'Comparison of self is always false',
2378 'patterns': [r".*: self-comparison always evaluates to false"]},
2379 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'constant-logical-operand',
2380 'description': 'Logical op with constant operand',
2381 'patterns': [r".*: use of logical '.+' with constant operand"]},
2382 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'literal-suffix',
2383 'description': 'Needs a space between literal and string macro',
2384 'patterns': [r".*: warning: invalid suffix on literal.+ requires a space .+Wliteral-suffix"]},
2385 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '#warnings',
2386 'description': 'Warnings from #warning',
2387 'patterns': [r".*: warning: .+-W#warnings"]},
2388 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'absolute-value',
2389 'description': 'Using float/int absolute value function with int/float argument',
2390 'patterns': [r".*: warning: using .+ absolute value function .+ when argument is .+ type .+Wabsolute-value",
2391 r".*: warning: absolute value function '.+' given .+ which may cause truncation .+Wabsolute-value"]},
2392 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wc++11-extensions',
2393 'description': 'Using C++11 extensions',
2394 'patterns': [r".*: warning: 'auto' type specifier is a C\+\+11 extension"]},
2395 {'category': 'C/C++', 'severity': Severity.LOW,
2396 'description': 'Refers to implicitly defined namespace',
2397 'patterns': [r".*: warning: using directive refers to implicitly-defined namespace .+"]},
2398 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Winvalid-pp-token',
2399 'description': 'Invalid pp token',
2400 'patterns': [r".*: warning: missing .+Winvalid-pp-token"]},
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07002401 {'category': 'link', 'severity': Severity.LOW,
2402 'description': 'need glibc to link',
2403 'patterns': [r".*: warning: .* requires at runtime .* glibc .* for linking"]},
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07002404
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002405 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2406 'description': 'Operator new returns NULL',
2407 'patterns': [r".*: warning: 'operator new' must not return NULL unless it is declared 'throw\(\)' .+"]},
2408 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wnull-arithmetic',
2409 'description': 'NULL used in arithmetic',
2410 'patterns': [r".*: warning: NULL used in arithmetic",
2411 r".*: warning: comparison between NULL and non-pointer"]},
2412 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'header-guard',
2413 'description': 'Misspelled header guard',
2414 'patterns': [r".*: warning: '.+' is used as a header guard .+ followed by .+ different macro"]},
2415 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'empty-body',
2416 'description': 'Empty loop body',
2417 'patterns': [r".*: warning: .+ loop has empty body"]},
2418 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'enum-conversion',
2419 'description': 'Implicit conversion from enumeration type',
2420 'patterns': [r".*: warning: implicit conversion from enumeration type '.+'"]},
2421 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'switch',
2422 'description': 'case value not in enumerated type',
2423 'patterns': [r".*: warning: case value not in enumerated type '.+'"]},
2424 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2425 'description': 'Undefined result',
2426 'patterns': [r".*: warning: The result of .+ is undefined",
2427 r".*: warning: passing an object that .+ has undefined behavior \[-Wvarargs\]",
2428 r".*: warning: 'this' pointer cannot be null in well-defined C\+\+ code;",
2429 r".*: warning: shifting a negative signed value is undefined"]},
2430 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2431 'description': 'Division by zero',
2432 'patterns': [r".*: warning: Division by zero"]},
2433 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2434 'description': 'Use of deprecated method',
2435 'patterns': [r".*: warning: '.+' is deprecated .+"]},
2436 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2437 'description': 'Use of garbage or uninitialized value',
2438 'patterns': [r".*: warning: .+ is a garbage value",
2439 r".*: warning: Function call argument is an uninitialized value",
2440 r".*: warning: Undefined or garbage value returned to caller",
2441 r".*: warning: Called .+ pointer is.+uninitialized",
2442 r".*: warning: Called .+ pointer is.+uninitalized", # match a typo in compiler message
2443 r".*: warning: Use of zero-allocated memory",
2444 r".*: warning: Dereference of undefined pointer value",
2445 r".*: warning: Passed-by-value .+ contains uninitialized data",
2446 r".*: warning: Branch condition evaluates to a garbage value",
2447 r".*: warning: The .+ of .+ is an uninitialized value.",
2448 r".*: warning: .+ is used uninitialized whenever .+sometimes-uninitialized",
2449 r".*: warning: Assigned value is garbage or undefined"]},
2450 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2451 'description': 'Result of malloc type incompatible with sizeof operand type',
2452 'patterns': [r".*: warning: Result of '.+' is converted to .+ incompatible with sizeof operand type"]},
2453 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsizeof-array-argument',
2454 'description': 'Sizeof on array argument',
2455 'patterns': [r".*: warning: sizeof on array function parameter will return"]},
2456 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsizeof-pointer-memacces',
2457 'description': 'Bad argument size of memory access functions',
2458 'patterns': [r".*: warning: .+\[-Wsizeof-pointer-memaccess\]"]},
2459 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2460 'description': 'Return value not checked',
2461 'patterns': [r".*: warning: The return value from .+ is not checked"]},
2462 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2463 'description': 'Possible heap pollution',
2464 'patterns': [r".*: warning: .*Possible heap pollution from .+ type .+"]},
2465 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2466 'description': 'Allocation size of 0 byte',
2467 'patterns': [r".*: warning: Call to .+ has an allocation size of 0 byte"]},
2468 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2469 'description': 'Result of malloc type incompatible with sizeof operand type',
2470 'patterns': [r".*: warning: Result of '.+' is converted to .+ incompatible with sizeof operand type"]},
2471 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wfor-loop-analysis',
2472 'description': 'Variable used in loop condition not modified in loop body',
2473 'patterns': [r".*: warning: variable '.+' used in loop condition.*Wfor-loop-analysis"]},
2474 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2475 'description': 'Closing a previously closed file',
2476 'patterns': [r".*: warning: Closing a previously closed file"]},
2477 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunnamed-type-template-args',
2478 'description': 'Unnamed template type argument',
2479 'patterns': [r".*: warning: template argument.+Wunnamed-type-template-args"]},
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07002480
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002481 {'category': 'C/C++', 'severity': Severity.HARMLESS,
2482 'description': 'Discarded qualifier from pointer target type',
2483 'patterns': [r".*: warning: .+ discards '.+' qualifier from pointer target type"]},
2484 {'category': 'C/C++', 'severity': Severity.HARMLESS,
2485 'description': 'Use snprintf instead of sprintf',
2486 'patterns': [r".*: warning: .*sprintf is often misused; please use snprintf"]},
2487 {'category': 'C/C++', 'severity': Severity.HARMLESS,
2488 'description': 'Unsupported optimizaton flag',
2489 'patterns': [r".*: warning: optimization flag '.+' is not supported"]},
2490 {'category': 'C/C++', 'severity': Severity.HARMLESS,
2491 'description': 'Extra or missing parentheses',
2492 'patterns': [r".*: warning: equality comparison with extraneous parentheses",
2493 r".*: warning: .+ within .+Wlogical-op-parentheses"]},
2494 {'category': 'C/C++', 'severity': Severity.HARMLESS, 'option': 'mismatched-tags',
2495 'description': 'Mismatched class vs struct tags',
2496 'patterns': [r".*: warning: '.+' defined as a .+ here but previously declared as a .+mismatched-tags",
2497 r".*: warning: .+ was previously declared as a .+mismatched-tags"]},
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07002498 {'category': 'FindEmulator', 'severity': Severity.HARMLESS,
2499 'description': 'FindEmulator: No such file or directory',
2500 'patterns': [r".*: warning: FindEmulator: .* No such file or directory"]},
2501 {'category': 'google_tests', 'severity': Severity.HARMLESS,
2502 'description': 'google_tests: unknown installed file',
2503 'patterns': [r".*: warning: .*_tests: Unknown installed file for module"]},
2504 {'category': 'make', 'severity': Severity.HARMLESS,
2505 'description': 'unusual tags debug eng',
2506 'patterns': [r".*: warning: .*: unusual tags debug eng"]},
Marco Nelissen594375d2009-07-14 09:04:04 -07002507
2508 # 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 -07002509 {'category': 'C/C++', 'severity': Severity.SKIP,
2510 'description': 'skip, ,',
2511 'patterns': [r".*: warning: ,$"]},
2512 {'category': 'C/C++', 'severity': Severity.SKIP,
2513 'description': 'skip,',
2514 'patterns': [r".*: warning: $"]},
2515 {'category': 'C/C++', 'severity': Severity.SKIP,
2516 'description': 'skip, In file included from ...',
2517 'patterns': [r".*: warning: In file included from .+,"]},
Marco Nelissen594375d2009-07-14 09:04:04 -07002518
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07002519 # warnings from clang-tidy
Chih-Hung Hsieh2cd467b2017-11-16 15:42:11 -08002520 group_tidy_warn_pattern('android'),
Chih-Hung Hsieh9e9355d2018-06-04 11:32:32 -07002521 simple_tidy_warn_pattern('bugprone-argument-comment'),
2522 simple_tidy_warn_pattern('bugprone-copy-constructor-init'),
2523 simple_tidy_warn_pattern('bugprone-fold-init-type'),
2524 simple_tidy_warn_pattern('bugprone-forward-declaration-namespace'),
2525 simple_tidy_warn_pattern('bugprone-forwarding-reference-overload'),
2526 simple_tidy_warn_pattern('bugprone-inaccurate-erase'),
2527 simple_tidy_warn_pattern('bugprone-incorrect-roundings'),
2528 simple_tidy_warn_pattern('bugprone-integer-division'),
2529 simple_tidy_warn_pattern('bugprone-lambda-function-name'),
2530 simple_tidy_warn_pattern('bugprone-macro-parentheses'),
2531 simple_tidy_warn_pattern('bugprone-misplaced-widening-cast'),
2532 simple_tidy_warn_pattern('bugprone-move-forwarding-reference'),
2533 simple_tidy_warn_pattern('bugprone-sizeof-expression'),
2534 simple_tidy_warn_pattern('bugprone-string-constructor'),
2535 simple_tidy_warn_pattern('bugprone-string-integer-assignment'),
2536 simple_tidy_warn_pattern('bugprone-suspicious-enum-usage'),
2537 simple_tidy_warn_pattern('bugprone-suspicious-missing-comma'),
2538 simple_tidy_warn_pattern('bugprone-suspicious-string-compare'),
2539 simple_tidy_warn_pattern('bugprone-suspicious-semicolon'),
2540 simple_tidy_warn_pattern('bugprone-undefined-memory-manipulation'),
2541 simple_tidy_warn_pattern('bugprone-unused-raii'),
2542 simple_tidy_warn_pattern('bugprone-use-after-move'),
2543 group_tidy_warn_pattern('bugprone'),
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07002544 group_tidy_warn_pattern('cert'),
2545 group_tidy_warn_pattern('clang-diagnostic'),
2546 group_tidy_warn_pattern('cppcoreguidelines'),
2547 group_tidy_warn_pattern('llvm'),
2548 simple_tidy_warn_pattern('google-default-arguments'),
2549 simple_tidy_warn_pattern('google-runtime-int'),
2550 simple_tidy_warn_pattern('google-runtime-operator'),
2551 simple_tidy_warn_pattern('google-runtime-references'),
2552 group_tidy_warn_pattern('google-build'),
2553 group_tidy_warn_pattern('google-explicit'),
2554 group_tidy_warn_pattern('google-redability'),
2555 group_tidy_warn_pattern('google-global'),
2556 group_tidy_warn_pattern('google-redability'),
2557 group_tidy_warn_pattern('google-redability'),
2558 group_tidy_warn_pattern('google'),
2559 simple_tidy_warn_pattern('hicpp-explicit-conversions'),
2560 simple_tidy_warn_pattern('hicpp-function-size'),
2561 simple_tidy_warn_pattern('hicpp-invalid-access-moved'),
2562 simple_tidy_warn_pattern('hicpp-member-init'),
2563 simple_tidy_warn_pattern('hicpp-delete-operators'),
2564 simple_tidy_warn_pattern('hicpp-special-member-functions'),
2565 simple_tidy_warn_pattern('hicpp-use-equals-default'),
2566 simple_tidy_warn_pattern('hicpp-use-equals-delete'),
2567 simple_tidy_warn_pattern('hicpp-no-assembler'),
2568 simple_tidy_warn_pattern('hicpp-noexcept-move'),
2569 simple_tidy_warn_pattern('hicpp-use-override'),
2570 group_tidy_warn_pattern('hicpp'),
2571 group_tidy_warn_pattern('modernize'),
2572 group_tidy_warn_pattern('misc'),
2573 simple_tidy_warn_pattern('performance-faster-string-find'),
2574 simple_tidy_warn_pattern('performance-for-range-copy'),
2575 simple_tidy_warn_pattern('performance-implicit-cast-in-loop'),
2576 simple_tidy_warn_pattern('performance-inefficient-string-concatenation'),
2577 simple_tidy_warn_pattern('performance-type-promotion-in-math-fn'),
2578 simple_tidy_warn_pattern('performance-unnecessary-copy-initialization'),
2579 simple_tidy_warn_pattern('performance-unnecessary-value-param'),
2580 group_tidy_warn_pattern('performance'),
2581 group_tidy_warn_pattern('readability'),
2582
2583 # warnings from clang-tidy's clang-analyzer checks
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002584 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002585 'description': 'clang-analyzer Unreachable code',
2586 'patterns': [r".*: warning: This statement is never executed.*UnreachableCode"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002587 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002588 'description': 'clang-analyzer Size of malloc may overflow',
2589 'patterns': [r".*: warning: .* size of .* may overflow .*MallocOverflow"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002590 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002591 'description': 'clang-analyzer Stream pointer might be NULL',
2592 'patterns': [r".*: warning: Stream pointer might be NULL .*unix.Stream"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002593 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002594 'description': 'clang-analyzer Opened file never closed',
2595 'patterns': [r".*: warning: Opened File never closed.*unix.Stream"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002596 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002597 'description': 'clang-analyzer sozeof() on a pointer type',
2598 'patterns': [r".*: warning: .*calls sizeof.* on a pointer type.*SizeofPtr"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002599 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002600 'description': 'clang-analyzer Pointer arithmetic on non-array variables',
2601 'patterns': [r".*: warning: Pointer arithmetic on non-array variables .*PointerArithm"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002602 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002603 'description': 'clang-analyzer Subtraction of pointers of different memory chunks',
2604 'patterns': [r".*: warning: Subtraction of two pointers .*PointerSub"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002605 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002606 'description': 'clang-analyzer Access out-of-bound array element',
2607 'patterns': [r".*: warning: Access out-of-bound array element .*ArrayBound"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002608 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002609 'description': 'clang-analyzer Out of bound memory access',
2610 'patterns': [r".*: warning: Out of bound memory access .*ArrayBoundV2"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002611 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002612 'description': 'clang-analyzer Possible lock order reversal',
2613 'patterns': [r".*: warning: .* Possible lock order reversal.*PthreadLock"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002614 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002615 'description': 'clang-analyzer Argument is a pointer to uninitialized value',
2616 'patterns': [r".*: warning: .* argument is a pointer to uninitialized value .*CallAndMessage"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002617 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002618 'description': 'clang-analyzer cast to struct',
2619 'patterns': [r".*: warning: Casting a non-structure type to a structure type .*CastToStruct"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002620 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002621 'description': 'clang-analyzer call path problems',
2622 'patterns': [r".*: warning: Call Path : .+"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002623 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07002624 'description': 'clang-analyzer excessive padding',
2625 'patterns': [r".*: warning: Excessive padding in '.*'"]},
2626 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002627 'description': 'clang-analyzer other',
2628 'patterns': [r".*: .+\[clang-analyzer-.+\]$",
2629 r".*: Call Path : .+$"]},
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07002630
Marco Nelissen594375d2009-07-14 09:04:04 -07002631 # catch-all for warnings this script doesn't know about yet
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002632 {'category': 'C/C++', 'severity': Severity.UNKNOWN,
2633 'description': 'Unclassified/unrecognized warnings',
2634 'patterns': [r".*: warning: .+"]},
Marco Nelissen594375d2009-07-14 09:04:04 -07002635]
2636
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07002637
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002638def project_name_and_pattern(name, pattern):
2639 return [name, '(^|.*/)' + pattern + '/.*: warning:']
2640
2641
2642def simple_project_pattern(pattern):
2643 return project_name_and_pattern(pattern, pattern)
2644
2645
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002646# A list of [project_name, file_path_pattern].
2647# project_name should not contain comma, to be used in CSV output.
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002648project_list = [
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002649 simple_project_pattern('art'),
2650 simple_project_pattern('bionic'),
2651 simple_project_pattern('bootable'),
2652 simple_project_pattern('build'),
2653 simple_project_pattern('cts'),
2654 simple_project_pattern('dalvik'),
2655 simple_project_pattern('developers'),
2656 simple_project_pattern('development'),
2657 simple_project_pattern('device'),
2658 simple_project_pattern('doc'),
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07002659 # match external/google* before external/
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002660 project_name_and_pattern('external/google', 'external/google.*'),
2661 project_name_and_pattern('external/non-google', 'external'),
2662 simple_project_pattern('frameworks/av/camera'),
2663 simple_project_pattern('frameworks/av/cmds'),
2664 simple_project_pattern('frameworks/av/drm'),
2665 simple_project_pattern('frameworks/av/include'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002666 simple_project_pattern('frameworks/av/media/img_utils'),
2667 simple_project_pattern('frameworks/av/media/libcpustats'),
2668 simple_project_pattern('frameworks/av/media/libeffects'),
2669 simple_project_pattern('frameworks/av/media/libmediaplayerservice'),
2670 simple_project_pattern('frameworks/av/media/libmedia'),
2671 simple_project_pattern('frameworks/av/media/libstagefright'),
2672 simple_project_pattern('frameworks/av/media/mtp'),
2673 simple_project_pattern('frameworks/av/media/ndk'),
2674 simple_project_pattern('frameworks/av/media/utils'),
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002675 project_name_and_pattern('frameworks/av/media/Other',
2676 'frameworks/av/media'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002677 simple_project_pattern('frameworks/av/radio'),
2678 simple_project_pattern('frameworks/av/services'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002679 simple_project_pattern('frameworks/av/soundtrigger'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002680 project_name_and_pattern('frameworks/av/Other', 'frameworks/av'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002681 simple_project_pattern('frameworks/base/cmds'),
2682 simple_project_pattern('frameworks/base/core'),
2683 simple_project_pattern('frameworks/base/drm'),
2684 simple_project_pattern('frameworks/base/media'),
2685 simple_project_pattern('frameworks/base/libs'),
2686 simple_project_pattern('frameworks/base/native'),
2687 simple_project_pattern('frameworks/base/packages'),
2688 simple_project_pattern('frameworks/base/rs'),
2689 simple_project_pattern('frameworks/base/services'),
2690 simple_project_pattern('frameworks/base/tests'),
2691 simple_project_pattern('frameworks/base/tools'),
2692 project_name_and_pattern('frameworks/base/Other', 'frameworks/base'),
Stephen Hinesd0aec892016-10-17 15:39:53 -07002693 simple_project_pattern('frameworks/compile/libbcc'),
2694 simple_project_pattern('frameworks/compile/mclinker'),
2695 simple_project_pattern('frameworks/compile/slang'),
2696 project_name_and_pattern('frameworks/compile/Other', 'frameworks/compile'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002697 simple_project_pattern('frameworks/minikin'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002698 simple_project_pattern('frameworks/ml'),
2699 simple_project_pattern('frameworks/native/cmds'),
2700 simple_project_pattern('frameworks/native/include'),
2701 simple_project_pattern('frameworks/native/libs'),
2702 simple_project_pattern('frameworks/native/opengl'),
2703 simple_project_pattern('frameworks/native/services'),
2704 simple_project_pattern('frameworks/native/vulkan'),
2705 project_name_and_pattern('frameworks/native/Other', 'frameworks/native'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002706 simple_project_pattern('frameworks/opt'),
2707 simple_project_pattern('frameworks/rs'),
2708 simple_project_pattern('frameworks/webview'),
2709 simple_project_pattern('frameworks/wilhelm'),
2710 project_name_and_pattern('frameworks/Other', 'frameworks'),
2711 simple_project_pattern('hardware/akm'),
2712 simple_project_pattern('hardware/broadcom'),
2713 simple_project_pattern('hardware/google'),
2714 simple_project_pattern('hardware/intel'),
2715 simple_project_pattern('hardware/interfaces'),
2716 simple_project_pattern('hardware/libhardware'),
2717 simple_project_pattern('hardware/libhardware_legacy'),
2718 simple_project_pattern('hardware/qcom'),
2719 simple_project_pattern('hardware/ril'),
2720 project_name_and_pattern('hardware/Other', 'hardware'),
2721 simple_project_pattern('kernel'),
2722 simple_project_pattern('libcore'),
2723 simple_project_pattern('libnativehelper'),
2724 simple_project_pattern('ndk'),
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002725 # match vendor/unbungled_google/packages before other packages
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002726 simple_project_pattern('unbundled_google'),
2727 simple_project_pattern('packages'),
2728 simple_project_pattern('pdk'),
2729 simple_project_pattern('prebuilts'),
2730 simple_project_pattern('system/bt'),
2731 simple_project_pattern('system/connectivity'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002732 simple_project_pattern('system/core/adb'),
2733 simple_project_pattern('system/core/base'),
2734 simple_project_pattern('system/core/debuggerd'),
2735 simple_project_pattern('system/core/fastboot'),
2736 simple_project_pattern('system/core/fingerprintd'),
2737 simple_project_pattern('system/core/fs_mgr'),
2738 simple_project_pattern('system/core/gatekeeperd'),
2739 simple_project_pattern('system/core/healthd'),
2740 simple_project_pattern('system/core/include'),
2741 simple_project_pattern('system/core/init'),
2742 simple_project_pattern('system/core/libbacktrace'),
2743 simple_project_pattern('system/core/liblog'),
2744 simple_project_pattern('system/core/libpixelflinger'),
2745 simple_project_pattern('system/core/libprocessgroup'),
2746 simple_project_pattern('system/core/libsysutils'),
2747 simple_project_pattern('system/core/logcat'),
2748 simple_project_pattern('system/core/logd'),
2749 simple_project_pattern('system/core/run-as'),
2750 simple_project_pattern('system/core/sdcard'),
2751 simple_project_pattern('system/core/toolbox'),
2752 project_name_and_pattern('system/core/Other', 'system/core'),
2753 simple_project_pattern('system/extras/ANRdaemon'),
2754 simple_project_pattern('system/extras/cpustats'),
2755 simple_project_pattern('system/extras/crypto-perf'),
2756 simple_project_pattern('system/extras/ext4_utils'),
2757 simple_project_pattern('system/extras/f2fs_utils'),
2758 simple_project_pattern('system/extras/iotop'),
2759 simple_project_pattern('system/extras/libfec'),
2760 simple_project_pattern('system/extras/memory_replay'),
2761 simple_project_pattern('system/extras/micro_bench'),
2762 simple_project_pattern('system/extras/mmap-perf'),
2763 simple_project_pattern('system/extras/multinetwork'),
2764 simple_project_pattern('system/extras/perfprofd'),
2765 simple_project_pattern('system/extras/procrank'),
2766 simple_project_pattern('system/extras/runconuid'),
2767 simple_project_pattern('system/extras/showmap'),
2768 simple_project_pattern('system/extras/simpleperf'),
2769 simple_project_pattern('system/extras/su'),
2770 simple_project_pattern('system/extras/tests'),
2771 simple_project_pattern('system/extras/verity'),
2772 project_name_and_pattern('system/extras/Other', 'system/extras'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002773 simple_project_pattern('system/gatekeeper'),
2774 simple_project_pattern('system/keymaster'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002775 simple_project_pattern('system/libhidl'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002776 simple_project_pattern('system/libhwbinder'),
2777 simple_project_pattern('system/media'),
2778 simple_project_pattern('system/netd'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002779 simple_project_pattern('system/nvram'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002780 simple_project_pattern('system/security'),
2781 simple_project_pattern('system/sepolicy'),
2782 simple_project_pattern('system/tools'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002783 simple_project_pattern('system/update_engine'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002784 simple_project_pattern('system/vold'),
2785 project_name_and_pattern('system/Other', 'system'),
2786 simple_project_pattern('toolchain'),
2787 simple_project_pattern('test'),
2788 simple_project_pattern('tools'),
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07002789 # match vendor/google* before vendor/
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002790 project_name_and_pattern('vendor/google', 'vendor/google.*'),
2791 project_name_and_pattern('vendor/non-google', 'vendor'),
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07002792 # keep out/obj and other patterns at the end.
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002793 ['out/obj',
2794 '.*/(gen|obj[^/]*)/(include|EXECUTABLES|SHARED_LIBRARIES|'
2795 'STATIC_LIBRARIES|NATIVE_TESTS)/.*: warning:'],
2796 ['other', '.*'] # all other unrecognized patterns
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002797]
2798
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002799project_patterns = []
2800project_names = []
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002801warning_messages = []
2802warning_records = []
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002803
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07002804
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002805def initialize_arrays():
2806 """Complete global arrays before they are used."""
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002807 global project_names, project_patterns
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002808 project_names = [p[0] for p in project_list]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002809 project_patterns = [re.compile(p[1]) for p in project_list]
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002810 for w in warn_patterns:
2811 w['members'] = []
2812 if 'option' not in w:
2813 w['option'] = ''
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002814 # Each warning pattern has a 'projects' dictionary, that
2815 # maps a project name to number of warnings in that project.
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002816 w['projects'] = {}
2817
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002818
2819initialize_arrays()
2820
2821
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -07002822android_root = ''
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002823platform_version = 'unknown'
2824target_product = 'unknown'
2825target_variant = 'unknown'
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002826
2827
2828##### Data and functions to dump html file. ##################################
2829
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002830html_head_scripts = """\
2831 <script type="text/javascript">
2832 function expand(id) {
2833 var e = document.getElementById(id);
2834 var f = document.getElementById(id + "_mark");
2835 if (e.style.display == 'block') {
2836 e.style.display = 'none';
2837 f.innerHTML = '&#x2295';
2838 }
2839 else {
2840 e.style.display = 'block';
2841 f.innerHTML = '&#x2296';
2842 }
2843 };
2844 function expandCollapse(show) {
2845 for (var id = 1; ; id++) {
2846 var e = document.getElementById(id + "");
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07002847 var f = document.getElementById(id + "_mark");
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002848 if (!e || !f) break;
2849 e.style.display = (show ? 'block' : 'none');
2850 f.innerHTML = (show ? '&#x2296' : '&#x2295');
2851 }
2852 };
2853 </script>
2854 <style type="text/css">
2855 th,td{border-collapse:collapse; border:1px solid black;}
2856 .button{color:blue;font-size:110%;font-weight:bolder;}
2857 .bt{color:black;background-color:transparent;border:none;outline:none;
2858 font-size:140%;font-weight:bolder;}
2859 .c0{background-color:#e0e0e0;}
2860 .c1{background-color:#d0d0d0;}
2861 .t1{border-collapse:collapse; width:100%; border:1px solid black;}
2862 </style>
2863 <script src="https://www.gstatic.com/charts/loader.js"></script>
2864"""
Marco Nelissen594375d2009-07-14 09:04:04 -07002865
Marco Nelissen594375d2009-07-14 09:04:04 -07002866
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002867def html_big(param):
2868 return '<font size="+2">' + param + '</font>'
Marco Nelissen594375d2009-07-14 09:04:04 -07002869
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07002870
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002871def dump_html_prologue(title):
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002872 print '<html>\n<head>'
2873 print '<title>' + title + '</title>'
2874 print html_head_scripts
2875 emit_stats_by_project()
2876 print '</head>\n<body>'
2877 print html_big(title)
2878 print '<p>'
Marco Nelissen594375d2009-07-14 09:04:04 -07002879
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002880
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002881def dump_html_epilogue():
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002882 print '</body>\n</head>\n</html>'
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07002883
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002884
2885def sort_warnings():
2886 for i in warn_patterns:
2887 i['members'] = sorted(set(i['members']))
2888
2889
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002890def emit_stats_by_project():
2891 """Dump a google chart table of warnings per project and severity."""
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002892 # warnings[p][s] is number of warnings in project p of severity s.
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002893 warnings = {p: {s: 0 for s in Severity.range} for p in project_names}
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002894 for i in warn_patterns:
2895 s = i['severity']
2896 for p in i['projects']:
2897 warnings[p][s] += i['projects'][p]
2898
2899 # total_by_project[p] is number of warnings in project p.
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002900 total_by_project = {p: sum(warnings[p][s] for s in Severity.range)
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002901 for p in project_names}
2902
2903 # total_by_severity[s] is number of warnings of severity s.
2904 total_by_severity = {s: sum(warnings[p][s] for p in project_names)
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002905 for s in Severity.range}
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07002906
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002907 # emit table header
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002908 stats_header = ['Project']
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002909 for s in Severity.range:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002910 if total_by_severity[s]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002911 stats_header.append("<span style='background-color:{}'>{}</span>".
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002912 format(Severity.colors[s],
2913 Severity.column_headers[s]))
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002914 stats_header.append('TOTAL')
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07002915
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002916 # emit a row of warning counts per project, skip no-warning projects
2917 total_all_projects = 0
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002918 stats_rows = []
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002919 for p in project_names:
2920 if total_by_project[p]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002921 one_row = [p]
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002922 for s in Severity.range:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002923 if total_by_severity[s]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002924 one_row.append(warnings[p][s])
2925 one_row.append(total_by_project[p])
2926 stats_rows.append(one_row)
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002927 total_all_projects += total_by_project[p]
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07002928
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002929 # emit a row of warning counts per severity
2930 total_all_severities = 0
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002931 one_row = ['<b>TOTAL</b>']
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002932 for s in Severity.range:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002933 if total_by_severity[s]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002934 one_row.append(total_by_severity[s])
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002935 total_all_severities += total_by_severity[s]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002936 one_row.append(total_all_projects)
2937 stats_rows.append(one_row)
2938 print '<script>'
2939 emit_const_string_array('StatsHeader', stats_header)
2940 emit_const_object_array('StatsRows', stats_rows)
2941 print draw_table_javascript
2942 print '</script>'
Marco Nelissen594375d2009-07-14 09:04:04 -07002943
2944
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002945def dump_stats():
2946 """Dump some stats about total number of warnings and such."""
2947 known = 0
2948 skipped = 0
2949 unknown = 0
2950 sort_warnings()
2951 for i in warn_patterns:
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002952 if i['severity'] == Severity.UNKNOWN:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002953 unknown += len(i['members'])
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002954 elif i['severity'] == Severity.SKIP:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002955 skipped += len(i['members'])
Ian Rogersf3829732016-05-10 12:06:01 -07002956 else:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002957 known += len(i['members'])
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002958 print 'Number of classified warnings: <b>' + str(known) + '</b><br>'
2959 print 'Number of skipped warnings: <b>' + str(skipped) + '</b><br>'
2960 print 'Number of unclassified warnings: <b>' + str(unknown) + '</b><br>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002961 total = unknown + known + skipped
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002962 extra_msg = ''
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002963 if total < 1000:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002964 extra_msg = ' (low count may indicate incremental build)'
2965 print 'Total number of warnings: <b>' + str(total) + '</b>' + extra_msg
Marco Nelissen594375d2009-07-14 09:04:04 -07002966
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07002967
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002968# New base table of warnings, [severity, warn_id, project, warning_message]
2969# Need buttons to show warnings in different grouping options.
2970# (1) Current, group by severity, id for each warning pattern
2971# sort by severity, warn_id, warning_message
2972# (2) Current --byproject, group by severity,
2973# id for each warning pattern + project name
2974# sort by severity, warn_id, project, warning_message
2975# (3) New, group by project + severity,
2976# id for each warning pattern
2977# sort by project, severity, warn_id, warning_message
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002978def emit_buttons():
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002979 print ('<button class="button" onclick="expandCollapse(1);">'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002980 'Expand all warnings</button>\n'
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002981 '<button class="button" onclick="expandCollapse(0);">'
2982 'Collapse all warnings</button>\n'
2983 '<button class="button" onclick="groupBySeverity();">'
2984 'Group warnings by severity</button>\n'
2985 '<button class="button" onclick="groupByProject();">'
2986 'Group warnings by project</button><br>')
Marco Nelissen594375d2009-07-14 09:04:04 -07002987
2988
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002989def all_patterns(category):
2990 patterns = ''
2991 for i in category['patterns']:
2992 patterns += i
2993 patterns += ' / '
2994 return patterns
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002995
2996
2997def dump_fixed():
2998 """Show which warnings no longer occur."""
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002999 anchor = 'fixed_warnings'
3000 mark = anchor + '_mark'
3001 print ('\n<br><p style="background-color:lightblue"><b>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003002 '<button id="' + mark + '" '
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003003 'class="bt" onclick="expand(\'' + anchor + '\');">'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003004 '&#x2295</button> Fixed warnings. '
3005 'No more occurrences. Please consider turning these into '
3006 'errors if possible, before they are reintroduced in to the build'
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003007 ':</b></p>')
3008 print '<blockquote>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003009 fixed_patterns = []
3010 for i in warn_patterns:
3011 if not i['members']:
3012 fixed_patterns.append(i['description'] + ' (' +
3013 all_patterns(i) + ')')
3014 if i['option']:
3015 fixed_patterns.append(' ' + i['option'])
3016 fixed_patterns.sort()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003017 print '<div id="' + anchor + '" style="display:none;"><table>'
3018 cur_row_class = 0
3019 for text in fixed_patterns:
3020 cur_row_class = 1 - cur_row_class
3021 # remove last '\n'
3022 t = text[:-1] if text[-1] == '\n' else text
3023 print '<tr><td class="c' + str(cur_row_class) + '">' + t + '</td></tr>'
3024 print '</table></div>'
3025 print '</blockquote>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003026
3027
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003028def find_project_index(line):
3029 for p in range(len(project_patterns)):
3030 if project_patterns[p].match(line):
3031 return p
3032 return -1
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003033
3034
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07003035def classify_one_warning(line, results):
Chih-Hung Hsieh9be27762018-06-07 10:51:47 -07003036 """Classify one warning line."""
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003037 for i in range(len(warn_patterns)):
3038 w = warn_patterns[i]
3039 for cpat in w['compiled_patterns']:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003040 if cpat.match(line):
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003041 p = find_project_index(line)
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07003042 results.append([line, i, p])
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003043 return
3044 else:
3045 # If we end up here, there was a problem parsing the log
3046 # probably caused by 'make -j' mixing the output from
3047 # 2 or more concurrent compiles
3048 pass
Marco Nelissen594375d2009-07-14 09:04:04 -07003049
3050
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07003051def classify_warnings(lines):
3052 results = []
3053 for line in lines:
3054 classify_one_warning(line, results)
Chih-Hung Hsieh76d00652016-11-09 18:19:05 -08003055 # After the main work, ignore all other signals to a child process,
3056 # to avoid bad warning/error messages from the exit clean-up process.
3057 if args.processes > 1:
3058 signal.signal(signal.SIGTERM, lambda *args: sys.exit(-signal.SIGTERM))
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07003059 return results
3060
3061
3062def parallel_classify_warnings(warning_lines):
3063 """Classify all warning lines with num_cpu parallel processes."""
Chih-Hung Hsieh76d00652016-11-09 18:19:05 -08003064 compile_patterns()
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07003065 num_cpu = args.processes
Chih-Hung Hsieh63de3002016-10-28 10:53:34 -07003066 if num_cpu > 1:
3067 groups = [[] for x in range(num_cpu)]
3068 i = 0
3069 for x in warning_lines:
3070 groups[i].append(x)
3071 i = (i + 1) % num_cpu
3072 pool = multiprocessing.Pool(num_cpu)
3073 group_results = pool.map(classify_warnings, groups)
3074 else:
3075 group_results = [classify_warnings(warning_lines)]
3076
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07003077 for result in group_results:
3078 for line, pattern_idx, project_idx in result:
3079 pattern = warn_patterns[pattern_idx]
3080 pattern['members'].append(line)
3081 message_idx = len(warning_messages)
3082 warning_messages.append(line)
3083 warning_records.append([pattern_idx, project_idx, message_idx])
3084 pname = '???' if project_idx < 0 else project_names[project_idx]
3085 # Count warnings by project.
3086 if pname in pattern['projects']:
3087 pattern['projects'][pname] += 1
3088 else:
3089 pattern['projects'][pname] = 1
3090
3091
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003092def compile_patterns():
3093 """Precompiling every pattern speeds up parsing by about 30x."""
3094 for i in warn_patterns:
3095 i['compiled_patterns'] = []
3096 for pat in i['patterns']:
3097 i['compiled_patterns'].append(re.compile(pat))
3098
3099
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -07003100def find_android_root(path):
3101 """Set and return android_root path if it is found."""
3102 global android_root
3103 parts = path.split('/')
3104 for idx in reversed(range(2, len(parts))):
3105 root_path = '/'.join(parts[:idx])
3106 # Android root directory should contain this script.
Colin Crossfdea8932017-12-06 14:38:40 -08003107 if os.path.exists(root_path + '/build/make/tools/warn.py'):
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -07003108 android_root = root_path
3109 return root_path
3110 return ''
3111
3112
3113def remove_android_root_prefix(path):
3114 """Remove android_root prefix from path if it is found."""
3115 if path.startswith(android_root):
3116 return path[1 + len(android_root):]
3117 else:
3118 return path
3119
3120
3121def normalize_path(path):
3122 """Normalize file path relative to android_root."""
3123 # If path is not an absolute path, just normalize it.
3124 path = os.path.normpath(path)
3125 if path[0] != '/':
3126 return path
3127 # Remove known prefix of root path and normalize the suffix.
3128 if android_root or find_android_root(path):
3129 return remove_android_root_prefix(path)
3130 else:
3131 return path
3132
3133
3134def normalize_warning_line(line):
3135 """Normalize file path relative to android_root in a warning line."""
3136 # replace fancy quotes with plain ol' quotes
3137 line = line.replace('‘', "'")
3138 line = line.replace('’', "'")
3139 line = line.strip()
3140 first_column = line.find(':')
3141 if first_column > 0:
3142 return normalize_path(line[:first_column]) + line[first_column:]
3143 else:
3144 return line
3145
3146
Chih-Hung Hsieh76d00652016-11-09 18:19:05 -08003147def parse_input_file(infile):
Chih-Hung Hsiehef21d142017-04-27 10:25:37 -07003148 """Parse input file, collect parameters and warning lines."""
3149 global android_root
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003150 global platform_version
3151 global target_product
3152 global target_variant
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003153 line_counter = 0
3154
Chih-Hung Hsieh5722f922016-10-11 15:33:19 -07003155 # handle only warning messages with a file path
3156 warning_pattern = re.compile('^[^ ]*/[^ ]*: warning: .*')
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003157
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07003158 # Collect all warnings into the warning_lines set.
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003159 warning_lines = set()
3160 for line in infile:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003161 if warning_pattern.match(line):
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -07003162 line = normalize_warning_line(line)
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07003163 warning_lines.add(line)
Chih-Hung Hsieh655c5422017-06-07 15:52:13 -07003164 elif line_counter < 100:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003165 # save a little bit of time by only doing this for the first few lines
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003166 line_counter += 1
3167 m = re.search('(?<=^PLATFORM_VERSION=).*', line)
3168 if m is not None:
3169 platform_version = m.group(0)
3170 m = re.search('(?<=^TARGET_PRODUCT=).*', line)
3171 if m is not None:
3172 target_product = m.group(0)
3173 m = re.search('(?<=^TARGET_BUILD_VARIANT=).*', line)
3174 if m is not None:
3175 target_variant = m.group(0)
Chih-Hung Hsiehef21d142017-04-27 10:25:37 -07003176 m = re.search('.* TOP=([^ ]*) .*', line)
3177 if m is not None:
3178 android_root = m.group(1)
Chih-Hung Hsieh76d00652016-11-09 18:19:05 -08003179 return warning_lines
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003180
3181
Chih-Hung Hsieh5722f922016-10-11 15:33:19 -07003182# Return s with escaped backslash and quotation characters.
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003183def escape_string(s):
Chih-Hung Hsieh5722f922016-10-11 15:33:19 -07003184 return s.replace('\\', '\\\\').replace('"', '\\"')
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003185
3186
3187# Return s without trailing '\n' and escape the quotation characters.
3188def strip_escape_string(s):
3189 if not s:
3190 return s
3191 s = s[:-1] if s[-1] == '\n' else s
3192 return escape_string(s)
3193
3194
3195def emit_warning_array(name):
3196 print 'var warning_{} = ['.format(name)
3197 for i in range(len(warn_patterns)):
3198 print '{},'.format(warn_patterns[i][name])
3199 print '];'
3200
3201
3202def emit_warning_arrays():
3203 emit_warning_array('severity')
3204 print 'var warning_description = ['
3205 for i in range(len(warn_patterns)):
3206 if warn_patterns[i]['members']:
3207 print '"{}",'.format(escape_string(warn_patterns[i]['description']))
3208 else:
3209 print '"",' # no such warning
3210 print '];'
3211
3212scripts_for_warning_groups = """
3213 function compareMessages(x1, x2) { // of the same warning type
3214 return (WarningMessages[x1[2]] <= WarningMessages[x2[2]]) ? -1 : 1;
3215 }
3216 function byMessageCount(x1, x2) {
3217 return x2[2] - x1[2]; // reversed order
3218 }
3219 function bySeverityMessageCount(x1, x2) {
3220 // orer by severity first
3221 if (x1[1] != x2[1])
3222 return x1[1] - x2[1];
3223 return byMessageCount(x1, x2);
3224 }
3225 const ParseLinePattern = /^([^ :]+):(\\d+):(.+)/;
3226 function addURL(line) {
3227 if (FlagURL == "") return line;
3228 if (FlagSeparator == "") {
3229 return line.replace(ParseLinePattern,
George Burgess IV169f5f12017-04-21 13:35:52 -07003230 "<a target='_blank' href='" + FlagURL + "/$1'>$1</a>:$2:$3");
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003231 }
3232 return line.replace(ParseLinePattern,
George Burgess IV169f5f12017-04-21 13:35:52 -07003233 "<a target='_blank' href='" + FlagURL + "/$1" + FlagSeparator +
3234 "$2'>$1:$2</a>:$3");
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003235 }
3236 function createArrayOfDictionaries(n) {
3237 var result = [];
3238 for (var i=0; i<n; i++) result.push({});
3239 return result;
3240 }
3241 function groupWarningsBySeverity() {
3242 // groups is an array of dictionaries,
3243 // each dictionary maps from warning type to array of warning messages.
3244 var groups = createArrayOfDictionaries(SeverityColors.length);
3245 for (var i=0; i<Warnings.length; i++) {
3246 var w = Warnings[i][0];
3247 var s = WarnPatternsSeverity[w];
3248 var k = w.toString();
3249 if (!(k in groups[s]))
3250 groups[s][k] = [];
3251 groups[s][k].push(Warnings[i]);
3252 }
3253 return groups;
3254 }
3255 function groupWarningsByProject() {
3256 var groups = createArrayOfDictionaries(ProjectNames.length);
3257 for (var i=0; i<Warnings.length; i++) {
3258 var w = Warnings[i][0];
3259 var p = Warnings[i][1];
3260 var k = w.toString();
3261 if (!(k in groups[p]))
3262 groups[p][k] = [];
3263 groups[p][k].push(Warnings[i]);
3264 }
3265 return groups;
3266 }
3267 var GlobalAnchor = 0;
3268 function createWarningSection(header, color, group) {
3269 var result = "";
3270 var groupKeys = [];
3271 var totalMessages = 0;
3272 for (var k in group) {
3273 totalMessages += group[k].length;
3274 groupKeys.push([k, WarnPatternsSeverity[parseInt(k)], group[k].length]);
3275 }
3276 groupKeys.sort(bySeverityMessageCount);
3277 for (var idx=0; idx<groupKeys.length; idx++) {
3278 var k = groupKeys[idx][0];
3279 var messages = group[k];
3280 var w = parseInt(k);
3281 var wcolor = SeverityColors[WarnPatternsSeverity[w]];
3282 var description = WarnPatternsDescription[w];
3283 if (description.length == 0)
3284 description = "???";
3285 GlobalAnchor += 1;
3286 result += "<table class='t1'><tr bgcolor='" + wcolor + "'><td>" +
3287 "<button class='bt' id='" + GlobalAnchor + "_mark" +
3288 "' onclick='expand(\\"" + GlobalAnchor + "\\");'>" +
3289 "&#x2295</button> " +
3290 description + " (" + messages.length + ")</td></tr></table>";
3291 result += "<div id='" + GlobalAnchor +
3292 "' style='display:none;'><table class='t1'>";
3293 var c = 0;
3294 messages.sort(compareMessages);
3295 for (var i=0; i<messages.length; i++) {
3296 result += "<tr><td class='c" + c + "'>" +
3297 addURL(WarningMessages[messages[i][2]]) + "</td></tr>";
3298 c = 1 - c;
3299 }
3300 result += "</table></div>";
3301 }
3302 if (result.length > 0) {
3303 return "<br><span style='background-color:" + color + "'><b>" +
3304 header + ": " + totalMessages +
3305 "</b></span><blockquote><table class='t1'>" +
3306 result + "</table></blockquote>";
3307
3308 }
3309 return ""; // empty section
3310 }
3311 function generateSectionsBySeverity() {
3312 var result = "";
3313 var groups = groupWarningsBySeverity();
3314 for (s=0; s<SeverityColors.length; s++) {
3315 result += createWarningSection(SeverityHeaders[s], SeverityColors[s], groups[s]);
3316 }
3317 return result;
3318 }
3319 function generateSectionsByProject() {
3320 var result = "";
3321 var groups = groupWarningsByProject();
3322 for (i=0; i<groups.length; i++) {
3323 result += createWarningSection(ProjectNames[i], 'lightgrey', groups[i]);
3324 }
3325 return result;
3326 }
3327 function groupWarnings(generator) {
3328 GlobalAnchor = 0;
3329 var e = document.getElementById("warning_groups");
3330 e.innerHTML = generator();
3331 }
3332 function groupBySeverity() {
3333 groupWarnings(generateSectionsBySeverity);
3334 }
3335 function groupByProject() {
3336 groupWarnings(generateSectionsByProject);
3337 }
3338"""
3339
3340
3341# Emit a JavaScript const string
3342def emit_const_string(name, value):
3343 print 'const ' + name + ' = "' + escape_string(value) + '";'
3344
3345
3346# Emit a JavaScript const integer array.
3347def emit_const_int_array(name, array):
3348 print 'const ' + name + ' = ['
3349 for n in array:
3350 print str(n) + ','
3351 print '];'
3352
3353
3354# Emit a JavaScript const string array.
3355def emit_const_string_array(name, array):
3356 print 'const ' + name + ' = ['
3357 for s in array:
3358 print '"' + strip_escape_string(s) + '",'
3359 print '];'
3360
3361
3362# Emit a JavaScript const object array.
3363def emit_const_object_array(name, array):
3364 print 'const ' + name + ' = ['
3365 for x in array:
3366 print str(x) + ','
3367 print '];'
3368
3369
3370def emit_js_data():
3371 """Dump dynamic HTML page's static JavaScript data."""
3372 emit_const_string('FlagURL', args.url if args.url else '')
3373 emit_const_string('FlagSeparator', args.separator if args.separator else '')
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07003374 emit_const_string_array('SeverityColors', Severity.colors)
3375 emit_const_string_array('SeverityHeaders', Severity.headers)
3376 emit_const_string_array('SeverityColumnHeaders', Severity.column_headers)
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003377 emit_const_string_array('ProjectNames', project_names)
3378 emit_const_int_array('WarnPatternsSeverity',
3379 [w['severity'] for w in warn_patterns])
3380 emit_const_string_array('WarnPatternsDescription',
3381 [w['description'] for w in warn_patterns])
3382 emit_const_string_array('WarnPatternsOption',
3383 [w['option'] for w in warn_patterns])
3384 emit_const_string_array('WarningMessages', warning_messages)
3385 emit_const_object_array('Warnings', warning_records)
3386
3387draw_table_javascript = """
3388google.charts.load('current', {'packages':['table']});
3389google.charts.setOnLoadCallback(drawTable);
3390function drawTable() {
3391 var data = new google.visualization.DataTable();
3392 data.addColumn('string', StatsHeader[0]);
3393 for (var i=1; i<StatsHeader.length; i++) {
3394 data.addColumn('number', StatsHeader[i]);
3395 }
3396 data.addRows(StatsRows);
3397 for (var i=0; i<StatsRows.length; i++) {
3398 for (var j=0; j<StatsHeader.length; j++) {
3399 data.setProperty(i, j, 'style', 'border:1px solid black;');
3400 }
3401 }
3402 var table = new google.visualization.Table(document.getElementById('stats_table'));
3403 table.draw(data, {allowHtml: true, alternatingRowStyle: true});
3404}
3405"""
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003406
3407
3408def dump_html():
3409 """Dump the html output to stdout."""
3410 dump_html_prologue('Warnings for ' + platform_version + ' - ' +
3411 target_product + ' - ' + target_variant)
3412 dump_stats()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003413 print '<br><div id="stats_table"></div><br>'
3414 print '\n<script>'
3415 emit_js_data()
3416 print scripts_for_warning_groups
3417 print '</script>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003418 emit_buttons()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003419 # Warning messages are grouped by severities or project names.
3420 print '<br><div id="warning_groups"></div>'
3421 if args.byproject:
3422 print '<script>groupByProject();</script>'
3423 else:
3424 print '<script>groupBySeverity();</script>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003425 dump_fixed()
3426 dump_html_epilogue()
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07003427
3428
3429##### Functions to count warnings and dump csv file. #########################
3430
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07003431
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003432def description_for_csv(category):
3433 if not category['description']:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003434 return '?'
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003435 return category['description']
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07003436
3437
Sam Saccone03aaa7e2017-04-10 15:37:47 -07003438def count_severity(writer, sev, kind):
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003439 """Count warnings of given severity."""
3440 total = 0
3441 for i in warn_patterns:
3442 if i['severity'] == sev and i['members']:
3443 n = len(i['members'])
3444 total += n
Sam Saccone03aaa7e2017-04-10 15:37:47 -07003445 warning = kind + ': ' + description_for_csv(i)
3446 writer.writerow([n, '', warning])
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003447 # print number of warnings for each project, ordered by project name.
3448 projects = i['projects'].keys()
3449 projects.sort()
3450 for p in projects:
Sam Saccone03aaa7e2017-04-10 15:37:47 -07003451 writer.writerow([i['projects'][p], p, warning])
3452 writer.writerow([total, '', kind + ' warnings'])
3453
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003454 return total
3455
3456
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003457# dump number of warnings in csv format to stdout
Sam Saccone03aaa7e2017-04-10 15:37:47 -07003458def dump_csv(writer):
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003459 """Dump number of warnings in csv format to stdout."""
3460 sort_warnings()
3461 total = 0
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07003462 for s in Severity.range:
Sam Saccone03aaa7e2017-04-10 15:37:47 -07003463 total += count_severity(writer, s, Severity.column_headers[s])
3464 writer.writerow([total, '', 'All warnings'])
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003465
3466
Meike Baumgärtnerac9d5df2016-09-28 10:48:06 -07003467def main():
Chih-Hung Hsieh76d00652016-11-09 18:19:05 -08003468 warning_lines = parse_input_file(open(args.buildlog, 'r'))
3469 parallel_classify_warnings(warning_lines)
Sam Saccone03aaa7e2017-04-10 15:37:47 -07003470 # If a user pases a csv path, save the fileoutput to the path
3471 # If the user also passed gencsv write the output to stdout
3472 # If the user did not pass gencsv flag dump the html report to stdout.
3473 if args.csvpath:
3474 with open(args.csvpath, 'w') as f:
3475 dump_csv(csv.writer(f, lineterminator='\n'))
Meike Baumgärtnerac9d5df2016-09-28 10:48:06 -07003476 if args.gencsv:
Sam Saccone03aaa7e2017-04-10 15:37:47 -07003477 dump_csv(csv.writer(sys.stdout, lineterminator='\n'))
Meike Baumgärtnerac9d5df2016-09-28 10:48:06 -07003478 else:
3479 dump_html()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003480
Meike Baumgärtnerac9d5df2016-09-28 10:48:06 -07003481
3482# Run main function if warn.py is the main program.
3483if __name__ == '__main__':
3484 main()