blob: bcde64a234e2fcbaaaf75057e7fe24118ed47502 [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
Chih-Hung Hsiehb2afb632018-07-20 15:36:26 -070078import cgi
Sam Saccone03aaa7e2017-04-10 15:37:47 -070079import csv
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -070080import multiprocessing
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -070081import os
Marco Nelissen594375d2009-07-14 09:04:04 -070082import re
Chih-Hung Hsieh76d00652016-11-09 18:19:05 -080083import signal
84import sys
Marco Nelissen594375d2009-07-14 09:04:04 -070085
Ian Rogersf3829732016-05-10 12:06:01 -070086parser = argparse.ArgumentParser(description='Convert a build log into HTML')
Sam Saccone03aaa7e2017-04-10 15:37:47 -070087parser.add_argument('--csvpath',
88 help='Save CSV warning file to the passed absolute path',
89 default=None)
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -070090parser.add_argument('--gencsv',
91 help='Generate a CSV file with number of various warnings',
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -070092 action='store_true',
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -070093 default=False)
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -070094parser.add_argument('--byproject',
95 help='Separate warnings in HTML output by project names',
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -070096 action='store_true',
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -070097 default=False)
Ian Rogersf3829732016-05-10 12:06:01 -070098parser.add_argument('--url',
99 help='Root URL of an Android source code tree prefixed '
100 'before files in warnings')
101parser.add_argument('--separator',
102 help='Separator between the end of a URL and the line '
103 'number argument. e.g. #')
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -0700104parser.add_argument('--processes',
105 type=int,
106 default=multiprocessing.cpu_count(),
107 help='Number of parallel processes to process warnings')
Ian Rogersf3829732016-05-10 12:06:01 -0700108parser.add_argument(dest='buildlog', metavar='build.log',
109 help='Path to build.log file')
110args = parser.parse_args()
Marco Nelissen594375d2009-07-14 09:04:04 -0700111
Marco Nelissen594375d2009-07-14 09:04:04 -0700112
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700113class Severity(object):
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700114 """Severity levels and attributes."""
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -0700115 # numbered by dump order
116 FIXMENOW = 0
117 HIGH = 1
118 MEDIUM = 2
119 LOW = 3
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -0700120 ANALYZER = 4
121 TIDY = 5
122 HARMLESS = 6
123 UNKNOWN = 7
124 SKIP = 8
125 range = range(SKIP + 1)
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700126 attributes = [
127 # pylint:disable=bad-whitespace
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700128 ['fuchsia', 'FixNow', 'Critical warnings, fix me now'],
129 ['red', 'High', 'High severity warnings'],
130 ['orange', 'Medium', 'Medium severity warnings'],
131 ['yellow', 'Low', 'Low severity warnings'],
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -0700132 ['hotpink', 'Analyzer', 'Clang-Analyzer warnings'],
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700133 ['peachpuff', 'Tidy', 'Clang-Tidy warnings'],
134 ['limegreen', 'Harmless', 'Harmless warnings'],
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -0700135 ['lightblue', 'Unknown', 'Unknown warnings'],
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700136 ['grey', 'Unhandled', 'Unhandled warnings']
137 ]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -0700138 colors = [a[0] for a in attributes]
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700139 column_headers = [a[1] for a in attributes]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -0700140 headers = [a[2] for a in attributes]
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700141
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -0700142
143def tidy_warn_pattern(description, pattern):
144 return {
145 'category': 'C/C++',
146 'severity': Severity.TIDY,
147 'description': 'clang-tidy ' + description,
148 'patterns': [r'.*: .+\[' + pattern + r'\]$']
149 }
150
151
152def simple_tidy_warn_pattern(description):
153 return tidy_warn_pattern(description, description)
154
155
156def group_tidy_warn_pattern(description):
157 return tidy_warn_pattern(description, description + r'-.+')
158
159
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700160warn_patterns = [
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700161 # pylint:disable=line-too-long,g-inconsistent-quotes
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -0700162 {'category': 'C/C++', 'severity': Severity.ANALYZER,
163 'description': 'clang-analyzer Security warning',
164 'patterns': [r".*: warning: .+\[clang-analyzer-security.*\]"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700165 {'category': 'make', 'severity': Severity.MEDIUM,
166 'description': 'make: overriding commands/ignoring old commands',
167 'patterns': [r".*: warning: overriding commands for target .+",
168 r".*: warning: ignoring old commands for target .+"]},
169 {'category': 'make', 'severity': Severity.HIGH,
170 'description': 'make: LOCAL_CLANG is false',
171 'patterns': [r".*: warning: LOCAL_CLANG is set to false"]},
172 {'category': 'make', 'severity': Severity.HIGH,
173 'description': 'SDK App using platform shared library',
174 'patterns': [r".*: warning: .+ \(.*app:sdk.*\) should not link to .+ \(native:platform\)"]},
175 {'category': 'make', 'severity': Severity.HIGH,
176 'description': 'System module linking to a vendor module',
177 'patterns': [r".*: warning: .+ \(.+\) should not link to .+ \(partition:.+\)"]},
178 {'category': 'make', 'severity': Severity.MEDIUM,
179 'description': 'Invalid SDK/NDK linking',
180 'patterns': [r".*: warning: .+ \(.+\) should not link to .+ \(.+\)"]},
Chih-Hung Hsieh9e9355d2018-06-04 11:32:32 -0700181 {'category': 'make', 'severity': Severity.MEDIUM,
182 'description': 'Duplicate header copy',
183 'patterns': [r".*: warning: Duplicate header copy: .+"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700184 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wimplicit-function-declaration',
185 'description': 'Implicit function declaration',
186 'patterns': [r".*: warning: implicit declaration of function .+",
187 r".*: warning: implicitly declaring library function"]},
188 {'category': 'C/C++', 'severity': Severity.SKIP,
189 'description': 'skip, conflicting types for ...',
190 'patterns': [r".*: warning: conflicting types for '.+'"]},
191 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wtype-limits',
192 'description': 'Expression always evaluates to true or false',
193 'patterns': [r".*: warning: comparison is always .+ due to limited range of data type",
194 r".*: warning: comparison of unsigned .*expression .+ is always true",
195 r".*: warning: comparison of unsigned .*expression .+ is always false"]},
196 {'category': 'C/C++', 'severity': Severity.HIGH,
197 'description': 'Potential leak of memory, bad free, use after free',
198 'patterns': [r".*: warning: Potential leak of memory",
199 r".*: warning: Potential memory leak",
200 r".*: warning: Memory allocated by alloca\(\) should not be deallocated",
201 r".*: warning: Memory allocated by .+ should be deallocated by .+ not .+",
202 r".*: warning: 'delete' applied to a pointer that was allocated",
203 r".*: warning: Use of memory after it is freed",
204 r".*: warning: Argument to .+ is the address of .+ variable",
205 r".*: warning: Argument to free\(\) is offset by .+ of memory allocated by",
206 r".*: warning: Attempt to .+ released memory"]},
207 {'category': 'C/C++', 'severity': Severity.HIGH,
208 'description': 'Use transient memory for control value',
209 'patterns': [r".*: warning: .+Using such transient memory for the control value is .*dangerous."]},
210 {'category': 'C/C++', 'severity': Severity.HIGH,
211 'description': 'Return address of stack memory',
212 'patterns': [r".*: warning: Address of stack memory .+ returned to caller",
213 r".*: warning: Address of stack memory .+ will be a dangling reference"]},
214 {'category': 'C/C++', 'severity': Severity.HIGH,
215 'description': 'Problem with vfork',
216 'patterns': [r".*: warning: This .+ is prohibited after a successful vfork",
217 r".*: warning: Call to function '.+' is insecure "]},
218 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': 'infinite-recursion',
219 'description': 'Infinite recursion',
220 'patterns': [r".*: warning: all paths through this function will call itself"]},
221 {'category': 'C/C++', 'severity': Severity.HIGH,
222 'description': 'Potential buffer overflow',
223 'patterns': [r".*: warning: Size argument is greater than .+ the destination buffer",
224 r".*: warning: Potential buffer overflow.",
225 r".*: warning: String copy function overflows destination buffer"]},
226 {'category': 'C/C++', 'severity': Severity.MEDIUM,
227 'description': 'Incompatible pointer types',
228 'patterns': [r".*: warning: assignment from incompatible pointer type",
229 r".*: warning: return from incompatible pointer type",
230 r".*: warning: passing argument [0-9]+ of '.*' from incompatible pointer type",
231 r".*: warning: initialization from incompatible pointer type"]},
232 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-fno-builtin',
233 'description': 'Incompatible declaration of built in function',
234 'patterns': [r".*: warning: incompatible implicit declaration of built-in function .+"]},
235 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wincompatible-library-redeclaration',
236 'description': 'Incompatible redeclaration of library function',
237 'patterns': [r".*: warning: incompatible redeclaration of library function .+"]},
238 {'category': 'C/C++', 'severity': Severity.HIGH,
239 'description': 'Null passed as non-null argument',
240 'patterns': [r".*: warning: Null passed to a callee that requires a non-null"]},
241 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused-parameter',
242 'description': 'Unused parameter',
243 'patterns': [r".*: warning: unused parameter '.*'"]},
244 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused',
Chih-Hung Hsieh9e9355d2018-06-04 11:32:32 -0700245 'description': 'Unused function, variable, label, comparison, etc.',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700246 'patterns': [r".*: warning: '.+' defined but not used",
247 r".*: warning: unused function '.+'",
Chih-Hung Hsieh9e9355d2018-06-04 11:32:32 -0700248 r".*: warning: unused label '.+'",
249 r".*: warning: relational comparison result unused",
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -0700250 r".*: warning: lambda capture .* is not used",
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700251 r".*: warning: private field '.+' is not used",
252 r".*: warning: unused variable '.+'"]},
253 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused-value',
254 'description': 'Statement with no effect or result unused',
255 'patterns': [r".*: warning: statement with no effect",
256 r".*: warning: expression result unused"]},
257 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused-result',
258 'description': 'Ignoreing return value of function',
259 'patterns': [r".*: warning: ignoring return value of function .+Wunused-result"]},
260 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-field-initializers',
261 'description': 'Missing initializer',
262 'patterns': [r".*: warning: missing initializer"]},
263 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wdelete-non-virtual-dtor',
264 'description': 'Need virtual destructor',
265 'patterns': [r".*: warning: delete called .* has virtual functions but non-virtual destructor"]},
266 {'category': 'cont.', 'severity': Severity.SKIP,
267 'description': 'skip, near initialization for ...',
268 'patterns': [r".*: warning: \(near initialization for '.+'\)"]},
269 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wdate-time',
270 'description': 'Expansion of data or time macro',
271 'patterns': [r".*: warning: expansion of date or time macro is not reproducible"]},
272 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wformat',
273 'description': 'Format string does not match arguments',
274 'patterns': [r".*: warning: format '.+' expects type '.+', but argument [0-9]+ has type '.+'",
275 r".*: warning: more '%' conversions than data arguments",
276 r".*: warning: data argument not used by format string",
277 r".*: warning: incomplete format specifier",
278 r".*: warning: unknown conversion type .* in format",
279 r".*: warning: format .+ expects .+ but argument .+Wformat=",
280 r".*: warning: field precision should have .+ but argument has .+Wformat",
281 r".*: warning: format specifies type .+ but the argument has .*type .+Wformat"]},
282 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wformat-extra-args',
283 'description': 'Too many arguments for format string',
284 'patterns': [r".*: warning: too many arguments for format"]},
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -0700285 {'category': 'C/C++', 'severity': Severity.MEDIUM,
286 'description': 'Too many arguments in call',
287 'patterns': [r".*: warning: too many arguments in call to "]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700288 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wformat-invalid-specifier',
289 'description': 'Invalid format specifier',
290 'patterns': [r".*: warning: invalid .+ specifier '.+'.+format-invalid-specifier"]},
291 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsign-compare',
292 'description': 'Comparison between signed and unsigned',
293 'patterns': [r".*: warning: comparison between signed and unsigned",
294 r".*: warning: comparison of promoted \~unsigned with unsigned",
295 r".*: warning: signed and unsigned type in conditional expression"]},
296 {'category': 'C/C++', 'severity': Severity.MEDIUM,
297 'description': 'Comparison between enum and non-enum',
298 'patterns': [r".*: warning: enumeral and non-enumeral type in conditional expression"]},
299 {'category': 'libpng', 'severity': Severity.MEDIUM,
300 'description': 'libpng: zero area',
301 'patterns': [r".*libpng warning: Ignoring attempt to set cHRM RGB triangle with zero area"]},
302 {'category': 'aapt', 'severity': Severity.MEDIUM,
303 'description': 'aapt: no comment for public symbol',
304 'patterns': [r".*: warning: No comment for public symbol .+"]},
305 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-braces',
306 'description': 'Missing braces around initializer',
307 'patterns': [r".*: warning: missing braces around initializer.*"]},
308 {'category': 'C/C++', 'severity': Severity.HARMLESS,
309 'description': 'No newline at end of file',
310 'patterns': [r".*: warning: no newline at end of file"]},
311 {'category': 'C/C++', 'severity': Severity.HARMLESS,
312 'description': 'Missing space after macro name',
313 'patterns': [r".*: warning: missing whitespace after the macro name"]},
314 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wcast-align',
315 'description': 'Cast increases required alignment',
316 'patterns': [r".*: warning: cast from .* to .* increases required alignment .*"]},
317 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wcast-qual',
318 'description': 'Qualifier discarded',
319 'patterns': [r".*: warning: passing argument [0-9]+ of '.+' discards qualifiers from pointer target type",
320 r".*: warning: assignment discards qualifiers from pointer target type",
321 r".*: warning: passing .+ to parameter of type .+ discards qualifiers",
322 r".*: warning: assigning to .+ from .+ discards qualifiers",
323 r".*: warning: initializing .+ discards qualifiers .+types-discards-qualifiers",
324 r".*: warning: return discards qualifiers from pointer target type"]},
325 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunknown-attributes',
326 'description': 'Unknown attribute',
327 'patterns': [r".*: warning: unknown attribute '.+'"]},
328 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wignored-attributes',
329 'description': 'Attribute ignored',
330 'patterns': [r".*: warning: '_*packed_*' attribute ignored",
331 r".*: warning: attribute declaration must precede definition .+ignored-attributes"]},
332 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wvisibility',
333 'description': 'Visibility problem',
334 'patterns': [r".*: warning: declaration of '.+' will not be visible outside of this function"]},
335 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wattributes',
336 'description': 'Visibility mismatch',
337 'patterns': [r".*: warning: '.+' declared with greater visibility than the type of its field '.+'"]},
338 {'category': 'C/C++', 'severity': Severity.MEDIUM,
339 'description': 'Shift count greater than width of type',
340 'patterns': [r".*: warning: (left|right) shift count >= width of type"]},
341 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wextern-initializer',
342 'description': 'extern <foo> is initialized',
343 'patterns': [r".*: warning: '.+' initialized and declared 'extern'",
344 r".*: warning: 'extern' variable has an initializer"]},
345 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wold-style-declaration',
346 'description': 'Old style declaration',
347 'patterns': [r".*: warning: 'static' is not at beginning of declaration"]},
348 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wreturn-type',
349 'description': 'Missing return value',
350 'patterns': [r".*: warning: control reaches end of non-void function"]},
351 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wimplicit-int',
352 'description': 'Implicit int type',
353 'patterns': [r".*: warning: type specifier missing, defaults to 'int'",
354 r".*: warning: type defaults to 'int' in declaration of '.+'"]},
355 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmain-return-type',
356 'description': 'Main function should return int',
357 'patterns': [r".*: warning: return type of 'main' is not 'int'"]},
358 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wuninitialized',
359 'description': 'Variable may be used uninitialized',
360 'patterns': [r".*: warning: '.+' may be used uninitialized in this function"]},
361 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wuninitialized',
362 'description': 'Variable is used uninitialized',
363 'patterns': [r".*: warning: '.+' is used uninitialized in this function",
364 r".*: warning: variable '.+' is uninitialized when used here"]},
365 {'category': 'ld', 'severity': Severity.MEDIUM, 'option': '-fshort-enums',
366 'description': 'ld: possible enum size mismatch',
367 'patterns': [r".*: warning: .* uses variable-size enums yet the output is to use 32-bit enums; use of enum values across objects may fail"]},
368 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wpointer-sign',
369 'description': 'Pointer targets differ in signedness',
370 'patterns': [r".*: warning: pointer targets in initialization differ in signedness",
371 r".*: warning: pointer targets in assignment differ in signedness",
372 r".*: warning: pointer targets in return differ in signedness",
373 r".*: warning: pointer targets in passing argument [0-9]+ of '.+' differ in signedness"]},
374 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wstrict-overflow',
375 'description': 'Assuming overflow does not occur',
376 'patterns': [r".*: warning: assuming signed overflow does not occur when assuming that .* is always (true|false)"]},
377 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wempty-body',
378 'description': 'Suggest adding braces around empty body',
379 'patterns': [r".*: warning: suggest braces around empty body in an 'if' statement",
380 r".*: warning: empty body in an if-statement",
381 r".*: warning: suggest braces around empty body in an 'else' statement",
382 r".*: warning: empty body in an else-statement"]},
383 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wparentheses',
384 'description': 'Suggest adding parentheses',
385 'patterns': [r".*: warning: suggest explicit braces to avoid ambiguous 'else'",
386 r".*: warning: suggest parentheses around arithmetic in operand of '.+'",
387 r".*: warning: suggest parentheses around comparison in operand of '.+'",
388 r".*: warning: logical not is only applied to the left hand side of this comparison",
389 r".*: warning: using the result of an assignment as a condition without parentheses",
390 r".*: warning: .+ has lower precedence than .+ be evaluated first .+Wparentheses",
391 r".*: warning: suggest parentheses around '.+?' .+ '.+?'",
392 r".*: warning: suggest parentheses around assignment used as truth value"]},
393 {'category': 'C/C++', 'severity': Severity.MEDIUM,
394 'description': 'Static variable used in non-static inline function',
395 'patterns': [r".*: warning: '.+' is static but used in inline function '.+' which is not static"]},
396 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wimplicit int',
397 'description': 'No type or storage class (will default to int)',
398 'patterns': [r".*: warning: data definition has no type or storage class"]},
399 {'category': 'C/C++', 'severity': Severity.MEDIUM,
400 'description': 'Null pointer',
401 'patterns': [r".*: warning: Dereference of null pointer",
402 r".*: warning: Called .+ pointer is null",
403 r".*: warning: Forming reference to null pointer",
404 r".*: warning: Returning null reference",
405 r".*: warning: Null pointer passed as an argument to a 'nonnull' parameter",
406 r".*: warning: .+ results in a null pointer dereference",
407 r".*: warning: Access to .+ results in a dereference of a null pointer",
408 r".*: warning: Null pointer argument in"]},
409 {'category': 'cont.', 'severity': Severity.SKIP,
410 'description': 'skip, parameter name (without types) in function declaration',
411 'patterns': [r".*: warning: parameter names \(without types\) in function declaration"]},
412 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wstrict-aliasing',
413 'description': 'Dereferencing <foo> breaks strict aliasing rules',
414 'patterns': [r".*: warning: dereferencing .* break strict-aliasing rules"]},
415 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wpointer-to-int-cast',
416 'description': 'Cast from pointer to integer of different size',
417 'patterns': [r".*: warning: cast from pointer to integer of different size",
418 r".*: warning: initialization makes pointer from integer without a cast"]},
419 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wint-to-pointer-cast',
420 'description': 'Cast to pointer from integer of different size',
421 'patterns': [r".*: warning: cast to pointer from integer of different size"]},
422 {'category': 'C/C++', 'severity': Severity.MEDIUM,
423 'description': 'Symbol redefined',
424 'patterns': [r".*: warning: "".+"" redefined"]},
425 {'category': 'cont.', 'severity': Severity.SKIP,
426 'description': 'skip, ... location of the previous definition',
427 'patterns': [r".*: warning: this is the location of the previous definition"]},
428 {'category': 'ld', 'severity': Severity.MEDIUM,
429 'description': 'ld: type and size of dynamic symbol are not defined',
430 'patterns': [r".*: warning: type and size of dynamic symbol `.+' are not defined"]},
431 {'category': 'C/C++', 'severity': Severity.MEDIUM,
432 'description': 'Pointer from integer without cast',
433 'patterns': [r".*: warning: assignment makes pointer from integer without a cast"]},
434 {'category': 'C/C++', 'severity': Severity.MEDIUM,
435 'description': 'Pointer from integer without cast',
436 'patterns': [r".*: warning: passing argument [0-9]+ of '.+' makes pointer from integer without a cast"]},
437 {'category': 'C/C++', 'severity': Severity.MEDIUM,
438 'description': 'Integer from pointer without cast',
439 'patterns': [r".*: warning: assignment makes integer from pointer without a cast"]},
440 {'category': 'C/C++', 'severity': Severity.MEDIUM,
441 'description': 'Integer from pointer without cast',
442 'patterns': [r".*: warning: passing argument [0-9]+ of '.+' makes integer from pointer without a cast"]},
443 {'category': 'C/C++', 'severity': Severity.MEDIUM,
444 'description': 'Integer from pointer without cast',
445 'patterns': [r".*: warning: return makes integer from pointer without a cast"]},
446 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunknown-pragmas',
447 'description': 'Ignoring pragma',
448 'patterns': [r".*: warning: ignoring #pragma .+"]},
449 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-W#pragma-messages',
450 'description': 'Pragma warning messages',
451 'patterns': [r".*: warning: .+W#pragma-messages"]},
452 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wclobbered',
453 'description': 'Variable might be clobbered by longjmp or vfork',
454 'patterns': [r".*: warning: variable '.+' might be clobbered by 'longjmp' or 'vfork'"]},
455 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wclobbered',
456 'description': 'Argument might be clobbered by longjmp or vfork',
457 'patterns': [r".*: warning: argument '.+' might be clobbered by 'longjmp' or 'vfork'"]},
458 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wredundant-decls',
459 'description': 'Redundant declaration',
460 'patterns': [r".*: warning: redundant redeclaration of '.+'"]},
461 {'category': 'cont.', 'severity': Severity.SKIP,
462 'description': 'skip, previous declaration ... was here',
463 'patterns': [r".*: warning: previous declaration of '.+' was here"]},
464 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wswitch-enum',
465 'description': 'Enum value not handled in switch',
466 'patterns': [r".*: warning: .*enumeration value.* not handled in switch.+Wswitch"]},
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -0700467 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wuser-defined-warnings',
468 'description': 'User defined warnings',
469 'patterns': [r".*: warning: .* \[-Wuser-defined-warnings\]$"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700470 {'category': 'java', 'severity': Severity.MEDIUM, 'option': '-encoding',
471 'description': 'Java: Non-ascii characters used, but ascii encoding specified',
472 'patterns': [r".*: warning: unmappable character for encoding ascii"]},
473 {'category': 'java', 'severity': Severity.MEDIUM,
474 'description': 'Java: Non-varargs call of varargs method with inexact argument type for last parameter',
475 'patterns': [r".*: warning: non-varargs call of varargs method with inexact argument type for last parameter"]},
476 {'category': 'java', 'severity': Severity.MEDIUM,
477 'description': 'Java: Unchecked method invocation',
478 'patterns': [r".*: warning: \[unchecked\] unchecked method invocation: .+ in class .+"]},
479 {'category': 'java', 'severity': Severity.MEDIUM,
480 'description': 'Java: Unchecked conversion',
481 'patterns': [r".*: warning: \[unchecked\] unchecked conversion"]},
482 {'category': 'java', 'severity': Severity.MEDIUM,
483 'description': '_ used as an identifier',
484 'patterns': [r".*: warning: '_' used as an identifier"]},
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -0700485 {'category': 'java', 'severity': Severity.HIGH,
486 'description': 'Use of internal proprietary API',
487 'patterns': [r".*: warning: .* is internal proprietary API and may be removed"]},
Ian Rogers32bb9bd2016-05-09 23:19:42 -0700488
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800489 # Warnings from Javac
Ian Rogers6e520032016-05-13 08:59:00 -0700490 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700491 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700492 'description': 'Java: Use of deprecated member',
493 'patterns': [r'.*: warning: \[deprecation\] .+']},
494 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700495 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700496 'description': 'Java: Unchecked conversion',
497 'patterns': [r'.*: warning: \[unchecked\] .+']},
Ian Rogers32bb9bd2016-05-09 23:19:42 -0700498
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800499 # Begin warnings generated by Error Prone
500 {'category': 'java',
501 'severity': Severity.LOW,
502 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800503 'Java: Use parameter comments to document ambiguous literals',
504 'patterns': [r".*: warning: \[BooleanParameter\] .+"]},
505 {'category': 'java',
506 'severity': Severity.LOW,
507 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -0700508 'Java: Field name is CONSTANT_CASE, but field is not static and final',
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800509 'patterns': [r".*: warning: \[ConstantField\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -0700510 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700511 'severity': Severity.LOW,
Ian Rogers6e520032016-05-13 08:59:00 -0700512 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700513 'Java: @Multibinds is a more efficient and declarative mechanism for ensuring that a set multibinding is present in the graph.',
514 'patterns': [r".*: warning: \[EmptySetMultibindingContributions\] .+"]},
515 {'category': 'java',
516 'severity': Severity.LOW,
517 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -0700518 'Java: This field is only assigned during initialization; consider making it final',
519 'patterns': [r".*: warning: \[FieldCanBeFinal\] .+"]},
Andreas Gampe2e987af2018-06-08 09:55:41 -0700520 {'category': 'java',
521 'severity': Severity.LOW,
522 'description':
523 'Java: Fields that can be null should be annotated @Nullable',
524 'patterns': [r".*: warning: \[FieldMissingNullable\] .+"]},
525 {'category': 'java',
526 'severity': Severity.LOW,
527 'description':
Chih-Hung Hsieh9be27762018-06-07 10:51:47 -0700528 r'Java: Use Java\'s utility functional interfaces instead of Function\u003cA, B> for primitive types.',
Andreas Gampecf528ca2018-01-25 11:55:43 -0800529 'patterns': [r".*: warning: \[LambdaFunctionalInterface\] .+"]},
530 {'category': 'java',
531 'severity': Severity.LOW,
532 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800533 'Java: A private method that does not reference the enclosing instance can be static',
534 'patterns': [r".*: warning: \[MethodCanBeStatic\] .+"]},
535 {'category': 'java',
536 'severity': Severity.LOW,
537 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800538 'Java: C-style array declarations should not be used',
539 'patterns': [r".*: warning: \[MixedArrayDimensions\] .+"]},
540 {'category': 'java',
541 'severity': Severity.LOW,
542 'description':
543 'Java: Variable declarations should declare only one variable',
544 'patterns': [r".*: warning: \[MultiVariableDeclaration\] .+"]},
545 {'category': 'java',
546 'severity': Severity.LOW,
547 'description':
548 'Java: Source files should not contain multiple top-level class declarations',
549 'patterns': [r".*: warning: \[MultipleTopLevelClasses\] .+"]},
550 {'category': 'java',
551 'severity': Severity.LOW,
552 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800553 'Java: Avoid having multiple unary operators acting on the same variable in a method call',
554 'patterns': [r".*: warning: \[MultipleUnaryOperatorsInMethodCall\] .+"]},
555 {'category': 'java',
556 'severity': Severity.LOW,
557 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800558 'Java: Package names should match the directory they are declared in',
559 'patterns': [r".*: warning: \[PackageLocation\] .+"]},
560 {'category': 'java',
561 'severity': Severity.LOW,
562 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800563 'Java: Non-standard parameter comment; prefer `/*paramName=*/ arg`',
564 'patterns': [r".*: warning: \[ParameterComment\] .+"]},
565 {'category': 'java',
566 'severity': Severity.LOW,
567 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700568 'Java: Method parameters that aren\'t checked for null shouldn\'t be annotated @Nullable',
569 'patterns': [r".*: warning: \[ParameterNotNullable\] .+"]},
570 {'category': 'java',
571 'severity': Severity.LOW,
572 'description':
573 'Java: Add a private constructor to modules that will not be instantiated by Dagger.',
Andreas Gampeb9dc23a2018-06-08 10:11:26 -0700574 'patterns': [r".*: warning: \[PrivateConstructorForNoninstantiableModule\] .+"]},
Andreas Gampe2e987af2018-06-08 09:55:41 -0700575 {'category': 'java',
576 'severity': Severity.LOW,
577 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800578 'Java: Utility classes (only static members) are not designed to be instantiated and should be made noninstantiable with a default constructor.',
579 'patterns': [r".*: warning: \[PrivateConstructorForUtilityClass\] .+"]},
580 {'category': 'java',
581 'severity': Severity.LOW,
582 'description':
583 'Java: Unused imports',
584 'patterns': [r".*: warning: \[RemoveUnusedImports\] .+"]},
585 {'category': 'java',
586 'severity': Severity.LOW,
587 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700588 'Java: Methods that can return null should be annotated @Nullable',
589 'patterns': [r".*: warning: \[ReturnMissingNullable\] .+"]},
590 {'category': 'java',
591 'severity': Severity.LOW,
592 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -0700593 'Java: Scopes on modules have no function and will soon be an error.',
594 'patterns': [r".*: warning: \[ScopeOnModule\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -0800595 {'category': 'java',
596 'severity': Severity.LOW,
597 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -0700598 'Java: The default case of a switch should appear at the end of the last statement group',
599 'patterns': [r".*: warning: \[SwitchDefault\] .+"]},
Andreas Gampe2e987af2018-06-08 09:55:41 -0700600 {'category': 'java',
601 'severity': Severity.LOW,
602 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800603 'Java: Unchecked exceptions do not need to be declared in the method signature.',
604 'patterns': [r".*: warning: \[ThrowsUncheckedException\] .+"]},
605 {'category': 'java',
606 'severity': Severity.LOW,
607 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800608 'Java: Type parameters must be a single letter with an optional numeric suffix, or an UpperCamelCase name followed by the letter \'T\'.',
609 'patterns': [r".*: warning: \[TypeParameterNaming\] .+"]},
610 {'category': 'java',
611 'severity': Severity.LOW,
612 'description':
613 'Java: Constructors and methods with the same name should appear sequentially with no other code in between',
614 'patterns': [r".*: warning: \[UngroupedOverloads\] .+"]},
615 {'category': 'java',
616 'severity': Severity.LOW,
617 'description':
618 'Java: Unnecessary call to NullPointerTester#setDefault',
619 'patterns': [r".*: warning: \[UnnecessarySetDefault\] .+"]},
620 {'category': 'java',
621 'severity': Severity.LOW,
622 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800623 'Java: Using static imports for types is unnecessary',
624 'patterns': [r".*: warning: \[UnnecessaryStaticImport\] .+"]},
625 {'category': 'java',
626 'severity': Severity.LOW,
627 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700628 'Java: @Binds is a more efficient and declarative mechanism for delegating a binding.',
629 'patterns': [r".*: warning: \[UseBinds\] .+"]},
630 {'category': 'java',
631 'severity': Severity.LOW,
632 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800633 'Java: Wildcard imports, static or otherwise, should not be used',
634 'patterns': [r".*: warning: \[WildcardImport\] .+"]},
635 {'category': 'java',
Andreas Gampecf528ca2018-01-25 11:55:43 -0800636 'severity': Severity.MEDIUM,
637 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700638 'Java: Method reference is ambiguous',
639 'patterns': [r".*: warning: \[AmbiguousMethodReference\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -0800640 {'category': 'java',
641 'severity': Severity.MEDIUM,
642 'description':
643 'Java: Arguments are in the wrong order or could be commented for clarity.',
644 'patterns': [r".*: warning: \[ArgumentSelectionDefectChecker\] .+"]},
645 {'category': 'java',
646 'severity': Severity.MEDIUM,
647 'description':
648 'Java: Arguments are swapped in assertEquals-like call',
649 'patterns': [r".*: warning: \[AssertEqualsArgumentOrderChecker\] .+"]},
650 {'category': 'java',
651 'severity': Severity.MEDIUM,
652 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800653 'Java: Assertions may be disabled at runtime and do not guarantee that execution will halt here; consider throwing an exception instead',
654 'patterns': [r".*: warning: \[AssertFalse\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -0700655 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700656 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700657 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -0700658 'Java: The lambda passed to assertThows should contain exactly one statement',
659 'patterns': [r".*: warning: \[AssertThrowsMultipleStatements\] .+"]},
660 {'category': 'java',
661 'severity': Severity.MEDIUM,
662 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800663 'Java: This assertion throws an AssertionError if it fails, which will be caught by an enclosing try block.',
664 'patterns': [r".*: warning: \[AssertionFailureIgnored\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -0700665 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700666 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700667 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700668 'Java: @AssistedInject and @Inject should not be used on different constructors in the same class.',
669 'patterns': [r".*: warning: \[AssistedInjectAndInjectOnConstructors\] .+"]},
670 {'category': 'java',
671 'severity': Severity.MEDIUM,
672 'description':
Ian Rogers6e520032016-05-13 08:59:00 -0700673 'Java: Classes that implement Annotation must override equals and hashCode. Consider using AutoAnnotation instead of implementing Annotation by hand.',
674 'patterns': [r".*: warning: \[BadAnnotationImplementation\] .+"]},
675 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700676 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700677 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800678 'Java: Possible sign flip from narrowing conversion',
679 'patterns': [r".*: warning: \[BadComparable\] .+"]},
680 {'category': 'java',
681 'severity': Severity.MEDIUM,
682 'description':
Ian Rogers6e520032016-05-13 08:59:00 -0700683 'Java: BigDecimal(double) and BigDecimal.valueOf(double) may lose precision, prefer BigDecimal(String) or BigDecimal(long)',
684 'patterns': [r".*: warning: \[BigDecimalLiteralDouble\] .+"]},
685 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700686 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700687 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700688 '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.',
689 'patterns': [r".*: warning: \[BinderIdentityRestoredDangerously\] .+"]},
690 {'category': 'java',
691 'severity': Severity.MEDIUM,
692 'description':
693 'Java: This code declares a binding for a common value type without a Qualifier annotation.',
694 'patterns': [r".*: warning: \[BindingToUnqualifiedCommonType\] .+"]},
695 {'category': 'java',
696 'severity': Severity.MEDIUM,
697 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800698 'Java: valueOf or autoboxing provides better time and space performance',
699 'patterns': [r".*: warning: \[BoxedPrimitiveConstructor\] .+"]},
700 {'category': 'java',
701 'severity': Severity.MEDIUM,
702 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -0700703 'Java: ByteBuffer.array() shouldn\'t be called unless ByteBuffer.arrayOffset() is used or if the ByteBuffer was initialized using ByteBuffer.wrap() or ByteBuffer.allocate().',
704 'patterns': [r".*: warning: \[ByteBufferBackingArray\] .+"]},
705 {'category': 'java',
706 'severity': Severity.MEDIUM,
707 'description':
Ian Rogers6e520032016-05-13 08:59:00 -0700708 'Java: Mockito cannot mock final classes',
709 'patterns': [r".*: warning: \[CannotMockFinalClass\] .+"]},
710 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700711 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700712 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800713 'Java: Duration can be expressed more clearly with different units',
714 'patterns': [r".*: warning: \[CanonicalDuration\] .+"]},
715 {'category': 'java',
716 'severity': Severity.MEDIUM,
717 'description':
718 'Java: Logging or rethrowing exceptions should usually be preferred to catching and calling printStackTrace',
719 'patterns': [r".*: warning: \[CatchAndPrintStackTrace\] .+"]},
720 {'category': 'java',
721 'severity': Severity.MEDIUM,
722 'description':
723 'Java: Ignoring exceptions and calling fail() is unnecessary, and makes test output less useful',
724 'patterns': [r".*: warning: \[CatchFail\] .+"]},
725 {'category': 'java',
726 'severity': Severity.MEDIUM,
727 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800728 'Java: Inner class is non-static but does not reference enclosing class',
729 'patterns': [r".*: warning: \[ClassCanBeStatic\] .+"]},
730 {'category': 'java',
731 'severity': Severity.MEDIUM,
732 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800733 'Java: Class.newInstance() bypasses exception checking; prefer getDeclaredConstructor().newInstance()',
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800734 'patterns': [r".*: warning: \[ClassNewInstance\] .+"]},
735 {'category': 'java',
736 'severity': Severity.MEDIUM,
737 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800738 'Java: The type of the array parameter of Collection.toArray needs to be compatible with the array type',
739 'patterns': [r".*: warning: \[CollectionToArraySafeParameter\] .+"]},
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800740 {'category': 'java',
741 'severity': Severity.MEDIUM,
742 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800743 'Java: Collector.of() should not use state',
744 'patterns': [r".*: warning: \[CollectorShouldNotUseState\] .+"]},
745 {'category': 'java',
746 'severity': Severity.MEDIUM,
747 'description':
748 'Java: Class should not implement both `Comparable` and `Comparator`',
749 'patterns': [r".*: warning: \[ComparableAndComparator\] .+"]},
750 {'category': 'java',
751 'severity': Severity.MEDIUM,
752 'description':
753 'Java: Constructors should not invoke overridable methods.',
754 'patterns': [r".*: warning: \[ConstructorInvokesOverridable\] .+"]},
755 {'category': 'java',
756 'severity': Severity.MEDIUM,
757 'description':
758 'Java: Constructors should not pass the \'this\' reference out in method invocations, since the object may not be fully constructed.',
759 'patterns': [r".*: warning: \[ConstructorLeaksThis\] .+"]},
760 {'category': 'java',
761 'severity': Severity.MEDIUM,
762 'description':
763 'Java: DateFormat is not thread-safe, and should not be used as a constant field.',
764 'patterns': [r".*: warning: \[DateFormatConstant\] .+"]},
765 {'category': 'java',
766 'severity': Severity.MEDIUM,
767 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -0700768 'Java: Implicit use of the platform default charset, which can result in differing behaviour between JVM executions or incorrect behavior if the encoding of the data source doesn\'t match expectations.',
Andreas Gampecf528ca2018-01-25 11:55:43 -0800769 'patterns': [r".*: warning: \[DefaultCharset\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -0700770 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700771 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700772 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -0700773 'Java: Prefer collection factory methods or builders to the double-brace initialization pattern.',
774 'patterns': [r".*: warning: \[DoubleBraceInitialization\] .+"]},
775 {'category': 'java',
776 'severity': Severity.MEDIUM,
777 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700778 'Java: Double-checked locking on non-volatile fields is unsafe',
779 'patterns': [r".*: warning: \[DoubleCheckedLocking\] .+"]},
780 {'category': 'java',
781 'severity': Severity.MEDIUM,
782 'description':
Ian Rogers6e520032016-05-13 08:59:00 -0700783 'Java: Empty top-level type declaration',
784 'patterns': [r".*: warning: \[EmptyTopLevelDeclaration\] .+"]},
785 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700786 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700787 'description':
788 'Java: Classes that override equals should also override hashCode.',
789 'patterns': [r".*: warning: \[EqualsHashCode\] .+"]},
790 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700791 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700792 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700793 'Java: An equality test between objects with incompatible types always returns false',
794 'patterns': [r".*: warning: \[EqualsIncompatibleType\] .+"]},
795 {'category': 'java',
796 'severity': Severity.MEDIUM,
797 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800798 'Java: Calls to ExpectedException#expect should always be followed by exactly one statement.',
799 'patterns': [r".*: warning: \[ExpectedExceptionChecker\] .+"]},
800 {'category': 'java',
801 'severity': Severity.MEDIUM,
802 'description':
803 'Java: Switch case may fall through',
804 'patterns': [r".*: warning: \[FallThrough\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -0700805 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700806 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700807 'description':
808 '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.',
809 'patterns': [r".*: warning: \[Finally\] .+"]},
810 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700811 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700812 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800813 'Java: Use parentheses to make the precedence explicit',
814 'patterns': [r".*: warning: \[FloatCast\] .+"]},
815 {'category': 'java',
816 'severity': Severity.MEDIUM,
817 'description':
818 'Java: Floating point literal loses precision',
819 'patterns': [r".*: warning: \[FloatingPointLiteralPrecision\] .+"]},
820 {'category': 'java',
821 'severity': Severity.MEDIUM,
822 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700823 'Java: Classes extending PreferenceActivity must implement isValidFragment such that it does not unconditionally return true to prevent vulnerability to fragment injection attacks.',
824 'patterns': [r".*: warning: \[FragmentInjection\] .+"]},
825 {'category': 'java',
826 'severity': Severity.MEDIUM,
827 'description':
828 'Java: Subclasses of Fragment must be instantiable via Class#newInstance(): the class must be public, static and have a public nullary constructor',
829 'patterns': [r".*: warning: \[FragmentNotInstantiable\] .+"]},
830 {'category': 'java',
831 'severity': Severity.MEDIUM,
832 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800833 'Java: Overloads will be ambiguous when passing lambda arguments',
834 'patterns': [r".*: warning: \[FunctionalInterfaceClash\] .+"]},
835 {'category': 'java',
836 'severity': Severity.MEDIUM,
837 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800838 'Java: Return value of methods returning Future must be checked. Ignoring returned Futures suppresses exceptions thrown from the code that completes the Future.',
839 'patterns': [r".*: warning: \[FutureReturnValueIgnored\] .+"]},
840 {'category': 'java',
841 'severity': Severity.MEDIUM,
842 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800843 'Java: Calling getClass() on an enum may return a subclass of the enum type',
844 'patterns': [r".*: warning: \[GetClassOnEnum\] .+"]},
845 {'category': 'java',
846 'severity': Severity.MEDIUM,
847 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700848 'Java: Hardcoded reference to /sdcard',
849 'patterns': [r".*: warning: \[HardCodedSdCardPath\] .+"]},
850 {'category': 'java',
851 'severity': Severity.MEDIUM,
852 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800853 'Java: Hiding fields of superclasses may cause confusion and errors',
854 'patterns': [r".*: warning: \[HidingField\] .+"]},
855 {'category': 'java',
856 'severity': Severity.MEDIUM,
857 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700858 'Java: Annotations should always be immutable',
859 'patterns': [r".*: warning: \[ImmutableAnnotationChecker\] .+"]},
860 {'category': 'java',
861 'severity': Severity.MEDIUM,
862 'description':
863 'Java: Enums should always be immutable',
864 'patterns': [r".*: warning: \[ImmutableEnumChecker\] .+"]},
865 {'category': 'java',
866 'severity': Severity.MEDIUM,
867 'description':
Ian Rogers6e520032016-05-13 08:59:00 -0700868 'Java: This annotation has incompatible modifiers as specified by its @IncompatibleModifiers annotation',
869 'patterns': [r".*: warning: \[IncompatibleModifiers\] .+"]},
870 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700871 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700872 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -0700873 'Java: It is confusing to have a field and a parameter under the same scope that differ only in capitalization.',
874 'patterns': [r".*: warning: \[InconsistentCapitalization\] .+"]},
875 {'category': 'java',
876 'severity': Severity.MEDIUM,
877 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700878 'Java: The ordering of parameters in overloaded methods should be as consistent as possible (when viewed from left to right)',
879 'patterns': [r".*: warning: \[InconsistentOverloads\] .+"]},
880 {'category': 'java',
881 'severity': Severity.MEDIUM,
882 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800883 'Java: This for loop increments the same variable in the header and in the body',
884 'patterns': [r".*: warning: \[IncrementInForLoopAndHeader\] .+"]},
885 {'category': 'java',
886 'severity': Severity.MEDIUM,
887 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700888 'Java: Constructors on abstract classes are never directly @Injected, only the constructors of their subclasses can be @Inject\'ed.',
889 'patterns': [r".*: warning: \[InjectOnConstructorOfAbstractClass\] .+"]},
890 {'category': 'java',
891 'severity': Severity.MEDIUM,
892 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800893 'Java: Please also override int read(byte[], int, int), otherwise multi-byte reads from this input stream are likely to be slow.',
894 'patterns': [r".*: warning: \[InputStreamSlowMultibyteRead\] .+"]},
895 {'category': 'java',
896 'severity': Severity.MEDIUM,
897 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800898 'Java: Casting inside an if block should be plausibly consistent with the instanceof type',
899 'patterns': [r".*: warning: \[InstanceOfAndCastMatchWrongType\] .+"]},
900 {'category': 'java',
901 'severity': Severity.MEDIUM,
902 'description':
903 'Java: Expression of type int may overflow before being assigned to a long',
904 'patterns': [r".*: warning: \[IntLongMath\] .+"]},
905 {'category': 'java',
906 'severity': Severity.MEDIUM,
907 'description':
Ian Rogers6e520032016-05-13 08:59:00 -0700908 'Java: Class should not implement both `Iterable` and `Iterator`',
909 'patterns': [r".*: warning: \[IterableAndIterator\] .+"]},
910 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700911 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700912 'description':
913 'Java: Floating-point comparison without error tolerance',
914 'patterns': [r".*: warning: \[JUnit3FloatingPointComparisonWithoutDelta\] .+"]},
915 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700916 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700917 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800918 'Java: Some JUnit4 construct cannot be used in a JUnit3 context. Convert your class to JUnit4 style to use them.',
919 'patterns': [r".*: warning: \[JUnit4ClassUsedInJUnit3\] .+"]},
920 {'category': 'java',
921 'severity': Severity.MEDIUM,
922 'description':
Ian Rogers6e520032016-05-13 08:59:00 -0700923 'Java: Test class inherits from JUnit 3\'s TestCase but has JUnit 4 @Test annotations.',
924 'patterns': [r".*: warning: \[JUnitAmbiguousTestClass\] .+"]},
925 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700926 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700927 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800928 'Java: Never reuse class names from java.lang',
929 'patterns': [r".*: warning: \[JavaLangClash\] .+"]},
930 {'category': 'java',
931 'severity': Severity.MEDIUM,
932 'description':
933 'Java: Suggests alternatives to obsolete JDK classes.',
934 'patterns': [r".*: warning: \[JdkObsolete\] .+"]},
935 {'category': 'java',
936 'severity': Severity.MEDIUM,
937 'description':
938 'Java: Assignment where a boolean expression was expected; use == if this assignment wasn\'t expected or add parentheses for clarity.',
939 'patterns': [r".*: warning: \[LogicalAssignment\] .+"]},
940 {'category': 'java',
941 'severity': Severity.MEDIUM,
942 'description':
943 'Java: Switches on enum types should either handle all values, or have a default case.',
Ian Rogers6e520032016-05-13 08:59:00 -0700944 'patterns': [r".*: warning: \[MissingCasesInEnumSwitch\] .+"]},
945 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700946 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700947 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800948 'Java: 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.)',
949 'patterns': [r".*: warning: \[MissingDefault\] .+"]},
950 {'category': 'java',
951 'severity': Severity.MEDIUM,
952 'description':
Ian Rogers6e520032016-05-13 08:59:00 -0700953 'Java: Not calling fail() when expecting an exception masks bugs',
954 'patterns': [r".*: warning: \[MissingFail\] .+"]},
955 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700956 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700957 'description':
958 'Java: method overrides method in supertype; expected @Override',
959 'patterns': [r".*: warning: \[MissingOverride\] .+"]},
960 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700961 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700962 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800963 'Java: Modifying a collection while iterating over it in a loop may cause a ConcurrentModificationException to be thrown.',
964 'patterns': [r".*: warning: \[ModifyCollectionInEnhancedForLoop\] .+"]},
965 {'category': 'java',
966 'severity': Severity.MEDIUM,
967 'description':
968 'Java: Multiple calls to either parallel or sequential are unnecessary and cause confusion.',
969 'patterns': [r".*: warning: \[MultipleParallelOrSequentialCalls\] .+"]},
970 {'category': 'java',
971 'severity': Severity.MEDIUM,
972 'description':
973 'Java: Constant field declarations should use the immutable type (such as ImmutableList) instead of the general collection interface type (such as List)',
974 'patterns': [r".*: warning: \[MutableConstantField\] .+"]},
975 {'category': 'java',
976 'severity': Severity.MEDIUM,
977 'description':
978 'Java: Method return type should use the immutable type (such as ImmutableList) instead of the general collection interface type (such as List)',
979 'patterns': [r".*: warning: \[MutableMethodReturnType\] .+"]},
980 {'category': 'java',
981 'severity': Severity.MEDIUM,
982 'description':
983 'Java: Compound assignments may hide dangerous casts',
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800984 'patterns': [r".*: warning: \[NarrowingCompoundAssignment\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -0700985 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700986 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700987 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800988 'Java: Nested instanceOf conditions of disjoint types create blocks of code that never execute',
989 'patterns': [r".*: warning: \[NestedInstanceOfConditions\] .+"]},
990 {'category': 'java',
991 'severity': Severity.MEDIUM,
992 'description':
Ian Rogers6e520032016-05-13 08:59:00 -0700993 'Java: This update of a volatile variable is non-atomic',
994 'patterns': [r".*: warning: \[NonAtomicVolatileUpdate\] .+"]},
995 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700996 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700997 'description':
998 'Java: Static import of member uses non-canonical name',
999 'patterns': [r".*: warning: \[NonCanonicalStaticMemberImport\] .+"]},
1000 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001001 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001002 'description':
1003 'Java: equals method doesn\'t override Object.equals',
1004 'patterns': [r".*: warning: \[NonOverridingEquals\] .+"]},
1005 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001006 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001007 'description':
1008 'Java: Constructors should not be annotated with @Nullable since they cannot return null',
1009 'patterns': [r".*: warning: \[NullableConstructor\] .+"]},
1010 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001011 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001012 'description':
1013 'Java: @Nullable should not be used for primitive types since they cannot be null',
1014 'patterns': [r".*: warning: \[NullablePrimitive\] .+"]},
1015 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001016 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001017 'description':
1018 'Java: void-returning methods should not be annotated with @Nullable, since they cannot return null',
1019 'patterns': [r".*: warning: \[NullableVoid\] .+"]},
1020 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001021 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001022 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001023 'Java: Calling toString on Objects that don\'t override toString() doesn\'t provide useful information',
1024 'patterns': [r".*: warning: \[ObjectToString\] .+"]},
1025 {'category': 'java',
1026 'severity': Severity.MEDIUM,
1027 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001028 'Java: Use grouping parenthesis to make the operator precedence explicit',
1029 'patterns': [r".*: warning: \[OperatorPrecedence\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001030 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001031 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001032 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001033 'Java: One should not call optional.get() inside an if statement that checks !optional.isPresent',
1034 'patterns': [r".*: warning: \[OptionalNotPresent\] .+"]},
1035 {'category': 'java',
1036 'severity': Severity.MEDIUM,
1037 'description':
1038 'Java: String literal contains format specifiers, but is not passed to a format method',
1039 'patterns': [r".*: warning: \[OrphanedFormatString\] .+"]},
1040 {'category': 'java',
1041 'severity': Severity.MEDIUM,
1042 'description':
1043 'Java: To return a custom message with a Throwable class, one should override getMessage() instead of toString() for Throwable.',
1044 'patterns': [r".*: warning: \[OverrideThrowableToString\] .+"]},
1045 {'category': 'java',
1046 'severity': Severity.MEDIUM,
1047 'description':
1048 'Java: Varargs doesn\'t agree for overridden method',
1049 'patterns': [r".*: warning: \[Overrides\] .+"]},
1050 {'category': 'java',
1051 'severity': Severity.MEDIUM,
1052 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001053 '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.',
1054 'patterns': [r".*: warning: \[OverridesGuiceInjectableMethod\] .+"]},
1055 {'category': 'java',
1056 'severity': Severity.MEDIUM,
1057 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001058 'Java: Detects `/* name= */`-style comments on actual parameters where the name doesn\'t match the formal parameter',
1059 'patterns': [r".*: warning: \[ParameterName\] .+"]},
1060 {'category': 'java',
1061 'severity': Severity.MEDIUM,
1062 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001063 'Java: Preconditions only accepts the %s placeholder in error message strings',
1064 'patterns': [r".*: warning: \[PreconditionsInvalidPlaceholder\] .+"]},
1065 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001066 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001067 'description':
1068 'Java: Passing a primitive array to a varargs method is usually wrong',
1069 'patterns': [r".*: warning: \[PrimitiveArrayPassedToVarargsMethod\] .+"]},
1070 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001071 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001072 'description':
1073 'Java: Protobuf fields cannot be null, so this check is redundant',
1074 'patterns': [r".*: warning: \[ProtoFieldPreconditionsCheckNotNull\] .+"]},
1075 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001076 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001077 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001078 'Java: BugChecker has incorrect ProvidesFix tag, please update',
1079 'patterns': [r".*: warning: \[ProvidesFix\] .+"]},
1080 {'category': 'java',
1081 'severity': Severity.MEDIUM,
1082 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001083 'Java: Qualifiers/Scope annotations on @Inject methods don\'t have any effect. Move the qualifier annotation to the binding location.',
1084 'patterns': [r".*: warning: \[QualifierOrScopeOnInjectMethod\] .+"]},
1085 {'category': 'java',
1086 'severity': Severity.MEDIUM,
1087 'description':
1088 'Java: Injection frameworks currently don\'t understand Qualifiers in TYPE_PARAMETER or TYPE_USE contexts.',
Andreas Gampe2e987af2018-06-08 09:55:41 -07001089 'patterns': [r".*: warning: \[QualifierWithTypeUse\] .+"]},
1090 {'category': 'java',
1091 'severity': Severity.MEDIUM,
1092 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001093 'Java: reachabilityFence should always be called inside a finally block',
1094 'patterns': [r".*: warning: \[ReachabilityFenceUsage\] .+"]},
1095 {'category': 'java',
1096 'severity': Severity.MEDIUM,
1097 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001098 'Java: Thrown exception is a subtype of another',
1099 'patterns': [r".*: warning: \[RedundantThrows\] .+"]},
1100 {'category': 'java',
1101 'severity': Severity.MEDIUM,
1102 'description':
1103 'Java: Comparison using reference equality instead of value equality',
1104 'patterns': [r".*: warning: \[ReferenceEquality\] .+"]},
1105 {'category': 'java',
1106 'severity': Severity.MEDIUM,
1107 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001108 'Java: This annotation is missing required modifiers as specified by its @RequiredModifiers annotation',
1109 'patterns': [r".*: warning: \[RequiredModifiers\] .+"]},
1110 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001111 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001112 'description':
Chih-Hung Hsieh9be27762018-06-07 10:51:47 -07001113 r'Java: Prefer the short-circuiting boolean operators \u0026\u0026 and || to \u0026 and |.',
Andreas Gampecf528ca2018-01-25 11:55:43 -08001114 'patterns': [r".*: warning: \[ShortCircuitBoolean\] .+"]},
1115 {'category': 'java',
1116 'severity': Severity.MEDIUM,
1117 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001118 'Java: Writes to static fields should not be guarded by instance locks',
1119 'patterns': [r".*: warning: \[StaticGuardedByInstance\] .+"]},
1120 {'category': 'java',
1121 'severity': Severity.MEDIUM,
1122 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001123 'Java: A static variable or method should be qualified with a class name, not expression',
1124 'patterns': [r".*: warning: \[StaticQualifiedUsingExpression\] .+"]},
1125 {'category': 'java',
1126 'severity': Severity.MEDIUM,
1127 'description':
1128 'Java: Streams that encapsulate a closeable resource should be closed using try-with-resources',
1129 'patterns': [r".*: warning: \[StreamResourceLeak\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001130 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001131 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001132 'description':
1133 'Java: String comparison using reference equality instead of value equality',
1134 'patterns': [r".*: warning: \[StringEquality\] .+"]},
1135 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001136 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001137 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001138 'Java: String.split(String) has surprising behavior',
Andreas Gampecf528ca2018-01-25 11:55:43 -08001139 'patterns': [r".*: warning: \[StringSplitter\] .+"]},
1140 {'category': 'java',
1141 'severity': Severity.MEDIUM,
1142 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001143 'Java: Synchronizing on non-final fields is not safe: if the field is ever updated, different threads may end up locking on different objects.',
1144 'patterns': [r".*: warning: \[SynchronizeOnNonFinalField\] .+"]},
1145 {'category': 'java',
1146 'severity': Severity.MEDIUM,
1147 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001148 'Java: Using @Test(expected=...) is discouraged, since the test will pass if *any* statement in the test method throws the expected exception',
1149 'patterns': [r".*: warning: \[TestExceptionChecker\] .+"]},
1150 {'category': 'java',
1151 'severity': Severity.MEDIUM,
1152 'description':
1153 'Java: Thread.join needs to be surrounded by a loop until it succeeds, as in Uninterruptibles.joinUninterruptibly.',
1154 'patterns': [r".*: warning: \[ThreadJoinLoop\] .+"]},
1155 {'category': 'java',
1156 'severity': Severity.MEDIUM,
1157 'description':
1158 'Java: ThreadLocals should be stored in static fields',
1159 'patterns': [r".*: warning: \[ThreadLocalUsage\] .+"]},
1160 {'category': 'java',
1161 'severity': Severity.MEDIUM,
1162 'description':
1163 '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.',
1164 'patterns': [r".*: warning: \[ThreeLetterTimeZoneID\] .+"]},
1165 {'category': 'java',
1166 'severity': Severity.MEDIUM,
1167 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001168 'Java: Truth Library assert is called on a constant.',
1169 'patterns': [r".*: warning: \[TruthConstantAsserts\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001170 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001171 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001172 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001173 'Java: Argument is not compatible with the subject\'s type.',
1174 'patterns': [r".*: warning: \[TruthIncompatibleType\] .+"]},
1175 {'category': 'java',
1176 'severity': Severity.MEDIUM,
1177 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001178 'Java: Type parameter declaration overrides another type parameter already declared',
1179 'patterns': [r".*: warning: \[TypeParameterShadowing\] .+"]},
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001180 {'category': 'java',
1181 'severity': Severity.MEDIUM,
1182 'description':
1183 '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.',
1184 'patterns': [r".*: warning: \[TypeParameterUnusedInFormals\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001185 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001186 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001187 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001188 'Java: Avoid hash-based containers of java.net.URL--the containers rely on equals() and hashCode(), which cause java.net.URL to make blocking internet connections.',
Andreas Gampecf528ca2018-01-25 11:55:43 -08001189 'patterns': [r".*: warning: \[URLEqualsHashCode\] .+"]},
1190 {'category': 'java',
1191 'severity': Severity.MEDIUM,
1192 'description':
1193 'Java: Switch handles all enum values; an explicit default case is unnecessary and defeats error checking for non-exhaustive switches.',
1194 'patterns': [r".*: warning: \[UnnecessaryDefaultInEnumSwitch\] .+"]},
1195 {'category': 'java',
1196 'severity': Severity.MEDIUM,
1197 'description':
1198 'Java: Finalizer may run before native code finishes execution',
1199 'patterns': [r".*: warning: \[UnsafeFinalization\] .+"]},
1200 {'category': 'java',
1201 'severity': Severity.MEDIUM,
1202 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001203 'Java: Unsynchronized method overrides a synchronized method.',
1204 'patterns': [r".*: warning: \[UnsynchronizedOverridesSynchronized\] .+"]},
1205 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001206 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001207 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001208 'Java: Java assert is used in test. For testing purposes Assert.* matchers should be used.',
1209 'patterns': [r".*: warning: \[UseCorrectAssertInTests\] .+"]},
1210 {'category': 'java',
1211 'severity': Severity.MEDIUM,
1212 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001213 'Java: Non-constant variable missing @Var annotation',
1214 'patterns': [r".*: warning: \[Var\] .+"]},
1215 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001216 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001217 'description':
1218 'Java: Because of spurious wakeups, Object.wait() and Condition.await() must always be called in a loop',
1219 'patterns': [r".*: warning: \[WaitNotInLoop\] .+"]},
1220 {'category': 'java',
Andreas Gampecf528ca2018-01-25 11:55:43 -08001221 'severity': Severity.MEDIUM,
1222 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001223 '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.',
1224 'patterns': [r".*: warning: \[WakelockReleasedDangerously\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08001225 {'category': 'java',
1226 'severity': Severity.HIGH,
1227 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001228 'Java: AndroidInjection.inject() should always be invoked before calling super.lifecycleMethod()',
1229 'patterns': [r".*: warning: \[AndroidInjectionBeforeSuper\] .+"]},
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001230 {'category': 'java',
1231 'severity': Severity.HIGH,
1232 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001233 'Java: Reference equality used to compare arrays',
1234 'patterns': [r".*: warning: \[ArrayEquals\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001235 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001236 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001237 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001238 'Java: Arrays.fill(Object[], Object) called with incompatible types.',
1239 'patterns': [r".*: warning: \[ArrayFillIncompatibleType\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001240 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001241 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001242 'description':
1243 'Java: hashcode method on array does not hash array contents',
1244 'patterns': [r".*: warning: \[ArrayHashCode\] .+"]},
1245 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001246 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001247 'description':
1248 'Java: Calling toString on an array does not provide useful information',
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001249 'patterns': [r".*: warning: \[ArrayToString\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001250 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001251 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001252 'description':
1253 'Java: Arrays.asList does not autobox primitive arrays, as one might expect.',
1254 'patterns': [r".*: warning: \[ArraysAsListPrimitiveArray\] .+"]},
1255 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001256 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001257 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001258 'Java: @AssistedInject and @Inject cannot be used on the same constructor.',
1259 'patterns': [r".*: warning: \[AssistedInjectAndInjectOnSameConstructor\] .+"]},
1260 {'category': 'java',
1261 'severity': Severity.HIGH,
1262 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001263 'Java: AsyncCallable should not return a null Future, only a Future whose result is null.',
1264 'patterns': [r".*: warning: \[AsyncCallableReturnsNull\] .+"]},
1265 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001266 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001267 'description':
1268 'Java: AsyncFunction should not return a null Future, only a Future whose result is null.',
1269 'patterns': [r".*: warning: \[AsyncFunctionReturnsNull\] .+"]},
1270 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001271 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001272 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001273 'Java: @AutoFactory and @Inject should not be used in the same type.',
1274 'patterns': [r".*: warning: \[AutoFactoryAtInject\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001275 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001276 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001277 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001278 'Java: Arguments to AutoValue constructor are in the wrong order',
1279 'patterns': [r".*: warning: \[AutoValueConstructorOrderChecker\] .+"]},
1280 {'category': 'java',
1281 'severity': Severity.HIGH,
1282 'description':
1283 'Java: Shift by an amount that is out of range',
1284 'patterns': [r".*: warning: \[BadShiftAmount\] .+"]},
Andreas Gampe2e987af2018-06-08 09:55:41 -07001285 {'category': 'java',
1286 'severity': Severity.HIGH,
1287 'description':
1288 'Java: Object serialized in Bundle may have been flattened to base type.',
1289 'patterns': [r".*: warning: \[BundleDeserializationCast\] .+"]},
1290 {'category': 'java',
1291 'severity': Severity.HIGH,
1292 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001293 '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.',
1294 'patterns': [r".*: warning: \[ChainingConstructorIgnoresParameter\] .+"]},
1295 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001296 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001297 'description':
1298 'Java: Ignored return value of method that is annotated with @CheckReturnValue',
1299 'patterns': [r".*: warning: \[CheckReturnValue\] .+"]},
1300 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001301 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001302 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001303 'Java: The source file name should match the name of the top-level class it contains',
1304 'patterns': [r".*: warning: \[ClassName\] .+"]},
1305 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001306 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001307 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001308 'Java: Incompatible type as argument to Object-accepting Java collections method',
1309 'patterns': [r".*: warning: \[CollectionIncompatibleType\] .+"]},
1310 {'category': 'java',
1311 'severity': Severity.HIGH,
1312 'description':
Chih-Hung Hsieh9be27762018-06-07 10:51:47 -07001313 r'Java: Implementing \'Comparable\u003cT>\' where T is not compatible with the implementing class.',
Andreas Gampecf528ca2018-01-25 11:55:43 -08001314 'patterns': [r".*: warning: \[ComparableType\] .+"]},
1315 {'category': 'java',
1316 'severity': Severity.HIGH,
1317 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001318 'Java: This comparison method violates the contract',
1319 'patterns': [r".*: warning: \[ComparisonContractViolated\] .+"]},
1320 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001321 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001322 'description':
1323 'Java: Comparison to value that is out of range for the compared type',
1324 'patterns': [r".*: warning: \[ComparisonOutOfRange\] .+"]},
1325 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001326 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001327 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001328 'Java: @CompatibleWith\'s value is not a type argument.',
1329 'patterns': [r".*: warning: \[CompatibleWithAnnotationMisuse\] .+"]},
1330 {'category': 'java',
1331 'severity': Severity.HIGH,
1332 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001333 'Java: Non-compile-time constant expression passed to parameter with @CompileTimeConstant type annotation.',
1334 'patterns': [r".*: warning: \[CompileTimeConstant\] .+"]},
1335 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001336 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001337 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001338 'Java: Non-trivial compile time constant boolean expressions shouldn\'t be used.',
1339 'patterns': [r".*: warning: \[ComplexBooleanConstant\] .+"]},
1340 {'category': 'java',
1341 'severity': Severity.HIGH,
1342 'description':
1343 '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.',
1344 'patterns': [r".*: warning: \[ConditionalExpressionNumericPromotion\] .+"]},
1345 {'category': 'java',
1346 'severity': Severity.HIGH,
1347 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001348 'Java: Compile-time constant expression overflows',
1349 'patterns': [r".*: warning: \[ConstantOverflow\] .+"]},
1350 {'category': 'java',
1351 'severity': Severity.HIGH,
1352 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001353 'Java: Dagger @Provides methods may not return null unless annotated with @Nullable',
1354 'patterns': [r".*: warning: \[DaggerProvidesNull\] .+"]},
1355 {'category': 'java',
1356 'severity': Severity.HIGH,
1357 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001358 'Java: Exception created but not thrown',
1359 'patterns': [r".*: warning: \[DeadException\] .+"]},
1360 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001361 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001362 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001363 'Java: Thread created but not started',
1364 'patterns': [r".*: warning: \[DeadThread\] .+"]},
1365 {'category': 'java',
1366 'severity': Severity.HIGH,
1367 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001368 'Java: Deprecated item is not annotated with @Deprecated',
1369 'patterns': [r".*: warning: \[DepAnn\] .+"]},
1370 {'category': 'java',
1371 'severity': Severity.HIGH,
1372 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001373 'Java: Division by integer literal zero',
1374 'patterns': [r".*: warning: \[DivZero\] .+"]},
1375 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001376 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001377 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001378 'Java: This method should not be called.',
1379 'patterns': [r".*: warning: \[DoNotCall\] .+"]},
1380 {'category': 'java',
1381 'severity': Severity.HIGH,
1382 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001383 'Java: Empty statement after if',
1384 'patterns': [r".*: warning: \[EmptyIf\] .+"]},
1385 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001386 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001387 'description':
1388 'Java: == NaN always returns false; use the isNaN methods instead',
1389 'patterns': [r".*: warning: \[EqualsNaN\] .+"]},
1390 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001391 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001392 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001393 'Java: == must be used in equals method to check equality to itself or an infinite loop will occur.',
1394 'patterns': [r".*: warning: \[EqualsReference\] .+"]},
1395 {'category': 'java',
1396 'severity': Severity.HIGH,
1397 'description':
1398 '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 -07001399 'patterns': [r".*: warning: \[ForOverride\] .+"]},
1400 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001401 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001402 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001403 'Java: Invalid printf-style format string',
1404 'patterns': [r".*: warning: \[FormatString\] .+"]},
1405 {'category': 'java',
1406 'severity': Severity.HIGH,
1407 'description':
1408 'Java: Invalid format string passed to formatting method.',
1409 'patterns': [r".*: warning: \[FormatStringAnnotation\] .+"]},
1410 {'category': 'java',
1411 'severity': Severity.HIGH,
1412 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001413 '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.',
1414 'patterns': [r".*: warning: \[FunctionalInterfaceMethodChanged\] .+"]},
1415 {'category': 'java',
1416 'severity': Severity.HIGH,
1417 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001418 'Java: Futures.getChecked requires a checked exception type with a standard constructor.',
1419 'patterns': [r".*: warning: \[FuturesGetCheckedIllegalExceptionType\] .+"]},
1420 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001421 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001422 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001423 'Java: DoubleMath.fuzzyEquals should never be used in an Object.equals() method',
1424 'patterns': [r".*: warning: \[FuzzyEqualsShouldNotBeUsedInEqualsMethod\] .+"]},
1425 {'category': 'java',
1426 'severity': Severity.HIGH,
1427 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001428 'Java: Calling getClass() on an annotation may return a proxy class',
1429 'patterns': [r".*: warning: \[GetClassOnAnnotation\] .+"]},
1430 {'category': 'java',
1431 'severity': Severity.HIGH,
1432 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001433 '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',
1434 'patterns': [r".*: warning: \[GetClassOnClass\] .+"]},
1435 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001436 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001437 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001438 'Java: Checks for unguarded accesses to fields and methods with @GuardedBy annotations',
1439 'patterns': [r".*: warning: \[GuardedBy\] .+"]},
1440 {'category': 'java',
1441 'severity': Severity.HIGH,
1442 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001443 'Java: Scope annotation on implementation class of AssistedInject factory is not allowed',
1444 'patterns': [r".*: warning: \[GuiceAssistedInjectScoping\] .+"]},
1445 {'category': 'java',
1446 'severity': Severity.HIGH,
1447 'description':
1448 'Java: A constructor cannot have two @Assisted parameters of the same type unless they are disambiguated with named @Assisted annotations.',
1449 'patterns': [r".*: warning: \[GuiceAssistedParameters\] .+"]},
1450 {'category': 'java',
1451 'severity': Severity.HIGH,
1452 'description':
1453 'Java: Although Guice allows injecting final fields, doing so is disallowed because the injected value may not be visible to other threads.',
1454 'patterns': [r".*: warning: \[GuiceInjectOnFinalField\] .+"]},
1455 {'category': 'java',
1456 'severity': Severity.HIGH,
1457 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001458 'Java: contains() is a legacy method that is equivalent to containsValue()',
1459 'patterns': [r".*: warning: \[HashtableContains\] .+"]},
1460 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001461 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001462 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001463 'Java: A binary expression where both operands are the same is usually incorrect.',
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001464 'patterns': [r".*: warning: \[IdentityBinaryExpression\] .+"]},
1465 {'category': 'java',
1466 'severity': Severity.HIGH,
1467 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001468 'Java: Type declaration annotated with @Immutable is not immutable',
1469 'patterns': [r".*: warning: \[Immutable\] .+"]},
1470 {'category': 'java',
1471 'severity': Severity.HIGH,
1472 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001473 'Java: Modifying an immutable collection is guaranteed to throw an exception and leave the collection unmodified',
1474 'patterns': [r".*: warning: \[ImmutableModification\] .+"]},
1475 {'category': 'java',
1476 'severity': Severity.HIGH,
1477 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001478 'Java: Passing argument to a generic method with an incompatible type.',
1479 'patterns': [r".*: warning: \[IncompatibleArgumentType\] .+"]},
1480 {'category': 'java',
1481 'severity': Severity.HIGH,
1482 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001483 'Java: The first argument to indexOf is a Unicode code point, and the second is the index to start the search from',
1484 'patterns': [r".*: warning: \[IndexOfChar\] .+"]},
1485 {'category': 'java',
1486 'severity': Severity.HIGH,
1487 'description':
1488 'Java: Conditional expression in varargs call contains array and non-array arguments',
1489 'patterns': [r".*: warning: \[InexactVarargsConditional\] .+"]},
1490 {'category': 'java',
1491 'severity': Severity.HIGH,
1492 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001493 'Java: This method always recurses, and will cause a StackOverflowError',
1494 'patterns': [r".*: warning: \[InfiniteRecursion\] .+"]},
1495 {'category': 'java',
1496 'severity': Severity.HIGH,
1497 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001498 'Java: A scoping annotation\'s Target should include TYPE and METHOD.',
1499 'patterns': [r".*: warning: \[InjectInvalidTargetingOnScopingAnnotation\] .+"]},
1500 {'category': 'java',
1501 'severity': Severity.HIGH,
1502 'description':
1503 'Java: Using more than one qualifier annotation on the same element is not allowed.',
1504 'patterns': [r".*: warning: \[InjectMoreThanOneQualifier\] .+"]},
1505 {'category': 'java',
1506 'severity': Severity.HIGH,
1507 'description':
1508 'Java: A class can be annotated with at most one scope annotation.',
1509 'patterns': [r".*: warning: \[InjectMoreThanOneScopeAnnotationOnClass\] .+"]},
1510 {'category': 'java',
1511 'severity': Severity.HIGH,
1512 'description':
1513 'Java: Scope annotation on an interface or abstact class is not allowed',
1514 'patterns': [r".*: warning: \[InjectScopeAnnotationOnInterfaceOrAbstractClass\] .+"]},
1515 {'category': 'java',
1516 'severity': Severity.HIGH,
1517 'description':
1518 'Java: Scoping and qualifier annotations must have runtime retention.',
1519 'patterns': [r".*: warning: \[InjectScopeOrQualifierAnnotationRetention\] .+"]},
1520 {'category': 'java',
1521 'severity': Severity.HIGH,
1522 'description':
1523 'Java: Injected constructors cannot be optional nor have binding annotations',
1524 'patterns': [r".*: warning: \[InjectedConstructorAnnotations\] .+"]},
1525 {'category': 'java',
1526 'severity': Severity.HIGH,
1527 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001528 'Java: A standard cryptographic operation is used in a mode that is prone to vulnerabilities',
1529 'patterns': [r".*: warning: \[InsecureCryptoUsage\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001530 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001531 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001532 'description':
1533 'Java: Invalid syntax used for a regular expression',
1534 'patterns': [r".*: warning: \[InvalidPatternSyntax\] .+"]},
1535 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001536 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001537 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001538 'Java: Invalid time zone identifier. TimeZone.getTimeZone(String) will silently return GMT instead of the time zone you intended.',
1539 'patterns': [r".*: warning: \[InvalidTimeZoneID\] .+"]},
1540 {'category': 'java',
1541 'severity': Severity.HIGH,
1542 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001543 'Java: The argument to Class#isInstance(Object) should not be a Class',
1544 'patterns': [r".*: warning: \[IsInstanceOfClass\] .+"]},
1545 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001546 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001547 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001548 'Java: Log tag too long, cannot exceed 23 characters.',
1549 'patterns': [r".*: warning: \[IsLoggableTagLength\] .+"]},
1550 {'category': 'java',
1551 'severity': Severity.HIGH,
1552 'description':
Chih-Hung Hsieh9be27762018-06-07 10:51:47 -07001553 r'Java: Path implements Iterable\u003cPath>; prefer Collection\u003cPath> for clarity',
Andreas Gampecf528ca2018-01-25 11:55:43 -08001554 'patterns': [r".*: warning: \[IterablePathParameter\] .+"]},
1555 {'category': 'java',
1556 'severity': Severity.HIGH,
1557 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001558 'Java: jMock tests must have a @RunWith(JMock.class) annotation, or the Mockery field must have a @Rule JUnit annotation',
1559 'patterns': [r".*: warning: \[JMockTestWithoutRunWithOrRuleAnnotation\] .+"]},
1560 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001561 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001562 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001563 '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 -07001564 'patterns': [r".*: warning: \[JUnit3TestNotRun\] .+"]},
1565 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001566 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001567 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001568 'Java: This method should be static',
1569 'patterns': [r".*: warning: \[JUnit4ClassAnnotationNonStatic\] .+"]},
1570 {'category': 'java',
1571 'severity': Severity.HIGH,
1572 'description':
1573 'Java: setUp() method will not be run; please add JUnit\'s @Before annotation',
Ian Rogers6e520032016-05-13 08:59:00 -07001574 'patterns': [r".*: warning: \[JUnit4SetUpNotRun\] .+"]},
1575 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001576 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001577 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001578 'Java: tearDown() method will not be run; please add JUnit\'s @After annotation',
Ian Rogers6e520032016-05-13 08:59:00 -07001579 'patterns': [r".*: warning: \[JUnit4TearDownNotRun\] .+"]},
1580 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001581 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001582 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001583 'Java: This looks like a test method but is not run; please add @Test and @Ignore, or, if this is a helper method, reduce its visibility.',
Ian Rogers6e520032016-05-13 08:59:00 -07001584 'patterns': [r".*: warning: \[JUnit4TestNotRun\] .+"]},
1585 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001586 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001587 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001588 'Java: An object is tested for reference equality to itself using JUnit library.',
1589 'patterns': [r".*: warning: \[JUnitAssertSameCheck\] .+"]},
1590 {'category': 'java',
1591 'severity': Severity.HIGH,
1592 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001593 'Java: Abstract and default methods are not injectable with javax.inject.Inject',
1594 'patterns': [r".*: warning: \[JavaxInjectOnAbstractMethod\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08001595 {'category': 'java',
1596 'severity': Severity.HIGH,
1597 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001598 'Java: @javax.inject.Inject cannot be put on a final field.',
1599 'patterns': [r".*: warning: \[JavaxInjectOnFinalField\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08001600 {'category': 'java',
1601 'severity': Severity.HIGH,
1602 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001603 'Java: This pattern will silently corrupt certain byte sequences from the serialized protocol message. Use ByteString or byte[] directly',
1604 'patterns': [r".*: warning: \[LiteByteStringUtf8\] .+"]},
1605 {'category': 'java',
1606 'severity': Severity.HIGH,
1607 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001608 'Java: This method does not acquire the locks specified by its @LockMethod annotation',
1609 'patterns': [r".*: warning: \[LockMethodChecker\] .+"]},
1610 {'category': 'java',
1611 'severity': Severity.HIGH,
1612 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001613 'Java: Prefer \'L\' to \'l\' for the suffix to long literals',
1614 'patterns': [r".*: warning: \[LongLiteralLowerCaseSuffix\] .+"]},
Andreas Gampe2e987af2018-06-08 09:55:41 -07001615 {'category': 'java',
1616 'severity': Severity.HIGH,
1617 'description':
1618 'Java: Loop condition is never modified in loop body.',
1619 'patterns': [r".*: warning: \[LoopConditionChecker\] .+"]},
1620 {'category': 'java',
1621 'severity': Severity.HIGH,
1622 'description':
1623 'Java: Certain resources in `android.R.string` have names that do not match their content',
1624 'patterns': [r".*: warning: \[MislabeledAndroidString\] .+"]},
1625 {'category': 'java',
1626 'severity': Severity.HIGH,
1627 'description':
1628 'Java: Overriding method is missing a call to overridden super method',
1629 'patterns': [r".*: warning: \[MissingSuperCall\] .+"]},
1630 {'category': 'java',
1631 'severity': Severity.HIGH,
1632 'description':
1633 'Java: Use of "YYYY" (week year) in a date pattern without "ww" (week in year). You probably meant to use "yyyy" (year) instead.',
1634 'patterns': [r".*: warning: \[MisusedWeekYear\] .+"]},
1635 {'category': 'java',
1636 'severity': Severity.HIGH,
1637 'description':
1638 'Java: A bug in Mockito will cause this test to fail at runtime with a ClassCastException',
1639 'patterns': [r".*: warning: \[MockitoCast\] .+"]},
1640 {'category': 'java',
1641 'severity': Severity.HIGH,
1642 'description':
1643 'Java: Missing method call for verify(mock) here',
1644 'patterns': [r".*: warning: \[MockitoUsage\] .+"]},
1645 {'category': 'java',
1646 'severity': Severity.HIGH,
1647 'description':
1648 'Java: Using a collection function with itself as the argument.',
1649 'patterns': [r".*: warning: \[ModifyingCollectionWithItself\] .+"]},
1650 {'category': 'java',
1651 'severity': Severity.HIGH,
1652 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001653 'Java: This class has more than one @Inject-annotated constructor. Please remove the @Inject annotation from all but one of them.',
1654 'patterns': [r".*: warning: \[MoreThanOneInjectableConstructor\] .+"]},
1655 {'category': 'java',
1656 'severity': Severity.HIGH,
1657 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001658 'Java: The result of this method must be closed.',
1659 'patterns': [r".*: warning: \[MustBeClosedChecker\] .+"]},
1660 {'category': 'java',
1661 'severity': Severity.HIGH,
1662 'description':
1663 'Java: The first argument to nCopies is the number of copies, and the second is the item to copy',
1664 'patterns': [r".*: warning: \[NCopiesOfChar\] .+"]},
1665 {'category': 'java',
1666 'severity': Severity.HIGH,
1667 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001668 'Java: @NoAllocation was specified on this method, but something was found that would trigger an allocation',
1669 'patterns': [r".*: warning: \[NoAllocation\] .+"]},
1670 {'category': 'java',
1671 'severity': Severity.HIGH,
1672 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001673 'Java: Static import of type uses non-canonical name',
1674 'patterns': [r".*: warning: \[NonCanonicalStaticImport\] .+"]},
1675 {'category': 'java',
1676 'severity': Severity.HIGH,
1677 'description':
1678 'Java: @CompileTimeConstant parameters should be final or effectively final',
1679 'patterns': [r".*: warning: \[NonFinalCompileTimeConstant\] .+"]},
1680 {'category': 'java',
1681 'severity': Severity.HIGH,
1682 'description':
1683 'Java: Calling getAnnotation on an annotation that is not retained at runtime.',
1684 'patterns': [r".*: warning: \[NonRuntimeAnnotation\] .+"]},
1685 {'category': 'java',
1686 'severity': Severity.HIGH,
1687 'description':
1688 'Java: This conditional expression may evaluate to null, which will result in an NPE when the result is unboxed.',
1689 'patterns': [r".*: warning: \[NullTernary\] .+"]},
1690 {'category': 'java',
1691 'severity': Severity.HIGH,
1692 'description':
1693 'Java: Numeric comparison using reference equality instead of value equality',
1694 'patterns': [r".*: warning: \[NumericEquality\] .+"]},
1695 {'category': 'java',
1696 'severity': Severity.HIGH,
1697 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001698 'Java: Comparison using reference equality instead of value equality',
1699 'patterns': [r".*: warning: \[OptionalEquality\] .+"]},
Andreas Gampe2e987af2018-06-08 09:55:41 -07001700 {'category': 'java',
1701 'severity': Severity.HIGH,
1702 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001703 'Java: Annotations cannot be both Scope annotations and Qualifier annotations: this causes confusion when trying to use them.',
1704 'patterns': [r".*: warning: \[OverlappingQualifierAndScopeAnnotation\] .+"]},
1705 {'category': 'java',
1706 'severity': Severity.HIGH,
1707 'description':
1708 'Java: This method is not annotated with @Inject, but it overrides a method that is annotated with @javax.inject.Inject. The method will not be Injected.',
1709 'patterns': [r".*: warning: \[OverridesJavaxInjectableMethod\] .+"]},
Andreas Gampe2e987af2018-06-08 09:55:41 -07001710 {'category': 'java',
1711 'severity': Severity.HIGH,
1712 'description':
1713 'Java: Declaring types inside package-info.java files is very bad form',
1714 'patterns': [r".*: warning: \[PackageInfo\] .+"]},
1715 {'category': 'java',
1716 'severity': Severity.HIGH,
1717 'description':
1718 'Java: Method parameter has wrong package',
1719 'patterns': [r".*: warning: \[ParameterPackage\] .+"]},
1720 {'category': 'java',
1721 'severity': Severity.HIGH,
1722 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001723 'Java: Detects classes which implement Parcelable but don\'t have CREATOR',
1724 'patterns': [r".*: warning: \[ParcelableCreator\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08001725 {'category': 'java',
1726 'severity': Severity.HIGH,
1727 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001728 'Java: Literal passed as first argument to Preconditions.checkNotNull() can never be null',
1729 'patterns': [r".*: warning: \[PreconditionsCheckNotNull\] .+"]},
1730 {'category': 'java',
1731 'severity': Severity.HIGH,
1732 'description':
1733 'Java: First argument to `Preconditions.checkNotNull()` is a primitive rather than an object reference',
1734 'patterns': [r".*: warning: \[PreconditionsCheckNotNullPrimitive\] .+"]},
1735 {'category': 'java',
1736 'severity': Severity.HIGH,
1737 'description':
1738 'Java: Using ::equals as an incompatible Predicate; the predicate will always return false',
1739 'patterns': [r".*: warning: \[PredicateIncompatibleType\] .+"]},
1740 {'category': 'java',
1741 'severity': Severity.HIGH,
1742 'description':
1743 '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.',
1744 'patterns': [r".*: warning: \[PrivateSecurityContractProtoAccess\] .+"]},
1745 {'category': 'java',
1746 'severity': Severity.HIGH,
1747 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001748 'Java: Protobuf fields cannot be null',
1749 'patterns': [r".*: warning: \[ProtoFieldNullComparison\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08001750 {'category': 'java',
1751 'severity': Severity.HIGH,
1752 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001753 'Java: Comparing protobuf fields of type String using reference equality',
1754 'patterns': [r".*: warning: \[ProtoStringFieldReferenceEquality\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08001755 {'category': 'java',
1756 'severity': Severity.HIGH,
1757 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001758 'Java: To get the tag number of a protocol buffer enum, use getNumber() instead.',
1759 'patterns': [r".*: warning: \[ProtocolBufferOrdinal\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08001760 {'category': 'java',
1761 'severity': Severity.HIGH,
1762 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001763 'Java: @Provides methods need to be declared in a Module to have any effect.',
1764 'patterns': [r".*: warning: \[ProvidesMethodOutsideOfModule\] .+"]},
1765 {'category': 'java',
1766 'severity': Severity.HIGH,
1767 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001768 'Java: Casting a random number in the range [0.0, 1.0) to an integer or long always results in 0.',
1769 'patterns': [r".*: warning: \[RandomCast\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08001770 {'category': 'java',
1771 'severity': Severity.HIGH,
1772 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001773 'Java: Use Random.nextInt(int). Random.nextInt() % n can have negative results',
1774 'patterns': [r".*: warning: \[RandomModInteger\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08001775 {'category': 'java',
1776 'severity': Severity.HIGH,
1777 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001778 'Java: Return value of android.graphics.Rect.intersect() must be checked',
1779 'patterns': [r".*: warning: \[RectIntersectReturnValueIgnored\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08001780 {'category': 'java',
1781 'severity': Severity.HIGH,
1782 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001783 'Java: Use of method or class annotated with @RestrictTo',
1784 'patterns': [r".*: warning: \[RestrictTo\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08001785 {'category': 'java',
1786 'severity': Severity.HIGH,
1787 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001788 'Java: Check for non-whitelisted callers to RestrictedApiChecker.',
1789 'patterns': [r".*: warning: \[RestrictedApiChecker\] .+"]},
1790 {'category': 'java',
1791 'severity': Severity.HIGH,
1792 'description':
1793 'Java: Return value of this method must be used',
1794 'patterns': [r".*: warning: \[ReturnValueIgnored\] .+"]},
1795 {'category': 'java',
1796 'severity': Severity.HIGH,
1797 'description':
1798 'Java: Variable assigned to itself',
1799 'patterns': [r".*: warning: \[SelfAssignment\] .+"]},
1800 {'category': 'java',
1801 'severity': Severity.HIGH,
1802 'description':
1803 'Java: An object is compared to itself',
1804 'patterns': [r".*: warning: \[SelfComparison\] .+"]},
1805 {'category': 'java',
1806 'severity': Severity.HIGH,
1807 'description':
1808 'Java: Testing an object for equality with itself will always be true.',
1809 'patterns': [r".*: warning: \[SelfEquals\] .+"]},
1810 {'category': 'java',
1811 'severity': Severity.HIGH,
1812 'description':
1813 'Java: This method must be called with an even number of arguments.',
1814 'patterns': [r".*: warning: \[ShouldHaveEvenArgs\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08001815 {'category': 'java',
1816 'severity': Severity.HIGH,
1817 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001818 'Java: Comparison of a size >= 0 is always true, did you intend to check for non-emptiness?',
1819 'patterns': [r".*: warning: \[SizeGreaterThanOrEqualsZero\] .+"]},
1820 {'category': 'java',
1821 'severity': Severity.HIGH,
1822 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001823 'Java: Static and default interface methods are not natively supported on older Android devices. ',
1824 'patterns': [r".*: warning: \[StaticOrDefaultInterfaceMethod\] .+"]},
Andreas Gampe2e987af2018-06-08 09:55:41 -07001825 {'category': 'java',
1826 'severity': Severity.HIGH,
1827 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001828 'Java: Calling toString on a Stream does not provide useful information',
1829 'patterns': [r".*: warning: \[StreamToString\] .+"]},
Andreas Gampe2e987af2018-06-08 09:55:41 -07001830 {'category': 'java',
1831 'severity': Severity.HIGH,
1832 'description':
1833 'Java: StringBuilder does not have a char constructor; this invokes the int constructor.',
1834 'patterns': [r".*: warning: \[StringBuilderInitWithChar\] .+"]},
1835 {'category': 'java',
1836 'severity': Severity.HIGH,
1837 'description':
1838 'Java: Suppressing "deprecated" is probably a typo for "deprecation"',
1839 'patterns': [r".*: warning: \[SuppressWarningsDeprecated\] .+"]},
1840 {'category': 'java',
1841 'severity': Severity.HIGH,
1842 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001843 'Java: throwIfUnchecked(knownCheckedException) is a no-op.',
1844 'patterns': [r".*: warning: \[ThrowIfUncheckedKnownChecked\] .+"]},
1845 {'category': 'java',
1846 'severity': Severity.HIGH,
1847 'description':
1848 'Java: Throwing \'null\' always results in a NullPointerException being thrown.',
1849 'patterns': [r".*: warning: \[ThrowNull\] .+"]},
1850 {'category': 'java',
1851 'severity': Severity.HIGH,
1852 'description':
1853 'Java: isEqualTo should not be used to test an object for equality with itself; the assertion will never fail.',
1854 'patterns': [r".*: warning: \[TruthSelfEquals\] .+"]},
1855 {'category': 'java',
1856 'severity': Severity.HIGH,
1857 'description':
1858 'Java: Catching Throwable/Error masks failures from fail() or assert*() in the try block',
1859 'patterns': [r".*: warning: \[TryFailThrowable\] .+"]},
1860 {'category': 'java',
1861 'severity': Severity.HIGH,
1862 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001863 'Java: Type parameter used as type qualifier',
1864 'patterns': [r".*: warning: \[TypeParameterQualifier\] .+"]},
1865 {'category': 'java',
1866 'severity': Severity.HIGH,
1867 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001868 'Java: This method does not acquire the locks specified by its @UnlockMethod annotation',
1869 'patterns': [r".*: warning: \[UnlockMethod\] .+"]},
1870 {'category': 'java',
1871 'severity': Severity.HIGH,
1872 'description':
1873 'Java: Non-generic methods should not be invoked with type arguments',
1874 'patterns': [r".*: warning: \[UnnecessaryTypeArgument\] .+"]},
1875 {'category': 'java',
1876 'severity': Severity.HIGH,
1877 'description':
1878 'Java: Instance created but never used',
1879 'patterns': [r".*: warning: \[UnusedAnonymousClass\] .+"]},
1880 {'category': 'java',
1881 'severity': Severity.HIGH,
1882 'description':
1883 'Java: Collection is modified in place, but the result is not used',
1884 'patterns': [r".*: warning: \[UnusedCollectionModifiedInPlace\] .+"]},
1885 {'category': 'java',
1886 'severity': Severity.HIGH,
1887 'description':
1888 'Java: `var` should not be used as a type name.',
1889 'patterns': [r".*: warning: \[VarTypeName\] .+"]},
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001890
1891 # End warnings generated by Error Prone
Ian Rogers32bb9bd2016-05-09 23:19:42 -07001892
Ian Rogers6e520032016-05-13 08:59:00 -07001893 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001894 'severity': Severity.UNKNOWN,
Ian Rogers6e520032016-05-13 08:59:00 -07001895 'description': 'Java: Unclassified/unrecognized warnings',
1896 'patterns': [r".*: warning: \[.+\] .+"]},
Ian Rogers32bb9bd2016-05-09 23:19:42 -07001897
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001898 {'category': 'aapt', 'severity': Severity.MEDIUM,
1899 'description': 'aapt: No default translation',
1900 'patterns': [r".*: warning: string '.+' has no default translation in .*"]},
1901 {'category': 'aapt', 'severity': Severity.MEDIUM,
1902 'description': 'aapt: Missing default or required localization',
1903 'patterns': [r".*: warning: \*\*\*\* string '.+' has no default or required localization for '.+' in .+"]},
1904 {'category': 'aapt', 'severity': Severity.MEDIUM,
1905 'description': 'aapt: String marked untranslatable, but translation exists',
1906 'patterns': [r".*: warning: string '.+' in .* marked untranslatable but exists in locale '??_??'"]},
1907 {'category': 'aapt', 'severity': Severity.MEDIUM,
1908 'description': 'aapt: empty span in string',
1909 'patterns': [r".*: warning: empty '.+' span found in text '.+"]},
1910 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1911 'description': 'Taking address of temporary',
1912 'patterns': [r".*: warning: taking address of temporary"]},
1913 {'category': 'C/C++', 'severity': Severity.MEDIUM,
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07001914 'description': 'Taking address of packed member',
1915 'patterns': [r".*: warning: taking address of packed member"]},
1916 {'category': 'C/C++', 'severity': Severity.MEDIUM,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001917 'description': 'Possible broken line continuation',
1918 'patterns': [r".*: warning: backslash and newline separated by space"]},
1919 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wundefined-var-template',
1920 'description': 'Undefined variable template',
1921 'patterns': [r".*: warning: instantiation of variable .* no definition is available"]},
1922 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wundefined-inline',
1923 'description': 'Inline function is not defined',
1924 'patterns': [r".*: warning: inline function '.*' is not defined"]},
1925 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Warray-bounds',
1926 'description': 'Array subscript out of bounds',
1927 'patterns': [r".*: warning: array subscript is above array bounds",
1928 r".*: warning: Array subscript is undefined",
1929 r".*: warning: array subscript is below array bounds"]},
1930 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1931 'description': 'Excess elements in initializer',
1932 'patterns': [r".*: warning: excess elements in .+ initializer"]},
1933 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1934 'description': 'Decimal constant is unsigned only in ISO C90',
1935 'patterns': [r".*: warning: this decimal constant is unsigned only in ISO C90"]},
1936 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmain',
1937 'description': 'main is usually a function',
1938 'patterns': [r".*: warning: 'main' is usually a function"]},
1939 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1940 'description': 'Typedef ignored',
1941 'patterns': [r".*: warning: 'typedef' was ignored in this declaration"]},
1942 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Waddress',
1943 'description': 'Address always evaluates to true',
1944 'patterns': [r".*: warning: the address of '.+' will always evaluate as 'true'"]},
1945 {'category': 'C/C++', 'severity': Severity.FIXMENOW,
1946 'description': 'Freeing a non-heap object',
1947 'patterns': [r".*: warning: attempt to free a non-heap object '.+'"]},
1948 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wchar-subscripts',
1949 'description': 'Array subscript has type char',
1950 'patterns': [r".*: warning: array subscript .+ type 'char'.+Wchar-subscripts"]},
1951 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1952 'description': 'Constant too large for type',
1953 'patterns': [r".*: warning: integer constant is too large for '.+' type"]},
1954 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Woverflow',
1955 'description': 'Constant too large for type, truncated',
1956 'patterns': [r".*: warning: large integer implicitly truncated to unsigned type"]},
1957 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Winteger-overflow',
1958 'description': 'Overflow in expression',
1959 'patterns': [r".*: warning: overflow in expression; .*Winteger-overflow"]},
1960 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Woverflow',
1961 'description': 'Overflow in implicit constant conversion',
1962 'patterns': [r".*: warning: overflow in implicit constant conversion"]},
1963 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1964 'description': 'Declaration does not declare anything',
1965 'patterns': [r".*: warning: declaration 'class .+' does not declare anything"]},
1966 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wreorder',
1967 'description': 'Initialization order will be different',
1968 'patterns': [r".*: warning: '.+' will be initialized after",
1969 r".*: warning: field .+ will be initialized after .+Wreorder"]},
1970 {'category': 'cont.', 'severity': Severity.SKIP,
1971 'description': 'skip, ....',
1972 'patterns': [r".*: warning: '.+'"]},
1973 {'category': 'cont.', 'severity': Severity.SKIP,
1974 'description': 'skip, base ...',
1975 'patterns': [r".*: warning: base '.+'"]},
1976 {'category': 'cont.', 'severity': Severity.SKIP,
1977 'description': 'skip, when initialized here',
1978 'patterns': [r".*: warning: when initialized here"]},
1979 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-parameter-type',
1980 'description': 'Parameter type not specified',
1981 'patterns': [r".*: warning: type of '.+' defaults to 'int'"]},
1982 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-declarations',
1983 'description': 'Missing declarations',
1984 'patterns': [r".*: warning: declaration does not declare anything"]},
1985 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-noreturn',
1986 'description': 'Missing noreturn',
1987 'patterns': [r".*: warning: function '.*' could be declared with attribute 'noreturn'"]},
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001988 # pylint:disable=anomalous-backslash-in-string
1989 # TODO(chh): fix the backslash pylint warning.
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001990 {'category': 'gcc', 'severity': Severity.MEDIUM,
1991 'description': 'Invalid option for C file',
1992 'patterns': [r".*: warning: command line option "".+"" is valid for C\+\+\/ObjC\+\+ but not for C"]},
1993 {'category': 'C/C++', 'severity': Severity.MEDIUM,
1994 'description': 'User warning',
1995 'patterns': [r".*: warning: #warning "".+"""]},
1996 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wvexing-parse',
1997 'description': 'Vexing parsing problem',
1998 'patterns': [r".*: warning: empty parentheses interpreted as a function declaration"]},
1999 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wextra',
2000 'description': 'Dereferencing void*',
2001 'patterns': [r".*: warning: dereferencing 'void \*' pointer"]},
2002 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2003 'description': 'Comparison of pointer and integer',
2004 'patterns': [r".*: warning: ordered comparison of pointer with integer zero",
2005 r".*: warning: .*comparison between pointer and integer"]},
2006 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2007 'description': 'Use of error-prone unary operator',
2008 'patterns': [r".*: warning: use of unary operator that may be intended as compound assignment"]},
2009 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wwrite-strings',
2010 'description': 'Conversion of string constant to non-const char*',
2011 'patterns': [r".*: warning: deprecated conversion from string constant to '.+'"]},
2012 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wstrict-prototypes',
2013 'description': 'Function declaration isn''t a prototype',
2014 'patterns': [r".*: warning: function declaration isn't a prototype"]},
2015 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wignored-qualifiers',
2016 'description': 'Type qualifiers ignored on function return value',
2017 'patterns': [r".*: warning: type qualifiers ignored on function return type",
2018 r".*: warning: .+ type qualifier .+ has no effect .+Wignored-qualifiers"]},
2019 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2020 'description': '<foo> declared inside parameter list, scope limited to this definition',
2021 'patterns': [r".*: warning: '.+' declared inside parameter list"]},
2022 {'category': 'cont.', 'severity': Severity.SKIP,
2023 'description': 'skip, its scope is only this ...',
2024 'patterns': [r".*: warning: its scope is only this definition or declaration, which is probably not what you want"]},
2025 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wcomment',
2026 'description': 'Line continuation inside comment',
2027 'patterns': [r".*: warning: multi-line comment"]},
2028 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wcomment',
2029 'description': 'Comment inside comment',
2030 'patterns': [r".*: warning: "".+"" within comment"]},
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07002031 # Warning "value stored is never read" could be from clang-tidy or clang static analyzer.
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002032 {'category': 'C/C++', 'severity': Severity.ANALYZER,
2033 'description': 'clang-analyzer Value stored is never read',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002034 'patterns': [r".*: warning: Value stored to .+ is never read.*clang-analyzer-deadcode.DeadStores"]},
2035 {'category': 'C/C++', 'severity': Severity.LOW,
2036 'description': 'Value stored is never read',
2037 'patterns': [r".*: warning: Value stored to .+ is never read"]},
2038 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wdeprecated-declarations',
2039 'description': 'Deprecated declarations',
2040 'patterns': [r".*: warning: .+ is deprecated.+deprecated-declarations"]},
2041 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wdeprecated-register',
2042 'description': 'Deprecated register',
2043 'patterns': [r".*: warning: 'register' storage class specifier is deprecated"]},
2044 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wpointer-sign',
2045 'description': 'Converts between pointers to integer types with different sign',
2046 'patterns': [r".*: warning: .+ converts between pointers to integer types with different sign"]},
2047 {'category': 'C/C++', 'severity': Severity.HARMLESS,
2048 'description': 'Extra tokens after #endif',
2049 'patterns': [r".*: warning: extra tokens at end of #endif directive"]},
2050 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wenum-compare',
2051 'description': 'Comparison between different enums',
2052 'patterns': [r".*: warning: comparison between '.+' and '.+'.+Wenum-compare"]},
2053 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wconversion',
2054 'description': 'Conversion may change value',
2055 'patterns': [r".*: warning: converting negative value '.+' to '.+'",
2056 r".*: warning: conversion to '.+' .+ may (alter|change)"]},
2057 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wconversion-null',
2058 'description': 'Converting to non-pointer type from NULL',
2059 'patterns': [r".*: warning: converting to non-pointer type '.+' from NULL"]},
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07002060 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsign-conversion',
2061 'description': 'Implicit sign conversion',
2062 'patterns': [r".*: warning: implicit conversion changes signedness"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002063 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wnull-conversion',
2064 'description': 'Converting NULL to non-pointer type',
2065 'patterns': [r".*: warning: implicit conversion of NULL constant to '.+'"]},
2066 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wnon-literal-null-conversion',
2067 'description': 'Zero used as null pointer',
2068 'patterns': [r".*: warning: expression .* zero treated as a null pointer constant"]},
2069 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2070 'description': 'Implicit conversion changes value',
2071 'patterns': [r".*: warning: implicit conversion .* changes value from .* to .*-conversion"]},
2072 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2073 'description': 'Passing NULL as non-pointer argument',
2074 'patterns': [r".*: warning: passing NULL to non-pointer argument [0-9]+ of '.+'"]},
2075 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wctor-dtor-privacy',
2076 'description': 'Class seems unusable because of private ctor/dtor',
2077 'patterns': [r".*: warning: all member functions in class '.+' are private"]},
Marco Nelissen594375d2009-07-14 09:04:04 -07002078 # 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 -07002079 {'category': 'C/C++', 'severity': Severity.SKIP, 'option': '-Wctor-dtor-privacy',
2080 'description': 'Class seems unusable because of private ctor/dtor',
2081 'patterns': [r".*: warning: 'class .+' only defines a private destructor and has no friends"]},
2082 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wctor-dtor-privacy',
2083 'description': 'Class seems unusable because of private ctor/dtor',
2084 'patterns': [r".*: warning: 'class .+' only defines private constructors and has no friends"]},
2085 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wgnu-static-float-init',
2086 'description': 'In-class initializer for static const float/double',
2087 'patterns': [r".*: warning: in-class initializer for static data member of .+const (float|double)"]},
2088 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wpointer-arith',
2089 'description': 'void* used in arithmetic',
2090 'patterns': [r".*: warning: pointer of type 'void \*' used in (arithmetic|subtraction)",
2091 r".*: warning: arithmetic on .+ to void is a GNU extension.*Wpointer-arith",
2092 r".*: warning: wrong type argument to increment"]},
2093 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsign-promo',
2094 'description': 'Overload resolution chose to promote from unsigned or enum to signed type',
2095 'patterns': [r".*: warning: passing '.+' chooses '.+' over '.+'.*Wsign-promo"]},
2096 {'category': 'cont.', 'severity': Severity.SKIP,
2097 'description': 'skip, in call to ...',
2098 'patterns': [r".*: warning: in call to '.+'"]},
2099 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wextra',
2100 'description': 'Base should be explicitly initialized in copy constructor',
2101 'patterns': [r".*: warning: base class '.+' should be explicitly initialized in the copy constructor"]},
2102 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2103 'description': 'VLA has zero or negative size',
2104 'patterns': [r".*: warning: Declared variable-length array \(VLA\) has .+ size"]},
2105 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2106 'description': 'Return value from void function',
2107 'patterns': [r".*: warning: 'return' with a value, in function returning void"]},
2108 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'multichar',
2109 'description': 'Multi-character character constant',
2110 'patterns': [r".*: warning: multi-character character constant"]},
2111 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'writable-strings',
2112 'description': 'Conversion from string literal to char*',
2113 'patterns': [r".*: warning: .+ does not allow conversion from string literal to 'char \*'"]},
2114 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wextra-semi',
2115 'description': 'Extra \';\'',
2116 'patterns': [r".*: warning: extra ';' .+extra-semi"]},
2117 {'category': 'C/C++', 'severity': Severity.LOW,
2118 'description': 'Useless specifier',
2119 'patterns': [r".*: warning: useless storage class specifier in empty declaration"]},
2120 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wduplicate-decl-specifier',
2121 'description': 'Duplicate declaration specifier',
2122 'patterns': [r".*: warning: duplicate '.+' declaration specifier"]},
2123 {'category': 'logtags', 'severity': Severity.LOW,
2124 'description': 'Duplicate logtag',
2125 'patterns': [r".*: warning: tag \".+\" \(.+\) duplicated in .+"]},
2126 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'typedef-redefinition',
2127 'description': 'Typedef redefinition',
2128 'patterns': [r".*: warning: redefinition of typedef '.+' is a C11 feature"]},
2129 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'gnu-designator',
2130 'description': 'GNU old-style field designator',
2131 'patterns': [r".*: warning: use of GNU old-style field designator extension"]},
2132 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'missing-field-initializers',
2133 'description': 'Missing field initializers',
2134 'patterns': [r".*: warning: missing field '.+' initializer"]},
2135 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'missing-braces',
2136 'description': 'Missing braces',
2137 'patterns': [r".*: warning: suggest braces around initialization of",
2138 r".*: warning: too many braces around scalar initializer .+Wmany-braces-around-scalar-init",
2139 r".*: warning: braces around scalar initializer"]},
2140 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'sign-compare',
2141 'description': 'Comparison of integers of different signs',
2142 'patterns': [r".*: warning: comparison of integers of different signs.+sign-compare"]},
2143 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'dangling-else',
2144 'description': 'Add braces to avoid dangling else',
2145 'patterns': [r".*: warning: add explicit braces to avoid dangling else"]},
2146 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'initializer-overrides',
2147 'description': 'Initializer overrides prior initialization',
2148 'patterns': [r".*: warning: initializer overrides prior initialization of this subobject"]},
2149 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'self-assign',
2150 'description': 'Assigning value to self',
2151 'patterns': [r".*: warning: explicitly assigning value of .+ to itself"]},
2152 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'gnu-variable-sized-type-not-at-end',
2153 'description': 'GNU extension, variable sized type not at end',
2154 'patterns': [r".*: warning: field '.+' with variable sized type '.+' not at the end of a struct or class"]},
2155 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'tautological-constant-out-of-range-compare',
2156 'description': 'Comparison of constant is always false/true',
2157 'patterns': [r".*: comparison of .+ is always .+Wtautological-constant-out-of-range-compare"]},
2158 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'overloaded-virtual',
2159 'description': 'Hides overloaded virtual function',
2160 'patterns': [r".*: '.+' hides overloaded virtual function"]},
2161 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'incompatible-pointer-types',
2162 'description': 'Incompatible pointer types',
2163 'patterns': [r".*: warning: incompatible pointer types .+Wincompatible-pointer-types"]},
2164 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'asm-operand-widths',
2165 'description': 'ASM value size does not match register size',
2166 'patterns': [r".*: warning: value size does not match register size specified by the constraint and modifier"]},
2167 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'tautological-compare',
2168 'description': 'Comparison of self is always false',
2169 'patterns': [r".*: self-comparison always evaluates to false"]},
2170 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'constant-logical-operand',
2171 'description': 'Logical op with constant operand',
2172 'patterns': [r".*: use of logical '.+' with constant operand"]},
2173 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'literal-suffix',
2174 'description': 'Needs a space between literal and string macro',
2175 'patterns': [r".*: warning: invalid suffix on literal.+ requires a space .+Wliteral-suffix"]},
2176 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '#warnings',
2177 'description': 'Warnings from #warning',
2178 'patterns': [r".*: warning: .+-W#warnings"]},
2179 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'absolute-value',
2180 'description': 'Using float/int absolute value function with int/float argument',
2181 'patterns': [r".*: warning: using .+ absolute value function .+ when argument is .+ type .+Wabsolute-value",
2182 r".*: warning: absolute value function '.+' given .+ which may cause truncation .+Wabsolute-value"]},
2183 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wc++11-extensions',
2184 'description': 'Using C++11 extensions',
2185 'patterns': [r".*: warning: 'auto' type specifier is a C\+\+11 extension"]},
2186 {'category': 'C/C++', 'severity': Severity.LOW,
2187 'description': 'Refers to implicitly defined namespace',
2188 'patterns': [r".*: warning: using directive refers to implicitly-defined namespace .+"]},
2189 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Winvalid-pp-token',
2190 'description': 'Invalid pp token',
2191 'patterns': [r".*: warning: missing .+Winvalid-pp-token"]},
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07002192 {'category': 'link', 'severity': Severity.LOW,
2193 'description': 'need glibc to link',
2194 'patterns': [r".*: warning: .* requires at runtime .* glibc .* for linking"]},
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07002195
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002196 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2197 'description': 'Operator new returns NULL',
2198 'patterns': [r".*: warning: 'operator new' must not return NULL unless it is declared 'throw\(\)' .+"]},
2199 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wnull-arithmetic',
2200 'description': 'NULL used in arithmetic',
2201 'patterns': [r".*: warning: NULL used in arithmetic",
2202 r".*: warning: comparison between NULL and non-pointer"]},
2203 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'header-guard',
2204 'description': 'Misspelled header guard',
2205 'patterns': [r".*: warning: '.+' is used as a header guard .+ followed by .+ different macro"]},
2206 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'empty-body',
2207 'description': 'Empty loop body',
2208 'patterns': [r".*: warning: .+ loop has empty body"]},
2209 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'enum-conversion',
2210 'description': 'Implicit conversion from enumeration type',
2211 'patterns': [r".*: warning: implicit conversion from enumeration type '.+'"]},
2212 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'switch',
2213 'description': 'case value not in enumerated type',
2214 'patterns': [r".*: warning: case value not in enumerated type '.+'"]},
2215 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2216 'description': 'Undefined result',
2217 'patterns': [r".*: warning: The result of .+ is undefined",
2218 r".*: warning: passing an object that .+ has undefined behavior \[-Wvarargs\]",
2219 r".*: warning: 'this' pointer cannot be null in well-defined C\+\+ code;",
2220 r".*: warning: shifting a negative signed value is undefined"]},
2221 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2222 'description': 'Division by zero',
2223 'patterns': [r".*: warning: Division by zero"]},
2224 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2225 'description': 'Use of deprecated method',
2226 'patterns': [r".*: warning: '.+' is deprecated .+"]},
2227 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2228 'description': 'Use of garbage or uninitialized value',
2229 'patterns': [r".*: warning: .+ is a garbage value",
2230 r".*: warning: Function call argument is an uninitialized value",
2231 r".*: warning: Undefined or garbage value returned to caller",
2232 r".*: warning: Called .+ pointer is.+uninitialized",
2233 r".*: warning: Called .+ pointer is.+uninitalized", # match a typo in compiler message
2234 r".*: warning: Use of zero-allocated memory",
2235 r".*: warning: Dereference of undefined pointer value",
2236 r".*: warning: Passed-by-value .+ contains uninitialized data",
2237 r".*: warning: Branch condition evaluates to a garbage value",
2238 r".*: warning: The .+ of .+ is an uninitialized value.",
2239 r".*: warning: .+ is used uninitialized whenever .+sometimes-uninitialized",
2240 r".*: warning: Assigned value is garbage or undefined"]},
2241 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2242 'description': 'Result of malloc type incompatible with sizeof operand type',
2243 'patterns': [r".*: warning: Result of '.+' is converted to .+ incompatible with sizeof operand type"]},
2244 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsizeof-array-argument',
2245 'description': 'Sizeof on array argument',
2246 'patterns': [r".*: warning: sizeof on array function parameter will return"]},
2247 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsizeof-pointer-memacces',
2248 'description': 'Bad argument size of memory access functions',
2249 'patterns': [r".*: warning: .+\[-Wsizeof-pointer-memaccess\]"]},
2250 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2251 'description': 'Return value not checked',
2252 'patterns': [r".*: warning: The return value from .+ is not checked"]},
2253 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2254 'description': 'Possible heap pollution',
2255 'patterns': [r".*: warning: .*Possible heap pollution from .+ type .+"]},
2256 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2257 'description': 'Allocation size of 0 byte',
2258 'patterns': [r".*: warning: Call to .+ has an allocation size of 0 byte"]},
2259 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2260 'description': 'Result of malloc type incompatible with sizeof operand type',
2261 'patterns': [r".*: warning: Result of '.+' is converted to .+ incompatible with sizeof operand type"]},
2262 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wfor-loop-analysis',
2263 'description': 'Variable used in loop condition not modified in loop body',
2264 'patterns': [r".*: warning: variable '.+' used in loop condition.*Wfor-loop-analysis"]},
2265 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2266 'description': 'Closing a previously closed file',
2267 'patterns': [r".*: warning: Closing a previously closed file"]},
2268 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunnamed-type-template-args',
2269 'description': 'Unnamed template type argument',
2270 'patterns': [r".*: warning: template argument.+Wunnamed-type-template-args"]},
Chih-Hung Hsiehe1672862018-08-31 16:19:19 -07002271 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wimplicit-fallthrough',
2272 'description': 'Unannotated fall-through between switch labels',
2273 'patterns': [r".*: warning: unannotated fall-through between switch labels.+Wimplicit-fallthrough"]},
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07002274
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002275 {'category': 'C/C++', 'severity': Severity.HARMLESS,
2276 'description': 'Discarded qualifier from pointer target type',
2277 'patterns': [r".*: warning: .+ discards '.+' qualifier from pointer target type"]},
2278 {'category': 'C/C++', 'severity': Severity.HARMLESS,
2279 'description': 'Use snprintf instead of sprintf',
2280 'patterns': [r".*: warning: .*sprintf is often misused; please use snprintf"]},
2281 {'category': 'C/C++', 'severity': Severity.HARMLESS,
2282 'description': 'Unsupported optimizaton flag',
2283 'patterns': [r".*: warning: optimization flag '.+' is not supported"]},
2284 {'category': 'C/C++', 'severity': Severity.HARMLESS,
2285 'description': 'Extra or missing parentheses',
2286 'patterns': [r".*: warning: equality comparison with extraneous parentheses",
2287 r".*: warning: .+ within .+Wlogical-op-parentheses"]},
2288 {'category': 'C/C++', 'severity': Severity.HARMLESS, 'option': 'mismatched-tags',
2289 'description': 'Mismatched class vs struct tags',
2290 'patterns': [r".*: warning: '.+' defined as a .+ here but previously declared as a .+mismatched-tags",
2291 r".*: warning: .+ was previously declared as a .+mismatched-tags"]},
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07002292 {'category': 'FindEmulator', 'severity': Severity.HARMLESS,
2293 'description': 'FindEmulator: No such file or directory',
2294 'patterns': [r".*: warning: FindEmulator: .* No such file or directory"]},
2295 {'category': 'google_tests', 'severity': Severity.HARMLESS,
2296 'description': 'google_tests: unknown installed file',
2297 'patterns': [r".*: warning: .*_tests: Unknown installed file for module"]},
2298 {'category': 'make', 'severity': Severity.HARMLESS,
2299 'description': 'unusual tags debug eng',
2300 'patterns': [r".*: warning: .*: unusual tags debug eng"]},
Marco Nelissen594375d2009-07-14 09:04:04 -07002301
2302 # 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 -07002303 {'category': 'C/C++', 'severity': Severity.SKIP,
2304 'description': 'skip, ,',
2305 'patterns': [r".*: warning: ,$"]},
2306 {'category': 'C/C++', 'severity': Severity.SKIP,
2307 'description': 'skip,',
2308 'patterns': [r".*: warning: $"]},
2309 {'category': 'C/C++', 'severity': Severity.SKIP,
2310 'description': 'skip, In file included from ...',
2311 'patterns': [r".*: warning: In file included from .+,"]},
Marco Nelissen594375d2009-07-14 09:04:04 -07002312
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07002313 # warnings from clang-tidy
Chih-Hung Hsieh2cd467b2017-11-16 15:42:11 -08002314 group_tidy_warn_pattern('android'),
Chih-Hung Hsieh9e9355d2018-06-04 11:32:32 -07002315 simple_tidy_warn_pattern('bugprone-argument-comment'),
2316 simple_tidy_warn_pattern('bugprone-copy-constructor-init'),
2317 simple_tidy_warn_pattern('bugprone-fold-init-type'),
2318 simple_tidy_warn_pattern('bugprone-forward-declaration-namespace'),
2319 simple_tidy_warn_pattern('bugprone-forwarding-reference-overload'),
2320 simple_tidy_warn_pattern('bugprone-inaccurate-erase'),
2321 simple_tidy_warn_pattern('bugprone-incorrect-roundings'),
2322 simple_tidy_warn_pattern('bugprone-integer-division'),
2323 simple_tidy_warn_pattern('bugprone-lambda-function-name'),
2324 simple_tidy_warn_pattern('bugprone-macro-parentheses'),
2325 simple_tidy_warn_pattern('bugprone-misplaced-widening-cast'),
2326 simple_tidy_warn_pattern('bugprone-move-forwarding-reference'),
2327 simple_tidy_warn_pattern('bugprone-sizeof-expression'),
2328 simple_tidy_warn_pattern('bugprone-string-constructor'),
2329 simple_tidy_warn_pattern('bugprone-string-integer-assignment'),
2330 simple_tidy_warn_pattern('bugprone-suspicious-enum-usage'),
2331 simple_tidy_warn_pattern('bugprone-suspicious-missing-comma'),
2332 simple_tidy_warn_pattern('bugprone-suspicious-string-compare'),
2333 simple_tidy_warn_pattern('bugprone-suspicious-semicolon'),
2334 simple_tidy_warn_pattern('bugprone-undefined-memory-manipulation'),
2335 simple_tidy_warn_pattern('bugprone-unused-raii'),
2336 simple_tidy_warn_pattern('bugprone-use-after-move'),
2337 group_tidy_warn_pattern('bugprone'),
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07002338 group_tidy_warn_pattern('cert'),
2339 group_tidy_warn_pattern('clang-diagnostic'),
2340 group_tidy_warn_pattern('cppcoreguidelines'),
2341 group_tidy_warn_pattern('llvm'),
2342 simple_tidy_warn_pattern('google-default-arguments'),
2343 simple_tidy_warn_pattern('google-runtime-int'),
2344 simple_tidy_warn_pattern('google-runtime-operator'),
2345 simple_tidy_warn_pattern('google-runtime-references'),
2346 group_tidy_warn_pattern('google-build'),
2347 group_tidy_warn_pattern('google-explicit'),
2348 group_tidy_warn_pattern('google-redability'),
2349 group_tidy_warn_pattern('google-global'),
2350 group_tidy_warn_pattern('google-redability'),
2351 group_tidy_warn_pattern('google-redability'),
2352 group_tidy_warn_pattern('google'),
2353 simple_tidy_warn_pattern('hicpp-explicit-conversions'),
2354 simple_tidy_warn_pattern('hicpp-function-size'),
2355 simple_tidy_warn_pattern('hicpp-invalid-access-moved'),
2356 simple_tidy_warn_pattern('hicpp-member-init'),
2357 simple_tidy_warn_pattern('hicpp-delete-operators'),
2358 simple_tidy_warn_pattern('hicpp-special-member-functions'),
2359 simple_tidy_warn_pattern('hicpp-use-equals-default'),
2360 simple_tidy_warn_pattern('hicpp-use-equals-delete'),
2361 simple_tidy_warn_pattern('hicpp-no-assembler'),
2362 simple_tidy_warn_pattern('hicpp-noexcept-move'),
2363 simple_tidy_warn_pattern('hicpp-use-override'),
2364 group_tidy_warn_pattern('hicpp'),
2365 group_tidy_warn_pattern('modernize'),
2366 group_tidy_warn_pattern('misc'),
2367 simple_tidy_warn_pattern('performance-faster-string-find'),
2368 simple_tidy_warn_pattern('performance-for-range-copy'),
2369 simple_tidy_warn_pattern('performance-implicit-cast-in-loop'),
2370 simple_tidy_warn_pattern('performance-inefficient-string-concatenation'),
2371 simple_tidy_warn_pattern('performance-type-promotion-in-math-fn'),
2372 simple_tidy_warn_pattern('performance-unnecessary-copy-initialization'),
2373 simple_tidy_warn_pattern('performance-unnecessary-value-param'),
2374 group_tidy_warn_pattern('performance'),
2375 group_tidy_warn_pattern('readability'),
2376
2377 # warnings from clang-tidy's clang-analyzer checks
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002378 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002379 'description': 'clang-analyzer Unreachable code',
2380 'patterns': [r".*: warning: This statement is never executed.*UnreachableCode"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002381 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002382 'description': 'clang-analyzer Size of malloc may overflow',
2383 'patterns': [r".*: warning: .* size of .* may overflow .*MallocOverflow"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002384 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002385 'description': 'clang-analyzer Stream pointer might be NULL',
2386 'patterns': [r".*: warning: Stream pointer might be NULL .*unix.Stream"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002387 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002388 'description': 'clang-analyzer Opened file never closed',
2389 'patterns': [r".*: warning: Opened File never closed.*unix.Stream"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002390 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002391 'description': 'clang-analyzer sozeof() on a pointer type',
2392 'patterns': [r".*: warning: .*calls sizeof.* on a pointer type.*SizeofPtr"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002393 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002394 'description': 'clang-analyzer Pointer arithmetic on non-array variables',
2395 'patterns': [r".*: warning: Pointer arithmetic on non-array variables .*PointerArithm"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002396 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002397 'description': 'clang-analyzer Subtraction of pointers of different memory chunks',
2398 'patterns': [r".*: warning: Subtraction of two pointers .*PointerSub"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002399 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002400 'description': 'clang-analyzer Access out-of-bound array element',
2401 'patterns': [r".*: warning: Access out-of-bound array element .*ArrayBound"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002402 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002403 'description': 'clang-analyzer Out of bound memory access',
2404 'patterns': [r".*: warning: Out of bound memory access .*ArrayBoundV2"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002405 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002406 'description': 'clang-analyzer Possible lock order reversal',
2407 'patterns': [r".*: warning: .* Possible lock order reversal.*PthreadLock"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002408 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002409 'description': 'clang-analyzer Argument is a pointer to uninitialized value',
2410 'patterns': [r".*: warning: .* argument is a pointer to uninitialized value .*CallAndMessage"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002411 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002412 'description': 'clang-analyzer cast to struct',
2413 'patterns': [r".*: warning: Casting a non-structure type to a structure type .*CastToStruct"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002414 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002415 'description': 'clang-analyzer call path problems',
2416 'patterns': [r".*: warning: Call Path : .+"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002417 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07002418 'description': 'clang-analyzer excessive padding',
2419 'patterns': [r".*: warning: Excessive padding in '.*'"]},
2420 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002421 'description': 'clang-analyzer other',
2422 'patterns': [r".*: .+\[clang-analyzer-.+\]$",
2423 r".*: Call Path : .+$"]},
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07002424
Marco Nelissen594375d2009-07-14 09:04:04 -07002425 # catch-all for warnings this script doesn't know about yet
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002426 {'category': 'C/C++', 'severity': Severity.UNKNOWN,
2427 'description': 'Unclassified/unrecognized warnings',
2428 'patterns': [r".*: warning: .+"]},
Marco Nelissen594375d2009-07-14 09:04:04 -07002429]
2430
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07002431
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002432def project_name_and_pattern(name, pattern):
2433 return [name, '(^|.*/)' + pattern + '/.*: warning:']
2434
2435
2436def simple_project_pattern(pattern):
2437 return project_name_and_pattern(pattern, pattern)
2438
2439
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002440# A list of [project_name, file_path_pattern].
2441# project_name should not contain comma, to be used in CSV output.
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002442project_list = [
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002443 simple_project_pattern('art'),
2444 simple_project_pattern('bionic'),
2445 simple_project_pattern('bootable'),
2446 simple_project_pattern('build'),
2447 simple_project_pattern('cts'),
2448 simple_project_pattern('dalvik'),
2449 simple_project_pattern('developers'),
2450 simple_project_pattern('development'),
2451 simple_project_pattern('device'),
2452 simple_project_pattern('doc'),
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07002453 # match external/google* before external/
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002454 project_name_and_pattern('external/google', 'external/google.*'),
2455 project_name_and_pattern('external/non-google', 'external'),
2456 simple_project_pattern('frameworks/av/camera'),
2457 simple_project_pattern('frameworks/av/cmds'),
2458 simple_project_pattern('frameworks/av/drm'),
2459 simple_project_pattern('frameworks/av/include'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002460 simple_project_pattern('frameworks/av/media/img_utils'),
2461 simple_project_pattern('frameworks/av/media/libcpustats'),
2462 simple_project_pattern('frameworks/av/media/libeffects'),
2463 simple_project_pattern('frameworks/av/media/libmediaplayerservice'),
2464 simple_project_pattern('frameworks/av/media/libmedia'),
2465 simple_project_pattern('frameworks/av/media/libstagefright'),
2466 simple_project_pattern('frameworks/av/media/mtp'),
2467 simple_project_pattern('frameworks/av/media/ndk'),
2468 simple_project_pattern('frameworks/av/media/utils'),
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002469 project_name_and_pattern('frameworks/av/media/Other',
2470 'frameworks/av/media'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002471 simple_project_pattern('frameworks/av/radio'),
2472 simple_project_pattern('frameworks/av/services'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002473 simple_project_pattern('frameworks/av/soundtrigger'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002474 project_name_and_pattern('frameworks/av/Other', 'frameworks/av'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002475 simple_project_pattern('frameworks/base/cmds'),
2476 simple_project_pattern('frameworks/base/core'),
2477 simple_project_pattern('frameworks/base/drm'),
2478 simple_project_pattern('frameworks/base/media'),
2479 simple_project_pattern('frameworks/base/libs'),
2480 simple_project_pattern('frameworks/base/native'),
2481 simple_project_pattern('frameworks/base/packages'),
2482 simple_project_pattern('frameworks/base/rs'),
2483 simple_project_pattern('frameworks/base/services'),
2484 simple_project_pattern('frameworks/base/tests'),
2485 simple_project_pattern('frameworks/base/tools'),
2486 project_name_and_pattern('frameworks/base/Other', 'frameworks/base'),
Stephen Hinesd0aec892016-10-17 15:39:53 -07002487 simple_project_pattern('frameworks/compile/libbcc'),
2488 simple_project_pattern('frameworks/compile/mclinker'),
2489 simple_project_pattern('frameworks/compile/slang'),
2490 project_name_and_pattern('frameworks/compile/Other', 'frameworks/compile'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002491 simple_project_pattern('frameworks/minikin'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002492 simple_project_pattern('frameworks/ml'),
2493 simple_project_pattern('frameworks/native/cmds'),
2494 simple_project_pattern('frameworks/native/include'),
2495 simple_project_pattern('frameworks/native/libs'),
2496 simple_project_pattern('frameworks/native/opengl'),
2497 simple_project_pattern('frameworks/native/services'),
2498 simple_project_pattern('frameworks/native/vulkan'),
2499 project_name_and_pattern('frameworks/native/Other', 'frameworks/native'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002500 simple_project_pattern('frameworks/opt'),
2501 simple_project_pattern('frameworks/rs'),
2502 simple_project_pattern('frameworks/webview'),
2503 simple_project_pattern('frameworks/wilhelm'),
2504 project_name_and_pattern('frameworks/Other', 'frameworks'),
2505 simple_project_pattern('hardware/akm'),
2506 simple_project_pattern('hardware/broadcom'),
2507 simple_project_pattern('hardware/google'),
2508 simple_project_pattern('hardware/intel'),
2509 simple_project_pattern('hardware/interfaces'),
2510 simple_project_pattern('hardware/libhardware'),
2511 simple_project_pattern('hardware/libhardware_legacy'),
2512 simple_project_pattern('hardware/qcom'),
2513 simple_project_pattern('hardware/ril'),
2514 project_name_and_pattern('hardware/Other', 'hardware'),
2515 simple_project_pattern('kernel'),
2516 simple_project_pattern('libcore'),
2517 simple_project_pattern('libnativehelper'),
2518 simple_project_pattern('ndk'),
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002519 # match vendor/unbungled_google/packages before other packages
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002520 simple_project_pattern('unbundled_google'),
2521 simple_project_pattern('packages'),
2522 simple_project_pattern('pdk'),
2523 simple_project_pattern('prebuilts'),
2524 simple_project_pattern('system/bt'),
2525 simple_project_pattern('system/connectivity'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002526 simple_project_pattern('system/core/adb'),
2527 simple_project_pattern('system/core/base'),
2528 simple_project_pattern('system/core/debuggerd'),
2529 simple_project_pattern('system/core/fastboot'),
2530 simple_project_pattern('system/core/fingerprintd'),
2531 simple_project_pattern('system/core/fs_mgr'),
2532 simple_project_pattern('system/core/gatekeeperd'),
2533 simple_project_pattern('system/core/healthd'),
2534 simple_project_pattern('system/core/include'),
2535 simple_project_pattern('system/core/init'),
2536 simple_project_pattern('system/core/libbacktrace'),
2537 simple_project_pattern('system/core/liblog'),
2538 simple_project_pattern('system/core/libpixelflinger'),
2539 simple_project_pattern('system/core/libprocessgroup'),
2540 simple_project_pattern('system/core/libsysutils'),
2541 simple_project_pattern('system/core/logcat'),
2542 simple_project_pattern('system/core/logd'),
2543 simple_project_pattern('system/core/run-as'),
2544 simple_project_pattern('system/core/sdcard'),
2545 simple_project_pattern('system/core/toolbox'),
2546 project_name_and_pattern('system/core/Other', 'system/core'),
2547 simple_project_pattern('system/extras/ANRdaemon'),
2548 simple_project_pattern('system/extras/cpustats'),
2549 simple_project_pattern('system/extras/crypto-perf'),
2550 simple_project_pattern('system/extras/ext4_utils'),
2551 simple_project_pattern('system/extras/f2fs_utils'),
2552 simple_project_pattern('system/extras/iotop'),
2553 simple_project_pattern('system/extras/libfec'),
2554 simple_project_pattern('system/extras/memory_replay'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002555 simple_project_pattern('system/extras/mmap-perf'),
2556 simple_project_pattern('system/extras/multinetwork'),
2557 simple_project_pattern('system/extras/perfprofd'),
2558 simple_project_pattern('system/extras/procrank'),
2559 simple_project_pattern('system/extras/runconuid'),
2560 simple_project_pattern('system/extras/showmap'),
2561 simple_project_pattern('system/extras/simpleperf'),
2562 simple_project_pattern('system/extras/su'),
2563 simple_project_pattern('system/extras/tests'),
2564 simple_project_pattern('system/extras/verity'),
2565 project_name_and_pattern('system/extras/Other', 'system/extras'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002566 simple_project_pattern('system/gatekeeper'),
2567 simple_project_pattern('system/keymaster'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002568 simple_project_pattern('system/libhidl'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002569 simple_project_pattern('system/libhwbinder'),
2570 simple_project_pattern('system/media'),
2571 simple_project_pattern('system/netd'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002572 simple_project_pattern('system/nvram'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002573 simple_project_pattern('system/security'),
2574 simple_project_pattern('system/sepolicy'),
2575 simple_project_pattern('system/tools'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002576 simple_project_pattern('system/update_engine'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002577 simple_project_pattern('system/vold'),
2578 project_name_and_pattern('system/Other', 'system'),
2579 simple_project_pattern('toolchain'),
2580 simple_project_pattern('test'),
2581 simple_project_pattern('tools'),
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07002582 # match vendor/google* before vendor/
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002583 project_name_and_pattern('vendor/google', 'vendor/google.*'),
2584 project_name_and_pattern('vendor/non-google', 'vendor'),
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07002585 # keep out/obj and other patterns at the end.
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002586 ['out/obj',
2587 '.*/(gen|obj[^/]*)/(include|EXECUTABLES|SHARED_LIBRARIES|'
2588 'STATIC_LIBRARIES|NATIVE_TESTS)/.*: warning:'],
2589 ['other', '.*'] # all other unrecognized patterns
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002590]
2591
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002592project_patterns = []
2593project_names = []
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002594warning_messages = []
2595warning_records = []
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002596
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07002597
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002598def initialize_arrays():
2599 """Complete global arrays before they are used."""
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002600 global project_names, project_patterns
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002601 project_names = [p[0] for p in project_list]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002602 project_patterns = [re.compile(p[1]) for p in project_list]
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002603 for w in warn_patterns:
2604 w['members'] = []
2605 if 'option' not in w:
2606 w['option'] = ''
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002607 # Each warning pattern has a 'projects' dictionary, that
2608 # maps a project name to number of warnings in that project.
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002609 w['projects'] = {}
2610
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002611
2612initialize_arrays()
2613
2614
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -07002615android_root = ''
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002616platform_version = 'unknown'
2617target_product = 'unknown'
2618target_variant = 'unknown'
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002619
2620
2621##### Data and functions to dump html file. ##################################
2622
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002623html_head_scripts = """\
2624 <script type="text/javascript">
2625 function expand(id) {
2626 var e = document.getElementById(id);
2627 var f = document.getElementById(id + "_mark");
2628 if (e.style.display == 'block') {
2629 e.style.display = 'none';
2630 f.innerHTML = '&#x2295';
2631 }
2632 else {
2633 e.style.display = 'block';
2634 f.innerHTML = '&#x2296';
2635 }
2636 };
2637 function expandCollapse(show) {
2638 for (var id = 1; ; id++) {
2639 var e = document.getElementById(id + "");
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07002640 var f = document.getElementById(id + "_mark");
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002641 if (!e || !f) break;
2642 e.style.display = (show ? 'block' : 'none');
2643 f.innerHTML = (show ? '&#x2296' : '&#x2295');
2644 }
2645 };
2646 </script>
2647 <style type="text/css">
2648 th,td{border-collapse:collapse; border:1px solid black;}
2649 .button{color:blue;font-size:110%;font-weight:bolder;}
2650 .bt{color:black;background-color:transparent;border:none;outline:none;
2651 font-size:140%;font-weight:bolder;}
2652 .c0{background-color:#e0e0e0;}
2653 .c1{background-color:#d0d0d0;}
2654 .t1{border-collapse:collapse; width:100%; border:1px solid black;}
2655 </style>
2656 <script src="https://www.gstatic.com/charts/loader.js"></script>
2657"""
Marco Nelissen594375d2009-07-14 09:04:04 -07002658
Marco Nelissen594375d2009-07-14 09:04:04 -07002659
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002660def html_big(param):
2661 return '<font size="+2">' + param + '</font>'
Marco Nelissen594375d2009-07-14 09:04:04 -07002662
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07002663
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002664def dump_html_prologue(title):
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002665 print '<html>\n<head>'
2666 print '<title>' + title + '</title>'
2667 print html_head_scripts
2668 emit_stats_by_project()
2669 print '</head>\n<body>'
2670 print html_big(title)
2671 print '<p>'
Marco Nelissen594375d2009-07-14 09:04:04 -07002672
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002673
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002674def dump_html_epilogue():
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002675 print '</body>\n</head>\n</html>'
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07002676
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002677
2678def sort_warnings():
2679 for i in warn_patterns:
2680 i['members'] = sorted(set(i['members']))
2681
2682
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002683def emit_stats_by_project():
2684 """Dump a google chart table of warnings per project and severity."""
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002685 # warnings[p][s] is number of warnings in project p of severity s.
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002686 warnings = {p: {s: 0 for s in Severity.range} for p in project_names}
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002687 for i in warn_patterns:
2688 s = i['severity']
2689 for p in i['projects']:
2690 warnings[p][s] += i['projects'][p]
2691
2692 # total_by_project[p] is number of warnings in project p.
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002693 total_by_project = {p: sum(warnings[p][s] for s in Severity.range)
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002694 for p in project_names}
2695
2696 # total_by_severity[s] is number of warnings of severity s.
2697 total_by_severity = {s: sum(warnings[p][s] for p in project_names)
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002698 for s in Severity.range}
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07002699
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002700 # emit table header
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002701 stats_header = ['Project']
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002702 for s in Severity.range:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002703 if total_by_severity[s]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002704 stats_header.append("<span style='background-color:{}'>{}</span>".
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002705 format(Severity.colors[s],
2706 Severity.column_headers[s]))
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002707 stats_header.append('TOTAL')
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07002708
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002709 # emit a row of warning counts per project, skip no-warning projects
2710 total_all_projects = 0
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002711 stats_rows = []
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002712 for p in project_names:
2713 if total_by_project[p]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002714 one_row = [p]
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002715 for s in Severity.range:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002716 if total_by_severity[s]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002717 one_row.append(warnings[p][s])
2718 one_row.append(total_by_project[p])
2719 stats_rows.append(one_row)
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002720 total_all_projects += total_by_project[p]
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07002721
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002722 # emit a row of warning counts per severity
2723 total_all_severities = 0
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002724 one_row = ['<b>TOTAL</b>']
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002725 for s in Severity.range:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002726 if total_by_severity[s]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002727 one_row.append(total_by_severity[s])
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002728 total_all_severities += total_by_severity[s]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002729 one_row.append(total_all_projects)
2730 stats_rows.append(one_row)
2731 print '<script>'
2732 emit_const_string_array('StatsHeader', stats_header)
2733 emit_const_object_array('StatsRows', stats_rows)
2734 print draw_table_javascript
2735 print '</script>'
Marco Nelissen594375d2009-07-14 09:04:04 -07002736
2737
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002738def dump_stats():
2739 """Dump some stats about total number of warnings and such."""
2740 known = 0
2741 skipped = 0
2742 unknown = 0
2743 sort_warnings()
2744 for i in warn_patterns:
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002745 if i['severity'] == Severity.UNKNOWN:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002746 unknown += len(i['members'])
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002747 elif i['severity'] == Severity.SKIP:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002748 skipped += len(i['members'])
Ian Rogersf3829732016-05-10 12:06:01 -07002749 else:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002750 known += len(i['members'])
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002751 print 'Number of classified warnings: <b>' + str(known) + '</b><br>'
2752 print 'Number of skipped warnings: <b>' + str(skipped) + '</b><br>'
2753 print 'Number of unclassified warnings: <b>' + str(unknown) + '</b><br>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002754 total = unknown + known + skipped
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002755 extra_msg = ''
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002756 if total < 1000:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002757 extra_msg = ' (low count may indicate incremental build)'
2758 print 'Total number of warnings: <b>' + str(total) + '</b>' + extra_msg
Marco Nelissen594375d2009-07-14 09:04:04 -07002759
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07002760
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002761# New base table of warnings, [severity, warn_id, project, warning_message]
2762# Need buttons to show warnings in different grouping options.
2763# (1) Current, group by severity, id for each warning pattern
2764# sort by severity, warn_id, warning_message
2765# (2) Current --byproject, group by severity,
2766# id for each warning pattern + project name
2767# sort by severity, warn_id, project, warning_message
2768# (3) New, group by project + severity,
2769# id for each warning pattern
2770# sort by project, severity, warn_id, warning_message
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002771def emit_buttons():
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002772 print ('<button class="button" onclick="expandCollapse(1);">'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002773 'Expand all warnings</button>\n'
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002774 '<button class="button" onclick="expandCollapse(0);">'
2775 'Collapse all warnings</button>\n'
2776 '<button class="button" onclick="groupBySeverity();">'
2777 'Group warnings by severity</button>\n'
2778 '<button class="button" onclick="groupByProject();">'
2779 'Group warnings by project</button><br>')
Marco Nelissen594375d2009-07-14 09:04:04 -07002780
2781
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002782def all_patterns(category):
2783 patterns = ''
2784 for i in category['patterns']:
2785 patterns += i
2786 patterns += ' / '
2787 return patterns
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002788
2789
2790def dump_fixed():
2791 """Show which warnings no longer occur."""
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002792 anchor = 'fixed_warnings'
2793 mark = anchor + '_mark'
2794 print ('\n<br><p style="background-color:lightblue"><b>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002795 '<button id="' + mark + '" '
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002796 'class="bt" onclick="expand(\'' + anchor + '\');">'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002797 '&#x2295</button> Fixed warnings. '
2798 'No more occurrences. Please consider turning these into '
2799 'errors if possible, before they are reintroduced in to the build'
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002800 ':</b></p>')
2801 print '<blockquote>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002802 fixed_patterns = []
2803 for i in warn_patterns:
2804 if not i['members']:
2805 fixed_patterns.append(i['description'] + ' (' +
2806 all_patterns(i) + ')')
2807 if i['option']:
2808 fixed_patterns.append(' ' + i['option'])
2809 fixed_patterns.sort()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002810 print '<div id="' + anchor + '" style="display:none;"><table>'
2811 cur_row_class = 0
2812 for text in fixed_patterns:
2813 cur_row_class = 1 - cur_row_class
2814 # remove last '\n'
2815 t = text[:-1] if text[-1] == '\n' else text
2816 print '<tr><td class="c' + str(cur_row_class) + '">' + t + '</td></tr>'
2817 print '</table></div>'
2818 print '</blockquote>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002819
2820
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002821def find_project_index(line):
2822 for p in range(len(project_patterns)):
2823 if project_patterns[p].match(line):
2824 return p
2825 return -1
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002826
2827
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002828def classify_one_warning(line, results):
Chih-Hung Hsieh9be27762018-06-07 10:51:47 -07002829 """Classify one warning line."""
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002830 for i in range(len(warn_patterns)):
2831 w = warn_patterns[i]
2832 for cpat in w['compiled_patterns']:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002833 if cpat.match(line):
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002834 p = find_project_index(line)
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002835 results.append([line, i, p])
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002836 return
2837 else:
2838 # If we end up here, there was a problem parsing the log
2839 # probably caused by 'make -j' mixing the output from
2840 # 2 or more concurrent compiles
2841 pass
Marco Nelissen594375d2009-07-14 09:04:04 -07002842
2843
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002844def classify_warnings(lines):
2845 results = []
2846 for line in lines:
2847 classify_one_warning(line, results)
Chih-Hung Hsieh76d00652016-11-09 18:19:05 -08002848 # After the main work, ignore all other signals to a child process,
2849 # to avoid bad warning/error messages from the exit clean-up process.
2850 if args.processes > 1:
2851 signal.signal(signal.SIGTERM, lambda *args: sys.exit(-signal.SIGTERM))
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002852 return results
2853
2854
2855def parallel_classify_warnings(warning_lines):
2856 """Classify all warning lines with num_cpu parallel processes."""
Chih-Hung Hsieh76d00652016-11-09 18:19:05 -08002857 compile_patterns()
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002858 num_cpu = args.processes
Chih-Hung Hsieh63de3002016-10-28 10:53:34 -07002859 if num_cpu > 1:
2860 groups = [[] for x in range(num_cpu)]
2861 i = 0
2862 for x in warning_lines:
2863 groups[i].append(x)
2864 i = (i + 1) % num_cpu
2865 pool = multiprocessing.Pool(num_cpu)
2866 group_results = pool.map(classify_warnings, groups)
2867 else:
2868 group_results = [classify_warnings(warning_lines)]
2869
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002870 for result in group_results:
2871 for line, pattern_idx, project_idx in result:
2872 pattern = warn_patterns[pattern_idx]
2873 pattern['members'].append(line)
2874 message_idx = len(warning_messages)
2875 warning_messages.append(line)
2876 warning_records.append([pattern_idx, project_idx, message_idx])
2877 pname = '???' if project_idx < 0 else project_names[project_idx]
2878 # Count warnings by project.
2879 if pname in pattern['projects']:
2880 pattern['projects'][pname] += 1
2881 else:
2882 pattern['projects'][pname] = 1
2883
2884
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002885def compile_patterns():
2886 """Precompiling every pattern speeds up parsing by about 30x."""
2887 for i in warn_patterns:
2888 i['compiled_patterns'] = []
2889 for pat in i['patterns']:
2890 i['compiled_patterns'].append(re.compile(pat))
2891
2892
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -07002893def find_android_root(path):
2894 """Set and return android_root path if it is found."""
2895 global android_root
2896 parts = path.split('/')
2897 for idx in reversed(range(2, len(parts))):
2898 root_path = '/'.join(parts[:idx])
2899 # Android root directory should contain this script.
Colin Crossfdea8932017-12-06 14:38:40 -08002900 if os.path.exists(root_path + '/build/make/tools/warn.py'):
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -07002901 android_root = root_path
2902 return root_path
2903 return ''
2904
2905
2906def remove_android_root_prefix(path):
2907 """Remove android_root prefix from path if it is found."""
2908 if path.startswith(android_root):
2909 return path[1 + len(android_root):]
2910 else:
2911 return path
2912
2913
2914def normalize_path(path):
2915 """Normalize file path relative to android_root."""
2916 # If path is not an absolute path, just normalize it.
2917 path = os.path.normpath(path)
2918 if path[0] != '/':
2919 return path
2920 # Remove known prefix of root path and normalize the suffix.
2921 if android_root or find_android_root(path):
2922 return remove_android_root_prefix(path)
2923 else:
2924 return path
2925
2926
2927def normalize_warning_line(line):
2928 """Normalize file path relative to android_root in a warning line."""
2929 # replace fancy quotes with plain ol' quotes
2930 line = line.replace('‘', "'")
2931 line = line.replace('’', "'")
2932 line = line.strip()
2933 first_column = line.find(':')
2934 if first_column > 0:
2935 return normalize_path(line[:first_column]) + line[first_column:]
2936 else:
2937 return line
2938
2939
Chih-Hung Hsieh76d00652016-11-09 18:19:05 -08002940def parse_input_file(infile):
Chih-Hung Hsiehef21d142017-04-27 10:25:37 -07002941 """Parse input file, collect parameters and warning lines."""
2942 global android_root
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002943 global platform_version
2944 global target_product
2945 global target_variant
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002946 line_counter = 0
2947
Chih-Hung Hsieh5722f922016-10-11 15:33:19 -07002948 # handle only warning messages with a file path
2949 warning_pattern = re.compile('^[^ ]*/[^ ]*: warning: .*')
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002950
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002951 # Collect all warnings into the warning_lines set.
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002952 warning_lines = set()
2953 for line in infile:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002954 if warning_pattern.match(line):
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -07002955 line = normalize_warning_line(line)
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002956 warning_lines.add(line)
Chih-Hung Hsieh655c5422017-06-07 15:52:13 -07002957 elif line_counter < 100:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002958 # save a little bit of time by only doing this for the first few lines
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002959 line_counter += 1
2960 m = re.search('(?<=^PLATFORM_VERSION=).*', line)
2961 if m is not None:
2962 platform_version = m.group(0)
2963 m = re.search('(?<=^TARGET_PRODUCT=).*', line)
2964 if m is not None:
2965 target_product = m.group(0)
2966 m = re.search('(?<=^TARGET_BUILD_VARIANT=).*', line)
2967 if m is not None:
2968 target_variant = m.group(0)
Chih-Hung Hsiehef21d142017-04-27 10:25:37 -07002969 m = re.search('.* TOP=([^ ]*) .*', line)
2970 if m is not None:
2971 android_root = m.group(1)
Chih-Hung Hsieh76d00652016-11-09 18:19:05 -08002972 return warning_lines
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002973
2974
Chih-Hung Hsieh5722f922016-10-11 15:33:19 -07002975# Return s with escaped backslash and quotation characters.
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002976def escape_string(s):
Chih-Hung Hsieh5722f922016-10-11 15:33:19 -07002977 return s.replace('\\', '\\\\').replace('"', '\\"')
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002978
2979
2980# Return s without trailing '\n' and escape the quotation characters.
2981def strip_escape_string(s):
2982 if not s:
2983 return s
2984 s = s[:-1] if s[-1] == '\n' else s
2985 return escape_string(s)
2986
2987
2988def emit_warning_array(name):
2989 print 'var warning_{} = ['.format(name)
2990 for i in range(len(warn_patterns)):
2991 print '{},'.format(warn_patterns[i][name])
2992 print '];'
2993
2994
2995def emit_warning_arrays():
2996 emit_warning_array('severity')
2997 print 'var warning_description = ['
2998 for i in range(len(warn_patterns)):
2999 if warn_patterns[i]['members']:
3000 print '"{}",'.format(escape_string(warn_patterns[i]['description']))
3001 else:
3002 print '"",' # no such warning
3003 print '];'
3004
3005scripts_for_warning_groups = """
3006 function compareMessages(x1, x2) { // of the same warning type
3007 return (WarningMessages[x1[2]] <= WarningMessages[x2[2]]) ? -1 : 1;
3008 }
3009 function byMessageCount(x1, x2) {
3010 return x2[2] - x1[2]; // reversed order
3011 }
3012 function bySeverityMessageCount(x1, x2) {
3013 // orer by severity first
3014 if (x1[1] != x2[1])
3015 return x1[1] - x2[1];
3016 return byMessageCount(x1, x2);
3017 }
3018 const ParseLinePattern = /^([^ :]+):(\\d+):(.+)/;
3019 function addURL(line) {
3020 if (FlagURL == "") return line;
3021 if (FlagSeparator == "") {
3022 return line.replace(ParseLinePattern,
George Burgess IV169f5f12017-04-21 13:35:52 -07003023 "<a target='_blank' href='" + FlagURL + "/$1'>$1</a>:$2:$3");
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003024 }
3025 return line.replace(ParseLinePattern,
George Burgess IV169f5f12017-04-21 13:35:52 -07003026 "<a target='_blank' href='" + FlagURL + "/$1" + FlagSeparator +
3027 "$2'>$1:$2</a>:$3");
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003028 }
3029 function createArrayOfDictionaries(n) {
3030 var result = [];
3031 for (var i=0; i<n; i++) result.push({});
3032 return result;
3033 }
3034 function groupWarningsBySeverity() {
3035 // groups is an array of dictionaries,
3036 // each dictionary maps from warning type to array of warning messages.
3037 var groups = createArrayOfDictionaries(SeverityColors.length);
3038 for (var i=0; i<Warnings.length; i++) {
3039 var w = Warnings[i][0];
3040 var s = WarnPatternsSeverity[w];
3041 var k = w.toString();
3042 if (!(k in groups[s]))
3043 groups[s][k] = [];
3044 groups[s][k].push(Warnings[i]);
3045 }
3046 return groups;
3047 }
3048 function groupWarningsByProject() {
3049 var groups = createArrayOfDictionaries(ProjectNames.length);
3050 for (var i=0; i<Warnings.length; i++) {
3051 var w = Warnings[i][0];
3052 var p = Warnings[i][1];
3053 var k = w.toString();
3054 if (!(k in groups[p]))
3055 groups[p][k] = [];
3056 groups[p][k].push(Warnings[i]);
3057 }
3058 return groups;
3059 }
3060 var GlobalAnchor = 0;
3061 function createWarningSection(header, color, group) {
3062 var result = "";
3063 var groupKeys = [];
3064 var totalMessages = 0;
3065 for (var k in group) {
3066 totalMessages += group[k].length;
3067 groupKeys.push([k, WarnPatternsSeverity[parseInt(k)], group[k].length]);
3068 }
3069 groupKeys.sort(bySeverityMessageCount);
3070 for (var idx=0; idx<groupKeys.length; idx++) {
3071 var k = groupKeys[idx][0];
3072 var messages = group[k];
3073 var w = parseInt(k);
3074 var wcolor = SeverityColors[WarnPatternsSeverity[w]];
3075 var description = WarnPatternsDescription[w];
3076 if (description.length == 0)
3077 description = "???";
3078 GlobalAnchor += 1;
3079 result += "<table class='t1'><tr bgcolor='" + wcolor + "'><td>" +
3080 "<button class='bt' id='" + GlobalAnchor + "_mark" +
3081 "' onclick='expand(\\"" + GlobalAnchor + "\\");'>" +
3082 "&#x2295</button> " +
3083 description + " (" + messages.length + ")</td></tr></table>";
3084 result += "<div id='" + GlobalAnchor +
3085 "' style='display:none;'><table class='t1'>";
3086 var c = 0;
3087 messages.sort(compareMessages);
3088 for (var i=0; i<messages.length; i++) {
3089 result += "<tr><td class='c" + c + "'>" +
3090 addURL(WarningMessages[messages[i][2]]) + "</td></tr>";
3091 c = 1 - c;
3092 }
3093 result += "</table></div>";
3094 }
3095 if (result.length > 0) {
3096 return "<br><span style='background-color:" + color + "'><b>" +
3097 header + ": " + totalMessages +
3098 "</b></span><blockquote><table class='t1'>" +
3099 result + "</table></blockquote>";
3100
3101 }
3102 return ""; // empty section
3103 }
3104 function generateSectionsBySeverity() {
3105 var result = "";
3106 var groups = groupWarningsBySeverity();
3107 for (s=0; s<SeverityColors.length; s++) {
3108 result += createWarningSection(SeverityHeaders[s], SeverityColors[s], groups[s]);
3109 }
3110 return result;
3111 }
3112 function generateSectionsByProject() {
3113 var result = "";
3114 var groups = groupWarningsByProject();
3115 for (i=0; i<groups.length; i++) {
3116 result += createWarningSection(ProjectNames[i], 'lightgrey', groups[i]);
3117 }
3118 return result;
3119 }
3120 function groupWarnings(generator) {
3121 GlobalAnchor = 0;
3122 var e = document.getElementById("warning_groups");
3123 e.innerHTML = generator();
3124 }
3125 function groupBySeverity() {
3126 groupWarnings(generateSectionsBySeverity);
3127 }
3128 function groupByProject() {
3129 groupWarnings(generateSectionsByProject);
3130 }
3131"""
3132
3133
3134# Emit a JavaScript const string
3135def emit_const_string(name, value):
3136 print 'const ' + name + ' = "' + escape_string(value) + '";'
3137
3138
3139# Emit a JavaScript const integer array.
3140def emit_const_int_array(name, array):
3141 print 'const ' + name + ' = ['
3142 for n in array:
3143 print str(n) + ','
3144 print '];'
3145
3146
3147# Emit a JavaScript const string array.
3148def emit_const_string_array(name, array):
3149 print 'const ' + name + ' = ['
3150 for s in array:
3151 print '"' + strip_escape_string(s) + '",'
3152 print '];'
3153
3154
Chih-Hung Hsiehb2afb632018-07-20 15:36:26 -07003155# Emit a JavaScript const string array for HTML.
3156def emit_const_html_string_array(name, array):
3157 print 'const ' + name + ' = ['
3158 for s in array:
3159 print '"' + cgi.escape(strip_escape_string(s)) + '",'
3160 print '];'
3161
3162
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003163# Emit a JavaScript const object array.
3164def emit_const_object_array(name, array):
3165 print 'const ' + name + ' = ['
3166 for x in array:
3167 print str(x) + ','
3168 print '];'
3169
3170
3171def emit_js_data():
3172 """Dump dynamic HTML page's static JavaScript data."""
3173 emit_const_string('FlagURL', args.url if args.url else '')
3174 emit_const_string('FlagSeparator', args.separator if args.separator else '')
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07003175 emit_const_string_array('SeverityColors', Severity.colors)
3176 emit_const_string_array('SeverityHeaders', Severity.headers)
3177 emit_const_string_array('SeverityColumnHeaders', Severity.column_headers)
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003178 emit_const_string_array('ProjectNames', project_names)
3179 emit_const_int_array('WarnPatternsSeverity',
3180 [w['severity'] for w in warn_patterns])
Chih-Hung Hsiehb2afb632018-07-20 15:36:26 -07003181 emit_const_html_string_array('WarnPatternsDescription',
3182 [w['description'] for w in warn_patterns])
3183 emit_const_html_string_array('WarnPatternsOption',
3184 [w['option'] for w in warn_patterns])
3185 emit_const_html_string_array('WarningMessages', warning_messages)
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003186 emit_const_object_array('Warnings', warning_records)
3187
3188draw_table_javascript = """
3189google.charts.load('current', {'packages':['table']});
3190google.charts.setOnLoadCallback(drawTable);
3191function drawTable() {
3192 var data = new google.visualization.DataTable();
3193 data.addColumn('string', StatsHeader[0]);
3194 for (var i=1; i<StatsHeader.length; i++) {
3195 data.addColumn('number', StatsHeader[i]);
3196 }
3197 data.addRows(StatsRows);
3198 for (var i=0; i<StatsRows.length; i++) {
3199 for (var j=0; j<StatsHeader.length; j++) {
3200 data.setProperty(i, j, 'style', 'border:1px solid black;');
3201 }
3202 }
3203 var table = new google.visualization.Table(document.getElementById('stats_table'));
3204 table.draw(data, {allowHtml: true, alternatingRowStyle: true});
3205}
3206"""
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003207
3208
3209def dump_html():
3210 """Dump the html output to stdout."""
3211 dump_html_prologue('Warnings for ' + platform_version + ' - ' +
3212 target_product + ' - ' + target_variant)
3213 dump_stats()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003214 print '<br><div id="stats_table"></div><br>'
3215 print '\n<script>'
3216 emit_js_data()
3217 print scripts_for_warning_groups
3218 print '</script>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003219 emit_buttons()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003220 # Warning messages are grouped by severities or project names.
3221 print '<br><div id="warning_groups"></div>'
3222 if args.byproject:
3223 print '<script>groupByProject();</script>'
3224 else:
3225 print '<script>groupBySeverity();</script>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003226 dump_fixed()
3227 dump_html_epilogue()
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07003228
3229
3230##### Functions to count warnings and dump csv file. #########################
3231
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07003232
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003233def description_for_csv(category):
3234 if not category['description']:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003235 return '?'
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003236 return category['description']
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07003237
3238
Sam Saccone03aaa7e2017-04-10 15:37:47 -07003239def count_severity(writer, sev, kind):
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003240 """Count warnings of given severity."""
3241 total = 0
3242 for i in warn_patterns:
3243 if i['severity'] == sev and i['members']:
3244 n = len(i['members'])
3245 total += n
Sam Saccone03aaa7e2017-04-10 15:37:47 -07003246 warning = kind + ': ' + description_for_csv(i)
3247 writer.writerow([n, '', warning])
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003248 # print number of warnings for each project, ordered by project name.
3249 projects = i['projects'].keys()
3250 projects.sort()
3251 for p in projects:
Sam Saccone03aaa7e2017-04-10 15:37:47 -07003252 writer.writerow([i['projects'][p], p, warning])
3253 writer.writerow([total, '', kind + ' warnings'])
3254
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003255 return total
3256
3257
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003258# dump number of warnings in csv format to stdout
Sam Saccone03aaa7e2017-04-10 15:37:47 -07003259def dump_csv(writer):
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003260 """Dump number of warnings in csv format to stdout."""
3261 sort_warnings()
3262 total = 0
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07003263 for s in Severity.range:
Sam Saccone03aaa7e2017-04-10 15:37:47 -07003264 total += count_severity(writer, s, Severity.column_headers[s])
3265 writer.writerow([total, '', 'All warnings'])
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003266
3267
Meike Baumgärtnerac9d5df2016-09-28 10:48:06 -07003268def main():
Chih-Hung Hsieh76d00652016-11-09 18:19:05 -08003269 warning_lines = parse_input_file(open(args.buildlog, 'r'))
3270 parallel_classify_warnings(warning_lines)
Sam Saccone03aaa7e2017-04-10 15:37:47 -07003271 # If a user pases a csv path, save the fileoutput to the path
3272 # If the user also passed gencsv write the output to stdout
3273 # If the user did not pass gencsv flag dump the html report to stdout.
3274 if args.csvpath:
3275 with open(args.csvpath, 'w') as f:
3276 dump_csv(csv.writer(f, lineterminator='\n'))
Meike Baumgärtnerac9d5df2016-09-28 10:48:06 -07003277 if args.gencsv:
Sam Saccone03aaa7e2017-04-10 15:37:47 -07003278 dump_csv(csv.writer(sys.stdout, lineterminator='\n'))
Meike Baumgärtnerac9d5df2016-09-28 10:48:06 -07003279 else:
3280 dump_html()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003281
Meike Baumgärtnerac9d5df2016-09-28 10:48:06 -07003282
3283# Run main function if warn.py is the main program.
3284if __name__ == '__main__':
3285 main()