blob: 7d9ba6530bb04a5eec5aca86cbde8d73c855eb35 [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]
35# platform_version
36# target_product
37# target_variant
38# compile_patterns, parse_input_file
39#
40# To emit html page of warning messages:
41# flags: --byproject, --url, --separator
42# Old stuff for static html components:
43# html_script_style: static html scripts and styles
44# htmlbig:
45# dump_stats, dump_html_prologue, dump_html_epilogue:
46# emit_buttons:
47# dump_fixed
48# sort_warnings:
49# emit_stats_by_project:
50# all_patterns,
51# findproject, classify_warning
52# dump_html
53#
54# New dynamic HTML page's static JavaScript data:
55# Some data are copied from Python to JavaScript, to generate HTML elements.
56# FlagURL args.url
57# FlagSeparator args.separator
58# SeverityColors: severity.colors
59# SeverityHeaders: severity.headers
60# SeverityColumnHeaders: severity.column_headers
61# ProjectNames: project_names, or project_list[*][0]
62# WarnPatternsSeverity: warn_patterns[*]['severity']
63# WarnPatternsDescription: warn_patterns[*]['description']
64# WarnPatternsOption: warn_patterns[*]['option']
65# WarningMessages: warning_messages
66# Warnings: warning_records
67# StatsHeader: warning count table header row
68# StatsRows: array of warning count table rows
69#
70# New dynamic HTML page's dynamic JavaScript data:
71#
72# New dynamic HTML related function to emit data:
73# escape_string, strip_escape_string, emit_warning_arrays
74# emit_js_data():
75#
76# To emit csv files of warning message counts:
77# flag --gencsv
78# description_for_csv, string_for_csv:
79# count_severity(sev, kind):
80# dump_csv():
81
Ian Rogersf3829732016-05-10 12:06:01 -070082import argparse
Marco Nelissen594375d2009-07-14 09:04:04 -070083import re
84
Ian Rogersf3829732016-05-10 12:06:01 -070085parser = argparse.ArgumentParser(description='Convert a build log into HTML')
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -070086parser.add_argument('--gencsv',
87 help='Generate a CSV file with number of various warnings',
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -070088 action='store_true',
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -070089 default=False)
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -070090parser.add_argument('--byproject',
91 help='Separate warnings in HTML output by project names',
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -070092 action='store_true',
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -070093 default=False)
Ian Rogersf3829732016-05-10 12:06:01 -070094parser.add_argument('--url',
95 help='Root URL of an Android source code tree prefixed '
96 'before files in warnings')
97parser.add_argument('--separator',
98 help='Separator between the end of a URL and the line '
99 'number argument. e.g. #')
100parser.add_argument(dest='buildlog', metavar='build.log',
101 help='Path to build.log file')
102args = parser.parse_args()
Marco Nelissen594375d2009-07-14 09:04:04 -0700103
Marco Nelissen594375d2009-07-14 09:04:04 -0700104
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700105class severity: # pylint:disable=invalid-name,old-style-class
106 """Severity levels and attributes."""
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -0700107 # numbered by dump order
108 FIXMENOW = 0
109 HIGH = 1
110 MEDIUM = 2
111 LOW = 3
112 TIDY = 4
113 HARMLESS = 5
114 UNKNOWN = 6
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700115 SKIP = 7
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -0700116 range = range(8)
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700117 attributes = [
118 # pylint:disable=bad-whitespace
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700119 ['fuchsia', 'FixNow', 'Critical warnings, fix me now'],
120 ['red', 'High', 'High severity warnings'],
121 ['orange', 'Medium', 'Medium severity warnings'],
122 ['yellow', 'Low', 'Low severity warnings'],
123 ['peachpuff', 'Tidy', 'Clang-Tidy warnings'],
124 ['limegreen', 'Harmless', 'Harmless warnings'],
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -0700125 ['lightblue', 'Unknown', 'Unknown warnings'],
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700126 ['grey', 'Unhandled', 'Unhandled warnings']
127 ]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -0700128 colors = [a[0] for a in attributes]
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700129 column_headers = [a[1] for a in attributes]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -0700130 headers = [a[2] for a in attributes]
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -0700131
132warn_patterns = [
133 # TODO(chh): fix pylint space and indentation warnings
134 # pylint:disable=bad-whitespace,bad-continuation,
135 # pylint:disable=line-too-long,g-inconsistent-quotes
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700136 { 'category':'make', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -0700137 'description':'make: overriding commands/ignoring old commands',
138 'patterns':[r".*: warning: overriding commands for target .+",
139 r".*: warning: ignoring old commands for target .+"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700140 { 'category':'make', 'severity':severity.HIGH,
Chih-Hung Hsiehd9cd1fa2016-08-02 14:22:06 -0700141 'description':'make: LOCAL_CLANG is false',
142 'patterns':[r".*: warning: LOCAL_CLANG is set to false"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700143 { 'category':'make', 'severity':severity.HIGH,
Dan Willemsen121e2842016-09-14 21:38:29 -0700144 'description':'SDK App using platform shared library',
145 'patterns':[r".*: warning: .+ \(.*app:sdk.*\) should not link to .+ \(native:platform\)"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700146 { 'category':'make', 'severity':severity.HIGH,
Dan Willemsen121e2842016-09-14 21:38:29 -0700147 'description':'System module linking to a vendor module',
148 'patterns':[r".*: warning: .+ \(.+\) should not link to .+ \(partition:.+\)"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700149 { 'category':'make', 'severity':severity.MEDIUM,
Dan Willemsen121e2842016-09-14 21:38:29 -0700150 'description':'Invalid SDK/NDK linking',
151 'patterns':[r".*: warning: .+ \(.+\) should not link to .+ \(.+\)"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700152 { 'category':'C/C++', 'severity':severity.HIGH, 'option':'-Wimplicit-function-declaration',
Marco Nelissen594375d2009-07-14 09:04:04 -0700153 'description':'Implicit function declaration',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700154 'patterns':[r".*: warning: implicit declaration of function .+",
155 r".*: warning: implicitly declaring library function" ] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700156 { 'category':'C/C++', 'severity':severity.SKIP,
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -0700157 'description':'skip, conflicting types for ...',
Marco Nelissen594375d2009-07-14 09:04:04 -0700158 'patterns':[r".*: warning: conflicting types for '.+'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700159 { 'category':'C/C++', 'severity':severity.HIGH, 'option':'-Wtype-limits',
Marco Nelissen594375d2009-07-14 09:04:04 -0700160 'description':'Expression always evaluates to true or false',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700161 'patterns':[r".*: warning: comparison is always .+ due to limited range of data type",
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700162 r".*: warning: comparison of unsigned .*expression .+ is always true",
163 r".*: warning: comparison of unsigned .*expression .+ is always false"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700164 { 'category':'C/C++', 'severity':severity.HIGH,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700165 'description':'Potential leak of memory, bad free, use after free',
166 'patterns':[r".*: warning: Potential leak of memory",
167 r".*: warning: Potential memory leak",
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700168 r".*: warning: Memory allocated by alloca\(\) should not be deallocated",
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700169 r".*: warning: Memory allocated by .+ should be deallocated by .+ not .+",
170 r".*: warning: 'delete' applied to a pointer that was allocated",
171 r".*: warning: Use of memory after it is freed",
172 r".*: warning: Argument to .+ is the address of .+ variable",
173 r".*: warning: Argument to free\(\) is offset by .+ of memory allocated by",
174 r".*: warning: Attempt to .+ released memory"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700175 { 'category':'C/C++', 'severity':severity.HIGH,
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700176 'description':'Use transient memory for control value',
177 'patterns':[r".*: warning: .+Using such transient memory for the control value is .*dangerous."] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700178 { 'category':'C/C++', 'severity':severity.HIGH,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700179 'description':'Return address of stack memory',
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700180 'patterns':[r".*: warning: Address of stack memory .+ returned to caller",
181 r".*: warning: Address of stack memory .+ will be a dangling reference"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700182 { 'category':'C/C++', 'severity':severity.HIGH,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700183 'description':'Problem with vfork',
184 'patterns':[r".*: warning: This .+ is prohibited after a successful vfork",
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700185 r".*: warning: Call to function '.+' is insecure "] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700186 { 'category':'C/C++', 'severity':severity.HIGH, 'option':'infinite-recursion',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700187 'description':'Infinite recursion',
188 'patterns':[r".*: warning: all paths through this function will call itself"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700189 { 'category':'C/C++', 'severity':severity.HIGH,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700190 'description':'Potential buffer overflow',
191 'patterns':[r".*: warning: Size argument is greater than .+ the destination buffer",
192 r".*: warning: Potential buffer overflow.",
193 r".*: warning: String copy function overflows destination buffer"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700194 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -0700195 'description':'Incompatible pointer types',
196 'patterns':[r".*: warning: assignment from incompatible pointer type",
Marco Nelissen8e201962010-03-10 16:16:02 -0800197 r".*: warning: return from incompatible pointer type",
Marco Nelissen594375d2009-07-14 09:04:04 -0700198 r".*: warning: passing argument [0-9]+ of '.*' from incompatible pointer type",
199 r".*: warning: initialization from incompatible pointer type"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700200 { 'category':'C/C++', 'severity':severity.HIGH, 'option':'-fno-builtin',
Marco Nelissen594375d2009-07-14 09:04:04 -0700201 'description':'Incompatible declaration of built in function',
202 'patterns':[r".*: warning: incompatible implicit declaration of built-in function .+"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700203 { 'category':'C/C++', 'severity':severity.HIGH, 'option':'-Wincompatible-library-redeclaration',
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -0700204 'description':'Incompatible redeclaration of library function',
205 'patterns':[r".*: warning: incompatible redeclaration of library function .+"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700206 { 'category':'C/C++', 'severity':severity.HIGH,
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700207 'description':'Null passed as non-null argument',
Chih-Hung Hsiehc21ddbd2016-07-20 10:08:51 -0700208 'patterns':[r".*: warning: Null passed to a callee that requires a non-null"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700209 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wunused-parameter',
Marco Nelissen594375d2009-07-14 09:04:04 -0700210 'description':'Unused parameter',
211 'patterns':[r".*: warning: unused parameter '.*'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700212 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wunused',
Marco Nelissen594375d2009-07-14 09:04:04 -0700213 'description':'Unused function, variable or label',
Marco Nelissen8e201962010-03-10 16:16:02 -0800214 'patterns':[r".*: warning: '.+' defined but not used",
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700215 r".*: warning: unused function '.+'",
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -0700216 r".*: warning: private field '.+' is not used",
Marco Nelissen8e201962010-03-10 16:16:02 -0800217 r".*: warning: unused variable '.+'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700218 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wunused-value',
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -0700219 'description':'Statement with no effect or result unused',
220 'patterns':[r".*: warning: statement with no effect",
221 r".*: warning: expression result unused"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700222 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wunused-result',
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -0700223 'description':'Ignoreing return value of function',
224 'patterns':[r".*: warning: ignoring return value of function .+Wunused-result"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700225 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wmissing-field-initializers',
Marco Nelissen594375d2009-07-14 09:04:04 -0700226 'description':'Missing initializer',
227 'patterns':[r".*: warning: missing initializer"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700228 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wdelete-non-virtual-dtor',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700229 'description':'Need virtual destructor',
230 'patterns':[r".*: warning: delete called .* has virtual functions but non-virtual destructor"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700231 { 'category':'cont.', 'severity':severity.SKIP,
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -0700232 'description':'skip, near initialization for ...',
Marco Nelissen594375d2009-07-14 09:04:04 -0700233 'patterns':[r".*: warning: \(near initialization for '.+'\)"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700234 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wdate-time',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700235 'description':'Expansion of data or time macro',
236 'patterns':[r".*: warning: expansion of date or time macro is not reproducible"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700237 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wformat',
Marco Nelissen594375d2009-07-14 09:04:04 -0700238 'description':'Format string does not match arguments',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700239 'patterns':[r".*: warning: format '.+' expects type '.+', but argument [0-9]+ has type '.+'",
240 r".*: warning: more '%' conversions than data arguments",
241 r".*: warning: data argument not used by format string",
242 r".*: warning: incomplete format specifier",
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700243 r".*: warning: unknown conversion type .* in format",
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700244 r".*: warning: format .+ expects .+ but argument .+Wformat=",
245 r".*: warning: field precision should have .+ but argument has .+Wformat",
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700246 r".*: warning: format specifies type .+ but the argument has .*type .+Wformat"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700247 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wformat-extra-args',
Marco Nelissen594375d2009-07-14 09:04:04 -0700248 'description':'Too many arguments for format string',
249 'patterns':[r".*: warning: too many arguments for format"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700250 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wformat-invalid-specifier',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700251 'description':'Invalid format specifier',
252 'patterns':[r".*: warning: invalid .+ specifier '.+'.+format-invalid-specifier"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700253 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wsign-compare',
Marco Nelissen594375d2009-07-14 09:04:04 -0700254 'description':'Comparison between signed and unsigned',
255 'patterns':[r".*: warning: comparison between signed and unsigned",
256 r".*: warning: comparison of promoted \~unsigned with unsigned",
257 r".*: warning: signed and unsigned type in conditional expression"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700258 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen8e201962010-03-10 16:16:02 -0800259 'description':'Comparison between enum and non-enum',
260 'patterns':[r".*: warning: enumeral and non-enumeral type in conditional expression"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700261 { 'category':'libpng', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -0700262 'description':'libpng: zero area',
263 'patterns':[r".*libpng warning: Ignoring attempt to set cHRM RGB triangle with zero area"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700264 { 'category':'aapt', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -0700265 'description':'aapt: no comment for public symbol',
266 'patterns':[r".*: warning: No comment for public symbol .+"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700267 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wmissing-braces',
Marco Nelissen594375d2009-07-14 09:04:04 -0700268 'description':'Missing braces around initializer',
269 'patterns':[r".*: warning: missing braces around initializer.*"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700270 { 'category':'C/C++', 'severity':severity.HARMLESS,
Marco Nelissen594375d2009-07-14 09:04:04 -0700271 'description':'No newline at end of file',
272 'patterns':[r".*: warning: no newline at end of file"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700273 { 'category':'C/C++', 'severity':severity.HARMLESS,
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700274 'description':'Missing space after macro name',
275 'patterns':[r".*: warning: missing whitespace after the macro name"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700276 { 'category':'C/C++', 'severity':severity.LOW, 'option':'-Wcast-align',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700277 'description':'Cast increases required alignment',
278 'patterns':[r".*: warning: cast from .* to .* increases required alignment .*"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700279 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wcast-qual',
Marco Nelissen594375d2009-07-14 09:04:04 -0700280 'description':'Qualifier discarded',
281 'patterns':[r".*: warning: passing argument [0-9]+ of '.+' discards qualifiers from pointer target type",
282 r".*: warning: assignment discards qualifiers from pointer target type",
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700283 r".*: warning: passing .+ to parameter of type .+ discards qualifiers",
284 r".*: warning: assigning to .+ from .+ discards qualifiers",
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700285 r".*: warning: initializing .+ discards qualifiers .+types-discards-qualifiers",
Marco Nelissen594375d2009-07-14 09:04:04 -0700286 r".*: warning: return discards qualifiers from pointer target type"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700287 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wunknown-attributes',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700288 'description':'Unknown attribute',
289 'patterns':[r".*: warning: unknown attribute '.+'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700290 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wignored-attributes',
Marco Nelissen594375d2009-07-14 09:04:04 -0700291 'description':'Attribute ignored',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700292 'patterns':[r".*: warning: '_*packed_*' attribute ignored",
293 r".*: warning: attribute declaration must precede definition .+ignored-attributes"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700294 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wvisibility',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700295 'description':'Visibility problem',
296 'patterns':[r".*: warning: declaration of '.+' will not be visible outside of this function"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700297 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wattributes',
Marco Nelissen594375d2009-07-14 09:04:04 -0700298 'description':'Visibility mismatch',
299 'patterns':[r".*: warning: '.+' declared with greater visibility than the type of its field '.+'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700300 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -0700301 'description':'Shift count greater than width of type',
302 'patterns':[r".*: warning: (left|right) shift count >= width of type"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700303 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wextern-initializer',
Marco Nelissen594375d2009-07-14 09:04:04 -0700304 'description':'extern <foo> is initialized',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700305 'patterns':[r".*: warning: '.+' initialized and declared 'extern'",
306 r".*: warning: 'extern' variable has an initializer"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700307 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wold-style-declaration',
Marco Nelissen594375d2009-07-14 09:04:04 -0700308 'description':'Old style declaration',
309 'patterns':[r".*: warning: 'static' is not at beginning of declaration"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700310 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wreturn-type',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700311 'description':'Missing return value',
312 'patterns':[r".*: warning: control reaches end of non-void function"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700313 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wimplicit-int',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700314 'description':'Implicit int type',
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -0700315 'patterns':[r".*: warning: type specifier missing, defaults to 'int'",
316 r".*: warning: type defaults to 'int' in declaration of '.+'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700317 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wmain-return-type',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700318 'description':'Main function should return int',
319 'patterns':[r".*: warning: return type of 'main' is not 'int'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700320 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wuninitialized',
Marco Nelissen594375d2009-07-14 09:04:04 -0700321 'description':'Variable may be used uninitialized',
322 'patterns':[r".*: warning: '.+' may be used uninitialized in this function"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700323 { 'category':'C/C++', 'severity':severity.HIGH, 'option':'-Wuninitialized',
Marco Nelissen594375d2009-07-14 09:04:04 -0700324 'description':'Variable is used uninitialized',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700325 'patterns':[r".*: warning: '.+' is used uninitialized in this function",
326 r".*: warning: variable '.+' is uninitialized when used here"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700327 { 'category':'ld', 'severity':severity.MEDIUM, 'option':'-fshort-enums',
Marco Nelissen594375d2009-07-14 09:04:04 -0700328 'description':'ld: possible enum size mismatch',
329 'patterns':[r".*: warning: .* uses variable-size enums yet the output is to use 32-bit enums; use of enum values across objects may fail"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700330 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wpointer-sign',
Marco Nelissen594375d2009-07-14 09:04:04 -0700331 'description':'Pointer targets differ in signedness',
332 'patterns':[r".*: warning: pointer targets in initialization differ in signedness",
333 r".*: warning: pointer targets in assignment differ in signedness",
334 r".*: warning: pointer targets in return differ in signedness",
335 r".*: warning: pointer targets in passing argument [0-9]+ of '.+' differ in signedness"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700336 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wstrict-overflow',
Marco Nelissen594375d2009-07-14 09:04:04 -0700337 'description':'Assuming overflow does not occur',
338 'patterns':[r".*: warning: assuming signed overflow does not occur when assuming that .* is always (true|false)"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700339 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wempty-body',
Marco Nelissen594375d2009-07-14 09:04:04 -0700340 'description':'Suggest adding braces around empty body',
341 'patterns':[r".*: warning: suggest braces around empty body in an 'if' statement",
342 r".*: warning: empty body in an if-statement",
343 r".*: warning: suggest braces around empty body in an 'else' statement",
344 r".*: warning: empty body in an else-statement"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700345 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wparentheses',
Marco Nelissen594375d2009-07-14 09:04:04 -0700346 'description':'Suggest adding parentheses',
347 'patterns':[r".*: warning: suggest explicit braces to avoid ambiguous 'else'",
348 r".*: warning: suggest parentheses around arithmetic in operand of '.+'",
349 r".*: warning: suggest parentheses around comparison in operand of '.+'",
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700350 r".*: warning: logical not is only applied to the left hand side of this comparison",
351 r".*: warning: using the result of an assignment as a condition without parentheses",
352 r".*: warning: .+ has lower precedence than .+ be evaluated first .+Wparentheses",
Marco Nelissen594375d2009-07-14 09:04:04 -0700353 r".*: warning: suggest parentheses around '.+?' .+ '.+?'",
354 r".*: warning: suggest parentheses around assignment used as truth value"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700355 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -0700356 'description':'Static variable used in non-static inline function',
357 'patterns':[r".*: warning: '.+' is static but used in inline function '.+' which is not static"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700358 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wimplicit int',
Marco Nelissen594375d2009-07-14 09:04:04 -0700359 'description':'No type or storage class (will default to int)',
360 'patterns':[r".*: warning: data definition has no type or storage class"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700361 { 'category':'C/C++', 'severity':severity.MEDIUM,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700362 'description':'Null pointer',
363 'patterns':[r".*: warning: Dereference of null pointer",
364 r".*: warning: Called .+ pointer is null",
365 r".*: warning: Forming reference to null pointer",
366 r".*: warning: Returning null reference",
367 r".*: warning: Null pointer passed as an argument to a 'nonnull' parameter",
368 r".*: warning: .+ results in a null pointer dereference",
369 r".*: warning: Access to .+ results in a dereference of a null pointer",
370 r".*: warning: Null pointer argument in"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700371 { 'category':'cont.', 'severity':severity.SKIP,
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -0700372 'description':'skip, parameter name (without types) in function declaration',
Marco Nelissen594375d2009-07-14 09:04:04 -0700373 'patterns':[r".*: warning: parameter names \(without types\) in function declaration"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700374 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wstrict-aliasing',
Marco Nelissen594375d2009-07-14 09:04:04 -0700375 'description':'Dereferencing <foo> breaks strict aliasing rules',
376 'patterns':[r".*: warning: dereferencing .* break strict-aliasing rules"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700377 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wpointer-to-int-cast',
Marco Nelissen594375d2009-07-14 09:04:04 -0700378 'description':'Cast from pointer to integer of different size',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700379 'patterns':[r".*: warning: cast from pointer to integer of different size",
380 r".*: warning: initialization makes pointer from integer without a cast"] } ,
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700381 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wint-to-pointer-cast',
Marco Nelissen594375d2009-07-14 09:04:04 -0700382 'description':'Cast to pointer from integer of different size',
383 'patterns':[r".*: warning: cast to pointer from integer of different size"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700384 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -0700385 'description':'Symbol redefined',
386 'patterns':[r".*: warning: "".+"" redefined"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700387 { 'category':'cont.', 'severity':severity.SKIP,
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -0700388 'description':'skip, ... location of the previous definition',
Marco Nelissen594375d2009-07-14 09:04:04 -0700389 'patterns':[r".*: warning: this is the location of the previous definition"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700390 { 'category':'ld', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -0700391 'description':'ld: type and size of dynamic symbol are not defined',
392 'patterns':[r".*: warning: type and size of dynamic symbol `.+' are not defined"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700393 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -0700394 'description':'Pointer from integer without cast',
395 'patterns':[r".*: warning: assignment makes pointer from integer without a cast"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700396 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -0700397 'description':'Pointer from integer without cast',
398 'patterns':[r".*: warning: passing argument [0-9]+ of '.+' makes pointer from integer without a cast"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700399 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -0700400 'description':'Integer from pointer without cast',
401 'patterns':[r".*: warning: assignment makes integer from pointer without a cast"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700402 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -0700403 'description':'Integer from pointer without cast',
404 'patterns':[r".*: warning: passing argument [0-9]+ of '.+' makes integer from pointer without a cast"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700405 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -0700406 'description':'Integer from pointer without cast',
407 'patterns':[r".*: warning: return makes integer from pointer without a cast"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700408 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wunknown-pragmas',
Marco Nelissen594375d2009-07-14 09:04:04 -0700409 'description':'Ignoring pragma',
410 'patterns':[r".*: warning: ignoring #pragma .+"] },
Chih-Hung Hsieh0a192072016-09-21 14:00:23 -0700411 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-W#pragma-messages',
412 'description':'Pragma warning messages',
413 'patterns':[r".*: warning: .+W#pragma-messages"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700414 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wclobbered',
Marco Nelissen594375d2009-07-14 09:04:04 -0700415 'description':'Variable might be clobbered by longjmp or vfork',
416 'patterns':[r".*: warning: variable '.+' might be clobbered by 'longjmp' or 'vfork'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700417 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wclobbered',
Marco Nelissen594375d2009-07-14 09:04:04 -0700418 'description':'Argument might be clobbered by longjmp or vfork',
419 'patterns':[r".*: warning: argument '.+' might be clobbered by 'longjmp' or 'vfork'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700420 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wredundant-decls',
Marco Nelissen594375d2009-07-14 09:04:04 -0700421 'description':'Redundant declaration',
422 'patterns':[r".*: warning: redundant redeclaration of '.+'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700423 { 'category':'cont.', 'severity':severity.SKIP,
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -0700424 'description':'skip, previous declaration ... was here',
Marco Nelissen594375d2009-07-14 09:04:04 -0700425 'patterns':[r".*: warning: previous declaration of '.+' was here"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700426 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wswitch-enum',
Marco Nelissen594375d2009-07-14 09:04:04 -0700427 'description':'Enum value not handled in switch',
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700428 'patterns':[r".*: warning: .*enumeration value.* not handled in switch.+Wswitch"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700429 { 'category':'java', 'severity':severity.MEDIUM, 'option':'-encoding',
Marco Nelissen594375d2009-07-14 09:04:04 -0700430 'description':'Java: Non-ascii characters used, but ascii encoding specified',
431 'patterns':[r".*: warning: unmappable character for encoding ascii"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700432 { 'category':'java', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -0700433 'description':'Java: Non-varargs call of varargs method with inexact argument type for last parameter',
434 'patterns':[r".*: warning: non-varargs call of varargs method with inexact argument type for last parameter"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700435 { 'category':'java', 'severity':severity.MEDIUM,
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700436 'description':'Java: Unchecked method invocation',
437 'patterns':[r".*: warning: \[unchecked\] unchecked method invocation: .+ in class .+"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700438 { 'category':'java', 'severity':severity.MEDIUM,
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700439 'description':'Java: Unchecked conversion',
440 'patterns':[r".*: warning: \[unchecked\] unchecked conversion"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700441 { 'category':'java', 'severity':severity.MEDIUM,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -0700442 'description':'_ used as an identifier',
443 'patterns':[r".*: warning: '_' used as an identifier"] },
Ian Rogers32bb9bd2016-05-09 23:19:42 -0700444
Ian Rogers6e520032016-05-13 08:59:00 -0700445 # Warnings from Error Prone.
446 {'category': 'java',
447 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700448 'description': 'Java: Use of deprecated member',
449 'patterns': [r'.*: warning: \[deprecation\] .+']},
450 {'category': 'java',
451 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700452 'description': 'Java: Unchecked conversion',
453 'patterns': [r'.*: warning: \[unchecked\] .+']},
Ian Rogers32bb9bd2016-05-09 23:19:42 -0700454
Ian Rogers6e520032016-05-13 08:59:00 -0700455 # Warnings from Error Prone (auto generated list).
456 {'category': 'java',
457 'severity': severity.LOW,
Ian Rogers6e520032016-05-13 08:59:00 -0700458 'description':
459 'Java: Deprecated item is not annotated with @Deprecated',
460 'patterns': [r".*: warning: \[DepAnn\] .+"]},
461 {'category': 'java',
462 'severity': severity.LOW,
Ian Rogers6e520032016-05-13 08:59:00 -0700463 'description':
464 'Java: Fallthrough warning suppression has no effect if warning is suppressed',
465 'patterns': [r".*: warning: \[FallthroughSuppression\] .+"]},
466 {'category': 'java',
467 'severity': severity.LOW,
Ian Rogers6e520032016-05-13 08:59:00 -0700468 'description':
469 'Java: Prefer \'L\' to \'l\' for the suffix to long literals',
470 'patterns': [r".*: warning: \[LongLiteralLowerCaseSuffix\] .+"]},
471 {'category': 'java',
472 'severity': severity.LOW,
Ian Rogers6e520032016-05-13 08:59:00 -0700473 'description':
474 'Java: @Binds is a more efficient and declaritive mechanism for delegating a binding.',
475 'patterns': [r".*: warning: \[UseBinds\] .+"]},
476 {'category': 'java',
477 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700478 'description':
479 'Java: Assertions may be disabled at runtime and do not guarantee that execution will halt here; consider throwing an exception instead',
480 'patterns': [r".*: warning: \[AssertFalse\] .+"]},
481 {'category': 'java',
482 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700483 'description':
484 'Java: Classes that implement Annotation must override equals and hashCode. Consider using AutoAnnotation instead of implementing Annotation by hand.',
485 'patterns': [r".*: warning: \[BadAnnotationImplementation\] .+"]},
486 {'category': 'java',
487 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700488 'description':
489 'Java: BigDecimal(double) and BigDecimal.valueOf(double) may lose precision, prefer BigDecimal(String) or BigDecimal(long)',
490 'patterns': [r".*: warning: \[BigDecimalLiteralDouble\] .+"]},
491 {'category': 'java',
492 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700493 'description':
494 'Java: Mockito cannot mock final classes',
495 'patterns': [r".*: warning: \[CannotMockFinalClass\] .+"]},
496 {'category': 'java',
497 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700498 'description':
499 'Java: This code, which counts elements using a loop, can be replaced by a simpler library method',
500 'patterns': [r".*: warning: \[ElementsCountedInLoop\] .+"]},
501 {'category': 'java',
502 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700503 'description':
504 'Java: Empty top-level type declaration',
505 'patterns': [r".*: warning: \[EmptyTopLevelDeclaration\] .+"]},
506 {'category': 'java',
507 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700508 'description':
509 'Java: Classes that override equals should also override hashCode.',
510 'patterns': [r".*: warning: \[EqualsHashCode\] .+"]},
511 {'category': 'java',
512 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700513 'description':
514 'Java: An equality test between objects with incompatible types always returns false',
515 'patterns': [r".*: warning: \[EqualsIncompatibleType\] .+"]},
516 {'category': 'java',
517 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700518 'description':
519 '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.',
520 'patterns': [r".*: warning: \[Finally\] .+"]},
521 {'category': 'java',
522 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700523 'description':
524 'Java: This annotation has incompatible modifiers as specified by its @IncompatibleModifiers annotation',
525 'patterns': [r".*: warning: \[IncompatibleModifiers\] .+"]},
526 {'category': 'java',
527 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700528 'description':
529 'Java: Class should not implement both `Iterable` and `Iterator`',
530 'patterns': [r".*: warning: \[IterableAndIterator\] .+"]},
531 {'category': 'java',
532 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700533 'description':
534 'Java: Floating-point comparison without error tolerance',
535 'patterns': [r".*: warning: \[JUnit3FloatingPointComparisonWithoutDelta\] .+"]},
536 {'category': 'java',
537 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700538 'description':
539 'Java: Test class inherits from JUnit 3\'s TestCase but has JUnit 4 @Test annotations.',
540 'patterns': [r".*: warning: \[JUnitAmbiguousTestClass\] .+"]},
541 {'category': 'java',
542 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700543 'description':
544 'Java: Enum switch statement is missing cases',
545 'patterns': [r".*: warning: \[MissingCasesInEnumSwitch\] .+"]},
546 {'category': 'java',
547 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700548 'description':
549 'Java: Not calling fail() when expecting an exception masks bugs',
550 'patterns': [r".*: warning: \[MissingFail\] .+"]},
551 {'category': 'java',
552 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700553 'description':
554 'Java: method overrides method in supertype; expected @Override',
555 'patterns': [r".*: warning: \[MissingOverride\] .+"]},
556 {'category': 'java',
557 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700558 'description':
559 'Java: Source files should not contain multiple top-level class declarations',
560 'patterns': [r".*: warning: \[MultipleTopLevelClasses\] .+"]},
561 {'category': 'java',
562 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700563 'description':
564 'Java: This update of a volatile variable is non-atomic',
565 'patterns': [r".*: warning: \[NonAtomicVolatileUpdate\] .+"]},
566 {'category': 'java',
567 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700568 'description':
569 'Java: Static import of member uses non-canonical name',
570 'patterns': [r".*: warning: \[NonCanonicalStaticMemberImport\] .+"]},
571 {'category': 'java',
572 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700573 'description':
574 'Java: equals method doesn\'t override Object.equals',
575 'patterns': [r".*: warning: \[NonOverridingEquals\] .+"]},
576 {'category': 'java',
577 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700578 'description':
579 'Java: Constructors should not be annotated with @Nullable since they cannot return null',
580 'patterns': [r".*: warning: \[NullableConstructor\] .+"]},
581 {'category': 'java',
582 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700583 'description':
584 'Java: @Nullable should not be used for primitive types since they cannot be null',
585 'patterns': [r".*: warning: \[NullablePrimitive\] .+"]},
586 {'category': 'java',
587 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700588 'description':
589 'Java: void-returning methods should not be annotated with @Nullable, since they cannot return null',
590 'patterns': [r".*: warning: \[NullableVoid\] .+"]},
591 {'category': 'java',
592 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700593 'description':
594 'Java: Package names should match the directory they are declared in',
595 'patterns': [r".*: warning: \[PackageLocation\] .+"]},
596 {'category': 'java',
597 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700598 'description':
599 'Java: Second argument to Preconditions.* is a call to String.format(), which can be unwrapped',
600 'patterns': [r".*: warning: \[PreconditionsErrorMessageEagerEvaluation\] .+"]},
601 {'category': 'java',
602 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700603 'description':
604 'Java: Preconditions only accepts the %s placeholder in error message strings',
605 'patterns': [r".*: warning: \[PreconditionsInvalidPlaceholder\] .+"]},
606 {'category': 'java',
607 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700608 'description':
609 'Java: Passing a primitive array to a varargs method is usually wrong',
610 'patterns': [r".*: warning: \[PrimitiveArrayPassedToVarargsMethod\] .+"]},
611 {'category': 'java',
612 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700613 'description':
614 'Java: Protobuf fields cannot be null, so this check is redundant',
615 'patterns': [r".*: warning: \[ProtoFieldPreconditionsCheckNotNull\] .+"]},
616 {'category': 'java',
617 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700618 'description':
619 'Java: This annotation is missing required modifiers as specified by its @RequiredModifiers annotation',
620 'patterns': [r".*: warning: \[RequiredModifiers\] .+"]},
621 {'category': 'java',
622 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700623 'description':
624 'Java: A static variable or method should not be accessed from an object instance',
625 'patterns': [r".*: warning: \[StaticAccessedFromInstance\] .+"]},
626 {'category': 'java',
627 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700628 'description':
629 'Java: String comparison using reference equality instead of value equality',
630 'patterns': [r".*: warning: \[StringEquality\] .+"]},
631 {'category': 'java',
632 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700633 'description':
634 '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.',
635 'patterns': [r".*: warning: \[TypeParameterUnusedInFormals\] .+"]},
636 {'category': 'java',
637 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700638 'description':
639 'Java: Using static imports for types is unnecessary',
640 'patterns': [r".*: warning: \[UnnecessaryStaticImport\] .+"]},
641 {'category': 'java',
642 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700643 'description':
644 'Java: Unsynchronized method overrides a synchronized method.',
645 'patterns': [r".*: warning: \[UnsynchronizedOverridesSynchronized\] .+"]},
646 {'category': 'java',
647 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700648 'description':
649 'Java: Non-constant variable missing @Var annotation',
650 'patterns': [r".*: warning: \[Var\] .+"]},
651 {'category': 'java',
652 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700653 'description':
654 'Java: Because of spurious wakeups, Object.wait() and Condition.await() must always be called in a loop',
655 'patterns': [r".*: warning: \[WaitNotInLoop\] .+"]},
656 {'category': 'java',
657 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700658 'description':
659 'Java: Subclasses of Fragment must be instantiable via Class#newInstance(): the class must be public, static and have a public nullary constructor',
660 'patterns': [r".*: warning: \[FragmentNotInstantiable\] .+"]},
661 {'category': 'java',
662 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700663 'description':
664 'Java: Hardcoded reference to /sdcard',
665 'patterns': [r".*: warning: \[HardCodedSdCardPath\] .+"]},
666 {'category': 'java',
667 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700668 'description':
669 'Java: Incompatible type as argument to Object-accepting Java collections method',
670 'patterns': [r".*: warning: \[CollectionIncompatibleType\] .+"]},
671 {'category': 'java',
672 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700673 'description':
674 'Java: @AssistedInject and @Inject should not be used on different constructors in the same class.',
675 'patterns': [r".*: warning: \[AssistedInjectAndInjectOnConstructors\] .+"]},
676 {'category': 'java',
677 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700678 'description':
679 'Java: Although Guice allows injecting final fields, doing so is not recommended because the injected value may not be visible to other threads.',
680 'patterns': [r".*: warning: \[GuiceInjectOnFinalField\] .+"]},
681 {'category': 'java',
682 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700683 'description':
684 '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.',
685 'patterns': [r".*: warning: \[OverridesGuiceInjectableMethod\] .+"]},
686 {'category': 'java',
687 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700688 'description':
689 'Java: Double-checked locking on non-volatile fields is unsafe',
690 'patterns': [r".*: warning: \[DoubleCheckedLocking\] .+"]},
691 {'category': 'java',
692 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700693 'description':
694 'Java: Writes to static fields should not be guarded by instance locks',
695 'patterns': [r".*: warning: \[StaticGuardedByInstance\] .+"]},
696 {'category': 'java',
697 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700698 'description':
699 'Java: Synchronizing on non-final fields is not safe: if the field is ever updated, different threads may end up locking on different objects.',
700 'patterns': [r".*: warning: \[SynchronizeOnNonFinalField\] .+"]},
701 {'category': 'java',
702 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700703 'description':
704 'Java: Reference equality used to compare arrays',
705 'patterns': [r".*: warning: \[ArrayEquals\] .+"]},
706 {'category': 'java',
707 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700708 'description':
709 'Java: hashcode method on array does not hash array contents',
710 'patterns': [r".*: warning: \[ArrayHashCode\] .+"]},
711 {'category': 'java',
712 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700713 'description':
714 'Java: Calling toString on an array does not provide useful information',
715 'patterns': [r".*: warning: \[ArrayToString.*\] .+"]},
716 {'category': 'java',
717 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700718 'description':
719 'Java: Arrays.asList does not autobox primitive arrays, as one might expect.',
720 'patterns': [r".*: warning: \[ArraysAsListPrimitiveArray\] .+"]},
721 {'category': 'java',
722 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700723 'description':
724 'Java: AsyncCallable should not return a null Future, only a Future whose result is null.',
725 'patterns': [r".*: warning: \[AsyncCallableReturnsNull\] .+"]},
726 {'category': 'java',
727 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700728 'description':
729 'Java: AsyncFunction should not return a null Future, only a Future whose result is null.',
730 'patterns': [r".*: warning: \[AsyncFunctionReturnsNull\] .+"]},
731 {'category': 'java',
732 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700733 'description':
734 'Java: Possible sign flip from narrowing conversion',
735 'patterns': [r".*: warning: \[BadComparable\] .+"]},
736 {'category': 'java',
737 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700738 'description':
739 'Java: Shift by an amount that is out of range',
740 'patterns': [r".*: warning: \[BadShiftAmount\] .+"]},
741 {'category': 'java',
742 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700743 'description':
744 'Java: valueOf provides better time and space performance',
745 'patterns': [r".*: warning: \[BoxedPrimitiveConstructor\] .+"]},
746 {'category': 'java',
747 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700748 'description':
749 '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.',
750 'patterns': [r".*: warning: \[ChainingConstructorIgnoresParameter\] .+"]},
751 {'category': 'java',
752 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700753 'description':
754 'Java: Ignored return value of method that is annotated with @CheckReturnValue',
755 'patterns': [r".*: warning: \[CheckReturnValue\] .+"]},
756 {'category': 'java',
757 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700758 'description':
759 'Java: Inner class is non-static but does not reference enclosing class',
760 'patterns': [r".*: warning: \[ClassCanBeStatic\] .+"]},
761 {'category': 'java',
762 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700763 'description':
764 'Java: The source file name should match the name of the top-level class it contains',
765 'patterns': [r".*: warning: \[ClassName\] .+"]},
766 {'category': 'java',
767 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700768 'description':
769 'Java: This comparison method violates the contract',
770 'patterns': [r".*: warning: \[ComparisonContractViolated\] .+"]},
771 {'category': 'java',
772 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700773 'description':
774 'Java: Comparison to value that is out of range for the compared type',
775 'patterns': [r".*: warning: \[ComparisonOutOfRange\] .+"]},
776 {'category': 'java',
777 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700778 'description':
779 'Java: Non-compile-time constant expression passed to parameter with @CompileTimeConstant type annotation.',
780 'patterns': [r".*: warning: \[CompileTimeConstant\] .+"]},
781 {'category': 'java',
782 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700783 'description':
784 'Java: Exception created but not thrown',
785 'patterns': [r".*: warning: \[DeadException\] .+"]},
786 {'category': 'java',
787 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700788 'description':
789 'Java: Division by integer literal zero',
790 'patterns': [r".*: warning: \[DivZero\] .+"]},
791 {'category': 'java',
792 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700793 'description':
794 'Java: Empty statement after if',
795 'patterns': [r".*: warning: \[EmptyIf\] .+"]},
796 {'category': 'java',
797 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700798 'description':
799 'Java: == NaN always returns false; use the isNaN methods instead',
800 'patterns': [r".*: warning: \[EqualsNaN\] .+"]},
801 {'category': 'java',
802 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700803 'description':
804 'Java: Method annotated @ForOverride must be protected or package-private and only invoked from declaring class',
805 'patterns': [r".*: warning: \[ForOverride\] .+"]},
806 {'category': 'java',
807 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700808 'description':
809 'Java: Futures.getChecked requires a checked exception type with a standard constructor.',
810 'patterns': [r".*: warning: \[FuturesGetCheckedIllegalExceptionType\] .+"]},
811 {'category': 'java',
812 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700813 'description':
814 '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',
815 'patterns': [r".*: warning: \[GetClassOnClass\] .+"]},
816 {'category': 'java',
817 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700818 'description':
819 'Java: An object is tested for equality to itself using Guava Libraries',
820 'patterns': [r".*: warning: \[GuavaSelfEquals\] .+"]},
821 {'category': 'java',
822 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700823 'description':
824 'Java: contains() is a legacy method that is equivalent to containsValue()',
825 'patterns': [r".*: warning: \[HashtableContains\] .+"]},
826 {'category': 'java',
827 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700828 'description':
829 'Java: Cipher.getInstance() is invoked using either the default settings or ECB mode',
830 'patterns': [r".*: warning: \[InsecureCipherMode\] .+"]},
831 {'category': 'java',
832 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700833 'description':
834 'Java: Invalid syntax used for a regular expression',
835 'patterns': [r".*: warning: \[InvalidPatternSyntax\] .+"]},
836 {'category': 'java',
837 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700838 'description':
839 'Java: The argument to Class#isInstance(Object) should not be a Class',
840 'patterns': [r".*: warning: \[IsInstanceOfClass\] .+"]},
841 {'category': 'java',
842 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700843 'description':
844 'Java: jMock tests must have a @RunWith(JMock.class) annotation, or the Mockery field must have a @Rule JUnit annotation',
845 'patterns': [r".*: warning: \[JMockTestWithoutRunWithOrRuleAnnotation\] .+"]},
846 {'category': 'java',
847 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700848 'description':
849 'Java: Test method will not be run; please prefix name with "test"',
850 'patterns': [r".*: warning: \[JUnit3TestNotRun\] .+"]},
851 {'category': 'java',
852 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700853 'description':
854 'Java: setUp() method will not be run; Please add a @Before annotation',
855 'patterns': [r".*: warning: \[JUnit4SetUpNotRun\] .+"]},
856 {'category': 'java',
857 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700858 'description':
859 'Java: tearDown() method will not be run; Please add an @After annotation',
860 'patterns': [r".*: warning: \[JUnit4TearDownNotRun\] .+"]},
861 {'category': 'java',
862 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700863 'description':
864 'Java: Test method will not be run; please add @Test annotation',
865 'patterns': [r".*: warning: \[JUnit4TestNotRun\] .+"]},
866 {'category': 'java',
867 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700868 'description':
869 'Java: Printf-like format string does not match its arguments',
870 'patterns': [r".*: warning: \[MalformedFormatString\] .+"]},
871 {'category': 'java',
872 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700873 'description':
874 'Java: Use of "YYYY" (week year) in a date pattern without "ww" (week in year). You probably meant to use "yyyy" (year) instead.',
875 'patterns': [r".*: warning: \[MisusedWeekYear\] .+"]},
876 {'category': 'java',
877 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700878 'description':
879 'Java: A bug in Mockito will cause this test to fail at runtime with a ClassCastException',
880 'patterns': [r".*: warning: \[MockitoCast\] .+"]},
881 {'category': 'java',
882 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700883 'description':
884 'Java: Missing method call for verify(mock) here',
885 'patterns': [r".*: warning: \[MockitoUsage\] .+"]},
886 {'category': 'java',
887 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700888 'description':
889 'Java: Modifying a collection with itself',
890 'patterns': [r".*: warning: \[ModifyingCollectionWithItself\] .+"]},
891 {'category': 'java',
892 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700893 'description':
894 'Java: Compound assignments to bytes, shorts, chars, and floats hide dangerous casts',
895 'patterns': [r".*: warning: \[NarrowingCompoundAssignment\] .+"]},
896 {'category': 'java',
897 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700898 'description':
899 'Java: @NoAllocation was specified on this method, but something was found that would trigger an allocation',
900 'patterns': [r".*: warning: \[NoAllocation\] .+"]},
901 {'category': 'java',
902 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700903 'description':
904 'Java: Static import of type uses non-canonical name',
905 'patterns': [r".*: warning: \[NonCanonicalStaticImport\] .+"]},
906 {'category': 'java',
907 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700908 'description':
909 'Java: @CompileTimeConstant parameters should be final',
910 'patterns': [r".*: warning: \[NonFinalCompileTimeConstant\] .+"]},
911 {'category': 'java',
912 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700913 'description':
914 'Java: Calling getAnnotation on an annotation that is not retained at runtime.',
915 'patterns': [r".*: warning: \[NonRuntimeAnnotation\] .+"]},
916 {'category': 'java',
917 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700918 'description':
919 'Java: Numeric comparison using reference equality instead of value equality',
920 'patterns': [r".*: warning: \[NumericEquality\] .+"]},
921 {'category': 'java',
922 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700923 'description':
924 'Java: Comparison using reference equality instead of value equality',
925 'patterns': [r".*: warning: \[OptionalEquality\] .+"]},
926 {'category': 'java',
927 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700928 'description':
929 'Java: Varargs doesn\'t agree for overridden method',
930 'patterns': [r".*: warning: \[Overrides\] .+"]},
931 {'category': 'java',
932 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700933 'description':
934 'Java: Literal passed as first argument to Preconditions.checkNotNull() can never be null',
935 'patterns': [r".*: warning: \[PreconditionsCheckNotNull\] .+"]},
936 {'category': 'java',
937 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700938 'description':
939 'Java: First argument to `Preconditions.checkNotNull()` is a primitive rather than an object reference',
940 'patterns': [r".*: warning: \[PreconditionsCheckNotNullPrimitive\] .+"]},
941 {'category': 'java',
942 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700943 'description':
944 'Java: Protobuf fields cannot be null',
945 'patterns': [r".*: warning: \[ProtoFieldNullComparison\] .+"]},
946 {'category': 'java',
947 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700948 'description':
949 'Java: Comparing protobuf fields of type String using reference equality',
950 'patterns': [r".*: warning: \[ProtoStringFieldReferenceEquality\] .+"]},
951 {'category': 'java',
952 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700953 'description':
954 'Java: Check for non-whitelisted callers to RestrictedApiChecker.',
955 'patterns': [r".*: warning: \[RestrictedApiChecker\] .+"]},
956 {'category': 'java',
957 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700958 'description':
959 'Java: Return value of this method must be used',
960 'patterns': [r".*: warning: \[ReturnValueIgnored\] .+"]},
961 {'category': 'java',
962 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700963 'description':
964 'Java: Variable assigned to itself',
965 'patterns': [r".*: warning: \[SelfAssignment\] .+"]},
966 {'category': 'java',
967 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700968 'description':
969 'Java: An object is compared to itself',
970 'patterns': [r".*: warning: \[SelfComparision\] .+"]},
971 {'category': 'java',
972 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700973 'description':
974 'Java: Variable compared to itself',
975 'patterns': [r".*: warning: \[SelfEquality\] .+"]},
976 {'category': 'java',
977 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700978 'description':
979 'Java: An object is tested for equality to itself',
980 'patterns': [r".*: warning: \[SelfEquals\] .+"]},
981 {'category': 'java',
982 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700983 'description':
984 'Java: Comparison of a size >= 0 is always true, did you intend to check for non-emptiness?',
985 'patterns': [r".*: warning: \[SizeGreaterThanOrEqualsZero\] .+"]},
986 {'category': 'java',
987 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700988 'description':
989 'Java: Calling toString on a Stream does not provide useful information',
990 'patterns': [r".*: warning: \[StreamToString\] .+"]},
991 {'category': 'java',
992 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700993 'description':
994 'Java: StringBuilder does not have a char constructor; this invokes the int constructor.',
995 'patterns': [r".*: warning: \[StringBuilderInitWithChar\] .+"]},
996 {'category': 'java',
997 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700998 'description':
999 'Java: Suppressing "deprecated" is probably a typo for "deprecation"',
1000 'patterns': [r".*: warning: \[SuppressWarningsDeprecated\] .+"]},
1001 {'category': 'java',
1002 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001003 'description':
1004 'Java: throwIfUnchecked(knownCheckedException) is a no-op.',
1005 'patterns': [r".*: warning: \[ThrowIfUncheckedKnownChecked\] .+"]},
1006 {'category': 'java',
1007 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001008 'description':
1009 'Java: Catching Throwable/Error masks failures from fail() or assert*() in the try block',
1010 'patterns': [r".*: warning: \[TryFailThrowable\] .+"]},
1011 {'category': 'java',
1012 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001013 'description':
1014 'Java: Type parameter used as type qualifier',
1015 'patterns': [r".*: warning: \[TypeParameterQualifier\] .+"]},
1016 {'category': 'java',
1017 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001018 'description':
1019 'Java: Non-generic methods should not be invoked with type arguments',
1020 'patterns': [r".*: warning: \[UnnecessaryTypeArgument\] .+"]},
1021 {'category': 'java',
1022 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001023 'description':
1024 'Java: Instance created but never used',
1025 'patterns': [r".*: warning: \[UnusedAnonymousClass\] .+"]},
1026 {'category': 'java',
1027 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001028 'description':
1029 'Java: Use of wildcard imports is forbidden',
1030 'patterns': [r".*: warning: \[WildcardImport\] .+"]},
1031 {'category': 'java',
1032 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001033 'description':
1034 'Java: Method parameter has wrong package',
1035 'patterns': [r".*: warning: \[ParameterPackage\] .+"]},
1036 {'category': 'java',
1037 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001038 'description':
1039 'Java: Certain resources in `android.R.string` have names that do not match their content',
1040 'patterns': [r".*: warning: \[MislabeledAndroidString\] .+"]},
1041 {'category': 'java',
1042 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001043 'description':
1044 'Java: Return value of android.graphics.Rect.intersect() must be checked',
1045 'patterns': [r".*: warning: \[RectIntersectReturnValueIgnored\] .+"]},
1046 {'category': 'java',
1047 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001048 'description':
1049 'Java: Invalid printf-style format string',
1050 'patterns': [r".*: warning: \[FormatString\] .+"]},
1051 {'category': 'java',
1052 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001053 'description':
1054 'Java: @AssistedInject and @Inject cannot be used on the same constructor.',
1055 'patterns': [r".*: warning: \[AssistedInjectAndInjectOnSameConstructor\] .+"]},
1056 {'category': 'java',
1057 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001058 'description':
1059 'Java: Injected constructors cannot be optional nor have binding annotations',
1060 'patterns': [r".*: warning: \[InjectedConstructorAnnotations\] .+"]},
1061 {'category': 'java',
1062 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001063 'description':
1064 'Java: The target of a scoping annotation must be set to METHOD and/or TYPE.',
1065 'patterns': [r".*: warning: \[InjectInvalidTargetingOnScopingAnnotation\] .+"]},
1066 {'category': 'java',
1067 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001068 'description':
1069 'Java: Abstract methods are not injectable with javax.inject.Inject.',
1070 'patterns': [r".*: warning: \[JavaxInjectOnAbstractMethod\] .+"]},
1071 {'category': 'java',
1072 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001073 'description':
1074 'Java: @javax.inject.Inject cannot be put on a final field.',
1075 'patterns': [r".*: warning: \[JavaxInjectOnFinalField\] .+"]},
1076 {'category': 'java',
1077 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001078 'description':
1079 'Java: A class may not have more than one injectable constructor.',
1080 'patterns': [r".*: warning: \[MoreThanOneInjectableConstructor\] .+"]},
1081 {'category': 'java',
1082 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001083 'description':
1084 'Java: Using more than one qualifier annotation on the same element is not allowed.',
1085 'patterns': [r".*: warning: \[InjectMoreThanOneQualifier\] .+"]},
1086 {'category': 'java',
1087 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001088 'description':
1089 'Java: A class can be annotated with at most one scope annotation',
1090 'patterns': [r".*: warning: \[InjectMoreThanOneScopeAnnotationOnClass\] .+"]},
1091 {'category': 'java',
1092 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001093 'description':
1094 'Java: Annotations cannot be both Qualifiers/BindingAnnotations and Scopes',
1095 'patterns': [r".*: warning: \[OverlappingQualifierAndScopeAnnotation\] .+"]},
1096 {'category': 'java',
1097 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001098 'description':
1099 'Java: Scope annotation on an interface or abstact class is not allowed',
1100 'patterns': [r".*: warning: \[InjectScopeAnnotationOnInterfaceOrAbstractClass\] .+"]},
1101 {'category': 'java',
1102 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001103 'description':
1104 'Java: Scoping and qualifier annotations must have runtime retention.',
1105 'patterns': [r".*: warning: \[InjectScopeOrQualifierAnnotationRetention\] .+"]},
1106 {'category': 'java',
1107 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001108 'description':
1109 'Java: Dagger @Provides methods may not return null unless annotated with @Nullable',
1110 'patterns': [r".*: warning: \[DaggerProvidesNull\] .+"]},
1111 {'category': 'java',
1112 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001113 'description':
1114 'Java: Scope annotation on implementation class of AssistedInject factory is not allowed',
1115 'patterns': [r".*: warning: \[GuiceAssistedInjectScoping\] .+"]},
1116 {'category': 'java',
1117 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001118 'description':
1119 'Java: A constructor cannot have two @Assisted parameters of the same type unless they are disambiguated with named @Assisted annotations. ',
1120 'patterns': [r".*: warning: \[GuiceAssistedParameters\] .+"]},
1121 {'category': 'java',
1122 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001123 'description':
1124 'Java: This method is not annotated with @Inject, but it overrides a method that is annotated with @javax.inject.Inject.',
1125 'patterns': [r".*: warning: \[OverridesJavaxInjectableMethod\] .+"]},
1126 {'category': 'java',
1127 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001128 'description':
1129 'Java: Checks for unguarded accesses to fields and methods with @GuardedBy annotations',
1130 'patterns': [r".*: warning: \[GuardedByChecker\] .+"]},
1131 {'category': 'java',
1132 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001133 'description':
1134 'Java: Invalid @GuardedBy expression',
1135 'patterns': [r".*: warning: \[GuardedByValidator\] .+"]},
1136 {'category': 'java',
1137 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001138 'description':
1139 'Java: Type declaration annotated with @Immutable is not immutable',
1140 'patterns': [r".*: warning: \[Immutable\] .+"]},
1141 {'category': 'java',
1142 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001143 'description':
1144 'Java: This method does not acquire the locks specified by its @LockMethod annotation',
1145 'patterns': [r".*: warning: \[LockMethodChecker\] .+"]},
1146 {'category': 'java',
1147 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001148 'description':
1149 'Java: This method does not acquire the locks specified by its @UnlockMethod annotation',
1150 'patterns': [r".*: warning: \[UnlockMethod\] .+"]},
Ian Rogers32bb9bd2016-05-09 23:19:42 -07001151
Ian Rogers6e520032016-05-13 08:59:00 -07001152 {'category': 'java',
1153 'severity': severity.UNKNOWN,
Ian Rogers6e520032016-05-13 08:59:00 -07001154 'description': 'Java: Unclassified/unrecognized warnings',
1155 'patterns': [r".*: warning: \[.+\] .+"]},
Ian Rogers32bb9bd2016-05-09 23:19:42 -07001156
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001157 { 'category':'aapt', 'severity':severity.MEDIUM,
Marco Nelissen8e201962010-03-10 16:16:02 -08001158 'description':'aapt: No default translation',
1159 'patterns':[r".*: warning: string '.+' has no default translation in .*"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001160 { 'category':'aapt', 'severity':severity.MEDIUM,
Marco Nelissen8e201962010-03-10 16:16:02 -08001161 'description':'aapt: Missing default or required localization',
1162 'patterns':[r".*: warning: \*\*\*\* string '.+' has no default or required localization for '.+' in .+"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001163 { 'category':'aapt', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -07001164 'description':'aapt: String marked untranslatable, but translation exists',
1165 'patterns':[r".*: warning: string '.+' in .* marked untranslatable but exists in locale '??_??'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001166 { 'category':'aapt', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -07001167 'description':'aapt: empty span in string',
1168 'patterns':[r".*: warning: empty '.+' span found in text '.+"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001169 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -07001170 'description':'Taking address of temporary',
1171 'patterns':[r".*: warning: taking address of temporary"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001172 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -07001173 'description':'Possible broken line continuation',
1174 'patterns':[r".*: warning: backslash and newline separated by space"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001175 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wundefined-var-template',
Chih-Hung Hsiehc21ddbd2016-07-20 10:08:51 -07001176 'description':'Undefined variable template',
1177 'patterns':[r".*: warning: instantiation of variable .* no definition is available"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001178 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wundefined-inline',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001179 'description':'Inline function is not defined',
1180 'patterns':[r".*: warning: inline function '.*' is not defined"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001181 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Warray-bounds',
Marco Nelissen594375d2009-07-14 09:04:04 -07001182 'description':'Array subscript out of bounds',
Marco Nelissen8e201962010-03-10 16:16:02 -08001183 'patterns':[r".*: warning: array subscript is above array bounds",
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001184 r".*: warning: Array subscript is undefined",
Marco Nelissen8e201962010-03-10 16:16:02 -08001185 r".*: warning: array subscript is below array bounds"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001186 { 'category':'C/C++', 'severity':severity.MEDIUM,
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001187 'description':'Excess elements in initializer',
1188 'patterns':[r".*: warning: excess elements in .+ initializer"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001189 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -07001190 'description':'Decimal constant is unsigned only in ISO C90',
1191 'patterns':[r".*: warning: this decimal constant is unsigned only in ISO C90"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001192 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wmain',
Marco Nelissen594375d2009-07-14 09:04:04 -07001193 'description':'main is usually a function',
1194 'patterns':[r".*: warning: 'main' is usually a function"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001195 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -07001196 'description':'Typedef ignored',
1197 'patterns':[r".*: warning: 'typedef' was ignored in this declaration"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001198 { 'category':'C/C++', 'severity':severity.HIGH, 'option':'-Waddress',
Marco Nelissen594375d2009-07-14 09:04:04 -07001199 'description':'Address always evaluates to true',
1200 'patterns':[r".*: warning: the address of '.+' will always evaluate as 'true'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001201 { 'category':'C/C++', 'severity':severity.FIXMENOW,
Marco Nelissen594375d2009-07-14 09:04:04 -07001202 'description':'Freeing a non-heap object',
1203 'patterns':[r".*: warning: attempt to free a non-heap object '.+'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001204 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wchar-subscripts',
Marco Nelissen594375d2009-07-14 09:04:04 -07001205 'description':'Array subscript has type char',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001206 'patterns':[r".*: warning: array subscript .+ type 'char'.+Wchar-subscripts"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001207 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -07001208 'description':'Constant too large for type',
1209 'patterns':[r".*: warning: integer constant is too large for '.+' type"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001210 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Woverflow',
Marco Nelissen594375d2009-07-14 09:04:04 -07001211 'description':'Constant too large for type, truncated',
1212 'patterns':[r".*: warning: large integer implicitly truncated to unsigned type"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001213 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Winteger-overflow',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001214 'description':'Overflow in expression',
1215 'patterns':[r".*: warning: overflow in expression; .*Winteger-overflow"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001216 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Woverflow',
Marco Nelissen594375d2009-07-14 09:04:04 -07001217 'description':'Overflow in implicit constant conversion',
1218 'patterns':[r".*: warning: overflow in implicit constant conversion"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001219 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -07001220 'description':'Declaration does not declare anything',
1221 'patterns':[r".*: warning: declaration 'class .+' does not declare anything"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001222 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wreorder',
Marco Nelissen594375d2009-07-14 09:04:04 -07001223 'description':'Initialization order will be different',
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001224 'patterns':[r".*: warning: '.+' will be initialized after",
1225 r".*: warning: field .+ will be initialized after .+Wreorder"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001226 { 'category':'cont.', 'severity':severity.SKIP,
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001227 'description':'skip, ....',
Marco Nelissen594375d2009-07-14 09:04:04 -07001228 'patterns':[r".*: warning: '.+'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001229 { 'category':'cont.', 'severity':severity.SKIP,
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001230 'description':'skip, base ...',
Marco Nelissen8e201962010-03-10 16:16:02 -08001231 'patterns':[r".*: warning: base '.+'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001232 { 'category':'cont.', 'severity':severity.SKIP,
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001233 'description':'skip, when initialized here',
Marco Nelissen594375d2009-07-14 09:04:04 -07001234 'patterns':[r".*: warning: when initialized here"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001235 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wmissing-parameter-type',
Marco Nelissen594375d2009-07-14 09:04:04 -07001236 'description':'Parameter type not specified',
1237 'patterns':[r".*: warning: type of '.+' defaults to 'int'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001238 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wmissing-declarations',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001239 'description':'Missing declarations',
1240 'patterns':[r".*: warning: declaration does not declare anything"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001241 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wmissing-noreturn',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001242 'description':'Missing noreturn',
1243 'patterns':[r".*: warning: function '.*' could be declared with attribute 'noreturn'"] },
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001244 # pylint:disable=anomalous-backslash-in-string
1245 # TODO(chh): fix the backslash pylint warning.
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001246 { 'category':'gcc', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -07001247 'description':'Invalid option for C file',
1248 'patterns':[r".*: warning: command line option "".+"" is valid for C\+\+\/ObjC\+\+ but not for C"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001249 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -07001250 'description':'User warning',
1251 'patterns':[r".*: warning: #warning "".+"""] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001252 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wvexing-parse',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001253 'description':'Vexing parsing problem',
1254 'patterns':[r".*: warning: empty parentheses interpreted as a function declaration"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001255 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wextra',
Marco Nelissen594375d2009-07-14 09:04:04 -07001256 'description':'Dereferencing void*',
1257 'patterns':[r".*: warning: dereferencing 'void \*' pointer"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001258 { 'category':'C/C++', 'severity':severity.MEDIUM,
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001259 'description':'Comparison of pointer and integer',
1260 'patterns':[r".*: warning: ordered comparison of pointer with integer zero",
1261 r".*: warning: .*comparison between pointer and integer"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001262 { 'category':'C/C++', 'severity':severity.MEDIUM,
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001263 'description':'Use of error-prone unary operator',
1264 'patterns':[r".*: warning: use of unary operator that may be intended as compound assignment"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001265 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wwrite-strings',
Marco Nelissen594375d2009-07-14 09:04:04 -07001266 'description':'Conversion of string constant to non-const char*',
1267 'patterns':[r".*: warning: deprecated conversion from string constant to '.+'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001268 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wstrict-prototypes',
Marco Nelissen594375d2009-07-14 09:04:04 -07001269 'description':'Function declaration isn''t a prototype',
1270 'patterns':[r".*: warning: function declaration isn't a prototype"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001271 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wignored-qualifiers',
Marco Nelissen594375d2009-07-14 09:04:04 -07001272 'description':'Type qualifiers ignored on function return value',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001273 'patterns':[r".*: warning: type qualifiers ignored on function return type",
1274 r".*: warning: .+ type qualifier .+ has no effect .+Wignored-qualifiers"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001275 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -07001276 'description':'<foo> declared inside parameter list, scope limited to this definition',
1277 'patterns':[r".*: warning: '.+' declared inside parameter list"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001278 { 'category':'cont.', 'severity':severity.SKIP,
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001279 'description':'skip, its scope is only this ...',
Marco Nelissen594375d2009-07-14 09:04:04 -07001280 'patterns':[r".*: warning: its scope is only this definition or declaration, which is probably not what you want"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001281 { 'category':'C/C++', 'severity':severity.LOW, 'option':'-Wcomment',
Marco Nelissen594375d2009-07-14 09:04:04 -07001282 'description':'Line continuation inside comment',
1283 'patterns':[r".*: warning: multi-line comment"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001284 { 'category':'C/C++', 'severity':severity.LOW, 'option':'-Wcomment',
Marco Nelissen8e201962010-03-10 16:16:02 -08001285 'description':'Comment inside comment',
1286 'patterns':[r".*: warning: "".+"" within comment"] },
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001287 # Warning "value stored is never read" could be from clang-tidy or clang static analyzer.
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001288 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001289 'description':'clang-tidy Value stored is never read',
1290 'patterns':[r".*: warning: Value stored to .+ is never read.*clang-analyzer-deadcode.DeadStores"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001291 { 'category':'C/C++', 'severity':severity.LOW,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001292 'description':'Value stored is never read',
1293 'patterns':[r".*: warning: Value stored to .+ is never read"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001294 { 'category':'C/C++', 'severity':severity.LOW, 'option':'-Wdeprecated-declarations',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001295 'description':'Deprecated declarations',
1296 'patterns':[r".*: warning: .+ is deprecated.+deprecated-declarations"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001297 { 'category':'C/C++', 'severity':severity.LOW, 'option':'-Wdeprecated-register',
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001298 'description':'Deprecated register',
1299 'patterns':[r".*: warning: 'register' storage class specifier is deprecated"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001300 { 'category':'C/C++', 'severity':severity.LOW, 'option':'-Wpointer-sign',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001301 'description':'Converts between pointers to integer types with different sign',
1302 'patterns':[r".*: warning: .+ converts between pointers to integer types with different sign"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001303 { 'category':'C/C++', 'severity':severity.HARMLESS,
Marco Nelissen594375d2009-07-14 09:04:04 -07001304 'description':'Extra tokens after #endif',
1305 'patterns':[r".*: warning: extra tokens at end of #endif directive"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001306 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wenum-compare',
Marco Nelissen594375d2009-07-14 09:04:04 -07001307 'description':'Comparison between different enums',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001308 'patterns':[r".*: warning: comparison between '.+' and '.+'.+Wenum-compare"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001309 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wconversion',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001310 'description':'Conversion may change value',
1311 'patterns':[r".*: warning: converting negative value '.+' to '.+'",
Chih-Hung Hsieh01530a62016-08-24 12:24:32 -07001312 r".*: warning: conversion to '.+' .+ may (alter|change)"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001313 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wconversion-null',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001314 'description':'Converting to non-pointer type from NULL',
1315 'patterns':[r".*: warning: converting to non-pointer type '.+' from NULL"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001316 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wnull-conversion',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001317 'description':'Converting NULL to non-pointer type',
1318 'patterns':[r".*: warning: implicit conversion of NULL constant to '.+'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001319 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wnon-literal-null-conversion',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001320 'description':'Zero used as null pointer',
1321 'patterns':[r".*: warning: expression .* zero treated as a null pointer constant"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001322 { 'category':'C/C++', 'severity':severity.MEDIUM,
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001323 'description':'Implicit conversion changes value',
Chih-Hung Hsiehc21ddbd2016-07-20 10:08:51 -07001324 'patterns':[r".*: warning: implicit conversion .* changes value from .* to .*-conversion"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001325 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -07001326 'description':'Passing NULL as non-pointer argument',
Marco Nelissen5236fbd2009-07-31 08:30:34 -07001327 'patterns':[r".*: warning: passing NULL to non-pointer argument [0-9]+ of '.+'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001328 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wctor-dtor-privacy',
Marco Nelissen594375d2009-07-14 09:04:04 -07001329 'description':'Class seems unusable because of private ctor/dtor' ,
1330 'patterns':[r".*: warning: all member functions in class '.+' are private"] },
1331 # skip this next one, because it only points out some RefBase-based classes where having a private destructor is perfectly fine
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001332 { 'category':'C/C++', 'severity':severity.SKIP, 'option':'-Wctor-dtor-privacy',
Marco Nelissen594375d2009-07-14 09:04:04 -07001333 'description':'Class seems unusable because of private ctor/dtor' ,
1334 'patterns':[r".*: warning: 'class .+' only defines a private destructor and has no friends"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001335 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wctor-dtor-privacy',
Marco Nelissen594375d2009-07-14 09:04:04 -07001336 'description':'Class seems unusable because of private ctor/dtor' ,
1337 'patterns':[r".*: warning: 'class .+' only defines private constructors and has no friends"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001338 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wgnu-static-float-init',
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001339 'description':'In-class initializer for static const float/double' ,
1340 'patterns':[r".*: warning: in-class initializer for static data member of .+const (float|double)"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001341 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wpointer-arith',
Marco Nelissen594375d2009-07-14 09:04:04 -07001342 'description':'void* used in arithmetic' ,
1343 'patterns':[r".*: warning: pointer of type 'void \*' used in (arithmetic|subtraction)",
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001344 r".*: warning: arithmetic on .+ to void is a GNU extension.*Wpointer-arith",
Marco Nelissen594375d2009-07-14 09:04:04 -07001345 r".*: warning: wrong type argument to increment"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001346 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wsign-promo',
Marco Nelissen594375d2009-07-14 09:04:04 -07001347 'description':'Overload resolution chose to promote from unsigned or enum to signed type' ,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001348 'patterns':[r".*: warning: passing '.+' chooses '.+' over '.+'.*Wsign-promo"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001349 { 'category':'cont.', 'severity':severity.SKIP,
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001350 'description':'skip, in call to ...',
Marco Nelissen594375d2009-07-14 09:04:04 -07001351 'patterns':[r".*: warning: in call to '.+'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001352 { 'category':'C/C++', 'severity':severity.HIGH, 'option':'-Wextra',
Marco Nelissen5236fbd2009-07-31 08:30:34 -07001353 'description':'Base should be explicitly initialized in copy constructor',
1354 'patterns':[r".*: warning: base class '.+' should be explicitly initialized in the copy constructor"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001355 { 'category':'C/C++', 'severity':severity.MEDIUM,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001356 'description':'VLA has zero or negative size',
1357 'patterns':[r".*: warning: Declared variable-length array \(VLA\) has .+ size"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001358 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen8e201962010-03-10 16:16:02 -08001359 'description':'Return value from void function',
1360 'patterns':[r".*: warning: 'return' with a value, in function returning void"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001361 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'multichar',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001362 'description':'Multi-character character constant',
1363 'patterns':[r".*: warning: multi-character character constant"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001364 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'writable-strings',
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001365 'description':'Conversion from string literal to char*',
1366 'patterns':[r".*: warning: .+ does not allow conversion from string literal to 'char \*'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001367 { 'category':'C/C++', 'severity':severity.LOW, 'option':'-Wextra-semi',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001368 'description':'Extra \';\'',
1369 'patterns':[r".*: warning: extra ';' .+extra-semi"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001370 { 'category':'C/C++', 'severity':severity.LOW,
Marco Nelissen8e201962010-03-10 16:16:02 -08001371 'description':'Useless specifier',
1372 'patterns':[r".*: warning: useless storage class specifier in empty declaration"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001373 { 'category':'C/C++', 'severity':severity.LOW, 'option':'-Wduplicate-decl-specifier',
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001374 'description':'Duplicate declaration specifier',
1375 'patterns':[r".*: warning: duplicate '.+' declaration specifier"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001376 { 'category':'logtags', 'severity':severity.LOW,
Marco Nelissen8e201962010-03-10 16:16:02 -08001377 'description':'Duplicate logtag',
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001378 'patterns':[r".*: warning: tag \".+\" \(.+\) duplicated in .+"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001379 { 'category':'logtags', 'severity':severity.LOW, 'option':'typedef-redefinition',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001380 'description':'Typedef redefinition',
1381 'patterns':[r".*: warning: redefinition of typedef '.+' is a C11 feature"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001382 { 'category':'logtags', 'severity':severity.LOW, 'option':'gnu-designator',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001383 'description':'GNU old-style field designator',
1384 'patterns':[r".*: warning: use of GNU old-style field designator extension"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001385 { 'category':'logtags', 'severity':severity.LOW, 'option':'missing-field-initializers',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001386 'description':'Missing field initializers',
1387 'patterns':[r".*: warning: missing field '.+' initializer"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001388 { 'category':'logtags', 'severity':severity.LOW, 'option':'missing-braces',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001389 'description':'Missing braces',
1390 'patterns':[r".*: warning: suggest braces around initialization of",
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001391 r".*: warning: too many braces around scalar initializer .+Wmany-braces-around-scalar-init",
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001392 r".*: warning: braces around scalar initializer"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001393 { 'category':'logtags', 'severity':severity.LOW, 'option':'sign-compare',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001394 'description':'Comparison of integers of different signs',
1395 'patterns':[r".*: warning: comparison of integers of different signs.+sign-compare"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001396 { 'category':'logtags', 'severity':severity.LOW, 'option':'dangling-else',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001397 'description':'Add braces to avoid dangling else',
1398 'patterns':[r".*: warning: add explicit braces to avoid dangling else"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001399 { 'category':'logtags', 'severity':severity.LOW, 'option':'initializer-overrides',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001400 'description':'Initializer overrides prior initialization',
1401 'patterns':[r".*: warning: initializer overrides prior initialization of this subobject"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001402 { 'category':'logtags', 'severity':severity.LOW, 'option':'self-assign',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001403 'description':'Assigning value to self',
1404 'patterns':[r".*: warning: explicitly assigning value of .+ to itself"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001405 { 'category':'logtags', 'severity':severity.LOW, 'option':'gnu-variable-sized-type-not-at-end',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001406 'description':'GNU extension, variable sized type not at end',
1407 'patterns':[r".*: warning: field '.+' with variable sized type '.+' not at the end of a struct or class"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001408 { 'category':'logtags', 'severity':severity.LOW, 'option':'tautological-constant-out-of-range-compare',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001409 'description':'Comparison of constant is always false/true',
1410 'patterns':[r".*: comparison of .+ is always .+Wtautological-constant-out-of-range-compare"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001411 { 'category':'logtags', 'severity':severity.LOW, 'option':'overloaded-virtual',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001412 'description':'Hides overloaded virtual function',
1413 'patterns':[r".*: '.+' hides overloaded virtual function"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001414 { 'category':'logtags', 'severity':severity.LOW, 'option':'incompatible-pointer-types',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001415 'description':'Incompatible pointer types',
1416 'patterns':[r".*: warning: incompatible pointer types .+Wincompatible-pointer-types"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001417 { 'category':'logtags', 'severity':severity.LOW, 'option':'asm-operand-widths',
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001418 'description':'ASM value size does not match register size',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001419 'patterns':[r".*: warning: value size does not match register size specified by the constraint and modifier"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001420 { 'category':'C/C++', 'severity':severity.LOW, 'option':'tautological-compare',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001421 'description':'Comparison of self is always false',
1422 'patterns':[r".*: self-comparison always evaluates to false"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001423 { 'category':'C/C++', 'severity':severity.LOW, 'option':'constant-logical-operand',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001424 'description':'Logical op with constant operand',
1425 'patterns':[r".*: use of logical '.+' with constant operand"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001426 { 'category':'C/C++', 'severity':severity.LOW, 'option':'literal-suffix',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001427 'description':'Needs a space between literal and string macro',
1428 'patterns':[r".*: warning: invalid suffix on literal.+ requires a space .+Wliteral-suffix"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001429 { 'category':'C/C++', 'severity':severity.LOW, 'option':'#warnings',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001430 'description':'Warnings from #warning',
1431 'patterns':[r".*: warning: .+-W#warnings"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001432 { 'category':'C/C++', 'severity':severity.LOW, 'option':'absolute-value',
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001433 'description':'Using float/int absolute value function with int/float argument',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001434 'patterns':[r".*: warning: using .+ absolute value function .+ when argument is .+ type .+Wabsolute-value",
1435 r".*: warning: absolute value function '.+' given .+ which may cause truncation .+Wabsolute-value"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001436 { 'category':'C/C++', 'severity':severity.LOW, 'option':'-Wc++11-extensions',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001437 'description':'Using C++11 extensions',
1438 'patterns':[r".*: warning: 'auto' type specifier is a C\+\+11 extension"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001439 { 'category':'C/C++', 'severity':severity.LOW,
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001440 'description':'Refers to implicitly defined namespace',
1441 'patterns':[r".*: warning: using directive refers to implicitly-defined namespace .+"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001442 { 'category':'C/C++', 'severity':severity.LOW, 'option':'-Winvalid-pp-token',
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001443 'description':'Invalid pp token',
1444 'patterns':[r".*: warning: missing .+Winvalid-pp-token"] },
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001445
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001446 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen8e201962010-03-10 16:16:02 -08001447 'description':'Operator new returns NULL',
1448 'patterns':[r".*: warning: 'operator new' must not return NULL unless it is declared 'throw\(\)' .+"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001449 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wnull-arithmetic',
Marco Nelissen8e201962010-03-10 16:16:02 -08001450 'description':'NULL used in arithmetic',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001451 'patterns':[r".*: warning: NULL used in arithmetic",
1452 r".*: warning: comparison between NULL and non-pointer"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001453 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'header-guard',
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001454 'description':'Misspelled header guard',
1455 'patterns':[r".*: warning: '.+' is used as a header guard .+ followed by .+ different macro"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001456 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'empty-body',
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001457 'description':'Empty loop body',
1458 'patterns':[r".*: warning: .+ loop has empty body"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001459 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'enum-conversion',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001460 'description':'Implicit conversion from enumeration type',
1461 'patterns':[r".*: warning: implicit conversion from enumeration type '.+'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001462 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'switch',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001463 'description':'case value not in enumerated type',
1464 'patterns':[r".*: warning: case value not in enumerated type '.+'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001465 { 'category':'C/C++', 'severity':severity.MEDIUM,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001466 'description':'Undefined result',
1467 'patterns':[r".*: warning: The result of .+ is undefined",
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07001468 r".*: warning: passing an object that .+ has undefined behavior \[-Wvarargs\]",
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001469 r".*: warning: 'this' pointer cannot be null in well-defined C\+\+ code;",
1470 r".*: warning: shifting a negative signed value is undefined"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001471 { 'category':'C/C++', 'severity':severity.MEDIUM,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001472 'description':'Division by zero',
1473 'patterns':[r".*: warning: Division by zero"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001474 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen8e201962010-03-10 16:16:02 -08001475 'description':'Use of deprecated method',
1476 'patterns':[r".*: warning: '.+' is deprecated .+"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001477 { 'category':'C/C++', 'severity':severity.MEDIUM,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001478 'description':'Use of garbage or uninitialized value',
1479 'patterns':[r".*: warning: .+ is a garbage value",
1480 r".*: warning: Function call argument is an uninitialized value",
1481 r".*: warning: Undefined or garbage value returned to caller",
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001482 r".*: warning: Called .+ pointer is.+uninitialized",
1483 r".*: warning: Called .+ pointer is.+uninitalized", # match a typo in compiler message
1484 r".*: warning: Use of zero-allocated memory",
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001485 r".*: warning: Dereference of undefined pointer value",
1486 r".*: warning: Passed-by-value .+ contains uninitialized data",
1487 r".*: warning: Branch condition evaluates to a garbage value",
1488 r".*: warning: The .+ of .+ is an uninitialized value.",
1489 r".*: warning: .+ is used uninitialized whenever .+sometimes-uninitialized",
1490 r".*: warning: Assigned value is garbage or undefined"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001491 { 'category':'C/C++', 'severity':severity.MEDIUM,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001492 'description':'Result of malloc type incompatible with sizeof operand type',
1493 'patterns':[r".*: warning: Result of '.+' is converted to .+ incompatible with sizeof operand type"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001494 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wsizeof-array-argument',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001495 'description':'Sizeof on array argument',
1496 'patterns':[r".*: warning: sizeof on array function parameter will return"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001497 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wsizeof-pointer-memacces',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001498 'description':'Bad argument size of memory access functions',
1499 'patterns':[r".*: warning: .+\[-Wsizeof-pointer-memaccess\]"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001500 { 'category':'C/C++', 'severity':severity.MEDIUM,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001501 'description':'Return value not checked',
1502 'patterns':[r".*: warning: The return value from .+ is not checked"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001503 { 'category':'C/C++', 'severity':severity.MEDIUM,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001504 'description':'Possible heap pollution',
1505 'patterns':[r".*: warning: .*Possible heap pollution from .+ type .+"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001506 { 'category':'C/C++', 'severity':severity.MEDIUM,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001507 'description':'Allocation size of 0 byte',
1508 'patterns':[r".*: warning: Call to .+ has an allocation size of 0 byte"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001509 { 'category':'C/C++', 'severity':severity.MEDIUM,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001510 'description':'Result of malloc type incompatible with sizeof operand type',
1511 'patterns':[r".*: warning: Result of '.+' is converted to .+ incompatible with sizeof operand type"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001512 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wfor-loop-analysis',
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001513 'description':'Variable used in loop condition not modified in loop body',
1514 'patterns':[r".*: warning: variable '.+' used in loop condition.*Wfor-loop-analysis"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001515 { 'category':'C/C++', 'severity':severity.MEDIUM,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001516 'description':'Closing a previously closed file',
1517 'patterns':[r".*: warning: Closing a previously closed file"] },
Chih-Hung Hsieh0a192072016-09-21 14:00:23 -07001518 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wunnamed-type-template-args',
1519 'description':'Unnamed template type argument',
1520 'patterns':[r".*: warning: template argument.+Wunnamed-type-template-args"] },
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001521
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001522 { 'category':'C/C++', 'severity':severity.HARMLESS,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001523 'description':'Discarded qualifier from pointer target type',
1524 'patterns':[r".*: warning: .+ discards '.+' qualifier from pointer target type"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001525 { 'category':'C/C++', 'severity':severity.HARMLESS,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001526 'description':'Use snprintf instead of sprintf',
1527 'patterns':[r".*: warning: .*sprintf is often misused; please use snprintf"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001528 { 'category':'C/C++', 'severity':severity.HARMLESS,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001529 'description':'Unsupported optimizaton flag',
1530 'patterns':[r".*: warning: optimization flag '.+' is not supported"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001531 { 'category':'C/C++', 'severity':severity.HARMLESS,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001532 'description':'Extra or missing parentheses',
1533 'patterns':[r".*: warning: equality comparison with extraneous parentheses",
1534 r".*: warning: .+ within .+Wlogical-op-parentheses"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001535 { 'category':'C/C++', 'severity':severity.HARMLESS, 'option':'mismatched-tags',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001536 'description':'Mismatched class vs struct tags',
1537 'patterns':[r".*: warning: '.+' defined as a .+ here but previously declared as a .+mismatched-tags",
1538 r".*: warning: .+ was previously declared as a .+mismatched-tags"] },
Marco Nelissen594375d2009-07-14 09:04:04 -07001539
1540 # these next ones are to deal with formatting problems resulting from the log being mixed up by 'make -j'
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001541 { 'category':'C/C++', 'severity':severity.SKIP,
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001542 'description':'skip, ,',
Marco Nelissen594375d2009-07-14 09:04:04 -07001543 'patterns':[r".*: warning: ,$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001544 { 'category':'C/C++', 'severity':severity.SKIP,
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001545 'description':'skip,',
Marco Nelissen594375d2009-07-14 09:04:04 -07001546 'patterns':[r".*: warning: $"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001547 { 'category':'C/C++', 'severity':severity.SKIP,
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001548 'description':'skip, In file included from ...',
Marco Nelissen594375d2009-07-14 09:04:04 -07001549 'patterns':[r".*: warning: In file included from .+,"] },
1550
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001551 # warnings from clang-tidy
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001552 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001553 'description':'clang-tidy readability',
1554 'patterns':[r".*: .+\[readability-.+\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001555 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001556 'description':'clang-tidy c++ core guidelines',
1557 'patterns':[r".*: .+\[cppcoreguidelines-.+\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001558 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsiehc21ddbd2016-07-20 10:08:51 -07001559 'description':'clang-tidy google-default-arguments',
1560 'patterns':[r".*: .+\[google-default-arguments\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001561 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsiehc21ddbd2016-07-20 10:08:51 -07001562 'description':'clang-tidy google-runtime-int',
1563 'patterns':[r".*: .+\[google-runtime-int\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001564 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsiehc21ddbd2016-07-20 10:08:51 -07001565 'description':'clang-tidy google-runtime-operator',
1566 'patterns':[r".*: .+\[google-runtime-operator\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001567 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsiehc21ddbd2016-07-20 10:08:51 -07001568 'description':'clang-tidy google-runtime-references',
1569 'patterns':[r".*: .+\[google-runtime-references\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001570 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001571 'description':'clang-tidy google-build',
1572 'patterns':[r".*: .+\[google-build-.+\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001573 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001574 'description':'clang-tidy google-explicit',
1575 'patterns':[r".*: .+\[google-explicit-.+\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001576 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsiehd742e902016-03-31 16:14:55 -07001577 'description':'clang-tidy google-readability',
1578 'patterns':[r".*: .+\[google-readability-.+\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001579 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsiehd742e902016-03-31 16:14:55 -07001580 'description':'clang-tidy google-global',
1581 'patterns':[r".*: .+\[google-global-.+\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001582 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsiehc21ddbd2016-07-20 10:08:51 -07001583 'description':'clang-tidy google- other',
1584 'patterns':[r".*: .+\[google-.+\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001585 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001586 'description':'clang-tidy modernize',
1587 'patterns':[r".*: .+\[modernize-.+\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001588 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001589 'description':'clang-tidy misc',
1590 'patterns':[r".*: .+\[misc-.+\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001591 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsiehc8682932016-07-26 14:27:03 -07001592 'description':'clang-tidy performance-faster-string-find',
1593 'patterns':[r".*: .+\[performance-faster-string-find\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001594 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsiehc8682932016-07-26 14:27:03 -07001595 'description':'clang-tidy performance-for-range-copy',
1596 'patterns':[r".*: .+\[performance-for-range-copy\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001597 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsiehc8682932016-07-26 14:27:03 -07001598 'description':'clang-tidy performance-implicit-cast-in-loop',
1599 'patterns':[r".*: .+\[performance-implicit-cast-in-loop\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001600 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsiehc8682932016-07-26 14:27:03 -07001601 'description':'clang-tidy performance-unnecessary-copy-initialization',
1602 'patterns':[r".*: .+\[performance-unnecessary-copy-initialization\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001603 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsiehc8682932016-07-26 14:27:03 -07001604 'description':'clang-tidy performance-unnecessary-value-param',
1605 'patterns':[r".*: .+\[performance-unnecessary-value-param\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001606 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001607 'description':'clang-analyzer Unreachable code',
1608 'patterns':[r".*: warning: This statement is never executed.*UnreachableCode"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001609 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001610 'description':'clang-analyzer Size of malloc may overflow',
1611 'patterns':[r".*: warning: .* size of .* may overflow .*MallocOverflow"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001612 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001613 'description':'clang-analyzer Stream pointer might be NULL',
1614 'patterns':[r".*: warning: Stream pointer might be NULL .*unix.Stream"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001615 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001616 'description':'clang-analyzer Opened file never closed',
1617 'patterns':[r".*: warning: Opened File never closed.*unix.Stream"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001618 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001619 'description':'clang-analyzer sozeof() on a pointer type',
1620 'patterns':[r".*: warning: .*calls sizeof.* on a pointer type.*SizeofPtr"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001621 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001622 'description':'clang-analyzer Pointer arithmetic on non-array variables',
1623 'patterns':[r".*: warning: Pointer arithmetic on non-array variables .*PointerArithm"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001624 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001625 'description':'clang-analyzer Subtraction of pointers of different memory chunks',
1626 'patterns':[r".*: warning: Subtraction of two pointers .*PointerSub"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001627 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001628 'description':'clang-analyzer Access out-of-bound array element',
1629 'patterns':[r".*: warning: Access out-of-bound array element .*ArrayBound"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001630 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001631 'description':'clang-analyzer Out of bound memory access',
1632 'patterns':[r".*: warning: Out of bound memory access .*ArrayBoundV2"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001633 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001634 'description':'clang-analyzer Possible lock order reversal',
1635 'patterns':[r".*: warning: .* Possible lock order reversal.*PthreadLock"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001636 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001637 'description':'clang-analyzer Argument is a pointer to uninitialized value',
1638 'patterns':[r".*: warning: .* argument is a pointer to uninitialized value .*CallAndMessage"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001639 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001640 'description':'clang-analyzer cast to struct',
1641 'patterns':[r".*: warning: Casting a non-structure type to a structure type .*CastToStruct"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001642 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001643 'description':'clang-analyzer call path problems',
1644 'patterns':[r".*: warning: Call Path : .+"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001645 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001646 'description':'clang-analyzer other',
1647 'patterns':[r".*: .+\[clang-analyzer-.+\]$",
1648 r".*: Call Path : .+$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001649 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001650 'description':'clang-tidy CERT',
1651 'patterns':[r".*: .+\[cert-.+\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001652 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001653 'description':'clang-tidy llvm',
1654 'patterns':[r".*: .+\[llvm-.+\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001655 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001656 'description':'clang-diagnostic',
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001657 'patterns':[r".*: .+\[clang-diagnostic-.+\]$"] },
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001658
Marco Nelissen594375d2009-07-14 09:04:04 -07001659 # catch-all for warnings this script doesn't know about yet
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001660 { 'category':'C/C++', 'severity':severity.UNKNOWN,
Marco Nelissen594375d2009-07-14 09:04:04 -07001661 'description':'Unclassified/unrecognized warnings',
1662 'patterns':[r".*: warning: .+"] },
1663]
1664
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001665
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001666# A list of [project_name, file_path_pattern].
1667# project_name should not contain comma, to be used in CSV output.
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001668project_list = [
1669 # pylint:disable=bad-whitespace,g-inconsistent-quotes,line-too-long
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07001670 ['art', r"(^|.*/)art/.*: warning:"],
1671 ['bionic', r"(^|.*/)bionic/.*: warning:"],
1672 ['bootable', r"(^|.*/)bootable/.*: warning:"],
1673 ['build', r"(^|.*/)build/.*: warning:"],
1674 ['cts', r"(^|.*/)cts/.*: warning:"],
1675 ['dalvik', r"(^|.*/)dalvik/.*: warning:"],
1676 ['developers', r"(^|.*/)developers/.*: warning:"],
1677 ['development', r"(^|.*/)development/.*: warning:"],
1678 ['device', r"(^|.*/)device/.*: warning:"],
1679 ['doc', r"(^|.*/)doc/.*: warning:"],
1680 # match external/google* before external/
1681 ['external/google', r"(^|.*/)external/google.*: warning:"],
1682 ['external/non-google', r"(^|.*/)external/.*: warning:"],
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001683 ['frameworks/av/camera',r"(^|.*/)frameworks/av/camera/.*: warning:"],
1684 ['frameworks/av/cmds', r"(^|.*/)frameworks/av/cmds/.*: warning:"],
1685 ['frameworks/av/drm', r"(^|.*/)frameworks/av/drm/.*: warning:"],
1686 ['frameworks/av/include',r"(^|.*/)frameworks/av/include/.*: warning:"],
1687 ['frameworks/av/media', r"(^|.*/)frameworks/av/media/.*: warning:"],
1688 ['frameworks/av/radio', r"(^|.*/)frameworks/av/radio/.*: warning:"],
1689 ['frameworks/av/services', r"(^|.*/)frameworks/av/services/.*: warning:"],
1690 ['frameworks/av/Other', r"(^|.*/)frameworks/av/.*: warning:"],
1691 ['frameworks/base', r"(^|.*/)frameworks/base/.*: warning:"],
1692 ['frameworks/compile', r"(^|.*/)frameworks/compile/.*: warning:"],
1693 ['frameworks/minikin', r"(^|.*/)frameworks/minikin/.*: warning:"],
1694 ['frameworks/native', r"(^|.*/)frameworks/native/.*: warning:"],
1695 ['frameworks/opt', r"(^|.*/)frameworks/opt/.*: warning:"],
1696 ['frameworks/rs', r"(^|.*/)frameworks/rs/.*: warning:"],
1697 ['frameworks/webview', r"(^|.*/)frameworks/webview/.*: warning:"],
1698 ['frameworks/wilhelm', r"(^|.*/)frameworks/wilhelm/.*: warning:"],
1699 ['frameworks/Other', r"(^|.*/)frameworks/.*: warning:"],
1700 ['hardware/akm', r"(^|.*/)hardware/akm/.*: warning:"],
1701 ['hardware/broadcom', r"(^|.*/)hardware/broadcom/.*: warning:"],
1702 ['hardware/google', r"(^|.*/)hardware/google/.*: warning:"],
1703 ['hardware/intel', r"(^|.*/)hardware/intel/.*: warning:"],
1704 ['hardware/interfaces', r"(^|.*/)hardware/interfaces/.*: warning:"],
1705 ['hardware/libhardware',r"(^|.*/)hardware/libhardware/.*: warning:"],
1706 ['hardware/libhardware_legacy',r"(^|.*/)hardware/libhardware_legacy/.*: warning:"],
1707 ['hardware/qcom', r"(^|.*/)hardware/qcom/.*: warning:"],
1708 ['hardware/ril', r"(^|.*/)hardware/ril/.*: warning:"],
1709 ['hardware/Other', r"(^|.*/)hardware/.*: warning:"],
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07001710 ['kernel', r"(^|.*/)kernel/.*: warning:"],
1711 ['libcore', r"(^|.*/)libcore/.*: warning:"],
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001712 ['libnativehelper', r"(^|.*/)libnativehelper/.*: warning:"],
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07001713 ['ndk', r"(^|.*/)ndk/.*: warning:"],
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001714 # match vendor/unbungled_google/packages before other packages
1715 ['unbundled_google', r"(^|.*/)unbundled_google/.*: warning:"],
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07001716 ['packages', r"(^|.*/)packages/.*: warning:"],
1717 ['pdk', r"(^|.*/)pdk/.*: warning:"],
1718 ['prebuilts', r"(^|.*/)prebuilts/.*: warning:"],
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001719 ['system/bt', r"(^|.*/)system/bt/.*: warning:"],
1720 ['system/connectivity', r"(^|.*/)system/connectivity/.*: warning:"],
1721 ['system/core', r"(^|.*/)system/core/.*: warning:"],
1722 ['system/extras', r"(^|.*/)system/extras/.*: warning:"],
1723 ['system/gatekeeper', r"(^|.*/)system/gatekeeper/.*: warning:"],
1724 ['system/keymaster', r"(^|.*/)system/keymaster/.*: warning:"],
1725 ['system/libhwbinder', r"(^|.*/)system/libhwbinder/.*: warning:"],
1726 ['system/media', r"(^|.*/)system/media/.*: warning:"],
1727 ['system/netd', r"(^|.*/)system/netd/.*: warning:"],
1728 ['system/security', r"(^|.*/)system/security/.*: warning:"],
1729 ['system/sepolicy', r"(^|.*/)system/sepolicy/.*: warning:"],
1730 ['system/tools', r"(^|.*/)system/tools/.*: warning:"],
1731 ['system/vold', r"(^|.*/)system/vold/.*: warning:"],
1732 ['system/Other', r"(^|.*/)system/.*: warning:"],
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07001733 ['toolchain', r"(^|.*/)toolchain/.*: warning:"],
1734 ['test', r"(^|.*/)test/.*: warning:"],
1735 ['tools', r"(^|.*/)tools/.*: warning:"],
1736 # match vendor/google* before vendor/
1737 ['vendor/google', r"(^|.*/)vendor/google.*: warning:"],
1738 ['vendor/non-google', r"(^|.*/)vendor/.*: warning:"],
1739 # keep out/obj and other patterns at the end.
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001740 ['out/obj', r".*/(gen|obj[^/]*)/(include|EXECUTABLES|SHARED_LIBRARIES|STATIC_LIBRARIES|NATIVE_TESTS)/.*: warning:"],
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07001741 ['other', r".*: warning:"],
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001742]
1743
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001744project_patterns = []
1745project_names = []
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001746warning_messages = []
1747warning_records = []
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001748
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001749
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001750def initialize_arrays():
1751 """Complete global arrays before they are used."""
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001752 global project_names, project_patterns
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001753 project_names = [p[0] for p in project_list]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001754 project_patterns = [re.compile(p[1]) for p in project_list]
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001755 for w in warn_patterns:
1756 w['members'] = []
1757 if 'option' not in w:
1758 w['option'] = ''
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001759 # Each warning pattern has a 'projects' dictionary, that
1760 # maps a project name to number of warnings in that project.
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001761 w['projects'] = {}
1762
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001763
1764initialize_arrays()
1765
1766
1767platform_version = 'unknown'
1768target_product = 'unknown'
1769target_variant = 'unknown'
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001770
1771
1772##### Data and functions to dump html file. ##################################
1773
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001774html_head_scripts = """\
1775 <script type="text/javascript">
1776 function expand(id) {
1777 var e = document.getElementById(id);
1778 var f = document.getElementById(id + "_mark");
1779 if (e.style.display == 'block') {
1780 e.style.display = 'none';
1781 f.innerHTML = '&#x2295';
1782 }
1783 else {
1784 e.style.display = 'block';
1785 f.innerHTML = '&#x2296';
1786 }
1787 };
1788 function expandCollapse(show) {
1789 for (var id = 1; ; id++) {
1790 var e = document.getElementById(id + "");
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07001791 var f = document.getElementById(id + "_mark");
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001792 if (!e || !f) break;
1793 e.style.display = (show ? 'block' : 'none');
1794 f.innerHTML = (show ? '&#x2296' : '&#x2295');
1795 }
1796 };
1797 </script>
1798 <style type="text/css">
1799 th,td{border-collapse:collapse; border:1px solid black;}
1800 .button{color:blue;font-size:110%;font-weight:bolder;}
1801 .bt{color:black;background-color:transparent;border:none;outline:none;
1802 font-size:140%;font-weight:bolder;}
1803 .c0{background-color:#e0e0e0;}
1804 .c1{background-color:#d0d0d0;}
1805 .t1{border-collapse:collapse; width:100%; border:1px solid black;}
1806 </style>
1807 <script src="https://www.gstatic.com/charts/loader.js"></script>
1808"""
Marco Nelissen594375d2009-07-14 09:04:04 -07001809
Marco Nelissen594375d2009-07-14 09:04:04 -07001810
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001811def html_big(param):
1812 return '<font size="+2">' + param + '</font>'
Marco Nelissen594375d2009-07-14 09:04:04 -07001813
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07001814
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001815def dump_html_prologue(title):
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001816 print '<html>\n<head>'
1817 print '<title>' + title + '</title>'
1818 print html_head_scripts
1819 emit_stats_by_project()
1820 print '</head>\n<body>'
1821 print html_big(title)
1822 print '<p>'
Marco Nelissen594375d2009-07-14 09:04:04 -07001823
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001824
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001825def dump_html_epilogue():
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001826 print '</body>\n</head>\n</html>'
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001827
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001828
1829def sort_warnings():
1830 for i in warn_patterns:
1831 i['members'] = sorted(set(i['members']))
1832
1833
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001834def emit_stats_by_project():
1835 """Dump a google chart table of warnings per project and severity."""
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001836 # warnings[p][s] is number of warnings in project p of severity s.
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001837 warnings = {p: {s: 0 for s in severity.range} for p in project_names}
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001838 for i in warn_patterns:
1839 s = i['severity']
1840 for p in i['projects']:
1841 warnings[p][s] += i['projects'][p]
1842
1843 # total_by_project[p] is number of warnings in project p.
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001844 total_by_project = {p: sum(warnings[p][s] for s in severity.range)
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001845 for p in project_names}
1846
1847 # total_by_severity[s] is number of warnings of severity s.
1848 total_by_severity = {s: sum(warnings[p][s] for p in project_names)
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001849 for s in severity.range}
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001850
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001851 # emit table header
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001852 stats_header = ['Project']
1853 for s in severity.range:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001854 if total_by_severity[s]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001855 stats_header.append("<span style='background-color:{}'>{}</span>".
1856 format(severity.colors[s],
1857 severity.column_headers[s]))
1858 stats_header.append('TOTAL')
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001859
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001860 # emit a row of warning counts per project, skip no-warning projects
1861 total_all_projects = 0
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001862 stats_rows = []
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001863 for p in project_names:
1864 if total_by_project[p]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001865 one_row = [p]
1866 for s in severity.range:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001867 if total_by_severity[s]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001868 one_row.append(warnings[p][s])
1869 one_row.append(total_by_project[p])
1870 stats_rows.append(one_row)
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001871 total_all_projects += total_by_project[p]
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001872
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001873 # emit a row of warning counts per severity
1874 total_all_severities = 0
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001875 one_row = ['<b>TOTAL</b>']
1876 for s in severity.range:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001877 if total_by_severity[s]:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001878 one_row.append(total_by_severity[s])
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001879 total_all_severities += total_by_severity[s]
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001880 one_row.append(total_all_projects)
1881 stats_rows.append(one_row)
1882 print '<script>'
1883 emit_const_string_array('StatsHeader', stats_header)
1884 emit_const_object_array('StatsRows', stats_rows)
1885 print draw_table_javascript
1886 print '</script>'
Marco Nelissen594375d2009-07-14 09:04:04 -07001887
1888
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001889def dump_stats():
1890 """Dump some stats about total number of warnings and such."""
1891 known = 0
1892 skipped = 0
1893 unknown = 0
1894 sort_warnings()
1895 for i in warn_patterns:
1896 if i['severity'] == severity.UNKNOWN:
1897 unknown += len(i['members'])
1898 elif i['severity'] == severity.SKIP:
1899 skipped += len(i['members'])
Ian Rogersf3829732016-05-10 12:06:01 -07001900 else:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001901 known += len(i['members'])
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001902 print 'Number of classified warnings: <b>' + str(known) + '</b><br>'
1903 print 'Number of skipped warnings: <b>' + str(skipped) + '</b><br>'
1904 print 'Number of unclassified warnings: <b>' + str(unknown) + '</b><br>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001905 total = unknown + known + skipped
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001906 extra_msg = ''
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001907 if total < 1000:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001908 extra_msg = ' (low count may indicate incremental build)'
1909 print 'Total number of warnings: <b>' + str(total) + '</b>' + extra_msg
Marco Nelissen594375d2009-07-14 09:04:04 -07001910
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07001911
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001912# New base table of warnings, [severity, warn_id, project, warning_message]
1913# Need buttons to show warnings in different grouping options.
1914# (1) Current, group by severity, id for each warning pattern
1915# sort by severity, warn_id, warning_message
1916# (2) Current --byproject, group by severity,
1917# id for each warning pattern + project name
1918# sort by severity, warn_id, project, warning_message
1919# (3) New, group by project + severity,
1920# id for each warning pattern
1921# sort by project, severity, warn_id, warning_message
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001922def emit_buttons():
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001923 print ('<button class="button" onclick="expandCollapse(1);">'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001924 'Expand all warnings</button>\n'
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001925 '<button class="button" onclick="expandCollapse(0);">'
1926 'Collapse all warnings</button>\n'
1927 '<button class="button" onclick="groupBySeverity();">'
1928 'Group warnings by severity</button>\n'
1929 '<button class="button" onclick="groupByProject();">'
1930 'Group warnings by project</button><br>')
Marco Nelissen594375d2009-07-14 09:04:04 -07001931
1932
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001933def all_patterns(category):
1934 patterns = ''
1935 for i in category['patterns']:
1936 patterns += i
1937 patterns += ' / '
1938 return patterns
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001939
1940
1941def dump_fixed():
1942 """Show which warnings no longer occur."""
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001943 anchor = 'fixed_warnings'
1944 mark = anchor + '_mark'
1945 print ('\n<br><p style="background-color:lightblue"><b>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001946 '<button id="' + mark + '" '
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001947 'class="bt" onclick="expand(\'' + anchor + '\');">'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001948 '&#x2295</button> Fixed warnings. '
1949 'No more occurrences. Please consider turning these into '
1950 'errors if possible, before they are reintroduced in to the build'
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001951 ':</b></p>')
1952 print '<blockquote>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001953 fixed_patterns = []
1954 for i in warn_patterns:
1955 if not i['members']:
1956 fixed_patterns.append(i['description'] + ' (' +
1957 all_patterns(i) + ')')
1958 if i['option']:
1959 fixed_patterns.append(' ' + i['option'])
1960 fixed_patterns.sort()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001961 print '<div id="' + anchor + '" style="display:none;"><table>'
1962 cur_row_class = 0
1963 for text in fixed_patterns:
1964 cur_row_class = 1 - cur_row_class
1965 # remove last '\n'
1966 t = text[:-1] if text[-1] == '\n' else text
1967 print '<tr><td class="c' + str(cur_row_class) + '">' + t + '</td></tr>'
1968 print '</table></div>'
1969 print '</blockquote>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001970
1971
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001972def find_project_index(line):
1973 for p in range(len(project_patterns)):
1974 if project_patterns[p].match(line):
1975 return p
1976 return -1
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001977
1978
1979def classify_warning(line):
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001980 for i in range(len(warn_patterns)):
1981 w = warn_patterns[i]
1982 for cpat in w['compiled_patterns']:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001983 if cpat.match(line):
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001984 w['members'].append(line)
1985 p = find_project_index(line)
1986 index = len(warning_messages)
1987 warning_messages.append(line)
1988 warning_records.append([i, p, index])
1989 pname = '???' if p < 0 else project_names[p]
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001990 # Count warnings by project.
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001991 if pname in w['projects']:
1992 w['projects'][pname] += 1
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001993 else:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07001994 w['projects'][pname] = 1
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001995 return
1996 else:
1997 # If we end up here, there was a problem parsing the log
1998 # probably caused by 'make -j' mixing the output from
1999 # 2 or more concurrent compiles
2000 pass
Marco Nelissen594375d2009-07-14 09:04:04 -07002001
2002
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002003def compile_patterns():
2004 """Precompiling every pattern speeds up parsing by about 30x."""
2005 for i in warn_patterns:
2006 i['compiled_patterns'] = []
2007 for pat in i['patterns']:
2008 i['compiled_patterns'].append(re.compile(pat))
2009
2010
2011def parse_input_file():
2012 """Parse input file, match warning lines."""
2013 global platform_version
2014 global target_product
2015 global target_variant
2016 infile = open(args.buildlog, 'r')
2017 line_counter = 0
2018
2019 warning_pattern = re.compile('.* warning:.*')
2020 compile_patterns()
2021
2022 # read the log file and classify all the warnings
2023 warning_lines = set()
2024 for line in infile:
2025 # replace fancy quotes with plain ol' quotes
2026 line = line.replace('‘', "'")
2027 line = line.replace('’', "'")
2028 if warning_pattern.match(line):
2029 if line not in warning_lines:
2030 classify_warning(line)
2031 warning_lines.add(line)
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002032 elif line_counter < 50:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002033 # save a little bit of time by only doing this for the first few lines
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002034 line_counter += 1
2035 m = re.search('(?<=^PLATFORM_VERSION=).*', line)
2036 if m is not None:
2037 platform_version = m.group(0)
2038 m = re.search('(?<=^TARGET_PRODUCT=).*', line)
2039 if m is not None:
2040 target_product = m.group(0)
2041 m = re.search('(?<=^TARGET_BUILD_VARIANT=).*', line)
2042 if m is not None:
2043 target_variant = m.group(0)
2044
2045
2046# Return s with escaped quotation characters.
2047def escape_string(s):
2048 return s.replace('"', '\\"')
2049
2050
2051# Return s without trailing '\n' and escape the quotation characters.
2052def strip_escape_string(s):
2053 if not s:
2054 return s
2055 s = s[:-1] if s[-1] == '\n' else s
2056 return escape_string(s)
2057
2058
2059def emit_warning_array(name):
2060 print 'var warning_{} = ['.format(name)
2061 for i in range(len(warn_patterns)):
2062 print '{},'.format(warn_patterns[i][name])
2063 print '];'
2064
2065
2066def emit_warning_arrays():
2067 emit_warning_array('severity')
2068 print 'var warning_description = ['
2069 for i in range(len(warn_patterns)):
2070 if warn_patterns[i]['members']:
2071 print '"{}",'.format(escape_string(warn_patterns[i]['description']))
2072 else:
2073 print '"",' # no such warning
2074 print '];'
2075
2076scripts_for_warning_groups = """
2077 function compareMessages(x1, x2) { // of the same warning type
2078 return (WarningMessages[x1[2]] <= WarningMessages[x2[2]]) ? -1 : 1;
2079 }
2080 function byMessageCount(x1, x2) {
2081 return x2[2] - x1[2]; // reversed order
2082 }
2083 function bySeverityMessageCount(x1, x2) {
2084 // orer by severity first
2085 if (x1[1] != x2[1])
2086 return x1[1] - x2[1];
2087 return byMessageCount(x1, x2);
2088 }
2089 const ParseLinePattern = /^([^ :]+):(\\d+):(.+)/;
2090 function addURL(line) {
2091 if (FlagURL == "") return line;
2092 if (FlagSeparator == "") {
2093 return line.replace(ParseLinePattern,
2094 "<a href='" + FlagURL + "/$1'>$1</a>:$2:$3");
2095 }
2096 return line.replace(ParseLinePattern,
2097 "<a href='" + FlagURL + "/$1" + FlagSeparator + "$2'>$1:$2</a>:$3");
2098 }
2099 function createArrayOfDictionaries(n) {
2100 var result = [];
2101 for (var i=0; i<n; i++) result.push({});
2102 return result;
2103 }
2104 function groupWarningsBySeverity() {
2105 // groups is an array of dictionaries,
2106 // each dictionary maps from warning type to array of warning messages.
2107 var groups = createArrayOfDictionaries(SeverityColors.length);
2108 for (var i=0; i<Warnings.length; i++) {
2109 var w = Warnings[i][0];
2110 var s = WarnPatternsSeverity[w];
2111 var k = w.toString();
2112 if (!(k in groups[s]))
2113 groups[s][k] = [];
2114 groups[s][k].push(Warnings[i]);
2115 }
2116 return groups;
2117 }
2118 function groupWarningsByProject() {
2119 var groups = createArrayOfDictionaries(ProjectNames.length);
2120 for (var i=0; i<Warnings.length; i++) {
2121 var w = Warnings[i][0];
2122 var p = Warnings[i][1];
2123 var k = w.toString();
2124 if (!(k in groups[p]))
2125 groups[p][k] = [];
2126 groups[p][k].push(Warnings[i]);
2127 }
2128 return groups;
2129 }
2130 var GlobalAnchor = 0;
2131 function createWarningSection(header, color, group) {
2132 var result = "";
2133 var groupKeys = [];
2134 var totalMessages = 0;
2135 for (var k in group) {
2136 totalMessages += group[k].length;
2137 groupKeys.push([k, WarnPatternsSeverity[parseInt(k)], group[k].length]);
2138 }
2139 groupKeys.sort(bySeverityMessageCount);
2140 for (var idx=0; idx<groupKeys.length; idx++) {
2141 var k = groupKeys[idx][0];
2142 var messages = group[k];
2143 var w = parseInt(k);
2144 var wcolor = SeverityColors[WarnPatternsSeverity[w]];
2145 var description = WarnPatternsDescription[w];
2146 if (description.length == 0)
2147 description = "???";
2148 GlobalAnchor += 1;
2149 result += "<table class='t1'><tr bgcolor='" + wcolor + "'><td>" +
2150 "<button class='bt' id='" + GlobalAnchor + "_mark" +
2151 "' onclick='expand(\\"" + GlobalAnchor + "\\");'>" +
2152 "&#x2295</button> " +
2153 description + " (" + messages.length + ")</td></tr></table>";
2154 result += "<div id='" + GlobalAnchor +
2155 "' style='display:none;'><table class='t1'>";
2156 var c = 0;
2157 messages.sort(compareMessages);
2158 for (var i=0; i<messages.length; i++) {
2159 result += "<tr><td class='c" + c + "'>" +
2160 addURL(WarningMessages[messages[i][2]]) + "</td></tr>";
2161 c = 1 - c;
2162 }
2163 result += "</table></div>";
2164 }
2165 if (result.length > 0) {
2166 return "<br><span style='background-color:" + color + "'><b>" +
2167 header + ": " + totalMessages +
2168 "</b></span><blockquote><table class='t1'>" +
2169 result + "</table></blockquote>";
2170
2171 }
2172 return ""; // empty section
2173 }
2174 function generateSectionsBySeverity() {
2175 var result = "";
2176 var groups = groupWarningsBySeverity();
2177 for (s=0; s<SeverityColors.length; s++) {
2178 result += createWarningSection(SeverityHeaders[s], SeverityColors[s], groups[s]);
2179 }
2180 return result;
2181 }
2182 function generateSectionsByProject() {
2183 var result = "";
2184 var groups = groupWarningsByProject();
2185 for (i=0; i<groups.length; i++) {
2186 result += createWarningSection(ProjectNames[i], 'lightgrey', groups[i]);
2187 }
2188 return result;
2189 }
2190 function groupWarnings(generator) {
2191 GlobalAnchor = 0;
2192 var e = document.getElementById("warning_groups");
2193 e.innerHTML = generator();
2194 }
2195 function groupBySeverity() {
2196 groupWarnings(generateSectionsBySeverity);
2197 }
2198 function groupByProject() {
2199 groupWarnings(generateSectionsByProject);
2200 }
2201"""
2202
2203
2204# Emit a JavaScript const string
2205def emit_const_string(name, value):
2206 print 'const ' + name + ' = "' + escape_string(value) + '";'
2207
2208
2209# Emit a JavaScript const integer array.
2210def emit_const_int_array(name, array):
2211 print 'const ' + name + ' = ['
2212 for n in array:
2213 print str(n) + ','
2214 print '];'
2215
2216
2217# Emit a JavaScript const string array.
2218def emit_const_string_array(name, array):
2219 print 'const ' + name + ' = ['
2220 for s in array:
2221 print '"' + strip_escape_string(s) + '",'
2222 print '];'
2223
2224
2225# Emit a JavaScript const object array.
2226def emit_const_object_array(name, array):
2227 print 'const ' + name + ' = ['
2228 for x in array:
2229 print str(x) + ','
2230 print '];'
2231
2232
2233def emit_js_data():
2234 """Dump dynamic HTML page's static JavaScript data."""
2235 emit_const_string('FlagURL', args.url if args.url else '')
2236 emit_const_string('FlagSeparator', args.separator if args.separator else '')
2237 emit_const_string_array('SeverityColors', severity.colors)
2238 emit_const_string_array('SeverityHeaders', severity.headers)
2239 emit_const_string_array('SeverityColumnHeaders', severity.column_headers)
2240 emit_const_string_array('ProjectNames', project_names)
2241 emit_const_int_array('WarnPatternsSeverity',
2242 [w['severity'] for w in warn_patterns])
2243 emit_const_string_array('WarnPatternsDescription',
2244 [w['description'] for w in warn_patterns])
2245 emit_const_string_array('WarnPatternsOption',
2246 [w['option'] for w in warn_patterns])
2247 emit_const_string_array('WarningMessages', warning_messages)
2248 emit_const_object_array('Warnings', warning_records)
2249
2250draw_table_javascript = """
2251google.charts.load('current', {'packages':['table']});
2252google.charts.setOnLoadCallback(drawTable);
2253function drawTable() {
2254 var data = new google.visualization.DataTable();
2255 data.addColumn('string', StatsHeader[0]);
2256 for (var i=1; i<StatsHeader.length; i++) {
2257 data.addColumn('number', StatsHeader[i]);
2258 }
2259 data.addRows(StatsRows);
2260 for (var i=0; i<StatsRows.length; i++) {
2261 for (var j=0; j<StatsHeader.length; j++) {
2262 data.setProperty(i, j, 'style', 'border:1px solid black;');
2263 }
2264 }
2265 var table = new google.visualization.Table(document.getElementById('stats_table'));
2266 table.draw(data, {allowHtml: true, alternatingRowStyle: true});
2267}
2268"""
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002269
2270
2271def dump_html():
2272 """Dump the html output to stdout."""
2273 dump_html_prologue('Warnings for ' + platform_version + ' - ' +
2274 target_product + ' - ' + target_variant)
2275 dump_stats()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002276 print '<br><div id="stats_table"></div><br>'
2277 print '\n<script>'
2278 emit_js_data()
2279 print scripts_for_warning_groups
2280 print '</script>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002281 emit_buttons()
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002282 # Warning messages are grouped by severities or project names.
2283 print '<br><div id="warning_groups"></div>'
2284 if args.byproject:
2285 print '<script>groupByProject();</script>'
2286 else:
2287 print '<script>groupBySeverity();</script>'
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002288 dump_fixed()
2289 dump_html_epilogue()
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002290
2291
2292##### Functions to count warnings and dump csv file. #########################
2293
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002294
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002295def description_for_csv(category):
2296 if not category['description']:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002297 return '?'
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002298 return category['description']
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002299
2300
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002301def string_for_csv(s):
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002302 # Only some Java warning desciptions have used quotation marks.
2303 # TODO(chh): if s has double quote character, s should be quoted.
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002304 if ',' in s:
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002305 # TODO(chh): replace a double quote with two double quotes in s.
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002306 return '"{}"'.format(s)
2307 return s
2308
2309
2310def count_severity(sev, kind):
2311 """Count warnings of given severity."""
2312 total = 0
2313 for i in warn_patterns:
2314 if i['severity'] == sev and i['members']:
2315 n = len(i['members'])
2316 total += n
2317 warning = string_for_csv(kind + ': ' + description_for_csv(i))
2318 print '{},,{}'.format(n, warning)
2319 # print number of warnings for each project, ordered by project name.
2320 projects = i['projects'].keys()
2321 projects.sort()
2322 for p in projects:
2323 print '{},{},{}'.format(i['projects'][p], p, warning)
2324 print '{},,{}'.format(total, kind + ' warnings')
2325 return total
2326
2327
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002328# dump number of warnings in csv format to stdout
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002329def dump_csv():
2330 """Dump number of warnings in csv format to stdout."""
2331 sort_warnings()
2332 total = 0
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002333 for s in severity.range:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002334 total += count_severity(s, severity.column_headers[s])
2335 print '{},,{}'.format(total, 'All warnings')
2336
2337
Chih-Hung Hsieh2a38c372016-09-22 19:22:07 -07002338##### Main function starts here. #########################
2339
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002340parse_input_file()
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002341if args.gencsv:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002342 dump_csv()
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002343else:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002344 dump_html()