blob: c710164ff3febccfcd32d416326d69be8048f400 [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 Gampe161ec1e2018-10-15 08:56:58 -0700508 'Java: This class\'s name looks like a Type Parameter.',
509 'patterns': [r".*: warning: \[ClassNamedLikeTypeParameter\] .+"]},
510 {'category': 'java',
511 'severity': Severity.LOW,
512 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -0700513 'Java: Field name is CONSTANT_CASE, but field is not static and final',
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800514 'patterns': [r".*: warning: \[ConstantField\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -0700515 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700516 'severity': Severity.LOW,
Ian Rogers6e520032016-05-13 08:59:00 -0700517 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700518 'Java: @Multibinds is a more efficient and declarative mechanism for ensuring that a set multibinding is present in the graph.',
519 'patterns': [r".*: warning: \[EmptySetMultibindingContributions\] .+"]},
520 {'category': 'java',
521 'severity': Severity.LOW,
522 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -0700523 'Java: Prefer assertThrows to ExpectedException',
524 'patterns': [r".*: warning: \[ExpectedExceptionRefactoring\] .+"]},
525 {'category': 'java',
526 'severity': Severity.LOW,
527 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -0700528 'Java: This field is only assigned during initialization; consider making it final',
529 'patterns': [r".*: warning: \[FieldCanBeFinal\] .+"]},
Andreas Gampe2e987af2018-06-08 09:55:41 -0700530 {'category': 'java',
531 'severity': Severity.LOW,
532 'description':
533 'Java: Fields that can be null should be annotated @Nullable',
534 'patterns': [r".*: warning: \[FieldMissingNullable\] .+"]},
535 {'category': 'java',
536 'severity': Severity.LOW,
537 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -0700538 'Java: Refactors uses of the JSR 305 @Immutable to Error Prone\'s annotation',
539 'patterns': [r".*: warning: \[ImmutableRefactoring\] .+"]},
540 {'category': 'java',
541 'severity': Severity.LOW,
542 'description':
543 'Java: Use Java\'s utility functional interfaces instead of Function\u003cA, B> for primitive types.',
Andreas Gampecf528ca2018-01-25 11:55:43 -0800544 'patterns': [r".*: warning: \[LambdaFunctionalInterface\] .+"]},
545 {'category': 'java',
546 'severity': Severity.LOW,
547 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800548 'Java: A private method that does not reference the enclosing instance can be static',
549 'patterns': [r".*: warning: \[MethodCanBeStatic\] .+"]},
550 {'category': 'java',
551 'severity': Severity.LOW,
552 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800553 'Java: C-style array declarations should not be used',
554 'patterns': [r".*: warning: \[MixedArrayDimensions\] .+"]},
555 {'category': 'java',
556 'severity': Severity.LOW,
557 'description':
558 'Java: Variable declarations should declare only one variable',
559 'patterns': [r".*: warning: \[MultiVariableDeclaration\] .+"]},
560 {'category': 'java',
561 'severity': Severity.LOW,
562 'description':
563 'Java: Source files should not contain multiple top-level class declarations',
564 'patterns': [r".*: warning: \[MultipleTopLevelClasses\] .+"]},
565 {'category': 'java',
566 'severity': Severity.LOW,
567 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800568 'Java: Avoid having multiple unary operators acting on the same variable in a method call',
569 'patterns': [r".*: warning: \[MultipleUnaryOperatorsInMethodCall\] .+"]},
570 {'category': 'java',
571 'severity': Severity.LOW,
572 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800573 'Java: Package names should match the directory they are declared in',
574 'patterns': [r".*: warning: \[PackageLocation\] .+"]},
575 {'category': 'java',
576 'severity': Severity.LOW,
577 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -0700578 'Java: Non-standard parameter comment; prefer `/* paramName= */ arg`',
Andreas Gampecf528ca2018-01-25 11:55:43 -0800579 'patterns': [r".*: warning: \[ParameterComment\] .+"]},
580 {'category': 'java',
581 'severity': Severity.LOW,
582 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700583 'Java: Method parameters that aren\'t checked for null shouldn\'t be annotated @Nullable',
584 'patterns': [r".*: warning: \[ParameterNotNullable\] .+"]},
585 {'category': 'java',
586 'severity': Severity.LOW,
587 'description':
588 'Java: Add a private constructor to modules that will not be instantiated by Dagger.',
Andreas Gampeb9dc23a2018-06-08 10:11:26 -0700589 'patterns': [r".*: warning: \[PrivateConstructorForNoninstantiableModule\] .+"]},
Andreas Gampe2e987af2018-06-08 09:55:41 -0700590 {'category': 'java',
591 'severity': Severity.LOW,
592 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800593 'Java: Utility classes (only static members) are not designed to be instantiated and should be made noninstantiable with a default constructor.',
594 'patterns': [r".*: warning: \[PrivateConstructorForUtilityClass\] .+"]},
595 {'category': 'java',
596 'severity': Severity.LOW,
597 'description':
598 'Java: Unused imports',
599 'patterns': [r".*: warning: \[RemoveUnusedImports\] .+"]},
600 {'category': 'java',
601 'severity': Severity.LOW,
602 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700603 'Java: Methods that can return null should be annotated @Nullable',
604 'patterns': [r".*: warning: \[ReturnMissingNullable\] .+"]},
605 {'category': 'java',
606 'severity': Severity.LOW,
607 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -0700608 'Java: Scopes on modules have no function and will soon be an error.',
609 'patterns': [r".*: warning: \[ScopeOnModule\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -0800610 {'category': 'java',
611 'severity': Severity.LOW,
612 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -0700613 'Java: The default case of a switch should appear at the end of the last statement group',
614 'patterns': [r".*: warning: \[SwitchDefault\] .+"]},
Andreas Gampe2e987af2018-06-08 09:55:41 -0700615 {'category': 'java',
616 'severity': Severity.LOW,
617 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -0700618 'Java: Prefer assertThrows to @Test(expected=...)',
619 'patterns': [r".*: warning: \[TestExceptionRefactoring\] .+"]},
620 {'category': 'java',
621 'severity': Severity.LOW,
622 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800623 'Java: Unchecked exceptions do not need to be declared in the method signature.',
624 'patterns': [r".*: warning: \[ThrowsUncheckedException\] .+"]},
625 {'category': 'java',
626 'severity': Severity.LOW,
627 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -0700628 'Java: Prefer assertThrows to try/fail',
629 'patterns': [r".*: warning: \[TryFailRefactoring\] .+"]},
630 {'category': 'java',
631 'severity': Severity.LOW,
632 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800633 'Java: Type parameters must be a single letter with an optional numeric suffix, or an UpperCamelCase name followed by the letter \'T\'.',
634 'patterns': [r".*: warning: \[TypeParameterNaming\] .+"]},
635 {'category': 'java',
636 'severity': Severity.LOW,
637 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -0700638 'Java: Constructors and methods with the same name should appear sequentially with no other code in between. Please re-order or re-name methods.',
Andreas Gampecf528ca2018-01-25 11:55:43 -0800639 'patterns': [r".*: warning: \[UngroupedOverloads\] .+"]},
640 {'category': 'java',
641 'severity': Severity.LOW,
642 'description':
643 'Java: Unnecessary call to NullPointerTester#setDefault',
644 'patterns': [r".*: warning: \[UnnecessarySetDefault\] .+"]},
645 {'category': 'java',
646 'severity': Severity.LOW,
647 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800648 'Java: Using static imports for types is unnecessary',
649 'patterns': [r".*: warning: \[UnnecessaryStaticImport\] .+"]},
650 {'category': 'java',
651 'severity': Severity.LOW,
652 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700653 'Java: @Binds is a more efficient and declarative mechanism for delegating a binding.',
654 'patterns': [r".*: warning: \[UseBinds\] .+"]},
655 {'category': 'java',
656 'severity': Severity.LOW,
657 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800658 'Java: Wildcard imports, static or otherwise, should not be used',
659 'patterns': [r".*: warning: \[WildcardImport\] .+"]},
660 {'category': 'java',
Andreas Gampecf528ca2018-01-25 11:55:43 -0800661 'severity': Severity.MEDIUM,
662 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700663 'Java: Method reference is ambiguous',
664 'patterns': [r".*: warning: \[AmbiguousMethodReference\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -0800665 {'category': 'java',
666 'severity': Severity.MEDIUM,
667 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -0700668 'Java: This method passes a pair of parameters through to String.format, but the enclosing method wasn\'t annotated @FormatMethod. Doing so gives compile-time rather than run-time protection against malformed format strings.',
669 'patterns': [r".*: warning: \[AnnotateFormatMethod\] .+"]},
670 {'category': 'java',
671 'severity': Severity.MEDIUM,
672 'description':
673 'Java: Annotations should be positioned after Javadocs, but before modifiers..',
674 'patterns': [r".*: warning: \[AnnotationPosition\] .+"]},
675 {'category': 'java',
676 'severity': Severity.MEDIUM,
677 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800678 'Java: Arguments are in the wrong order or could be commented for clarity.',
679 'patterns': [r".*: warning: \[ArgumentSelectionDefectChecker\] .+"]},
680 {'category': 'java',
681 'severity': Severity.MEDIUM,
682 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -0700683 'Java: Arrays do not override equals() or hashCode, so comparisons will be done on reference equality only. If neither deduplication nor lookup are needed, consider using a List instead. Otherwise, use IdentityHashMap/Set, a Map from a library that handles object arrays, or an Iterable/List of pairs.',
684 'patterns': [r".*: warning: \[ArrayAsKeyOfSetOrMap\] .+"]},
685 {'category': 'java',
686 'severity': Severity.MEDIUM,
687 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800688 'Java: Arguments are swapped in assertEquals-like call',
689 'patterns': [r".*: warning: \[AssertEqualsArgumentOrderChecker\] .+"]},
690 {'category': 'java',
691 'severity': Severity.MEDIUM,
692 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800693 'Java: Assertions may be disabled at runtime and do not guarantee that execution will halt here; consider throwing an exception instead',
694 'patterns': [r".*: warning: \[AssertFalse\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -0700695 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700696 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700697 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -0700698 'Java: The lambda passed to assertThrows should contain exactly one statement',
Andreas Gampeb9dc23a2018-06-08 10:11:26 -0700699 'patterns': [r".*: warning: \[AssertThrowsMultipleStatements\] .+"]},
700 {'category': 'java',
701 'severity': Severity.MEDIUM,
702 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800703 'Java: This assertion throws an AssertionError if it fails, which will be caught by an enclosing try block.',
704 'patterns': [r".*: warning: \[AssertionFailureIgnored\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -0700705 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700706 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700707 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700708 'Java: @AssistedInject and @Inject should not be used on different constructors in the same class.',
709 'patterns': [r".*: warning: \[AssistedInjectAndInjectOnConstructors\] .+"]},
710 {'category': 'java',
711 'severity': Severity.MEDIUM,
712 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -0700713 'Java: Make toString(), hashCode() and equals() final in AutoValue classes, so it is clear to readers that AutoValue is not overriding them',
714 'patterns': [r".*: warning: \[AutoValueFinalMethods\] .+"]},
715 {'category': 'java',
716 'severity': Severity.MEDIUM,
717 'description':
Ian Rogers6e520032016-05-13 08:59:00 -0700718 'Java: Classes that implement Annotation must override equals and hashCode. Consider using AutoAnnotation instead of implementing Annotation by hand.',
719 'patterns': [r".*: warning: \[BadAnnotationImplementation\] .+"]},
720 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700721 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700722 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800723 'Java: Possible sign flip from narrowing conversion',
724 'patterns': [r".*: warning: \[BadComparable\] .+"]},
725 {'category': 'java',
726 'severity': Severity.MEDIUM,
727 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -0700728 'Java: Importing nested classes/static methods/static fields with commonly-used names can make code harder to read, because it may not be clear from the context exactly which type is being referred to. Qualifying the name with that of the containing class can make the code clearer.',
729 'patterns': [r".*: warning: \[BadImport\] .+"]},
730 {'category': 'java',
731 'severity': Severity.MEDIUM,
732 'description':
733 'Java: instanceof used in a way that is equivalent to a null check.',
734 'patterns': [r".*: warning: \[BadInstanceof\] .+"]},
735 {'category': 'java',
736 'severity': Severity.MEDIUM,
737 'description':
738 'Java: BigDecimal#equals has surprising behavior: it also compares scale.',
739 'patterns': [r".*: warning: \[BigDecimalEquals\] .+"]},
740 {'category': 'java',
741 'severity': Severity.MEDIUM,
742 'description':
743 'Java: new BigDecimal(double) loses precision in this case.',
Ian Rogers6e520032016-05-13 08:59:00 -0700744 'patterns': [r".*: warning: \[BigDecimalLiteralDouble\] .+"]},
745 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700746 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700747 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700748 'Java: 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.',
749 'patterns': [r".*: warning: \[BinderIdentityRestoredDangerously\] .+"]},
750 {'category': 'java',
751 'severity': Severity.MEDIUM,
752 'description':
753 'Java: This code declares a binding for a common value type without a Qualifier annotation.',
754 'patterns': [r".*: warning: \[BindingToUnqualifiedCommonType\] .+"]},
755 {'category': 'java',
756 'severity': Severity.MEDIUM,
757 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800758 'Java: valueOf or autoboxing provides better time and space performance',
759 'patterns': [r".*: warning: \[BoxedPrimitiveConstructor\] .+"]},
760 {'category': 'java',
761 'severity': Severity.MEDIUM,
762 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -0700763 'Java: ByteBuffer.array() shouldn\'t be called unless ByteBuffer.arrayOffset() is used or if the ByteBuffer was initialized using ByteBuffer.wrap() or ByteBuffer.allocate().',
764 'patterns': [r".*: warning: \[ByteBufferBackingArray\] .+"]},
765 {'category': 'java',
766 'severity': Severity.MEDIUM,
767 'description':
Ian Rogers6e520032016-05-13 08:59:00 -0700768 'Java: Mockito cannot mock final classes',
769 'patterns': [r".*: warning: \[CannotMockFinalClass\] .+"]},
770 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700771 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700772 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800773 'Java: Duration can be expressed more clearly with different units',
774 'patterns': [r".*: warning: \[CanonicalDuration\] .+"]},
775 {'category': 'java',
776 'severity': Severity.MEDIUM,
777 'description':
778 'Java: Logging or rethrowing exceptions should usually be preferred to catching and calling printStackTrace',
779 'patterns': [r".*: warning: \[CatchAndPrintStackTrace\] .+"]},
780 {'category': 'java',
781 'severity': Severity.MEDIUM,
782 'description':
783 'Java: Ignoring exceptions and calling fail() is unnecessary, and makes test output less useful',
784 'patterns': [r".*: warning: \[CatchFail\] .+"]},
785 {'category': 'java',
786 'severity': Severity.MEDIUM,
787 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800788 'Java: Inner class is non-static but does not reference enclosing class',
789 'patterns': [r".*: warning: \[ClassCanBeStatic\] .+"]},
790 {'category': 'java',
791 'severity': Severity.MEDIUM,
792 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800793 'Java: Class.newInstance() bypasses exception checking; prefer getDeclaredConstructor().newInstance()',
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800794 'patterns': [r".*: warning: \[ClassNewInstance\] .+"]},
795 {'category': 'java',
796 'severity': Severity.MEDIUM,
797 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -0700798 'Java: Providing Closeable resources makes their lifecycle unclear',
799 'patterns': [r".*: warning: \[CloseableProvides\] .+"]},
800 {'category': 'java',
801 'severity': Severity.MEDIUM,
802 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800803 'Java: The type of the array parameter of Collection.toArray needs to be compatible with the array type',
804 'patterns': [r".*: warning: \[CollectionToArraySafeParameter\] .+"]},
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800805 {'category': 'java',
806 'severity': Severity.MEDIUM,
807 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800808 'Java: Collector.of() should not use state',
809 'patterns': [r".*: warning: \[CollectorShouldNotUseState\] .+"]},
810 {'category': 'java',
811 'severity': Severity.MEDIUM,
812 'description':
813 'Java: Class should not implement both `Comparable` and `Comparator`',
814 'patterns': [r".*: warning: \[ComparableAndComparator\] .+"]},
815 {'category': 'java',
816 'severity': Severity.MEDIUM,
817 'description':
818 'Java: Constructors should not invoke overridable methods.',
819 'patterns': [r".*: warning: \[ConstructorInvokesOverridable\] .+"]},
820 {'category': 'java',
821 'severity': Severity.MEDIUM,
822 'description':
823 'Java: Constructors should not pass the \'this\' reference out in method invocations, since the object may not be fully constructed.',
824 'patterns': [r".*: warning: \[ConstructorLeaksThis\] .+"]},
825 {'category': 'java',
826 'severity': Severity.MEDIUM,
827 'description':
828 'Java: DateFormat is not thread-safe, and should not be used as a constant field.',
829 'patterns': [r".*: warning: \[DateFormatConstant\] .+"]},
830 {'category': 'java',
831 'severity': Severity.MEDIUM,
832 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -0700833 '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 -0800834 'patterns': [r".*: warning: \[DefaultCharset\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -0700835 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700836 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700837 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -0700838 'Java: Avoid deprecated Thread methods; read the method\'s javadoc for details.',
839 'patterns': [r".*: warning: \[DeprecatedThreadMethods\] .+"]},
840 {'category': 'java',
841 'severity': Severity.MEDIUM,
842 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -0700843 'Java: Prefer collection factory methods or builders to the double-brace initialization pattern.',
844 'patterns': [r".*: warning: \[DoubleBraceInitialization\] .+"]},
845 {'category': 'java',
846 'severity': Severity.MEDIUM,
847 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700848 'Java: Double-checked locking on non-volatile fields is unsafe',
849 'patterns': [r".*: warning: \[DoubleCheckedLocking\] .+"]},
850 {'category': 'java',
851 'severity': Severity.MEDIUM,
852 'description':
Ian Rogers6e520032016-05-13 08:59:00 -0700853 'Java: Empty top-level type declaration',
854 'patterns': [r".*: warning: \[EmptyTopLevelDeclaration\] .+"]},
855 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700856 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700857 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -0700858 'Java: equals() implementation may throw NullPointerException when given null',
859 'patterns': [r".*: warning: \[EqualsBrokenForNull\] .+"]},
860 {'category': 'java',
861 'severity': Severity.MEDIUM,
862 'description':
863 'Java: Overriding Object#equals in a non-final class by using getClass rather than instanceof breaks substitutability of subclasses.',
864 'patterns': [r".*: warning: \[EqualsGetClass\] .+"]},
865 {'category': 'java',
866 'severity': Severity.MEDIUM,
867 'description':
Ian Rogers6e520032016-05-13 08:59:00 -0700868 'Java: Classes that override equals should also override hashCode.',
869 'patterns': [r".*: warning: \[EqualsHashCode\] .+"]},
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 Gampe2e987af2018-06-08 09:55:41 -0700873 'Java: An equality test between objects with incompatible types always returns false',
874 'patterns': [r".*: warning: \[EqualsIncompatibleType\] .+"]},
875 {'category': 'java',
876 'severity': Severity.MEDIUM,
877 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -0700878 'Java: The contract of #equals states that it should return false for incompatible types, while this implementation may throw ClassCastException.',
879 'patterns': [r".*: warning: \[EqualsUnsafeCast\] .+"]},
880 {'category': 'java',
881 'severity': Severity.MEDIUM,
882 'description':
883 'Java: Implementing #equals by just comparing hashCodes is fragile. Hashes collide frequently, and this will lead to false positives in #equals.',
884 'patterns': [r".*: warning: \[EqualsUsingHashCode\] .+"]},
885 {'category': 'java',
886 'severity': Severity.MEDIUM,
887 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800888 'Java: Calls to ExpectedException#expect should always be followed by exactly one statement.',
889 'patterns': [r".*: warning: \[ExpectedExceptionChecker\] .+"]},
890 {'category': 'java',
891 'severity': Severity.MEDIUM,
892 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -0700893 'Java: When only using JUnit Assert\'s static methods, you should import statically instead of extending.',
894 'patterns': [r".*: warning: \[ExtendingJUnitAssert\] .+"]},
895 {'category': 'java',
896 'severity': Severity.MEDIUM,
897 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800898 'Java: Switch case may fall through',
899 'patterns': [r".*: warning: \[FallThrough\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -0700900 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700901 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700902 'description':
903 '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.',
904 'patterns': [r".*: warning: \[Finally\] .+"]},
905 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700906 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700907 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800908 'Java: Use parentheses to make the precedence explicit',
909 'patterns': [r".*: warning: \[FloatCast\] .+"]},
910 {'category': 'java',
911 'severity': Severity.MEDIUM,
912 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -0700913 'Java: This fuzzy equality check is using a tolerance less than the gap to the next number. You may want a less restrictive tolerance, or to assert equality.',
914 'patterns': [r".*: warning: \[FloatingPointAssertionWithinEpsilon\] .+"]},
915 {'category': 'java',
916 'severity': Severity.MEDIUM,
917 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800918 'Java: Floating point literal loses precision',
919 'patterns': [r".*: warning: \[FloatingPointLiteralPrecision\] .+"]},
920 {'category': 'java',
921 'severity': Severity.MEDIUM,
922 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700923 'Java: Classes extending PreferenceActivity must implement isValidFragment such that it does not unconditionally return true to prevent vulnerability to fragment injection attacks.',
924 'patterns': [r".*: warning: \[FragmentInjection\] .+"]},
925 {'category': 'java',
926 'severity': Severity.MEDIUM,
927 'description':
928 'Java: Subclasses of Fragment must be instantiable via Class#newInstance(): the class must be public, static and have a public nullary constructor',
929 'patterns': [r".*: warning: \[FragmentNotInstantiable\] .+"]},
930 {'category': 'java',
931 'severity': Severity.MEDIUM,
932 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800933 'Java: Overloads will be ambiguous when passing lambda arguments',
934 'patterns': [r".*: warning: \[FunctionalInterfaceClash\] .+"]},
935 {'category': 'java',
936 'severity': Severity.MEDIUM,
937 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800938 'Java: Return value of methods returning Future must be checked. Ignoring returned Futures suppresses exceptions thrown from the code that completes the Future.',
939 'patterns': [r".*: warning: \[FutureReturnValueIgnored\] .+"]},
940 {'category': 'java',
941 'severity': Severity.MEDIUM,
942 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800943 'Java: Calling getClass() on an enum may return a subclass of the enum type',
944 'patterns': [r".*: warning: \[GetClassOnEnum\] .+"]},
945 {'category': 'java',
946 'severity': Severity.MEDIUM,
947 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700948 'Java: Hardcoded reference to /sdcard',
949 'patterns': [r".*: warning: \[HardCodedSdCardPath\] .+"]},
950 {'category': 'java',
951 'severity': Severity.MEDIUM,
952 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800953 'Java: Hiding fields of superclasses may cause confusion and errors',
954 'patterns': [r".*: warning: \[HidingField\] .+"]},
955 {'category': 'java',
956 'severity': Severity.MEDIUM,
957 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700958 'Java: Annotations should always be immutable',
959 'patterns': [r".*: warning: \[ImmutableAnnotationChecker\] .+"]},
960 {'category': 'java',
961 'severity': Severity.MEDIUM,
962 'description':
963 'Java: Enums should always be immutable',
964 'patterns': [r".*: warning: \[ImmutableEnumChecker\] .+"]},
965 {'category': 'java',
966 'severity': Severity.MEDIUM,
967 'description':
Ian Rogers6e520032016-05-13 08:59:00 -0700968 'Java: This annotation has incompatible modifiers as specified by its @IncompatibleModifiers annotation',
969 'patterns': [r".*: warning: \[IncompatibleModifiers\] .+"]},
970 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -0700971 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700972 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -0700973 'Java: It is confusing to have a field and a parameter under the same scope that differ only in capitalization.',
974 'patterns': [r".*: warning: \[InconsistentCapitalization\] .+"]},
975 {'category': 'java',
976 'severity': Severity.MEDIUM,
977 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -0700978 'Java: Including fields in hashCode which are not compared in equals violates the contract of hashCode.',
979 'patterns': [r".*: warning: \[InconsistentHashCode\] .+"]},
980 {'category': 'java',
981 'severity': Severity.MEDIUM,
982 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700983 'Java: The ordering of parameters in overloaded methods should be as consistent as possible (when viewed from left to right)',
984 'patterns': [r".*: warning: \[InconsistentOverloads\] .+"]},
985 {'category': 'java',
986 'severity': Severity.MEDIUM,
987 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -0800988 'Java: This for loop increments the same variable in the header and in the body',
989 'patterns': [r".*: warning: \[IncrementInForLoopAndHeader\] .+"]},
990 {'category': 'java',
991 'severity': Severity.MEDIUM,
992 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -0700993 'Java: Constructors on abstract classes are never directly @Injected, only the constructors of their subclasses can be @Inject\'ed.',
994 'patterns': [r".*: warning: \[InjectOnConstructorOfAbstractClass\] .+"]},
995 {'category': 'java',
996 'severity': Severity.MEDIUM,
997 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -0800998 'Java: Please also override int read(byte[], int, int), otherwise multi-byte reads from this input stream are likely to be slow.',
999 'patterns': [r".*: warning: \[InputStreamSlowMultibyteRead\] .+"]},
1000 {'category': 'java',
1001 'severity': Severity.MEDIUM,
1002 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001003 'Java: Casting inside an if block should be plausibly consistent with the instanceof type',
1004 'patterns': [r".*: warning: \[InstanceOfAndCastMatchWrongType\] .+"]},
1005 {'category': 'java',
1006 'severity': Severity.MEDIUM,
1007 'description':
1008 'Java: Expression of type int may overflow before being assigned to a long',
1009 'patterns': [r".*: warning: \[IntLongMath\] .+"]},
1010 {'category': 'java',
1011 'severity': Severity.MEDIUM,
1012 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001013 'Java: This @param tag doesn\'t refer to a parameter of the method.',
1014 'patterns': [r".*: warning: \[InvalidParam\] .+"]},
1015 {'category': 'java',
1016 'severity': Severity.MEDIUM,
1017 'description':
1018 'Java: This tag is invalid.',
1019 'patterns': [r".*: warning: \[InvalidTag\] .+"]},
1020 {'category': 'java',
1021 'severity': Severity.MEDIUM,
1022 'description':
1023 'Java: The documented method doesn\'t actually throw this checked exception.',
1024 'patterns': [r".*: warning: \[InvalidThrows\] .+"]},
1025 {'category': 'java',
1026 'severity': Severity.MEDIUM,
1027 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001028 'Java: Class should not implement both `Iterable` and `Iterator`',
1029 'patterns': [r".*: warning: \[IterableAndIterator\] .+"]},
1030 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001031 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001032 'description':
1033 'Java: Floating-point comparison without error tolerance',
1034 'patterns': [r".*: warning: \[JUnit3FloatingPointComparisonWithoutDelta\] .+"]},
1035 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001036 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001037 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001038 'Java: Some JUnit4 construct cannot be used in a JUnit3 context. Convert your class to JUnit4 style to use them.',
1039 'patterns': [r".*: warning: \[JUnit4ClassUsedInJUnit3\] .+"]},
1040 {'category': 'java',
1041 'severity': Severity.MEDIUM,
1042 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001043 'Java: Test class inherits from JUnit 3\'s TestCase but has JUnit 4 @Test annotations.',
1044 'patterns': [r".*: warning: \[JUnitAmbiguousTestClass\] .+"]},
1045 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001046 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001047 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001048 'Java: Never reuse class names from java.lang',
1049 'patterns': [r".*: warning: \[JavaLangClash\] .+"]},
1050 {'category': 'java',
1051 'severity': Severity.MEDIUM,
1052 'description':
1053 'Java: Suggests alternatives to obsolete JDK classes.',
1054 'patterns': [r".*: warning: \[JdkObsolete\] .+"]},
1055 {'category': 'java',
1056 'severity': Severity.MEDIUM,
1057 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001058 'Java: Calls to Lock#lock should be immediately followed by a try block which releases the lock.',
1059 'patterns': [r".*: warning: \[LockNotBeforeTry\] .+"]},
1060 {'category': 'java',
1061 'severity': Severity.MEDIUM,
1062 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001063 'Java: Assignment where a boolean expression was expected; use == if this assignment wasn\'t expected or add parentheses for clarity.',
1064 'patterns': [r".*: warning: \[LogicalAssignment\] .+"]},
1065 {'category': 'java',
1066 'severity': Severity.MEDIUM,
1067 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001068 'Java: Math.abs does not always give a positive result. Please consider other methods for positive random numbers.',
1069 'patterns': [r".*: warning: \[MathAbsoluteRandom\] .+"]},
1070 {'category': 'java',
1071 'severity': Severity.MEDIUM,
1072 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001073 'Java: Switches on enum types should either handle all values, or have a default case.',
Ian Rogers6e520032016-05-13 08:59:00 -07001074 'patterns': [r".*: warning: \[MissingCasesInEnumSwitch\] .+"]},
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: 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.)',
1079 'patterns': [r".*: warning: \[MissingDefault\] .+"]},
1080 {'category': 'java',
1081 'severity': Severity.MEDIUM,
1082 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001083 'Java: Not calling fail() when expecting an exception masks bugs',
1084 'patterns': [r".*: warning: \[MissingFail\] .+"]},
1085 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001086 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001087 'description':
1088 'Java: method overrides method in supertype; expected @Override',
1089 'patterns': [r".*: warning: \[MissingOverride\] .+"]},
1090 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001091 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001092 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001093 'Java: A collection or proto builder was created, but its values were never accessed.',
1094 'patterns': [r".*: warning: \[ModifiedButNotUsed\] .+"]},
1095 {'category': 'java',
1096 'severity': Severity.MEDIUM,
1097 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001098 'Java: Modifying a collection while iterating over it in a loop may cause a ConcurrentModificationException to be thrown.',
1099 'patterns': [r".*: warning: \[ModifyCollectionInEnhancedForLoop\] .+"]},
1100 {'category': 'java',
1101 'severity': Severity.MEDIUM,
1102 'description':
1103 'Java: Multiple calls to either parallel or sequential are unnecessary and cause confusion.',
1104 'patterns': [r".*: warning: \[MultipleParallelOrSequentialCalls\] .+"]},
1105 {'category': 'java',
1106 'severity': Severity.MEDIUM,
1107 'description':
1108 'Java: Constant field declarations should use the immutable type (such as ImmutableList) instead of the general collection interface type (such as List)',
1109 'patterns': [r".*: warning: \[MutableConstantField\] .+"]},
1110 {'category': 'java',
1111 'severity': Severity.MEDIUM,
1112 'description':
1113 'Java: Method return type should use the immutable type (such as ImmutableList) instead of the general collection interface type (such as List)',
1114 'patterns': [r".*: warning: \[MutableMethodReturnType\] .+"]},
1115 {'category': 'java',
1116 'severity': Severity.MEDIUM,
1117 'description':
1118 'Java: Compound assignments may hide dangerous casts',
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001119 'patterns': [r".*: warning: \[NarrowingCompoundAssignment\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001120 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001121 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001122 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001123 'Java: Nested instanceOf conditions of disjoint types create blocks of code that never execute',
1124 'patterns': [r".*: warning: \[NestedInstanceOfConditions\] .+"]},
1125 {'category': 'java',
1126 'severity': Severity.MEDIUM,
1127 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001128 'Java: Instead of returning a functional type, return the actual type that the returned function would return and use lambdas at use site.',
1129 'patterns': [r".*: warning: \[NoFunctionalReturnType\] .+"]},
1130 {'category': 'java',
1131 'severity': Severity.MEDIUM,
1132 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001133 'Java: This update of a volatile variable is non-atomic',
1134 'patterns': [r".*: warning: \[NonAtomicVolatileUpdate\] .+"]},
1135 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001136 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001137 'description':
1138 'Java: Static import of member uses non-canonical name',
1139 'patterns': [r".*: warning: \[NonCanonicalStaticMemberImport\] .+"]},
1140 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001141 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001142 'description':
1143 'Java: equals method doesn\'t override Object.equals',
1144 'patterns': [r".*: warning: \[NonOverridingEquals\] .+"]},
1145 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001146 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001147 'description':
1148 'Java: Constructors should not be annotated with @Nullable since they cannot return null',
1149 'patterns': [r".*: warning: \[NullableConstructor\] .+"]},
1150 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001151 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001152 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001153 'Java: Dereference of possibly-null value',
1154 'patterns': [r".*: warning: \[NullableDereference\] .+"]},
1155 {'category': 'java',
1156 'severity': Severity.MEDIUM,
1157 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001158 'Java: @Nullable should not be used for primitive types since they cannot be null',
1159 'patterns': [r".*: warning: \[NullablePrimitive\] .+"]},
1160 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001161 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001162 'description':
1163 'Java: void-returning methods should not be annotated with @Nullable, since they cannot return null',
1164 'patterns': [r".*: warning: \[NullableVoid\] .+"]},
1165 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001166 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001167 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001168 'Java: Calling toString on Objects that don\'t override toString() doesn\'t provide useful information',
1169 'patterns': [r".*: warning: \[ObjectToString\] .+"]},
1170 {'category': 'java',
1171 'severity': Severity.MEDIUM,
1172 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001173 'Java: Objects.hashCode(Object o) should not be passed a primitive value',
1174 'patterns': [r".*: warning: \[ObjectsHashCodePrimitive\] .+"]},
1175 {'category': 'java',
1176 'severity': Severity.MEDIUM,
1177 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001178 'Java: Use grouping parenthesis to make the operator precedence explicit',
1179 'patterns': [r".*: warning: \[OperatorPrecedence\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001180 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001181 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001182 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001183 'Java: One should not call optional.get() inside an if statement that checks !optional.isPresent',
1184 'patterns': [r".*: warning: \[OptionalNotPresent\] .+"]},
1185 {'category': 'java',
1186 'severity': Severity.MEDIUM,
1187 'description':
1188 'Java: String literal contains format specifiers, but is not passed to a format method',
1189 'patterns': [r".*: warning: \[OrphanedFormatString\] .+"]},
1190 {'category': 'java',
1191 'severity': Severity.MEDIUM,
1192 'description':
1193 'Java: To return a custom message with a Throwable class, one should override getMessage() instead of toString() for Throwable.',
1194 'patterns': [r".*: warning: \[OverrideThrowableToString\] .+"]},
1195 {'category': 'java',
1196 'severity': Severity.MEDIUM,
1197 'description':
1198 'Java: Varargs doesn\'t agree for overridden method',
1199 'patterns': [r".*: warning: \[Overrides\] .+"]},
1200 {'category': 'java',
1201 'severity': Severity.MEDIUM,
1202 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001203 '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.',
1204 'patterns': [r".*: warning: \[OverridesGuiceInjectableMethod\] .+"]},
1205 {'category': 'java',
1206 'severity': Severity.MEDIUM,
1207 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001208 'Java: Detects `/* name= */`-style comments on actual parameters where the name doesn\'t match the formal parameter',
1209 'patterns': [r".*: warning: \[ParameterName\] .+"]},
1210 {'category': 'java',
1211 'severity': Severity.MEDIUM,
1212 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001213 'Java: Preconditions only accepts the %s placeholder in error message strings',
1214 'patterns': [r".*: warning: \[PreconditionsInvalidPlaceholder\] .+"]},
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: Passing a primitive array to a varargs method is usually wrong',
1219 'patterns': [r".*: warning: \[PrimitiveArrayPassedToVarargsMethod\] .+"]},
1220 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001221 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001222 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001223 'Java: A field on a protocol buffer was set twice in the same chained expression.',
1224 'patterns': [r".*: warning: \[ProtoRedundantSet\] .+"]},
1225 {'category': 'java',
1226 'severity': Severity.MEDIUM,
1227 'description':
1228 'Java: Protos should not be used as a key to a map, in a set, or in a contains method on a descendant of a collection. Protos have non deterministic ordering and proto equality is deep, which is a performance issue.',
1229 'patterns': [r".*: warning: \[ProtosAsKeyOfSetOrMap\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001230 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001231 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001232 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001233 'Java: BugChecker has incorrect ProvidesFix tag, please update',
1234 'patterns': [r".*: warning: \[ProvidesFix\] .+"]},
1235 {'category': 'java',
1236 'severity': Severity.MEDIUM,
1237 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001238 'Java: Qualifiers/Scope annotations on @Inject methods don\'t have any effect. Move the qualifier annotation to the binding location.',
1239 'patterns': [r".*: warning: \[QualifierOrScopeOnInjectMethod\] .+"]},
1240 {'category': 'java',
1241 'severity': Severity.MEDIUM,
1242 'description':
1243 'Java: Injection frameworks currently don\'t understand Qualifiers in TYPE_PARAMETER or TYPE_USE contexts.',
Andreas Gampe2e987af2018-06-08 09:55:41 -07001244 'patterns': [r".*: warning: \[QualifierWithTypeUse\] .+"]},
1245 {'category': 'java',
1246 'severity': Severity.MEDIUM,
1247 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001248 'Java: reachabilityFence should always be called inside a finally block',
1249 'patterns': [r".*: warning: \[ReachabilityFenceUsage\] .+"]},
1250 {'category': 'java',
1251 'severity': Severity.MEDIUM,
1252 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001253 'Java: Thrown exception is a subtype of another',
1254 'patterns': [r".*: warning: \[RedundantThrows\] .+"]},
1255 {'category': 'java',
1256 'severity': Severity.MEDIUM,
1257 'description':
1258 'Java: Comparison using reference equality instead of value equality',
1259 'patterns': [r".*: warning: \[ReferenceEquality\] .+"]},
1260 {'category': 'java',
1261 'severity': Severity.MEDIUM,
1262 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001263 'Java: This annotation is missing required modifiers as specified by its @RequiredModifiers annotation',
1264 'patterns': [r".*: warning: \[RequiredModifiers\] .+"]},
1265 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001266 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001267 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001268 'Java: Void methods should not have a @return tag.',
1269 'patterns': [r".*: warning: \[ReturnFromVoid\] .+"]},
1270 {'category': 'java',
1271 'severity': Severity.MEDIUM,
1272 'description':
1273 'Java: Prefer the short-circuiting boolean operators \u0026\u0026 and || to \u0026 and |.',
Andreas Gampecf528ca2018-01-25 11:55:43 -08001274 'patterns': [r".*: warning: \[ShortCircuitBoolean\] .+"]},
1275 {'category': 'java',
1276 'severity': Severity.MEDIUM,
1277 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001278 'Java: Writes to static fields should not be guarded by instance locks',
1279 'patterns': [r".*: warning: \[StaticGuardedByInstance\] .+"]},
1280 {'category': 'java',
1281 'severity': Severity.MEDIUM,
1282 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001283 'Java: A static variable or method should be qualified with a class name, not expression',
1284 'patterns': [r".*: warning: \[StaticQualifiedUsingExpression\] .+"]},
1285 {'category': 'java',
1286 'severity': Severity.MEDIUM,
1287 'description':
1288 'Java: Streams that encapsulate a closeable resource should be closed using try-with-resources',
1289 'patterns': [r".*: warning: \[StreamResourceLeak\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001290 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001291 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001292 'description':
1293 'Java: String comparison using reference equality instead of value equality',
1294 'patterns': [r".*: warning: \[StringEquality\] .+"]},
1295 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001296 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001297 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001298 'Java: String.split(String) has surprising behavior',
Andreas Gampecf528ca2018-01-25 11:55:43 -08001299 'patterns': [r".*: warning: \[StringSplitter\] .+"]},
1300 {'category': 'java',
1301 'severity': Severity.MEDIUM,
1302 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001303 'Java: SWIG generated code that can\'t call a C++ destructor will leak memory',
1304 'patterns': [r".*: warning: \[SwigMemoryLeak\] .+"]},
1305 {'category': 'java',
1306 'severity': Severity.MEDIUM,
1307 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001308 'Java: Synchronizing on non-final fields is not safe: if the field is ever updated, different threads may end up locking on different objects.',
1309 'patterns': [r".*: warning: \[SynchronizeOnNonFinalField\] .+"]},
1310 {'category': 'java',
1311 'severity': Severity.MEDIUM,
1312 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001313 'Java: Code that contains System.exit() is untestable.',
1314 'patterns': [r".*: warning: \[SystemExitOutsideMain\] .+"]},
1315 {'category': 'java',
1316 'severity': Severity.MEDIUM,
1317 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001318 'Java: Using @Test(expected=...) is discouraged, since the test will pass if *any* statement in the test method throws the expected exception',
1319 'patterns': [r".*: warning: \[TestExceptionChecker\] .+"]},
1320 {'category': 'java',
1321 'severity': Severity.MEDIUM,
1322 'description':
1323 'Java: Thread.join needs to be surrounded by a loop until it succeeds, as in Uninterruptibles.joinUninterruptibly.',
1324 'patterns': [r".*: warning: \[ThreadJoinLoop\] .+"]},
1325 {'category': 'java',
1326 'severity': Severity.MEDIUM,
1327 'description':
1328 'Java: ThreadLocals should be stored in static fields',
1329 'patterns': [r".*: warning: \[ThreadLocalUsage\] .+"]},
1330 {'category': 'java',
1331 'severity': Severity.MEDIUM,
1332 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001333 'Java: Relying on the thread scheduler is discouraged; see Effective Java Item 72 (2nd edition) / 84 (3rd edition).',
1334 'patterns': [r".*: warning: \[ThreadPriorityCheck\] .+"]},
1335 {'category': 'java',
1336 'severity': Severity.MEDIUM,
1337 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001338 '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.',
1339 'patterns': [r".*: warning: \[ThreeLetterTimeZoneID\] .+"]},
1340 {'category': 'java',
1341 'severity': Severity.MEDIUM,
1342 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001343 'Java: An implementation of Object.toString() should never return null.',
1344 'patterns': [r".*: warning: \[ToStringReturnsNull\] .+"]},
1345 {'category': 'java',
1346 'severity': Severity.MEDIUM,
1347 'description':
1348 'Java: The actual and expected values appear to be swapped, which results in poor assertion failure messages. The actual value should come first.',
1349 'patterns': [r".*: warning: \[TruthAssertExpected\] .+"]},
1350 {'category': 'java',
1351 'severity': Severity.MEDIUM,
1352 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001353 'Java: Truth Library assert is called on a constant.',
1354 'patterns': [r".*: warning: \[TruthConstantAsserts\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001355 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001356 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001357 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001358 'Java: Argument is not compatible with the subject\'s type.',
1359 'patterns': [r".*: warning: \[TruthIncompatibleType\] .+"]},
1360 {'category': 'java',
1361 'severity': Severity.MEDIUM,
1362 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001363 'Java: Type parameter declaration shadows another named type',
1364 'patterns': [r".*: warning: \[TypeNameShadowing\] .+"]},
1365 {'category': 'java',
1366 'severity': Severity.MEDIUM,
1367 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001368 'Java: Type parameter declaration overrides another type parameter already declared',
1369 'patterns': [r".*: warning: \[TypeParameterShadowing\] .+"]},
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001370 {'category': 'java',
1371 'severity': Severity.MEDIUM,
1372 'description':
1373 '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.',
1374 'patterns': [r".*: warning: \[TypeParameterUnusedInFormals\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001375 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001376 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001377 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001378 '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 -08001379 'patterns': [r".*: warning: \[URLEqualsHashCode\] .+"]},
1380 {'category': 'java',
1381 'severity': Severity.MEDIUM,
1382 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001383 'Java: Collection, Iterable, Multimap, and Queue do not have well-defined equals behavior',
1384 'patterns': [r".*: warning: \[UndefinedEquals\] .+"]},
1385 {'category': 'java',
1386 'severity': Severity.MEDIUM,
1387 'description':
1388 'Java: Switch handles all enum values: an explicit default case is unnecessary and defeats error checking for non-exhaustive switches.',
Andreas Gampecf528ca2018-01-25 11:55:43 -08001389 'patterns': [r".*: warning: \[UnnecessaryDefaultInEnumSwitch\] .+"]},
1390 {'category': 'java',
1391 'severity': Severity.MEDIUM,
1392 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001393 'Java: Unnecessary use of grouping parentheses',
1394 'patterns': [r".*: warning: \[UnnecessaryParentheses\] .+"]},
1395 {'category': 'java',
1396 'severity': Severity.MEDIUM,
1397 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001398 'Java: Finalizer may run before native code finishes execution',
1399 'patterns': [r".*: warning: \[UnsafeFinalization\] .+"]},
1400 {'category': 'java',
1401 'severity': Severity.MEDIUM,
1402 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001403 'Java: Prefer `asSubclass` instead of casting the result of `newInstance`, to detect classes of incorrect type before invoking their constructors.This way, if the class is of the incorrect type,it will throw an exception before invoking its constructor.',
1404 'patterns': [r".*: warning: \[UnsafeReflectiveConstructionCast\] .+"]},
1405 {'category': 'java',
1406 'severity': Severity.MEDIUM,
1407 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001408 'Java: Unsynchronized method overrides a synchronized method.',
1409 'patterns': [r".*: warning: \[UnsynchronizedOverridesSynchronized\] .+"]},
1410 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001411 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001412 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001413 'Java: Unused.',
1414 'patterns': [r".*: warning: \[Unused\] .+"]},
1415 {'category': 'java',
1416 'severity': Severity.MEDIUM,
1417 'description':
1418 'Java: This catch block catches an exception and re-throws another, but swallows the caught exception rather than setting it as a cause. This can make debugging harder.',
1419 'patterns': [r".*: warning: \[UnusedException\] .+"]},
1420 {'category': 'java',
1421 'severity': Severity.MEDIUM,
1422 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001423 'Java: Java assert is used in test. For testing purposes Assert.* matchers should be used.',
1424 'patterns': [r".*: warning: \[UseCorrectAssertInTests\] .+"]},
1425 {'category': 'java',
1426 'severity': Severity.MEDIUM,
1427 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001428 'Java: Non-constant variable missing @Var annotation',
1429 'patterns': [r".*: warning: \[Var\] .+"]},
1430 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001431 'severity': Severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -07001432 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001433 'Java: variableName and type with the same name would refer to the static field instead of the class',
1434 'patterns': [r".*: warning: \[VariableNameSameAsType\] .+"]},
1435 {'category': 'java',
1436 'severity': Severity.MEDIUM,
1437 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001438 'Java: Because of spurious wakeups, Object.wait() and Condition.await() must always be called in a loop',
1439 'patterns': [r".*: warning: \[WaitNotInLoop\] .+"]},
1440 {'category': 'java',
Andreas Gampecf528ca2018-01-25 11:55:43 -08001441 'severity': Severity.MEDIUM,
1442 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001443 '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.',
1444 'patterns': [r".*: warning: \[WakelockReleasedDangerously\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08001445 {'category': 'java',
1446 'severity': Severity.HIGH,
1447 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001448 'Java: AndroidInjection.inject() should always be invoked before calling super.lifecycleMethod()',
1449 'patterns': [r".*: warning: \[AndroidInjectionBeforeSuper\] .+"]},
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001450 {'category': 'java',
1451 'severity': Severity.HIGH,
1452 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001453 'Java: Use of class, field, or method that is not compatible with legacy Android devices',
1454 'patterns': [r".*: warning: \[AndroidJdkLibsChecker\] .+"]},
1455 {'category': 'java',
1456 'severity': Severity.HIGH,
1457 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001458 'Java: Reference equality used to compare arrays',
1459 'patterns': [r".*: warning: \[ArrayEquals\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001460 {'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: Arrays.fill(Object[], Object) called with incompatible types.',
1464 'patterns': [r".*: warning: \[ArrayFillIncompatibleType\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001465 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001466 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001467 'description':
1468 'Java: hashcode method on array does not hash array contents',
1469 'patterns': [r".*: warning: \[ArrayHashCode\] .+"]},
1470 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001471 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001472 'description':
1473 'Java: Calling toString on an array does not provide useful information',
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001474 'patterns': [r".*: warning: \[ArrayToString\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001475 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001476 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001477 'description':
1478 'Java: Arrays.asList does not autobox primitive arrays, as one might expect.',
1479 'patterns': [r".*: warning: \[ArraysAsListPrimitiveArray\] .+"]},
1480 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001481 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001482 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001483 'Java: @AssistedInject and @Inject cannot be used on the same constructor.',
1484 'patterns': [r".*: warning: \[AssistedInjectAndInjectOnSameConstructor\] .+"]},
1485 {'category': 'java',
1486 'severity': Severity.HIGH,
1487 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001488 'Java: AsyncCallable should not return a null Future, only a Future whose result is null.',
1489 'patterns': [r".*: warning: \[AsyncCallableReturnsNull\] .+"]},
1490 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001491 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001492 'description':
1493 'Java: AsyncFunction should not return a null Future, only a Future whose result is null.',
1494 'patterns': [r".*: warning: \[AsyncFunctionReturnsNull\] .+"]},
1495 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001496 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001497 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001498 'Java: @AutoFactory and @Inject should not be used in the same type.',
1499 'patterns': [r".*: warning: \[AutoFactoryAtInject\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001500 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001501 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001502 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001503 'Java: Arguments to AutoValue constructor are in the wrong order',
1504 'patterns': [r".*: warning: \[AutoValueConstructorOrderChecker\] .+"]},
1505 {'category': 'java',
1506 'severity': Severity.HIGH,
1507 'description':
1508 'Java: Shift by an amount that is out of range',
1509 'patterns': [r".*: warning: \[BadShiftAmount\] .+"]},
Andreas Gampe2e987af2018-06-08 09:55:41 -07001510 {'category': 'java',
1511 'severity': Severity.HIGH,
1512 'description':
1513 'Java: Object serialized in Bundle may have been flattened to base type.',
1514 'patterns': [r".*: warning: \[BundleDeserializationCast\] .+"]},
1515 {'category': 'java',
1516 'severity': Severity.HIGH,
1517 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001518 '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.',
1519 'patterns': [r".*: warning: \[ChainingConstructorIgnoresParameter\] .+"]},
1520 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001521 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001522 'description':
1523 'Java: Ignored return value of method that is annotated with @CheckReturnValue',
1524 'patterns': [r".*: warning: \[CheckReturnValue\] .+"]},
1525 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001526 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001527 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001528 'Java: The source file name should match the name of the top-level class it contains',
1529 'patterns': [r".*: warning: \[ClassName\] .+"]},
1530 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001531 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001532 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001533 'Java: Incompatible type as argument to Object-accepting Java collections method',
1534 'patterns': [r".*: warning: \[CollectionIncompatibleType\] .+"]},
1535 {'category': 'java',
1536 'severity': Severity.HIGH,
1537 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001538 'Java: Implementing \'Comparable\u003cT>\' where T is not compatible with the implementing class.',
Andreas Gampecf528ca2018-01-25 11:55:43 -08001539 'patterns': [r".*: warning: \[ComparableType\] .+"]},
1540 {'category': 'java',
1541 'severity': Severity.HIGH,
1542 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001543 'Java: this == null is always false, this != null is always true',
1544 'patterns': [r".*: warning: \[ComparingThisWithNull\] .+"]},
1545 {'category': 'java',
1546 'severity': Severity.HIGH,
1547 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001548 'Java: This comparison method violates the contract',
1549 'patterns': [r".*: warning: \[ComparisonContractViolated\] .+"]},
1550 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001551 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001552 'description':
1553 'Java: Comparison to value that is out of range for the compared type',
1554 'patterns': [r".*: warning: \[ComparisonOutOfRange\] .+"]},
1555 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001556 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001557 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001558 'Java: @CompatibleWith\'s value is not a type argument.',
1559 'patterns': [r".*: warning: \[CompatibleWithAnnotationMisuse\] .+"]},
1560 {'category': 'java',
1561 'severity': Severity.HIGH,
1562 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001563 'Java: Non-compile-time constant expression passed to parameter with @CompileTimeConstant type annotation.',
1564 'patterns': [r".*: warning: \[CompileTimeConstant\] .+"]},
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: Non-trivial compile time constant boolean expressions shouldn\'t be used.',
1569 'patterns': [r".*: warning: \[ComplexBooleanConstant\] .+"]},
1570 {'category': 'java',
1571 'severity': Severity.HIGH,
1572 'description':
1573 '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.',
1574 'patterns': [r".*: warning: \[ConditionalExpressionNumericPromotion\] .+"]},
1575 {'category': 'java',
1576 'severity': Severity.HIGH,
1577 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001578 'Java: Compile-time constant expression overflows',
1579 'patterns': [r".*: warning: \[ConstantOverflow\] .+"]},
1580 {'category': 'java',
1581 'severity': Severity.HIGH,
1582 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001583 'Java: Dagger @Provides methods may not return null unless annotated with @Nullable',
1584 'patterns': [r".*: warning: \[DaggerProvidesNull\] .+"]},
1585 {'category': 'java',
1586 'severity': Severity.HIGH,
1587 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001588 'Java: Exception created but not thrown',
1589 'patterns': [r".*: warning: \[DeadException\] .+"]},
1590 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001591 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001592 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001593 'Java: Thread created but not started',
1594 'patterns': [r".*: warning: \[DeadThread\] .+"]},
1595 {'category': 'java',
1596 'severity': Severity.HIGH,
1597 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001598 'Java: Deprecated item is not annotated with @Deprecated',
1599 'patterns': [r".*: warning: \[DepAnn\] .+"]},
1600 {'category': 'java',
1601 'severity': Severity.HIGH,
1602 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001603 'Java: Division by integer literal zero',
1604 'patterns': [r".*: warning: \[DivZero\] .+"]},
1605 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001606 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001607 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001608 'Java: This method should not be called.',
1609 'patterns': [r".*: warning: \[DoNotCall\] .+"]},
1610 {'category': 'java',
1611 'severity': Severity.HIGH,
1612 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001613 'Java: Empty statement after if',
1614 'patterns': [r".*: warning: \[EmptyIf\] .+"]},
1615 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001616 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001617 'description':
1618 'Java: == NaN always returns false; use the isNaN methods instead',
1619 'patterns': [r".*: warning: \[EqualsNaN\] .+"]},
1620 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001621 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001622 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001623 'Java: == must be used in equals method to check equality to itself or an infinite loop will occur.',
1624 'patterns': [r".*: warning: \[EqualsReference\] .+"]},
1625 {'category': 'java',
1626 'severity': Severity.HIGH,
1627 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001628 'Java: Comparing different pairs of fields/getters in an equals implementation is probably a mistake.',
1629 'patterns': [r".*: warning: \[EqualsWrongThing\] .+"]},
1630 {'category': 'java',
1631 'severity': Severity.HIGH,
1632 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001633 '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 -07001634 'patterns': [r".*: warning: \[ForOverride\] .+"]},
1635 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001636 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001637 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001638 'Java: Invalid printf-style format string',
1639 'patterns': [r".*: warning: \[FormatString\] .+"]},
1640 {'category': 'java',
1641 'severity': Severity.HIGH,
1642 'description':
1643 'Java: Invalid format string passed to formatting method.',
1644 'patterns': [r".*: warning: \[FormatStringAnnotation\] .+"]},
1645 {'category': 'java',
1646 'severity': Severity.HIGH,
1647 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001648 '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.',
1649 'patterns': [r".*: warning: \[FunctionalInterfaceMethodChanged\] .+"]},
1650 {'category': 'java',
1651 'severity': Severity.HIGH,
1652 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001653 'Java: Futures.getChecked requires a checked exception type with a standard constructor.',
1654 'patterns': [r".*: warning: \[FuturesGetCheckedIllegalExceptionType\] .+"]},
1655 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001656 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001657 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001658 'Java: DoubleMath.fuzzyEquals should never be used in an Object.equals() method',
1659 'patterns': [r".*: warning: \[FuzzyEqualsShouldNotBeUsedInEqualsMethod\] .+"]},
1660 {'category': 'java',
1661 'severity': Severity.HIGH,
1662 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001663 'Java: Calling getClass() on an annotation may return a proxy class',
1664 'patterns': [r".*: warning: \[GetClassOnAnnotation\] .+"]},
1665 {'category': 'java',
1666 'severity': Severity.HIGH,
1667 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001668 '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',
1669 'patterns': [r".*: warning: \[GetClassOnClass\] .+"]},
1670 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001671 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001672 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001673 'Java: Checks for unguarded accesses to fields and methods with @GuardedBy annotations',
1674 'patterns': [r".*: warning: \[GuardedBy\] .+"]},
1675 {'category': 'java',
1676 'severity': Severity.HIGH,
1677 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001678 'Java: Scope annotation on implementation class of AssistedInject factory is not allowed',
1679 'patterns': [r".*: warning: \[GuiceAssistedInjectScoping\] .+"]},
1680 {'category': 'java',
1681 'severity': Severity.HIGH,
1682 'description':
1683 'Java: A constructor cannot have two @Assisted parameters of the same type unless they are disambiguated with named @Assisted annotations.',
1684 'patterns': [r".*: warning: \[GuiceAssistedParameters\] .+"]},
1685 {'category': 'java',
1686 'severity': Severity.HIGH,
1687 'description':
1688 'Java: Although Guice allows injecting final fields, doing so is disallowed because the injected value may not be visible to other threads.',
1689 'patterns': [r".*: warning: \[GuiceInjectOnFinalField\] .+"]},
1690 {'category': 'java',
1691 'severity': Severity.HIGH,
1692 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001693 'Java: contains() is a legacy method that is equivalent to containsValue()',
1694 'patterns': [r".*: warning: \[HashtableContains\] .+"]},
1695 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001696 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001697 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001698 'Java: A binary expression where both operands are the same is usually incorrect.',
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001699 'patterns': [r".*: warning: \[IdentityBinaryExpression\] .+"]},
1700 {'category': 'java',
1701 'severity': Severity.HIGH,
1702 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001703 'Java: Type declaration annotated with @Immutable is not immutable',
1704 'patterns': [r".*: warning: \[Immutable\] .+"]},
1705 {'category': 'java',
1706 'severity': Severity.HIGH,
1707 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001708 'Java: Modifying an immutable collection is guaranteed to throw an exception and leave the collection unmodified',
1709 'patterns': [r".*: warning: \[ImmutableModification\] .+"]},
1710 {'category': 'java',
1711 'severity': Severity.HIGH,
1712 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001713 'Java: Passing argument to a generic method with an incompatible type.',
1714 'patterns': [r".*: warning: \[IncompatibleArgumentType\] .+"]},
1715 {'category': 'java',
1716 'severity': Severity.HIGH,
1717 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001718 'Java: The first argument to indexOf is a Unicode code point, and the second is the index to start the search from',
1719 'patterns': [r".*: warning: \[IndexOfChar\] .+"]},
1720 {'category': 'java',
1721 'severity': Severity.HIGH,
1722 'description':
1723 'Java: Conditional expression in varargs call contains array and non-array arguments',
1724 'patterns': [r".*: warning: \[InexactVarargsConditional\] .+"]},
1725 {'category': 'java',
1726 'severity': Severity.HIGH,
1727 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001728 'Java: This method always recurses, and will cause a StackOverflowError',
1729 'patterns': [r".*: warning: \[InfiniteRecursion\] .+"]},
1730 {'category': 'java',
1731 'severity': Severity.HIGH,
1732 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001733 'Java: A scoping annotation\'s Target should include TYPE and METHOD.',
1734 'patterns': [r".*: warning: \[InjectInvalidTargetingOnScopingAnnotation\] .+"]},
1735 {'category': 'java',
1736 'severity': Severity.HIGH,
1737 'description':
1738 'Java: Using more than one qualifier annotation on the same element is not allowed.',
1739 'patterns': [r".*: warning: \[InjectMoreThanOneQualifier\] .+"]},
1740 {'category': 'java',
1741 'severity': Severity.HIGH,
1742 'description':
1743 'Java: A class can be annotated with at most one scope annotation.',
1744 'patterns': [r".*: warning: \[InjectMoreThanOneScopeAnnotationOnClass\] .+"]},
1745 {'category': 'java',
1746 'severity': Severity.HIGH,
1747 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001748 'Java: Members shouldn\'t be annotated with @Inject if constructor is already annotated @Inject',
1749 'patterns': [r".*: warning: \[InjectOnMemberAndConstructor\] .+"]},
1750 {'category': 'java',
1751 'severity': Severity.HIGH,
1752 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001753 'Java: Scope annotation on an interface or abstact class is not allowed',
1754 'patterns': [r".*: warning: \[InjectScopeAnnotationOnInterfaceOrAbstractClass\] .+"]},
1755 {'category': 'java',
1756 'severity': Severity.HIGH,
1757 'description':
1758 'Java: Scoping and qualifier annotations must have runtime retention.',
1759 'patterns': [r".*: warning: \[InjectScopeOrQualifierAnnotationRetention\] .+"]},
1760 {'category': 'java',
1761 'severity': Severity.HIGH,
1762 'description':
1763 'Java: Injected constructors cannot be optional nor have binding annotations',
1764 'patterns': [r".*: warning: \[InjectedConstructorAnnotations\] .+"]},
1765 {'category': 'java',
1766 'severity': Severity.HIGH,
1767 'description':
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08001768 'Java: A standard cryptographic operation is used in a mode that is prone to vulnerabilities',
1769 'patterns': [r".*: warning: \[InsecureCryptoUsage\] .+"]},
Ian Rogers6e520032016-05-13 08:59:00 -07001770 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001771 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001772 'description':
1773 'Java: Invalid syntax used for a regular expression',
1774 'patterns': [r".*: warning: \[InvalidPatternSyntax\] .+"]},
1775 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001776 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001777 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001778 'Java: Invalid time zone identifier. TimeZone.getTimeZone(String) will silently return GMT instead of the time zone you intended.',
1779 'patterns': [r".*: warning: \[InvalidTimeZoneID\] .+"]},
1780 {'category': 'java',
1781 'severity': Severity.HIGH,
1782 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001783 'Java: The argument to Class#isInstance(Object) should not be a Class',
1784 'patterns': [r".*: warning: \[IsInstanceOfClass\] .+"]},
1785 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001786 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001787 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001788 'Java: Log tag too long, cannot exceed 23 characters.',
1789 'patterns': [r".*: warning: \[IsLoggableTagLength\] .+"]},
1790 {'category': 'java',
1791 'severity': Severity.HIGH,
1792 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001793 'Java: Path implements Iterable\u003cPath>; prefer Collection\u003cPath> for clarity',
Andreas Gampecf528ca2018-01-25 11:55:43 -08001794 'patterns': [r".*: warning: \[IterablePathParameter\] .+"]},
1795 {'category': 'java',
1796 'severity': Severity.HIGH,
1797 'description':
Ian Rogers6e520032016-05-13 08:59:00 -07001798 'Java: jMock tests must have a @RunWith(JMock.class) annotation, or the Mockery field must have a @Rule JUnit annotation',
1799 'patterns': [r".*: warning: \[JMockTestWithoutRunWithOrRuleAnnotation\] .+"]},
1800 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001801 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001802 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001803 '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 -07001804 'patterns': [r".*: warning: \[JUnit3TestNotRun\] .+"]},
1805 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001806 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001807 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001808 'Java: This method should be static',
1809 'patterns': [r".*: warning: \[JUnit4ClassAnnotationNonStatic\] .+"]},
1810 {'category': 'java',
1811 'severity': Severity.HIGH,
1812 'description':
1813 'Java: setUp() method will not be run; please add JUnit\'s @Before annotation',
Ian Rogers6e520032016-05-13 08:59:00 -07001814 'patterns': [r".*: warning: \[JUnit4SetUpNotRun\] .+"]},
1815 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001816 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001817 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001818 'Java: tearDown() method will not be run; please add JUnit\'s @After annotation',
Ian Rogers6e520032016-05-13 08:59:00 -07001819 'patterns': [r".*: warning: \[JUnit4TearDownNotRun\] .+"]},
1820 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001821 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001822 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001823 '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 -07001824 'patterns': [r".*: warning: \[JUnit4TestNotRun\] .+"]},
1825 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07001826 'severity': Severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001827 'description':
Andreas Gampecf528ca2018-01-25 11:55:43 -08001828 'Java: An object is tested for reference equality to itself using JUnit library.',
1829 'patterns': [r".*: warning: \[JUnitAssertSameCheck\] .+"]},
1830 {'category': 'java',
1831 'severity': Severity.HIGH,
1832 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001833 'Java: Use of class, field, or method that is not compatible with JDK 7',
1834 'patterns': [r".*: warning: \[Java7ApiChecker\] .+"]},
1835 {'category': 'java',
1836 'severity': Severity.HIGH,
1837 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001838 'Java: Abstract and default methods are not injectable with javax.inject.Inject',
1839 'patterns': [r".*: warning: \[JavaxInjectOnAbstractMethod\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08001840 {'category': 'java',
1841 'severity': Severity.HIGH,
1842 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001843 'Java: @javax.inject.Inject cannot be put on a final field.',
1844 'patterns': [r".*: warning: \[JavaxInjectOnFinalField\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08001845 {'category': 'java',
1846 'severity': Severity.HIGH,
1847 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001848 'Java: This pattern will silently corrupt certain byte sequences from the serialized protocol message. Use ByteString or byte[] directly',
1849 'patterns': [r".*: warning: \[LiteByteStringUtf8\] .+"]},
1850 {'category': 'java',
1851 'severity': Severity.HIGH,
1852 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001853 'Java: This method does not acquire the locks specified by its @LockMethod annotation',
1854 'patterns': [r".*: warning: \[LockMethodChecker\] .+"]},
1855 {'category': 'java',
1856 'severity': Severity.HIGH,
1857 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001858 'Java: Prefer \'L\' to \'l\' for the suffix to long literals',
1859 'patterns': [r".*: warning: \[LongLiteralLowerCaseSuffix\] .+"]},
Andreas Gampe2e987af2018-06-08 09:55:41 -07001860 {'category': 'java',
1861 'severity': Severity.HIGH,
1862 'description':
1863 'Java: Loop condition is never modified in loop body.',
1864 'patterns': [r".*: warning: \[LoopConditionChecker\] .+"]},
1865 {'category': 'java',
1866 'severity': Severity.HIGH,
1867 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001868 'Java: Math.round(Integer) results in truncation',
1869 'patterns': [r".*: warning: \[MathRoundIntLong\] .+"]},
1870 {'category': 'java',
1871 'severity': Severity.HIGH,
1872 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001873 'Java: Certain resources in `android.R.string` have names that do not match their content',
1874 'patterns': [r".*: warning: \[MislabeledAndroidString\] .+"]},
1875 {'category': 'java',
1876 'severity': Severity.HIGH,
1877 'description':
1878 'Java: Overriding method is missing a call to overridden super method',
1879 'patterns': [r".*: warning: \[MissingSuperCall\] .+"]},
1880 {'category': 'java',
1881 'severity': Severity.HIGH,
1882 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001883 'Java: A terminating method call is required for a test helper to have any effect.',
1884 'patterns': [r".*: warning: \[MissingTestCall\] .+"]},
1885 {'category': 'java',
1886 'severity': Severity.HIGH,
1887 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001888 'Java: Use of "YYYY" (week year) in a date pattern without "ww" (week in year). You probably meant to use "yyyy" (year) instead.',
1889 'patterns': [r".*: warning: \[MisusedWeekYear\] .+"]},
1890 {'category': 'java',
1891 'severity': Severity.HIGH,
1892 'description':
1893 'Java: A bug in Mockito will cause this test to fail at runtime with a ClassCastException',
1894 'patterns': [r".*: warning: \[MockitoCast\] .+"]},
1895 {'category': 'java',
1896 'severity': Severity.HIGH,
1897 'description':
1898 'Java: Missing method call for verify(mock) here',
1899 'patterns': [r".*: warning: \[MockitoUsage\] .+"]},
1900 {'category': 'java',
1901 'severity': Severity.HIGH,
1902 'description':
1903 'Java: Using a collection function with itself as the argument.',
1904 'patterns': [r".*: warning: \[ModifyingCollectionWithItself\] .+"]},
1905 {'category': 'java',
1906 'severity': Severity.HIGH,
1907 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001908 'Java: This class has more than one @Inject-annotated constructor. Please remove the @Inject annotation from all but one of them.',
1909 'patterns': [r".*: warning: \[MoreThanOneInjectableConstructor\] .+"]},
1910 {'category': 'java',
1911 'severity': Severity.HIGH,
1912 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001913 'Java: The result of this method must be closed.',
1914 'patterns': [r".*: warning: \[MustBeClosedChecker\] .+"]},
1915 {'category': 'java',
1916 'severity': Severity.HIGH,
1917 'description':
1918 'Java: The first argument to nCopies is the number of copies, and the second is the item to copy',
1919 'patterns': [r".*: warning: \[NCopiesOfChar\] .+"]},
1920 {'category': 'java',
1921 'severity': Severity.HIGH,
1922 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001923 'Java: @NoAllocation was specified on this method, but something was found that would trigger an allocation',
1924 'patterns': [r".*: warning: \[NoAllocation\] .+"]},
1925 {'category': 'java',
1926 'severity': Severity.HIGH,
1927 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001928 'Java: Static import of type uses non-canonical name',
1929 'patterns': [r".*: warning: \[NonCanonicalStaticImport\] .+"]},
1930 {'category': 'java',
1931 'severity': Severity.HIGH,
1932 'description':
1933 'Java: @CompileTimeConstant parameters should be final or effectively final',
1934 'patterns': [r".*: warning: \[NonFinalCompileTimeConstant\] .+"]},
1935 {'category': 'java',
1936 'severity': Severity.HIGH,
1937 'description':
1938 'Java: Calling getAnnotation on an annotation that is not retained at runtime.',
1939 'patterns': [r".*: warning: \[NonRuntimeAnnotation\] .+"]},
1940 {'category': 'java',
1941 'severity': Severity.HIGH,
1942 'description':
1943 'Java: This conditional expression may evaluate to null, which will result in an NPE when the result is unboxed.',
1944 'patterns': [r".*: warning: \[NullTernary\] .+"]},
1945 {'category': 'java',
1946 'severity': Severity.HIGH,
1947 'description':
1948 'Java: Numeric comparison using reference equality instead of value equality',
1949 'patterns': [r".*: warning: \[NumericEquality\] .+"]},
1950 {'category': 'java',
1951 'severity': Severity.HIGH,
1952 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001953 'Java: Comparison using reference equality instead of value equality',
1954 'patterns': [r".*: warning: \[OptionalEquality\] .+"]},
Andreas Gampe2e987af2018-06-08 09:55:41 -07001955 {'category': 'java',
1956 'severity': Severity.HIGH,
1957 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001958 'Java: Annotations cannot be both Scope annotations and Qualifier annotations: this causes confusion when trying to use them.',
1959 'patterns': [r".*: warning: \[OverlappingQualifierAndScopeAnnotation\] .+"]},
1960 {'category': 'java',
1961 'severity': Severity.HIGH,
1962 'description':
1963 '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.',
1964 'patterns': [r".*: warning: \[OverridesJavaxInjectableMethod\] .+"]},
Andreas Gampe2e987af2018-06-08 09:55:41 -07001965 {'category': 'java',
1966 'severity': Severity.HIGH,
1967 'description':
1968 'Java: Declaring types inside package-info.java files is very bad form',
1969 'patterns': [r".*: warning: \[PackageInfo\] .+"]},
1970 {'category': 'java',
1971 'severity': Severity.HIGH,
1972 'description':
1973 'Java: Method parameter has wrong package',
1974 'patterns': [r".*: warning: \[ParameterPackage\] .+"]},
1975 {'category': 'java',
1976 'severity': Severity.HIGH,
1977 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07001978 'Java: Detects classes which implement Parcelable but don\'t have CREATOR',
1979 'patterns': [r".*: warning: \[ParcelableCreator\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08001980 {'category': 'java',
1981 'severity': Severity.HIGH,
1982 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07001983 'Java: Literal passed as first argument to Preconditions.checkNotNull() can never be null',
1984 'patterns': [r".*: warning: \[PreconditionsCheckNotNull\] .+"]},
1985 {'category': 'java',
1986 'severity': Severity.HIGH,
1987 'description':
1988 'Java: First argument to `Preconditions.checkNotNull()` is a primitive rather than an object reference',
1989 'patterns': [r".*: warning: \[PreconditionsCheckNotNullPrimitive\] .+"]},
1990 {'category': 'java',
1991 'severity': Severity.HIGH,
1992 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07001993 'Java: Using ::equals or ::isInstance as an incompatible Predicate; the predicate will always return false',
Andreas Gampe2e987af2018-06-08 09:55:41 -07001994 'patterns': [r".*: warning: \[PredicateIncompatibleType\] .+"]},
1995 {'category': 'java',
1996 'severity': Severity.HIGH,
1997 'description':
1998 '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.',
1999 'patterns': [r".*: warning: \[PrivateSecurityContractProtoAccess\] .+"]},
2000 {'category': 'java',
2001 'severity': Severity.HIGH,
2002 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07002003 'Java: Protobuf fields cannot be null.',
Andreas Gampe2e987af2018-06-08 09:55:41 -07002004 'patterns': [r".*: warning: \[ProtoFieldNullComparison\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08002005 {'category': 'java',
2006 'severity': Severity.HIGH,
2007 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07002008 'Java: Comparing protobuf fields of type String using reference equality',
2009 'patterns': [r".*: warning: \[ProtoStringFieldReferenceEquality\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08002010 {'category': 'java',
2011 'severity': Severity.HIGH,
2012 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07002013 'Java: To get the tag number of a protocol buffer enum, use getNumber() instead.',
2014 'patterns': [r".*: warning: \[ProtocolBufferOrdinal\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08002015 {'category': 'java',
2016 'severity': Severity.HIGH,
2017 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07002018 'Java: @Provides methods need to be declared in a Module to have any effect.',
2019 'patterns': [r".*: warning: \[ProvidesMethodOutsideOfModule\] .+"]},
2020 {'category': 'java',
2021 'severity': Severity.HIGH,
2022 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07002023 'Java: Casting a random number in the range [0.0, 1.0) to an integer or long always results in 0.',
2024 'patterns': [r".*: warning: \[RandomCast\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08002025 {'category': 'java',
2026 'severity': Severity.HIGH,
2027 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07002028 'Java: Use Random.nextInt(int). Random.nextInt() % n can have negative results',
2029 'patterns': [r".*: warning: \[RandomModInteger\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08002030 {'category': 'java',
2031 'severity': Severity.HIGH,
2032 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07002033 'Java: Return value of android.graphics.Rect.intersect() must be checked',
2034 'patterns': [r".*: warning: \[RectIntersectReturnValueIgnored\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08002035 {'category': 'java',
2036 'severity': Severity.HIGH,
2037 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07002038 'Java: Use of method or class annotated with @RestrictTo',
2039 'patterns': [r".*: warning: \[RestrictTo\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08002040 {'category': 'java',
2041 'severity': Severity.HIGH,
2042 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07002043 'Java: Check for non-whitelisted callers to RestrictedApiChecker.',
2044 'patterns': [r".*: warning: \[RestrictedApiChecker\] .+"]},
2045 {'category': 'java',
2046 'severity': Severity.HIGH,
2047 'description':
2048 'Java: Return value of this method must be used',
2049 'patterns': [r".*: warning: \[ReturnValueIgnored\] .+"]},
2050 {'category': 'java',
2051 'severity': Severity.HIGH,
2052 'description':
2053 'Java: Variable assigned to itself',
2054 'patterns': [r".*: warning: \[SelfAssignment\] .+"]},
2055 {'category': 'java',
2056 'severity': Severity.HIGH,
2057 'description':
2058 'Java: An object is compared to itself',
2059 'patterns': [r".*: warning: \[SelfComparison\] .+"]},
2060 {'category': 'java',
2061 'severity': Severity.HIGH,
2062 'description':
2063 'Java: Testing an object for equality with itself will always be true.',
2064 'patterns': [r".*: warning: \[SelfEquals\] .+"]},
2065 {'category': 'java',
2066 'severity': Severity.HIGH,
2067 'description':
2068 'Java: This method must be called with an even number of arguments.',
2069 'patterns': [r".*: warning: \[ShouldHaveEvenArgs\] .+"]},
Andreas Gampecf528ca2018-01-25 11:55:43 -08002070 {'category': 'java',
2071 'severity': Severity.HIGH,
2072 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07002073 'Java: Comparison of a size >= 0 is always true, did you intend to check for non-emptiness?',
2074 'patterns': [r".*: warning: \[SizeGreaterThanOrEqualsZero\] .+"]},
2075 {'category': 'java',
2076 'severity': Severity.HIGH,
2077 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07002078 'Java: Static and default interface methods are not natively supported on older Android devices. ',
2079 'patterns': [r".*: warning: \[StaticOrDefaultInterfaceMethod\] .+"]},
Andreas Gampe2e987af2018-06-08 09:55:41 -07002080 {'category': 'java',
2081 'severity': Severity.HIGH,
2082 'description':
Andreas Gampeb9dc23a2018-06-08 10:11:26 -07002083 'Java: Calling toString on a Stream does not provide useful information',
2084 'patterns': [r".*: warning: \[StreamToString\] .+"]},
Andreas Gampe2e987af2018-06-08 09:55:41 -07002085 {'category': 'java',
2086 'severity': Severity.HIGH,
2087 'description':
2088 'Java: StringBuilder does not have a char constructor; this invokes the int constructor.',
2089 'patterns': [r".*: warning: \[StringBuilderInitWithChar\] .+"]},
2090 {'category': 'java',
2091 'severity': Severity.HIGH,
2092 'description':
Andreas Gampe161ec1e2018-10-15 08:56:58 -07002093 'Java: String.substring(0) returns the original String',
2094 'patterns': [r".*: warning: \[SubstringOfZero\] .+"]},
2095 {'category': 'java',
2096 'severity': Severity.HIGH,
2097 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07002098 'Java: Suppressing "deprecated" is probably a typo for "deprecation"',
2099 'patterns': [r".*: warning: \[SuppressWarningsDeprecated\] .+"]},
2100 {'category': 'java',
2101 'severity': Severity.HIGH,
2102 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07002103 'Java: throwIfUnchecked(knownCheckedException) is a no-op.',
2104 'patterns': [r".*: warning: \[ThrowIfUncheckedKnownChecked\] .+"]},
2105 {'category': 'java',
2106 'severity': Severity.HIGH,
2107 'description':
2108 'Java: Throwing \'null\' always results in a NullPointerException being thrown.',
2109 'patterns': [r".*: warning: \[ThrowNull\] .+"]},
2110 {'category': 'java',
2111 'severity': Severity.HIGH,
2112 'description':
2113 'Java: isEqualTo should not be used to test an object for equality with itself; the assertion will never fail.',
2114 'patterns': [r".*: warning: \[TruthSelfEquals\] .+"]},
2115 {'category': 'java',
2116 'severity': Severity.HIGH,
2117 'description':
2118 'Java: Catching Throwable/Error masks failures from fail() or assert*() in the try block',
2119 'patterns': [r".*: warning: \[TryFailThrowable\] .+"]},
2120 {'category': 'java',
2121 'severity': Severity.HIGH,
2122 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07002123 'Java: Type parameter used as type qualifier',
2124 'patterns': [r".*: warning: \[TypeParameterQualifier\] .+"]},
2125 {'category': 'java',
2126 'severity': Severity.HIGH,
2127 'description':
Andreas Gampe2e987af2018-06-08 09:55:41 -07002128 'Java: This method does not acquire the locks specified by its @UnlockMethod annotation',
2129 'patterns': [r".*: warning: \[UnlockMethod\] .+"]},
2130 {'category': 'java',
2131 'severity': Severity.HIGH,
2132 'description':
2133 'Java: Non-generic methods should not be invoked with type arguments',
2134 'patterns': [r".*: warning: \[UnnecessaryTypeArgument\] .+"]},
2135 {'category': 'java',
2136 'severity': Severity.HIGH,
2137 'description':
2138 'Java: Instance created but never used',
2139 'patterns': [r".*: warning: \[UnusedAnonymousClass\] .+"]},
2140 {'category': 'java',
2141 'severity': Severity.HIGH,
2142 'description':
2143 'Java: Collection is modified in place, but the result is not used',
2144 'patterns': [r".*: warning: \[UnusedCollectionModifiedInPlace\] .+"]},
2145 {'category': 'java',
2146 'severity': Severity.HIGH,
2147 'description':
2148 'Java: `var` should not be used as a type name.',
2149 'patterns': [r".*: warning: \[VarTypeName\] .+"]},
Nick Glorioso8a7b25c2016-11-15 15:57:57 -08002150
2151 # End warnings generated by Error Prone
Ian Rogers32bb9bd2016-05-09 23:19:42 -07002152
Ian Rogers6e520032016-05-13 08:59:00 -07002153 {'category': 'java',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002154 'severity': Severity.UNKNOWN,
Ian Rogers6e520032016-05-13 08:59:00 -07002155 'description': 'Java: Unclassified/unrecognized warnings',
2156 'patterns': [r".*: warning: \[.+\] .+"]},
Ian Rogers32bb9bd2016-05-09 23:19:42 -07002157
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002158 {'category': 'aapt', 'severity': Severity.MEDIUM,
2159 'description': 'aapt: No default translation',
2160 'patterns': [r".*: warning: string '.+' has no default translation in .*"]},
2161 {'category': 'aapt', 'severity': Severity.MEDIUM,
2162 'description': 'aapt: Missing default or required localization',
2163 'patterns': [r".*: warning: \*\*\*\* string '.+' has no default or required localization for '.+' in .+"]},
2164 {'category': 'aapt', 'severity': Severity.MEDIUM,
2165 'description': 'aapt: String marked untranslatable, but translation exists',
2166 'patterns': [r".*: warning: string '.+' in .* marked untranslatable but exists in locale '??_??'"]},
2167 {'category': 'aapt', 'severity': Severity.MEDIUM,
2168 'description': 'aapt: empty span in string',
2169 'patterns': [r".*: warning: empty '.+' span found in text '.+"]},
2170 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2171 'description': 'Taking address of temporary',
2172 'patterns': [r".*: warning: taking address of temporary"]},
2173 {'category': 'C/C++', 'severity': Severity.MEDIUM,
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07002174 'description': 'Taking address of packed member',
2175 'patterns': [r".*: warning: taking address of packed member"]},
2176 {'category': 'C/C++', 'severity': Severity.MEDIUM,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002177 'description': 'Possible broken line continuation',
2178 'patterns': [r".*: warning: backslash and newline separated by space"]},
2179 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wundefined-var-template',
2180 'description': 'Undefined variable template',
2181 'patterns': [r".*: warning: instantiation of variable .* no definition is available"]},
2182 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wundefined-inline',
2183 'description': 'Inline function is not defined',
2184 'patterns': [r".*: warning: inline function '.*' is not defined"]},
2185 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Warray-bounds',
2186 'description': 'Array subscript out of bounds',
2187 'patterns': [r".*: warning: array subscript is above array bounds",
2188 r".*: warning: Array subscript is undefined",
2189 r".*: warning: array subscript is below array bounds"]},
2190 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2191 'description': 'Excess elements in initializer',
2192 'patterns': [r".*: warning: excess elements in .+ initializer"]},
2193 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2194 'description': 'Decimal constant is unsigned only in ISO C90',
2195 'patterns': [r".*: warning: this decimal constant is unsigned only in ISO C90"]},
2196 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmain',
2197 'description': 'main is usually a function',
2198 'patterns': [r".*: warning: 'main' is usually a function"]},
2199 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2200 'description': 'Typedef ignored',
2201 'patterns': [r".*: warning: 'typedef' was ignored in this declaration"]},
2202 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Waddress',
2203 'description': 'Address always evaluates to true',
2204 'patterns': [r".*: warning: the address of '.+' will always evaluate as 'true'"]},
2205 {'category': 'C/C++', 'severity': Severity.FIXMENOW,
2206 'description': 'Freeing a non-heap object',
2207 'patterns': [r".*: warning: attempt to free a non-heap object '.+'"]},
2208 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wchar-subscripts',
2209 'description': 'Array subscript has type char',
2210 'patterns': [r".*: warning: array subscript .+ type 'char'.+Wchar-subscripts"]},
2211 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2212 'description': 'Constant too large for type',
2213 'patterns': [r".*: warning: integer constant is too large for '.+' type"]},
2214 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Woverflow',
2215 'description': 'Constant too large for type, truncated',
2216 'patterns': [r".*: warning: large integer implicitly truncated to unsigned type"]},
2217 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Winteger-overflow',
2218 'description': 'Overflow in expression',
2219 'patterns': [r".*: warning: overflow in expression; .*Winteger-overflow"]},
2220 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Woverflow',
2221 'description': 'Overflow in implicit constant conversion',
2222 'patterns': [r".*: warning: overflow in implicit constant conversion"]},
2223 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2224 'description': 'Declaration does not declare anything',
2225 'patterns': [r".*: warning: declaration 'class .+' does not declare anything"]},
2226 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wreorder',
2227 'description': 'Initialization order will be different',
2228 'patterns': [r".*: warning: '.+' will be initialized after",
2229 r".*: warning: field .+ will be initialized after .+Wreorder"]},
2230 {'category': 'cont.', 'severity': Severity.SKIP,
2231 'description': 'skip, ....',
2232 'patterns': [r".*: warning: '.+'"]},
2233 {'category': 'cont.', 'severity': Severity.SKIP,
2234 'description': 'skip, base ...',
2235 'patterns': [r".*: warning: base '.+'"]},
2236 {'category': 'cont.', 'severity': Severity.SKIP,
2237 'description': 'skip, when initialized here',
2238 'patterns': [r".*: warning: when initialized here"]},
2239 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-parameter-type',
2240 'description': 'Parameter type not specified',
2241 'patterns': [r".*: warning: type of '.+' defaults to 'int'"]},
2242 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-declarations',
2243 'description': 'Missing declarations',
2244 'patterns': [r".*: warning: declaration does not declare anything"]},
2245 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-noreturn',
2246 'description': 'Missing noreturn',
2247 'patterns': [r".*: warning: function '.*' could be declared with attribute 'noreturn'"]},
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002248 # pylint:disable=anomalous-backslash-in-string
2249 # TODO(chh): fix the backslash pylint warning.
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002250 {'category': 'gcc', 'severity': Severity.MEDIUM,
2251 'description': 'Invalid option for C file',
2252 'patterns': [r".*: warning: command line option "".+"" is valid for C\+\+\/ObjC\+\+ but not for C"]},
2253 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2254 'description': 'User warning',
2255 'patterns': [r".*: warning: #warning "".+"""]},
2256 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wvexing-parse',
2257 'description': 'Vexing parsing problem',
2258 'patterns': [r".*: warning: empty parentheses interpreted as a function declaration"]},
2259 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wextra',
2260 'description': 'Dereferencing void*',
2261 'patterns': [r".*: warning: dereferencing 'void \*' pointer"]},
2262 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2263 'description': 'Comparison of pointer and integer',
2264 'patterns': [r".*: warning: ordered comparison of pointer with integer zero",
2265 r".*: warning: .*comparison between pointer and integer"]},
2266 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2267 'description': 'Use of error-prone unary operator',
2268 'patterns': [r".*: warning: use of unary operator that may be intended as compound assignment"]},
2269 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wwrite-strings',
2270 'description': 'Conversion of string constant to non-const char*',
2271 'patterns': [r".*: warning: deprecated conversion from string constant to '.+'"]},
2272 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wstrict-prototypes',
2273 'description': 'Function declaration isn''t a prototype',
2274 'patterns': [r".*: warning: function declaration isn't a prototype"]},
2275 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wignored-qualifiers',
2276 'description': 'Type qualifiers ignored on function return value',
2277 'patterns': [r".*: warning: type qualifiers ignored on function return type",
2278 r".*: warning: .+ type qualifier .+ has no effect .+Wignored-qualifiers"]},
2279 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2280 'description': '<foo> declared inside parameter list, scope limited to this definition',
2281 'patterns': [r".*: warning: '.+' declared inside parameter list"]},
2282 {'category': 'cont.', 'severity': Severity.SKIP,
2283 'description': 'skip, its scope is only this ...',
2284 'patterns': [r".*: warning: its scope is only this definition or declaration, which is probably not what you want"]},
2285 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wcomment',
2286 'description': 'Line continuation inside comment',
2287 'patterns': [r".*: warning: multi-line comment"]},
2288 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wcomment',
2289 'description': 'Comment inside comment',
2290 'patterns': [r".*: warning: "".+"" within comment"]},
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07002291 # Warning "value stored is never read" could be from clang-tidy or clang static analyzer.
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002292 {'category': 'C/C++', 'severity': Severity.ANALYZER,
2293 'description': 'clang-analyzer Value stored is never read',
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002294 'patterns': [r".*: warning: Value stored to .+ is never read.*clang-analyzer-deadcode.DeadStores"]},
2295 {'category': 'C/C++', 'severity': Severity.LOW,
2296 'description': 'Value stored is never read',
2297 'patterns': [r".*: warning: Value stored to .+ is never read"]},
2298 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wdeprecated-declarations',
2299 'description': 'Deprecated declarations',
2300 'patterns': [r".*: warning: .+ is deprecated.+deprecated-declarations"]},
2301 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wdeprecated-register',
2302 'description': 'Deprecated register',
2303 'patterns': [r".*: warning: 'register' storage class specifier is deprecated"]},
2304 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wpointer-sign',
2305 'description': 'Converts between pointers to integer types with different sign',
2306 'patterns': [r".*: warning: .+ converts between pointers to integer types with different sign"]},
2307 {'category': 'C/C++', 'severity': Severity.HARMLESS,
2308 'description': 'Extra tokens after #endif',
2309 'patterns': [r".*: warning: extra tokens at end of #endif directive"]},
2310 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wenum-compare',
2311 'description': 'Comparison between different enums',
2312 'patterns': [r".*: warning: comparison between '.+' and '.+'.+Wenum-compare"]},
2313 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wconversion',
2314 'description': 'Conversion may change value',
2315 'patterns': [r".*: warning: converting negative value '.+' to '.+'",
2316 r".*: warning: conversion to '.+' .+ may (alter|change)"]},
2317 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wconversion-null',
2318 'description': 'Converting to non-pointer type from NULL',
2319 'patterns': [r".*: warning: converting to non-pointer type '.+' from NULL"]},
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07002320 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsign-conversion',
2321 'description': 'Implicit sign conversion',
2322 'patterns': [r".*: warning: implicit conversion changes signedness"]},
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002323 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wnull-conversion',
2324 'description': 'Converting NULL to non-pointer type',
2325 'patterns': [r".*: warning: implicit conversion of NULL constant to '.+'"]},
2326 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wnon-literal-null-conversion',
2327 'description': 'Zero used as null pointer',
2328 'patterns': [r".*: warning: expression .* zero treated as a null pointer constant"]},
2329 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2330 'description': 'Implicit conversion changes value',
2331 'patterns': [r".*: warning: implicit conversion .* changes value from .* to .*-conversion"]},
2332 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2333 'description': 'Passing NULL as non-pointer argument',
2334 'patterns': [r".*: warning: passing NULL to non-pointer argument [0-9]+ of '.+'"]},
2335 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wctor-dtor-privacy',
2336 'description': 'Class seems unusable because of private ctor/dtor',
2337 'patterns': [r".*: warning: all member functions in class '.+' are private"]},
Marco Nelissen594375d2009-07-14 09:04:04 -07002338 # 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 -07002339 {'category': 'C/C++', 'severity': Severity.SKIP, 'option': '-Wctor-dtor-privacy',
2340 'description': 'Class seems unusable because of private ctor/dtor',
2341 'patterns': [r".*: warning: 'class .+' only defines a private destructor and has no friends"]},
2342 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wctor-dtor-privacy',
2343 'description': 'Class seems unusable because of private ctor/dtor',
2344 'patterns': [r".*: warning: 'class .+' only defines private constructors and has no friends"]},
2345 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wgnu-static-float-init',
2346 'description': 'In-class initializer for static const float/double',
2347 'patterns': [r".*: warning: in-class initializer for static data member of .+const (float|double)"]},
2348 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wpointer-arith',
2349 'description': 'void* used in arithmetic',
2350 'patterns': [r".*: warning: pointer of type 'void \*' used in (arithmetic|subtraction)",
2351 r".*: warning: arithmetic on .+ to void is a GNU extension.*Wpointer-arith",
2352 r".*: warning: wrong type argument to increment"]},
2353 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsign-promo',
2354 'description': 'Overload resolution chose to promote from unsigned or enum to signed type',
2355 'patterns': [r".*: warning: passing '.+' chooses '.+' over '.+'.*Wsign-promo"]},
2356 {'category': 'cont.', 'severity': Severity.SKIP,
2357 'description': 'skip, in call to ...',
2358 'patterns': [r".*: warning: in call to '.+'"]},
2359 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wextra',
2360 'description': 'Base should be explicitly initialized in copy constructor',
2361 'patterns': [r".*: warning: base class '.+' should be explicitly initialized in the copy constructor"]},
2362 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2363 'description': 'VLA has zero or negative size',
2364 'patterns': [r".*: warning: Declared variable-length array \(VLA\) has .+ size"]},
2365 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2366 'description': 'Return value from void function',
2367 'patterns': [r".*: warning: 'return' with a value, in function returning void"]},
2368 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'multichar',
2369 'description': 'Multi-character character constant',
2370 'patterns': [r".*: warning: multi-character character constant"]},
2371 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'writable-strings',
2372 'description': 'Conversion from string literal to char*',
2373 'patterns': [r".*: warning: .+ does not allow conversion from string literal to 'char \*'"]},
2374 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wextra-semi',
2375 'description': 'Extra \';\'',
2376 'patterns': [r".*: warning: extra ';' .+extra-semi"]},
2377 {'category': 'C/C++', 'severity': Severity.LOW,
2378 'description': 'Useless specifier',
2379 'patterns': [r".*: warning: useless storage class specifier in empty declaration"]},
2380 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wduplicate-decl-specifier',
2381 'description': 'Duplicate declaration specifier',
2382 'patterns': [r".*: warning: duplicate '.+' declaration specifier"]},
2383 {'category': 'logtags', 'severity': Severity.LOW,
2384 'description': 'Duplicate logtag',
2385 'patterns': [r".*: warning: tag \".+\" \(.+\) duplicated in .+"]},
2386 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'typedef-redefinition',
2387 'description': 'Typedef redefinition',
2388 'patterns': [r".*: warning: redefinition of typedef '.+' is a C11 feature"]},
2389 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'gnu-designator',
2390 'description': 'GNU old-style field designator',
2391 'patterns': [r".*: warning: use of GNU old-style field designator extension"]},
2392 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'missing-field-initializers',
2393 'description': 'Missing field initializers',
2394 'patterns': [r".*: warning: missing field '.+' initializer"]},
2395 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'missing-braces',
2396 'description': 'Missing braces',
2397 'patterns': [r".*: warning: suggest braces around initialization of",
2398 r".*: warning: too many braces around scalar initializer .+Wmany-braces-around-scalar-init",
2399 r".*: warning: braces around scalar initializer"]},
2400 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'sign-compare',
2401 'description': 'Comparison of integers of different signs',
2402 'patterns': [r".*: warning: comparison of integers of different signs.+sign-compare"]},
2403 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'dangling-else',
2404 'description': 'Add braces to avoid dangling else',
2405 'patterns': [r".*: warning: add explicit braces to avoid dangling else"]},
2406 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'initializer-overrides',
2407 'description': 'Initializer overrides prior initialization',
2408 'patterns': [r".*: warning: initializer overrides prior initialization of this subobject"]},
2409 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'self-assign',
2410 'description': 'Assigning value to self',
2411 'patterns': [r".*: warning: explicitly assigning value of .+ to itself"]},
2412 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'gnu-variable-sized-type-not-at-end',
2413 'description': 'GNU extension, variable sized type not at end',
2414 'patterns': [r".*: warning: field '.+' with variable sized type '.+' not at the end of a struct or class"]},
2415 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'tautological-constant-out-of-range-compare',
2416 'description': 'Comparison of constant is always false/true',
2417 'patterns': [r".*: comparison of .+ is always .+Wtautological-constant-out-of-range-compare"]},
2418 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'overloaded-virtual',
2419 'description': 'Hides overloaded virtual function',
2420 'patterns': [r".*: '.+' hides overloaded virtual function"]},
2421 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'incompatible-pointer-types',
2422 'description': 'Incompatible pointer types',
2423 'patterns': [r".*: warning: incompatible pointer types .+Wincompatible-pointer-types"]},
2424 {'category': 'logtags', 'severity': Severity.LOW, 'option': 'asm-operand-widths',
2425 'description': 'ASM value size does not match register size',
2426 'patterns': [r".*: warning: value size does not match register size specified by the constraint and modifier"]},
2427 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'tautological-compare',
2428 'description': 'Comparison of self is always false',
2429 'patterns': [r".*: self-comparison always evaluates to false"]},
2430 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'constant-logical-operand',
2431 'description': 'Logical op with constant operand',
2432 'patterns': [r".*: use of logical '.+' with constant operand"]},
2433 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'literal-suffix',
2434 'description': 'Needs a space between literal and string macro',
2435 'patterns': [r".*: warning: invalid suffix on literal.+ requires a space .+Wliteral-suffix"]},
2436 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '#warnings',
2437 'description': 'Warnings from #warning',
2438 'patterns': [r".*: warning: .+-W#warnings"]},
2439 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'absolute-value',
2440 'description': 'Using float/int absolute value function with int/float argument',
2441 'patterns': [r".*: warning: using .+ absolute value function .+ when argument is .+ type .+Wabsolute-value",
2442 r".*: warning: absolute value function '.+' given .+ which may cause truncation .+Wabsolute-value"]},
2443 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wc++11-extensions',
2444 'description': 'Using C++11 extensions',
2445 'patterns': [r".*: warning: 'auto' type specifier is a C\+\+11 extension"]},
2446 {'category': 'C/C++', 'severity': Severity.LOW,
2447 'description': 'Refers to implicitly defined namespace',
2448 'patterns': [r".*: warning: using directive refers to implicitly-defined namespace .+"]},
2449 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Winvalid-pp-token',
2450 'description': 'Invalid pp token',
2451 'patterns': [r".*: warning: missing .+Winvalid-pp-token"]},
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07002452 {'category': 'link', 'severity': Severity.LOW,
2453 'description': 'need glibc to link',
2454 'patterns': [r".*: warning: .* requires at runtime .* glibc .* for linking"]},
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07002455
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002456 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2457 'description': 'Operator new returns NULL',
2458 'patterns': [r".*: warning: 'operator new' must not return NULL unless it is declared 'throw\(\)' .+"]},
2459 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wnull-arithmetic',
2460 'description': 'NULL used in arithmetic',
2461 'patterns': [r".*: warning: NULL used in arithmetic",
2462 r".*: warning: comparison between NULL and non-pointer"]},
2463 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'header-guard',
2464 'description': 'Misspelled header guard',
2465 'patterns': [r".*: warning: '.+' is used as a header guard .+ followed by .+ different macro"]},
2466 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'empty-body',
2467 'description': 'Empty loop body',
2468 'patterns': [r".*: warning: .+ loop has empty body"]},
2469 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'enum-conversion',
2470 'description': 'Implicit conversion from enumeration type',
2471 'patterns': [r".*: warning: implicit conversion from enumeration type '.+'"]},
2472 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'switch',
2473 'description': 'case value not in enumerated type',
2474 'patterns': [r".*: warning: case value not in enumerated type '.+'"]},
2475 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2476 'description': 'Undefined result',
2477 'patterns': [r".*: warning: The result of .+ is undefined",
2478 r".*: warning: passing an object that .+ has undefined behavior \[-Wvarargs\]",
2479 r".*: warning: 'this' pointer cannot be null in well-defined C\+\+ code;",
2480 r".*: warning: shifting a negative signed value is undefined"]},
2481 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2482 'description': 'Division by zero',
2483 'patterns': [r".*: warning: Division by zero"]},
2484 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2485 'description': 'Use of deprecated method',
2486 'patterns': [r".*: warning: '.+' is deprecated .+"]},
2487 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2488 'description': 'Use of garbage or uninitialized value',
2489 'patterns': [r".*: warning: .+ is a garbage value",
2490 r".*: warning: Function call argument is an uninitialized value",
2491 r".*: warning: Undefined or garbage value returned to caller",
2492 r".*: warning: Called .+ pointer is.+uninitialized",
2493 r".*: warning: Called .+ pointer is.+uninitalized", # match a typo in compiler message
2494 r".*: warning: Use of zero-allocated memory",
2495 r".*: warning: Dereference of undefined pointer value",
2496 r".*: warning: Passed-by-value .+ contains uninitialized data",
2497 r".*: warning: Branch condition evaluates to a garbage value",
2498 r".*: warning: The .+ of .+ is an uninitialized value.",
2499 r".*: warning: .+ is used uninitialized whenever .+sometimes-uninitialized",
2500 r".*: warning: Assigned value is garbage or undefined"]},
2501 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2502 'description': 'Result of malloc type incompatible with sizeof operand type',
2503 'patterns': [r".*: warning: Result of '.+' is converted to .+ incompatible with sizeof operand type"]},
2504 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsizeof-array-argument',
2505 'description': 'Sizeof on array argument',
2506 'patterns': [r".*: warning: sizeof on array function parameter will return"]},
2507 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsizeof-pointer-memacces',
2508 'description': 'Bad argument size of memory access functions',
2509 'patterns': [r".*: warning: .+\[-Wsizeof-pointer-memaccess\]"]},
2510 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2511 'description': 'Return value not checked',
2512 'patterns': [r".*: warning: The return value from .+ is not checked"]},
2513 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2514 'description': 'Possible heap pollution',
2515 'patterns': [r".*: warning: .*Possible heap pollution from .+ type .+"]},
2516 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2517 'description': 'Allocation size of 0 byte',
2518 'patterns': [r".*: warning: Call to .+ has an allocation size of 0 byte"]},
2519 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2520 'description': 'Result of malloc type incompatible with sizeof operand type',
2521 'patterns': [r".*: warning: Result of '.+' is converted to .+ incompatible with sizeof operand type"]},
2522 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wfor-loop-analysis',
2523 'description': 'Variable used in loop condition not modified in loop body',
2524 'patterns': [r".*: warning: variable '.+' used in loop condition.*Wfor-loop-analysis"]},
2525 {'category': 'C/C++', 'severity': Severity.MEDIUM,
2526 'description': 'Closing a previously closed file',
2527 'patterns': [r".*: warning: Closing a previously closed file"]},
2528 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunnamed-type-template-args',
2529 'description': 'Unnamed template type argument',
2530 'patterns': [r".*: warning: template argument.+Wunnamed-type-template-args"]},
Chih-Hung Hsiehe1672862018-08-31 16:19:19 -07002531 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wimplicit-fallthrough',
2532 'description': 'Unannotated fall-through between switch labels',
2533 'patterns': [r".*: warning: unannotated fall-through between switch labels.+Wimplicit-fallthrough"]},
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07002534
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002535 {'category': 'C/C++', 'severity': Severity.HARMLESS,
2536 'description': 'Discarded qualifier from pointer target type',
2537 'patterns': [r".*: warning: .+ discards '.+' qualifier from pointer target type"]},
2538 {'category': 'C/C++', 'severity': Severity.HARMLESS,
2539 'description': 'Use snprintf instead of sprintf',
2540 'patterns': [r".*: warning: .*sprintf is often misused; please use snprintf"]},
2541 {'category': 'C/C++', 'severity': Severity.HARMLESS,
2542 'description': 'Unsupported optimizaton flag',
2543 'patterns': [r".*: warning: optimization flag '.+' is not supported"]},
2544 {'category': 'C/C++', 'severity': Severity.HARMLESS,
2545 'description': 'Extra or missing parentheses',
2546 'patterns': [r".*: warning: equality comparison with extraneous parentheses",
2547 r".*: warning: .+ within .+Wlogical-op-parentheses"]},
2548 {'category': 'C/C++', 'severity': Severity.HARMLESS, 'option': 'mismatched-tags',
2549 'description': 'Mismatched class vs struct tags',
2550 'patterns': [r".*: warning: '.+' defined as a .+ here but previously declared as a .+mismatched-tags",
2551 r".*: warning: .+ was previously declared as a .+mismatched-tags"]},
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07002552 {'category': 'FindEmulator', 'severity': Severity.HARMLESS,
2553 'description': 'FindEmulator: No such file or directory',
2554 'patterns': [r".*: warning: FindEmulator: .* No such file or directory"]},
2555 {'category': 'google_tests', 'severity': Severity.HARMLESS,
2556 'description': 'google_tests: unknown installed file',
2557 'patterns': [r".*: warning: .*_tests: Unknown installed file for module"]},
2558 {'category': 'make', 'severity': Severity.HARMLESS,
2559 'description': 'unusual tags debug eng',
2560 'patterns': [r".*: warning: .*: unusual tags debug eng"]},
Marco Nelissen594375d2009-07-14 09:04:04 -07002561
2562 # 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 -07002563 {'category': 'C/C++', 'severity': Severity.SKIP,
2564 'description': 'skip, ,',
2565 'patterns': [r".*: warning: ,$"]},
2566 {'category': 'C/C++', 'severity': Severity.SKIP,
2567 'description': 'skip,',
2568 'patterns': [r".*: warning: $"]},
2569 {'category': 'C/C++', 'severity': Severity.SKIP,
2570 'description': 'skip, In file included from ...',
2571 'patterns': [r".*: warning: In file included from .+,"]},
Marco Nelissen594375d2009-07-14 09:04:04 -07002572
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07002573 # warnings from clang-tidy
Chih-Hung Hsieh2cd467b2017-11-16 15:42:11 -08002574 group_tidy_warn_pattern('android'),
Chih-Hung Hsieh9e9355d2018-06-04 11:32:32 -07002575 simple_tidy_warn_pattern('bugprone-argument-comment'),
2576 simple_tidy_warn_pattern('bugprone-copy-constructor-init'),
2577 simple_tidy_warn_pattern('bugprone-fold-init-type'),
2578 simple_tidy_warn_pattern('bugprone-forward-declaration-namespace'),
2579 simple_tidy_warn_pattern('bugprone-forwarding-reference-overload'),
2580 simple_tidy_warn_pattern('bugprone-inaccurate-erase'),
2581 simple_tidy_warn_pattern('bugprone-incorrect-roundings'),
2582 simple_tidy_warn_pattern('bugprone-integer-division'),
2583 simple_tidy_warn_pattern('bugprone-lambda-function-name'),
2584 simple_tidy_warn_pattern('bugprone-macro-parentheses'),
2585 simple_tidy_warn_pattern('bugprone-misplaced-widening-cast'),
2586 simple_tidy_warn_pattern('bugprone-move-forwarding-reference'),
2587 simple_tidy_warn_pattern('bugprone-sizeof-expression'),
2588 simple_tidy_warn_pattern('bugprone-string-constructor'),
2589 simple_tidy_warn_pattern('bugprone-string-integer-assignment'),
2590 simple_tidy_warn_pattern('bugprone-suspicious-enum-usage'),
2591 simple_tidy_warn_pattern('bugprone-suspicious-missing-comma'),
2592 simple_tidy_warn_pattern('bugprone-suspicious-string-compare'),
2593 simple_tidy_warn_pattern('bugprone-suspicious-semicolon'),
2594 simple_tidy_warn_pattern('bugprone-undefined-memory-manipulation'),
2595 simple_tidy_warn_pattern('bugprone-unused-raii'),
2596 simple_tidy_warn_pattern('bugprone-use-after-move'),
2597 group_tidy_warn_pattern('bugprone'),
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07002598 group_tidy_warn_pattern('cert'),
2599 group_tidy_warn_pattern('clang-diagnostic'),
2600 group_tidy_warn_pattern('cppcoreguidelines'),
2601 group_tidy_warn_pattern('llvm'),
2602 simple_tidy_warn_pattern('google-default-arguments'),
2603 simple_tidy_warn_pattern('google-runtime-int'),
2604 simple_tidy_warn_pattern('google-runtime-operator'),
2605 simple_tidy_warn_pattern('google-runtime-references'),
2606 group_tidy_warn_pattern('google-build'),
2607 group_tidy_warn_pattern('google-explicit'),
2608 group_tidy_warn_pattern('google-redability'),
2609 group_tidy_warn_pattern('google-global'),
2610 group_tidy_warn_pattern('google-redability'),
2611 group_tidy_warn_pattern('google-redability'),
2612 group_tidy_warn_pattern('google'),
2613 simple_tidy_warn_pattern('hicpp-explicit-conversions'),
2614 simple_tidy_warn_pattern('hicpp-function-size'),
2615 simple_tidy_warn_pattern('hicpp-invalid-access-moved'),
2616 simple_tidy_warn_pattern('hicpp-member-init'),
2617 simple_tidy_warn_pattern('hicpp-delete-operators'),
2618 simple_tidy_warn_pattern('hicpp-special-member-functions'),
2619 simple_tidy_warn_pattern('hicpp-use-equals-default'),
2620 simple_tidy_warn_pattern('hicpp-use-equals-delete'),
2621 simple_tidy_warn_pattern('hicpp-no-assembler'),
2622 simple_tidy_warn_pattern('hicpp-noexcept-move'),
2623 simple_tidy_warn_pattern('hicpp-use-override'),
2624 group_tidy_warn_pattern('hicpp'),
2625 group_tidy_warn_pattern('modernize'),
2626 group_tidy_warn_pattern('misc'),
2627 simple_tidy_warn_pattern('performance-faster-string-find'),
2628 simple_tidy_warn_pattern('performance-for-range-copy'),
2629 simple_tidy_warn_pattern('performance-implicit-cast-in-loop'),
2630 simple_tidy_warn_pattern('performance-inefficient-string-concatenation'),
2631 simple_tidy_warn_pattern('performance-type-promotion-in-math-fn'),
2632 simple_tidy_warn_pattern('performance-unnecessary-copy-initialization'),
2633 simple_tidy_warn_pattern('performance-unnecessary-value-param'),
2634 group_tidy_warn_pattern('performance'),
2635 group_tidy_warn_pattern('readability'),
2636
2637 # warnings from clang-tidy's clang-analyzer checks
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002638 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002639 'description': 'clang-analyzer Unreachable code',
2640 'patterns': [r".*: warning: This statement is never executed.*UnreachableCode"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002641 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002642 'description': 'clang-analyzer Size of malloc may overflow',
2643 'patterns': [r".*: warning: .* size of .* may overflow .*MallocOverflow"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002644 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002645 'description': 'clang-analyzer Stream pointer might be NULL',
2646 'patterns': [r".*: warning: Stream pointer might be NULL .*unix.Stream"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002647 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002648 'description': 'clang-analyzer Opened file never closed',
2649 'patterns': [r".*: warning: Opened File never closed.*unix.Stream"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002650 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002651 'description': 'clang-analyzer sozeof() on a pointer type',
2652 'patterns': [r".*: warning: .*calls sizeof.* on a pointer type.*SizeofPtr"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002653 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002654 'description': 'clang-analyzer Pointer arithmetic on non-array variables',
2655 'patterns': [r".*: warning: Pointer arithmetic on non-array variables .*PointerArithm"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002656 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002657 'description': 'clang-analyzer Subtraction of pointers of different memory chunks',
2658 'patterns': [r".*: warning: Subtraction of two pointers .*PointerSub"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002659 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002660 'description': 'clang-analyzer Access out-of-bound array element',
2661 'patterns': [r".*: warning: Access out-of-bound array element .*ArrayBound"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002662 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002663 'description': 'clang-analyzer Out of bound memory access',
2664 'patterns': [r".*: warning: Out of bound memory access .*ArrayBoundV2"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002665 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002666 'description': 'clang-analyzer Possible lock order reversal',
2667 'patterns': [r".*: warning: .* Possible lock order reversal.*PthreadLock"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002668 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002669 'description': 'clang-analyzer Argument is a pointer to uninitialized value',
2670 'patterns': [r".*: warning: .* argument is a pointer to uninitialized value .*CallAndMessage"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002671 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002672 'description': 'clang-analyzer cast to struct',
2673 'patterns': [r".*: warning: Casting a non-structure type to a structure type .*CastToStruct"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002674 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002675 'description': 'clang-analyzer call path problems',
2676 'patterns': [r".*: warning: Call Path : .+"]},
Chih-Hung Hsieh1eabb0e2016-10-05 11:53:20 -07002677 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsieh8ef1aae2017-05-18 11:40:08 -07002678 'description': 'clang-analyzer excessive padding',
2679 'patterns': [r".*: warning: Excessive padding in '.*'"]},
2680 {'category': 'C/C++', 'severity': Severity.ANALYZER,
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002681 'description': 'clang-analyzer other',
2682 'patterns': [r".*: .+\[clang-analyzer-.+\]$",
2683 r".*: Call Path : .+$"]},
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07002684
Marco Nelissen594375d2009-07-14 09:04:04 -07002685 # catch-all for warnings this script doesn't know about yet
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002686 {'category': 'C/C++', 'severity': Severity.UNKNOWN,
2687 'description': 'Unclassified/unrecognized warnings',
2688 'patterns': [r".*: warning: .+"]},
Marco Nelissen594375d2009-07-14 09:04:04 -07002689]
2690
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07002691
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002692def project_name_and_pattern(name, pattern):
2693 return [name, '(^|.*/)' + pattern + '/.*: warning:']
2694
2695
2696def simple_project_pattern(pattern):
2697 return project_name_and_pattern(pattern, pattern)
2698
2699
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002700# A list of [project_name, file_path_pattern].
2701# project_name should not contain comma, to be used in CSV output.
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002702project_list = [
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002703 simple_project_pattern('art'),
2704 simple_project_pattern('bionic'),
2705 simple_project_pattern('bootable'),
2706 simple_project_pattern('build'),
2707 simple_project_pattern('cts'),
2708 simple_project_pattern('dalvik'),
2709 simple_project_pattern('developers'),
2710 simple_project_pattern('development'),
2711 simple_project_pattern('device'),
2712 simple_project_pattern('doc'),
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07002713 # match external/google* before external/
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002714 project_name_and_pattern('external/google', 'external/google.*'),
2715 project_name_and_pattern('external/non-google', 'external'),
2716 simple_project_pattern('frameworks/av/camera'),
2717 simple_project_pattern('frameworks/av/cmds'),
2718 simple_project_pattern('frameworks/av/drm'),
2719 simple_project_pattern('frameworks/av/include'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002720 simple_project_pattern('frameworks/av/media/img_utils'),
2721 simple_project_pattern('frameworks/av/media/libcpustats'),
2722 simple_project_pattern('frameworks/av/media/libeffects'),
2723 simple_project_pattern('frameworks/av/media/libmediaplayerservice'),
2724 simple_project_pattern('frameworks/av/media/libmedia'),
2725 simple_project_pattern('frameworks/av/media/libstagefright'),
2726 simple_project_pattern('frameworks/av/media/mtp'),
2727 simple_project_pattern('frameworks/av/media/ndk'),
2728 simple_project_pattern('frameworks/av/media/utils'),
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07002729 project_name_and_pattern('frameworks/av/media/Other',
2730 'frameworks/av/media'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002731 simple_project_pattern('frameworks/av/radio'),
2732 simple_project_pattern('frameworks/av/services'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002733 simple_project_pattern('frameworks/av/soundtrigger'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002734 project_name_and_pattern('frameworks/av/Other', 'frameworks/av'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002735 simple_project_pattern('frameworks/base/cmds'),
2736 simple_project_pattern('frameworks/base/core'),
2737 simple_project_pattern('frameworks/base/drm'),
2738 simple_project_pattern('frameworks/base/media'),
2739 simple_project_pattern('frameworks/base/libs'),
2740 simple_project_pattern('frameworks/base/native'),
2741 simple_project_pattern('frameworks/base/packages'),
2742 simple_project_pattern('frameworks/base/rs'),
2743 simple_project_pattern('frameworks/base/services'),
2744 simple_project_pattern('frameworks/base/tests'),
2745 simple_project_pattern('frameworks/base/tools'),
2746 project_name_and_pattern('frameworks/base/Other', 'frameworks/base'),
Stephen Hinesd0aec892016-10-17 15:39:53 -07002747 simple_project_pattern('frameworks/compile/libbcc'),
2748 simple_project_pattern('frameworks/compile/mclinker'),
2749 simple_project_pattern('frameworks/compile/slang'),
2750 project_name_and_pattern('frameworks/compile/Other', 'frameworks/compile'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002751 simple_project_pattern('frameworks/minikin'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002752 simple_project_pattern('frameworks/ml'),
2753 simple_project_pattern('frameworks/native/cmds'),
2754 simple_project_pattern('frameworks/native/include'),
2755 simple_project_pattern('frameworks/native/libs'),
2756 simple_project_pattern('frameworks/native/opengl'),
2757 simple_project_pattern('frameworks/native/services'),
2758 simple_project_pattern('frameworks/native/vulkan'),
2759 project_name_and_pattern('frameworks/native/Other', 'frameworks/native'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002760 simple_project_pattern('frameworks/opt'),
2761 simple_project_pattern('frameworks/rs'),
2762 simple_project_pattern('frameworks/webview'),
2763 simple_project_pattern('frameworks/wilhelm'),
2764 project_name_and_pattern('frameworks/Other', 'frameworks'),
2765 simple_project_pattern('hardware/akm'),
2766 simple_project_pattern('hardware/broadcom'),
2767 simple_project_pattern('hardware/google'),
2768 simple_project_pattern('hardware/intel'),
2769 simple_project_pattern('hardware/interfaces'),
2770 simple_project_pattern('hardware/libhardware'),
2771 simple_project_pattern('hardware/libhardware_legacy'),
2772 simple_project_pattern('hardware/qcom'),
2773 simple_project_pattern('hardware/ril'),
2774 project_name_and_pattern('hardware/Other', 'hardware'),
2775 simple_project_pattern('kernel'),
2776 simple_project_pattern('libcore'),
2777 simple_project_pattern('libnativehelper'),
2778 simple_project_pattern('ndk'),
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002779 # match vendor/unbungled_google/packages before other packages
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002780 simple_project_pattern('unbundled_google'),
2781 simple_project_pattern('packages'),
2782 simple_project_pattern('pdk'),
2783 simple_project_pattern('prebuilts'),
2784 simple_project_pattern('system/bt'),
2785 simple_project_pattern('system/connectivity'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002786 simple_project_pattern('system/core/adb'),
2787 simple_project_pattern('system/core/base'),
2788 simple_project_pattern('system/core/debuggerd'),
2789 simple_project_pattern('system/core/fastboot'),
2790 simple_project_pattern('system/core/fingerprintd'),
2791 simple_project_pattern('system/core/fs_mgr'),
2792 simple_project_pattern('system/core/gatekeeperd'),
2793 simple_project_pattern('system/core/healthd'),
2794 simple_project_pattern('system/core/include'),
2795 simple_project_pattern('system/core/init'),
2796 simple_project_pattern('system/core/libbacktrace'),
2797 simple_project_pattern('system/core/liblog'),
2798 simple_project_pattern('system/core/libpixelflinger'),
2799 simple_project_pattern('system/core/libprocessgroup'),
2800 simple_project_pattern('system/core/libsysutils'),
2801 simple_project_pattern('system/core/logcat'),
2802 simple_project_pattern('system/core/logd'),
2803 simple_project_pattern('system/core/run-as'),
2804 simple_project_pattern('system/core/sdcard'),
2805 simple_project_pattern('system/core/toolbox'),
2806 project_name_and_pattern('system/core/Other', 'system/core'),
2807 simple_project_pattern('system/extras/ANRdaemon'),
2808 simple_project_pattern('system/extras/cpustats'),
2809 simple_project_pattern('system/extras/crypto-perf'),
2810 simple_project_pattern('system/extras/ext4_utils'),
2811 simple_project_pattern('system/extras/f2fs_utils'),
2812 simple_project_pattern('system/extras/iotop'),
2813 simple_project_pattern('system/extras/libfec'),
2814 simple_project_pattern('system/extras/memory_replay'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002815 simple_project_pattern('system/extras/mmap-perf'),
2816 simple_project_pattern('system/extras/multinetwork'),
2817 simple_project_pattern('system/extras/perfprofd'),
2818 simple_project_pattern('system/extras/procrank'),
2819 simple_project_pattern('system/extras/runconuid'),
2820 simple_project_pattern('system/extras/showmap'),
2821 simple_project_pattern('system/extras/simpleperf'),
2822 simple_project_pattern('system/extras/su'),
2823 simple_project_pattern('system/extras/tests'),
2824 simple_project_pattern('system/extras/verity'),
2825 project_name_and_pattern('system/extras/Other', 'system/extras'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002826 simple_project_pattern('system/gatekeeper'),
2827 simple_project_pattern('system/keymaster'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002828 simple_project_pattern('system/libhidl'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002829 simple_project_pattern('system/libhwbinder'),
2830 simple_project_pattern('system/media'),
2831 simple_project_pattern('system/netd'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002832 simple_project_pattern('system/nvram'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002833 simple_project_pattern('system/security'),
2834 simple_project_pattern('system/sepolicy'),
2835 simple_project_pattern('system/tools'),
Chih-Hung Hsieh144864e2016-10-14 12:27:17 -07002836 simple_project_pattern('system/update_engine'),
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002837 simple_project_pattern('system/vold'),
2838 project_name_and_pattern('system/Other', 'system'),
2839 simple_project_pattern('toolchain'),
2840 simple_project_pattern('test'),
2841 simple_project_pattern('tools'),
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07002842 # match vendor/google* before vendor/
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002843 project_name_and_pattern('vendor/google', 'vendor/google.*'),
2844 project_name_and_pattern('vendor/non-google', 'vendor'),
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07002845 # keep out/obj and other patterns at the end.
Chih-Hung Hsieh9f766232016-09-27 15:39:28 -07002846 ['out/obj',
2847 '.*/(gen|obj[^/]*)/(include|EXECUTABLES|SHARED_LIBRARIES|'
2848 'STATIC_LIBRARIES|NATIVE_TESTS)/.*: warning:'],
2849 ['other', '.*'] # all other unrecognized patterns
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002850]
2851
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002852project_patterns = []
2853project_names = []
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002854warning_messages = []
2855warning_records = []
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002856
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07002857
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002858def initialize_arrays():
2859 """Complete global arrays before they are used."""
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002860 global project_names, project_patterns
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002861 project_names = [p[0] for p in project_list]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002862 project_patterns = [re.compile(p[1]) for p in project_list]
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002863 for w in warn_patterns:
2864 w['members'] = []
2865 if 'option' not in w:
2866 w['option'] = ''
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002867 # Each warning pattern has a 'projects' dictionary, that
2868 # maps a project name to number of warnings in that project.
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002869 w['projects'] = {}
2870
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002871
2872initialize_arrays()
2873
2874
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -07002875android_root = ''
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002876platform_version = 'unknown'
2877target_product = 'unknown'
2878target_variant = 'unknown'
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002879
2880
2881##### Data and functions to dump html file. ##################################
2882
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002883html_head_scripts = """\
2884 <script type="text/javascript">
2885 function expand(id) {
2886 var e = document.getElementById(id);
2887 var f = document.getElementById(id + "_mark");
2888 if (e.style.display == 'block') {
2889 e.style.display = 'none';
2890 f.innerHTML = '&#x2295';
2891 }
2892 else {
2893 e.style.display = 'block';
2894 f.innerHTML = '&#x2296';
2895 }
2896 };
2897 function expandCollapse(show) {
2898 for (var id = 1; ; id++) {
2899 var e = document.getElementById(id + "");
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07002900 var f = document.getElementById(id + "_mark");
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002901 if (!e || !f) break;
2902 e.style.display = (show ? 'block' : 'none');
2903 f.innerHTML = (show ? '&#x2296' : '&#x2295');
2904 }
2905 };
2906 </script>
2907 <style type="text/css">
2908 th,td{border-collapse:collapse; border:1px solid black;}
2909 .button{color:blue;font-size:110%;font-weight:bolder;}
2910 .bt{color:black;background-color:transparent;border:none;outline:none;
2911 font-size:140%;font-weight:bolder;}
2912 .c0{background-color:#e0e0e0;}
2913 .c1{background-color:#d0d0d0;}
2914 .t1{border-collapse:collapse; width:100%; border:1px solid black;}
2915 </style>
2916 <script src="https://www.gstatic.com/charts/loader.js"></script>
2917"""
Marco Nelissen594375d2009-07-14 09:04:04 -07002918
Marco Nelissen594375d2009-07-14 09:04:04 -07002919
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002920def html_big(param):
2921 return '<font size="+2">' + param + '</font>'
Marco Nelissen594375d2009-07-14 09:04:04 -07002922
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07002923
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002924def dump_html_prologue(title):
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002925 print '<html>\n<head>'
2926 print '<title>' + title + '</title>'
2927 print html_head_scripts
2928 emit_stats_by_project()
2929 print '</head>\n<body>'
2930 print html_big(title)
2931 print '<p>'
Marco Nelissen594375d2009-07-14 09:04:04 -07002932
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002933
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002934def dump_html_epilogue():
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002935 print '</body>\n</head>\n</html>'
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07002936
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002937
2938def sort_warnings():
2939 for i in warn_patterns:
2940 i['members'] = sorted(set(i['members']))
2941
2942
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002943def emit_stats_by_project():
2944 """Dump a google chart table of warnings per project and severity."""
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002945 # warnings[p][s] is number of warnings in project p of severity s.
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002946 warnings = {p: {s: 0 for s in Severity.range} for p in project_names}
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002947 for i in warn_patterns:
2948 s = i['severity']
2949 for p in i['projects']:
2950 warnings[p][s] += i['projects'][p]
2951
2952 # total_by_project[p] is number of warnings in project p.
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002953 total_by_project = {p: sum(warnings[p][s] for s in Severity.range)
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002954 for p in project_names}
2955
2956 # total_by_severity[s] is number of warnings of severity s.
2957 total_by_severity = {s: sum(warnings[p][s] for p in project_names)
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002958 for s in Severity.range}
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07002959
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002960 # emit table header
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002961 stats_header = ['Project']
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002962 for s in Severity.range:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002963 if total_by_severity[s]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002964 stats_header.append("<span style='background-color:{}'>{}</span>".
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002965 format(Severity.colors[s],
2966 Severity.column_headers[s]))
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002967 stats_header.append('TOTAL')
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07002968
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002969 # emit a row of warning counts per project, skip no-warning projects
2970 total_all_projects = 0
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002971 stats_rows = []
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002972 for p in project_names:
2973 if total_by_project[p]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002974 one_row = [p]
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002975 for s in Severity.range:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002976 if total_by_severity[s]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002977 one_row.append(warnings[p][s])
2978 one_row.append(total_by_project[p])
2979 stats_rows.append(one_row)
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002980 total_all_projects += total_by_project[p]
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07002981
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002982 # emit a row of warning counts per severity
2983 total_all_severities = 0
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002984 one_row = ['<b>TOTAL</b>']
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07002985 for s in Severity.range:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002986 if total_by_severity[s]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002987 one_row.append(total_by_severity[s])
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002988 total_all_severities += total_by_severity[s]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002989 one_row.append(total_all_projects)
2990 stats_rows.append(one_row)
2991 print '<script>'
2992 emit_const_string_array('StatsHeader', stats_header)
2993 emit_const_object_array('StatsRows', stats_rows)
2994 print draw_table_javascript
2995 print '</script>'
Marco Nelissen594375d2009-07-14 09:04:04 -07002996
2997
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002998def dump_stats():
2999 """Dump some stats about total number of warnings and such."""
3000 known = 0
3001 skipped = 0
3002 unknown = 0
3003 sort_warnings()
3004 for i in warn_patterns:
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07003005 if i['severity'] == Severity.UNKNOWN:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003006 unknown += len(i['members'])
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07003007 elif i['severity'] == Severity.SKIP:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003008 skipped += len(i['members'])
Ian Rogersf3829732016-05-10 12:06:01 -07003009 else:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003010 known += len(i['members'])
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003011 print 'Number of classified warnings: <b>' + str(known) + '</b><br>'
3012 print 'Number of skipped warnings: <b>' + str(skipped) + '</b><br>'
3013 print 'Number of unclassified warnings: <b>' + str(unknown) + '</b><br>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003014 total = unknown + known + skipped
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003015 extra_msg = ''
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003016 if total < 1000:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003017 extra_msg = ' (low count may indicate incremental build)'
3018 print 'Total number of warnings: <b>' + str(total) + '</b>' + extra_msg
Marco Nelissen594375d2009-07-14 09:04:04 -07003019
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07003020
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003021# New base table of warnings, [severity, warn_id, project, warning_message]
3022# Need buttons to show warnings in different grouping options.
3023# (1) Current, group by severity, id for each warning pattern
3024# sort by severity, warn_id, warning_message
3025# (2) Current --byproject, group by severity,
3026# id for each warning pattern + project name
3027# sort by severity, warn_id, project, warning_message
3028# (3) New, group by project + severity,
3029# id for each warning pattern
3030# sort by project, severity, warn_id, warning_message
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003031def emit_buttons():
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003032 print ('<button class="button" onclick="expandCollapse(1);">'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003033 'Expand all warnings</button>\n'
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003034 '<button class="button" onclick="expandCollapse(0);">'
3035 'Collapse all warnings</button>\n'
3036 '<button class="button" onclick="groupBySeverity();">'
3037 'Group warnings by severity</button>\n'
3038 '<button class="button" onclick="groupByProject();">'
3039 'Group warnings by project</button><br>')
Marco Nelissen594375d2009-07-14 09:04:04 -07003040
3041
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003042def all_patterns(category):
3043 patterns = ''
3044 for i in category['patterns']:
3045 patterns += i
3046 patterns += ' / '
3047 return patterns
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003048
3049
3050def dump_fixed():
3051 """Show which warnings no longer occur."""
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003052 anchor = 'fixed_warnings'
3053 mark = anchor + '_mark'
3054 print ('\n<br><p style="background-color:lightblue"><b>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003055 '<button id="' + mark + '" '
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003056 'class="bt" onclick="expand(\'' + anchor + '\');">'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003057 '&#x2295</button> Fixed warnings. '
3058 'No more occurrences. Please consider turning these into '
3059 'errors if possible, before they are reintroduced in to the build'
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003060 ':</b></p>')
3061 print '<blockquote>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003062 fixed_patterns = []
3063 for i in warn_patterns:
3064 if not i['members']:
3065 fixed_patterns.append(i['description'] + ' (' +
3066 all_patterns(i) + ')')
3067 if i['option']:
3068 fixed_patterns.append(' ' + i['option'])
3069 fixed_patterns.sort()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003070 print '<div id="' + anchor + '" style="display:none;"><table>'
3071 cur_row_class = 0
3072 for text in fixed_patterns:
3073 cur_row_class = 1 - cur_row_class
3074 # remove last '\n'
3075 t = text[:-1] if text[-1] == '\n' else text
3076 print '<tr><td class="c' + str(cur_row_class) + '">' + t + '</td></tr>'
3077 print '</table></div>'
3078 print '</blockquote>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003079
3080
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003081def find_project_index(line):
3082 for p in range(len(project_patterns)):
3083 if project_patterns[p].match(line):
3084 return p
3085 return -1
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003086
3087
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07003088def classify_one_warning(line, results):
Chih-Hung Hsieh9be27762018-06-07 10:51:47 -07003089 """Classify one warning line."""
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003090 for i in range(len(warn_patterns)):
3091 w = warn_patterns[i]
3092 for cpat in w['compiled_patterns']:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003093 if cpat.match(line):
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003094 p = find_project_index(line)
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07003095 results.append([line, i, p])
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003096 return
3097 else:
3098 # If we end up here, there was a problem parsing the log
3099 # probably caused by 'make -j' mixing the output from
3100 # 2 or more concurrent compiles
3101 pass
Marco Nelissen594375d2009-07-14 09:04:04 -07003102
3103
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07003104def classify_warnings(lines):
3105 results = []
3106 for line in lines:
3107 classify_one_warning(line, results)
Chih-Hung Hsieh76d00652016-11-09 18:19:05 -08003108 # After the main work, ignore all other signals to a child process,
3109 # to avoid bad warning/error messages from the exit clean-up process.
3110 if args.processes > 1:
3111 signal.signal(signal.SIGTERM, lambda *args: sys.exit(-signal.SIGTERM))
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07003112 return results
3113
3114
3115def parallel_classify_warnings(warning_lines):
3116 """Classify all warning lines with num_cpu parallel processes."""
Chih-Hung Hsieh76d00652016-11-09 18:19:05 -08003117 compile_patterns()
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07003118 num_cpu = args.processes
Chih-Hung Hsieh63de3002016-10-28 10:53:34 -07003119 if num_cpu > 1:
3120 groups = [[] for x in range(num_cpu)]
3121 i = 0
3122 for x in warning_lines:
3123 groups[i].append(x)
3124 i = (i + 1) % num_cpu
3125 pool = multiprocessing.Pool(num_cpu)
3126 group_results = pool.map(classify_warnings, groups)
3127 else:
3128 group_results = [classify_warnings(warning_lines)]
3129
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07003130 for result in group_results:
3131 for line, pattern_idx, project_idx in result:
3132 pattern = warn_patterns[pattern_idx]
3133 pattern['members'].append(line)
3134 message_idx = len(warning_messages)
3135 warning_messages.append(line)
3136 warning_records.append([pattern_idx, project_idx, message_idx])
3137 pname = '???' if project_idx < 0 else project_names[project_idx]
3138 # Count warnings by project.
3139 if pname in pattern['projects']:
3140 pattern['projects'][pname] += 1
3141 else:
3142 pattern['projects'][pname] = 1
3143
3144
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003145def compile_patterns():
3146 """Precompiling every pattern speeds up parsing by about 30x."""
3147 for i in warn_patterns:
3148 i['compiled_patterns'] = []
3149 for pat in i['patterns']:
3150 i['compiled_patterns'].append(re.compile(pat))
3151
3152
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -07003153def find_android_root(path):
3154 """Set and return android_root path if it is found."""
3155 global android_root
3156 parts = path.split('/')
3157 for idx in reversed(range(2, len(parts))):
3158 root_path = '/'.join(parts[:idx])
3159 # Android root directory should contain this script.
Colin Crossfdea8932017-12-06 14:38:40 -08003160 if os.path.exists(root_path + '/build/make/tools/warn.py'):
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -07003161 android_root = root_path
3162 return root_path
3163 return ''
3164
3165
3166def remove_android_root_prefix(path):
3167 """Remove android_root prefix from path if it is found."""
3168 if path.startswith(android_root):
3169 return path[1 + len(android_root):]
3170 else:
3171 return path
3172
3173
3174def normalize_path(path):
3175 """Normalize file path relative to android_root."""
3176 # If path is not an absolute path, just normalize it.
3177 path = os.path.normpath(path)
3178 if path[0] != '/':
3179 return path
3180 # Remove known prefix of root path and normalize the suffix.
3181 if android_root or find_android_root(path):
3182 return remove_android_root_prefix(path)
3183 else:
3184 return path
3185
3186
3187def normalize_warning_line(line):
3188 """Normalize file path relative to android_root in a warning line."""
3189 # replace fancy quotes with plain ol' quotes
3190 line = line.replace('‘', "'")
3191 line = line.replace('’', "'")
3192 line = line.strip()
3193 first_column = line.find(':')
3194 if first_column > 0:
3195 return normalize_path(line[:first_column]) + line[first_column:]
3196 else:
3197 return line
3198
3199
Chih-Hung Hsieh76d00652016-11-09 18:19:05 -08003200def parse_input_file(infile):
Chih-Hung Hsiehef21d142017-04-27 10:25:37 -07003201 """Parse input file, collect parameters and warning lines."""
3202 global android_root
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003203 global platform_version
3204 global target_product
3205 global target_variant
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003206 line_counter = 0
3207
Chih-Hung Hsieh5722f922016-10-11 15:33:19 -07003208 # handle only warning messages with a file path
3209 warning_pattern = re.compile('^[^ ]*/[^ ]*: warning: .*')
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003210
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07003211 # Collect all warnings into the warning_lines set.
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003212 warning_lines = set()
3213 for line in infile:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003214 if warning_pattern.match(line):
Chih-Hung Hsieha45c5c12016-10-11 15:30:26 -07003215 line = normalize_warning_line(line)
Chih-Hung Hsieha6bd0442016-10-11 15:25:26 -07003216 warning_lines.add(line)
Chih-Hung Hsieh655c5422017-06-07 15:52:13 -07003217 elif line_counter < 100:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003218 # save a little bit of time by only doing this for the first few lines
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003219 line_counter += 1
3220 m = re.search('(?<=^PLATFORM_VERSION=).*', line)
3221 if m is not None:
3222 platform_version = m.group(0)
3223 m = re.search('(?<=^TARGET_PRODUCT=).*', line)
3224 if m is not None:
3225 target_product = m.group(0)
3226 m = re.search('(?<=^TARGET_BUILD_VARIANT=).*', line)
3227 if m is not None:
3228 target_variant = m.group(0)
Chih-Hung Hsiehef21d142017-04-27 10:25:37 -07003229 m = re.search('.* TOP=([^ ]*) .*', line)
3230 if m is not None:
3231 android_root = m.group(1)
Chih-Hung Hsieh76d00652016-11-09 18:19:05 -08003232 return warning_lines
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003233
3234
Chih-Hung Hsieh5722f922016-10-11 15:33:19 -07003235# Return s with escaped backslash and quotation characters.
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003236def escape_string(s):
Chih-Hung Hsieh5722f922016-10-11 15:33:19 -07003237 return s.replace('\\', '\\\\').replace('"', '\\"')
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003238
3239
3240# Return s without trailing '\n' and escape the quotation characters.
3241def strip_escape_string(s):
3242 if not s:
3243 return s
3244 s = s[:-1] if s[-1] == '\n' else s
3245 return escape_string(s)
3246
3247
3248def emit_warning_array(name):
3249 print 'var warning_{} = ['.format(name)
3250 for i in range(len(warn_patterns)):
3251 print '{},'.format(warn_patterns[i][name])
3252 print '];'
3253
3254
3255def emit_warning_arrays():
3256 emit_warning_array('severity')
3257 print 'var warning_description = ['
3258 for i in range(len(warn_patterns)):
3259 if warn_patterns[i]['members']:
3260 print '"{}",'.format(escape_string(warn_patterns[i]['description']))
3261 else:
3262 print '"",' # no such warning
3263 print '];'
3264
3265scripts_for_warning_groups = """
3266 function compareMessages(x1, x2) { // of the same warning type
3267 return (WarningMessages[x1[2]] <= WarningMessages[x2[2]]) ? -1 : 1;
3268 }
3269 function byMessageCount(x1, x2) {
3270 return x2[2] - x1[2]; // reversed order
3271 }
3272 function bySeverityMessageCount(x1, x2) {
3273 // orer by severity first
3274 if (x1[1] != x2[1])
3275 return x1[1] - x2[1];
3276 return byMessageCount(x1, x2);
3277 }
3278 const ParseLinePattern = /^([^ :]+):(\\d+):(.+)/;
3279 function addURL(line) {
3280 if (FlagURL == "") return line;
3281 if (FlagSeparator == "") {
3282 return line.replace(ParseLinePattern,
George Burgess IV169f5f12017-04-21 13:35:52 -07003283 "<a target='_blank' href='" + FlagURL + "/$1'>$1</a>:$2:$3");
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003284 }
3285 return line.replace(ParseLinePattern,
George Burgess IV169f5f12017-04-21 13:35:52 -07003286 "<a target='_blank' href='" + FlagURL + "/$1" + FlagSeparator +
3287 "$2'>$1:$2</a>:$3");
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003288 }
3289 function createArrayOfDictionaries(n) {
3290 var result = [];
3291 for (var i=0; i<n; i++) result.push({});
3292 return result;
3293 }
3294 function groupWarningsBySeverity() {
3295 // groups is an array of dictionaries,
3296 // each dictionary maps from warning type to array of warning messages.
3297 var groups = createArrayOfDictionaries(SeverityColors.length);
3298 for (var i=0; i<Warnings.length; i++) {
3299 var w = Warnings[i][0];
3300 var s = WarnPatternsSeverity[w];
3301 var k = w.toString();
3302 if (!(k in groups[s]))
3303 groups[s][k] = [];
3304 groups[s][k].push(Warnings[i]);
3305 }
3306 return groups;
3307 }
3308 function groupWarningsByProject() {
3309 var groups = createArrayOfDictionaries(ProjectNames.length);
3310 for (var i=0; i<Warnings.length; i++) {
3311 var w = Warnings[i][0];
3312 var p = Warnings[i][1];
3313 var k = w.toString();
3314 if (!(k in groups[p]))
3315 groups[p][k] = [];
3316 groups[p][k].push(Warnings[i]);
3317 }
3318 return groups;
3319 }
3320 var GlobalAnchor = 0;
3321 function createWarningSection(header, color, group) {
3322 var result = "";
3323 var groupKeys = [];
3324 var totalMessages = 0;
3325 for (var k in group) {
3326 totalMessages += group[k].length;
3327 groupKeys.push([k, WarnPatternsSeverity[parseInt(k)], group[k].length]);
3328 }
3329 groupKeys.sort(bySeverityMessageCount);
3330 for (var idx=0; idx<groupKeys.length; idx++) {
3331 var k = groupKeys[idx][0];
3332 var messages = group[k];
3333 var w = parseInt(k);
3334 var wcolor = SeverityColors[WarnPatternsSeverity[w]];
3335 var description = WarnPatternsDescription[w];
3336 if (description.length == 0)
3337 description = "???";
3338 GlobalAnchor += 1;
3339 result += "<table class='t1'><tr bgcolor='" + wcolor + "'><td>" +
3340 "<button class='bt' id='" + GlobalAnchor + "_mark" +
3341 "' onclick='expand(\\"" + GlobalAnchor + "\\");'>" +
3342 "&#x2295</button> " +
3343 description + " (" + messages.length + ")</td></tr></table>";
3344 result += "<div id='" + GlobalAnchor +
3345 "' style='display:none;'><table class='t1'>";
3346 var c = 0;
3347 messages.sort(compareMessages);
3348 for (var i=0; i<messages.length; i++) {
3349 result += "<tr><td class='c" + c + "'>" +
3350 addURL(WarningMessages[messages[i][2]]) + "</td></tr>";
3351 c = 1 - c;
3352 }
3353 result += "</table></div>";
3354 }
3355 if (result.length > 0) {
3356 return "<br><span style='background-color:" + color + "'><b>" +
3357 header + ": " + totalMessages +
3358 "</b></span><blockquote><table class='t1'>" +
3359 result + "</table></blockquote>";
3360
3361 }
3362 return ""; // empty section
3363 }
3364 function generateSectionsBySeverity() {
3365 var result = "";
3366 var groups = groupWarningsBySeverity();
3367 for (s=0; s<SeverityColors.length; s++) {
3368 result += createWarningSection(SeverityHeaders[s], SeverityColors[s], groups[s]);
3369 }
3370 return result;
3371 }
3372 function generateSectionsByProject() {
3373 var result = "";
3374 var groups = groupWarningsByProject();
3375 for (i=0; i<groups.length; i++) {
3376 result += createWarningSection(ProjectNames[i], 'lightgrey', groups[i]);
3377 }
3378 return result;
3379 }
3380 function groupWarnings(generator) {
3381 GlobalAnchor = 0;
3382 var e = document.getElementById("warning_groups");
3383 e.innerHTML = generator();
3384 }
3385 function groupBySeverity() {
3386 groupWarnings(generateSectionsBySeverity);
3387 }
3388 function groupByProject() {
3389 groupWarnings(generateSectionsByProject);
3390 }
3391"""
3392
3393
3394# Emit a JavaScript const string
3395def emit_const_string(name, value):
3396 print 'const ' + name + ' = "' + escape_string(value) + '";'
3397
3398
3399# Emit a JavaScript const integer array.
3400def emit_const_int_array(name, array):
3401 print 'const ' + name + ' = ['
3402 for n in array:
3403 print str(n) + ','
3404 print '];'
3405
3406
3407# Emit a JavaScript const string array.
3408def emit_const_string_array(name, array):
3409 print 'const ' + name + ' = ['
3410 for s in array:
3411 print '"' + strip_escape_string(s) + '",'
3412 print '];'
3413
3414
Chih-Hung Hsiehb2afb632018-07-20 15:36:26 -07003415# Emit a JavaScript const string array for HTML.
3416def emit_const_html_string_array(name, array):
3417 print 'const ' + name + ' = ['
3418 for s in array:
3419 print '"' + cgi.escape(strip_escape_string(s)) + '",'
3420 print '];'
3421
3422
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003423# Emit a JavaScript const object array.
3424def emit_const_object_array(name, array):
3425 print 'const ' + name + ' = ['
3426 for x in array:
3427 print str(x) + ','
3428 print '];'
3429
3430
3431def emit_js_data():
3432 """Dump dynamic HTML page's static JavaScript data."""
3433 emit_const_string('FlagURL', args.url if args.url else '')
3434 emit_const_string('FlagSeparator', args.separator if args.separator else '')
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07003435 emit_const_string_array('SeverityColors', Severity.colors)
3436 emit_const_string_array('SeverityHeaders', Severity.headers)
3437 emit_const_string_array('SeverityColumnHeaders', Severity.column_headers)
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003438 emit_const_string_array('ProjectNames', project_names)
3439 emit_const_int_array('WarnPatternsSeverity',
3440 [w['severity'] for w in warn_patterns])
Chih-Hung Hsiehb2afb632018-07-20 15:36:26 -07003441 emit_const_html_string_array('WarnPatternsDescription',
3442 [w['description'] for w in warn_patterns])
3443 emit_const_html_string_array('WarnPatternsOption',
3444 [w['option'] for w in warn_patterns])
3445 emit_const_html_string_array('WarningMessages', warning_messages)
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003446 emit_const_object_array('Warnings', warning_records)
3447
3448draw_table_javascript = """
3449google.charts.load('current', {'packages':['table']});
3450google.charts.setOnLoadCallback(drawTable);
3451function drawTable() {
3452 var data = new google.visualization.DataTable();
3453 data.addColumn('string', StatsHeader[0]);
3454 for (var i=1; i<StatsHeader.length; i++) {
3455 data.addColumn('number', StatsHeader[i]);
3456 }
3457 data.addRows(StatsRows);
3458 for (var i=0; i<StatsRows.length; i++) {
3459 for (var j=0; j<StatsHeader.length; j++) {
3460 data.setProperty(i, j, 'style', 'border:1px solid black;');
3461 }
3462 }
3463 var table = new google.visualization.Table(document.getElementById('stats_table'));
3464 table.draw(data, {allowHtml: true, alternatingRowStyle: true});
3465}
3466"""
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003467
3468
3469def dump_html():
3470 """Dump the html output to stdout."""
3471 dump_html_prologue('Warnings for ' + platform_version + ' - ' +
3472 target_product + ' - ' + target_variant)
3473 dump_stats()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003474 print '<br><div id="stats_table"></div><br>'
3475 print '\n<script>'
3476 emit_js_data()
3477 print scripts_for_warning_groups
3478 print '</script>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003479 emit_buttons()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003480 # Warning messages are grouped by severities or project names.
3481 print '<br><div id="warning_groups"></div>'
3482 if args.byproject:
3483 print '<script>groupByProject();</script>'
3484 else:
3485 print '<script>groupBySeverity();</script>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003486 dump_fixed()
3487 dump_html_epilogue()
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07003488
3489
3490##### Functions to count warnings and dump csv file. #########################
3491
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07003492
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003493def description_for_csv(category):
3494 if not category['description']:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003495 return '?'
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003496 return category['description']
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07003497
3498
Sam Saccone03aaa7e2017-04-10 15:37:47 -07003499def count_severity(writer, sev, kind):
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003500 """Count warnings of given severity."""
3501 total = 0
3502 for i in warn_patterns:
3503 if i['severity'] == sev and i['members']:
3504 n = len(i['members'])
3505 total += n
Sam Saccone03aaa7e2017-04-10 15:37:47 -07003506 warning = kind + ': ' + description_for_csv(i)
3507 writer.writerow([n, '', warning])
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003508 # print number of warnings for each project, ordered by project name.
3509 projects = i['projects'].keys()
3510 projects.sort()
3511 for p in projects:
Sam Saccone03aaa7e2017-04-10 15:37:47 -07003512 writer.writerow([i['projects'][p], p, warning])
3513 writer.writerow([total, '', kind + ' warnings'])
3514
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003515 return total
3516
3517
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003518# dump number of warnings in csv format to stdout
Sam Saccone03aaa7e2017-04-10 15:37:47 -07003519def dump_csv(writer):
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003520 """Dump number of warnings in csv format to stdout."""
3521 sort_warnings()
3522 total = 0
Chih-Hung Hsiehb426c542016-09-27 18:08:52 -07003523 for s in Severity.range:
Sam Saccone03aaa7e2017-04-10 15:37:47 -07003524 total += count_severity(writer, s, Severity.column_headers[s])
3525 writer.writerow([total, '', 'All warnings'])
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07003526
3527
Meike Baumgärtnerac9d5df2016-09-28 10:48:06 -07003528def main():
Chih-Hung Hsieh76d00652016-11-09 18:19:05 -08003529 warning_lines = parse_input_file(open(args.buildlog, 'r'))
3530 parallel_classify_warnings(warning_lines)
Sam Saccone03aaa7e2017-04-10 15:37:47 -07003531 # If a user pases a csv path, save the fileoutput to the path
3532 # If the user also passed gencsv write the output to stdout
3533 # If the user did not pass gencsv flag dump the html report to stdout.
3534 if args.csvpath:
3535 with open(args.csvpath, 'w') as f:
3536 dump_csv(csv.writer(f, lineterminator='\n'))
Meike Baumgärtnerac9d5df2016-09-28 10:48:06 -07003537 if args.gencsv:
Sam Saccone03aaa7e2017-04-10 15:37:47 -07003538 dump_csv(csv.writer(sys.stdout, lineterminator='\n'))
Meike Baumgärtnerac9d5df2016-09-28 10:48:06 -07003539 else:
3540 dump_html()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07003541
Meike Baumgärtnerac9d5df2016-09-28 10:48:06 -07003542
3543# Run main function if warn.py is the main program.
3544if __name__ == '__main__':
3545 main()