blob: f635ea111b41003d9817bc4db57e9a3771ca3cae [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
Ian Rogersf3829732016-05-10 12:06:01 -070011import argparse
Marco Nelissen594375d2009-07-14 09:04:04 -070012import re
13
Ian Rogersf3829732016-05-10 12:06:01 -070014parser = argparse.ArgumentParser(description='Convert a build log into HTML')
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -070015parser.add_argument('--gencsv',
16 help='Generate a CSV file with number of various warnings',
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -070017 action='store_true',
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -070018 default=False)
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -070019parser.add_argument('--byproject',
20 help='Separate warnings in HTML output by project names',
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -070021 action='store_true',
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -070022 default=False)
Ian Rogersf3829732016-05-10 12:06:01 -070023parser.add_argument('--url',
24 help='Root URL of an Android source code tree prefixed '
25 'before files in warnings')
26parser.add_argument('--separator',
27 help='Separator between the end of a URL and the line '
28 'number argument. e.g. #')
29parser.add_argument(dest='buildlog', metavar='build.log',
30 help='Path to build.log file')
31args = parser.parse_args()
Marco Nelissen594375d2009-07-14 09:04:04 -070032
Marco Nelissen594375d2009-07-14 09:04:04 -070033
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -070034# if you add another level, don't forget to give it a color below
35class severity: # pylint:disable=invalid-name,old-style-class
36 """Severity levels and attributes."""
37 UNKNOWN = 0
38 FIXMENOW = 1
39 HIGH = 2
40 MEDIUM = 3
41 LOW = 4
42 TIDY = 5
43 HARMLESS = 6
44 SKIP = 7
45 attributes = [
46 # pylint:disable=bad-whitespace
47 ['lightblue', 'Unknown', 'Unknown warnings'],
48 ['fuchsia', 'FixNow', 'Critical warnings, fix me now'],
49 ['red', 'High', 'High severity warnings'],
50 ['orange', 'Medium', 'Medium severity warnings'],
51 ['yellow', 'Low', 'Low severity warnings'],
52 ['peachpuff', 'Tidy', 'Clang-Tidy warnings'],
53 ['limegreen', 'Harmless', 'Harmless warnings'],
54 ['grey', 'Unhandled', 'Unhandled warnings']
55 ]
56 color = [a[0] for a in attributes]
57 column_headers = [a[1] for a in attributes]
58 header = [a[2] for a in attributes]
59 # order to dump by severity
60 kinds = [FIXMENOW, HIGH, MEDIUM, LOW, TIDY, HARMLESS, UNKNOWN, SKIP]
61
62warn_patterns = [
63 # TODO(chh): fix pylint space and indentation warnings
64 # pylint:disable=bad-whitespace,bad-continuation,
65 # pylint:disable=line-too-long,g-inconsistent-quotes
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -070066 { 'category':'make', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -070067 'description':'make: overriding commands/ignoring old commands',
68 'patterns':[r".*: warning: overriding commands for target .+",
69 r".*: warning: ignoring old commands for target .+"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -070070 { 'category':'make', 'severity':severity.HIGH,
Chih-Hung Hsiehd9cd1fa2016-08-02 14:22:06 -070071 'description':'make: LOCAL_CLANG is false',
72 'patterns':[r".*: warning: LOCAL_CLANG is set to false"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -070073 { 'category':'make', 'severity':severity.HIGH,
Dan Willemsen121e2842016-09-14 21:38:29 -070074 'description':'SDK App using platform shared library',
75 'patterns':[r".*: warning: .+ \(.*app:sdk.*\) should not link to .+ \(native:platform\)"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -070076 { 'category':'make', 'severity':severity.HIGH,
Dan Willemsen121e2842016-09-14 21:38:29 -070077 'description':'System module linking to a vendor module',
78 'patterns':[r".*: warning: .+ \(.+\) should not link to .+ \(partition:.+\)"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -070079 { 'category':'make', 'severity':severity.MEDIUM,
Dan Willemsen121e2842016-09-14 21:38:29 -070080 'description':'Invalid SDK/NDK linking',
81 'patterns':[r".*: warning: .+ \(.+\) should not link to .+ \(.+\)"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -070082 { 'category':'C/C++', 'severity':severity.HIGH, 'option':'-Wimplicit-function-declaration',
Marco Nelissen594375d2009-07-14 09:04:04 -070083 'description':'Implicit function declaration',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -070084 'patterns':[r".*: warning: implicit declaration of function .+",
85 r".*: warning: implicitly declaring library function" ] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -070086 { 'category':'C/C++', 'severity':severity.SKIP,
Marco Nelissen594375d2009-07-14 09:04:04 -070087 'description':'',
88 'patterns':[r".*: warning: conflicting types for '.+'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -070089 { 'category':'C/C++', 'severity':severity.HIGH, 'option':'-Wtype-limits',
Marco Nelissen594375d2009-07-14 09:04:04 -070090 'description':'Expression always evaluates to true or false',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -070091 'patterns':[r".*: warning: comparison is always .+ due to limited range of data type",
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -070092 r".*: warning: comparison of unsigned .*expression .+ is always true",
93 r".*: warning: comparison of unsigned .*expression .+ is always false"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -070094 { 'category':'C/C++', 'severity':severity.HIGH,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -070095 'description':'Potential leak of memory, bad free, use after free',
96 'patterns':[r".*: warning: Potential leak of memory",
97 r".*: warning: Potential memory leak",
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -070098 r".*: warning: Memory allocated by alloca\(\) should not be deallocated",
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -070099 r".*: warning: Memory allocated by .+ should be deallocated by .+ not .+",
100 r".*: warning: 'delete' applied to a pointer that was allocated",
101 r".*: warning: Use of memory after it is freed",
102 r".*: warning: Argument to .+ is the address of .+ variable",
103 r".*: warning: Argument to free\(\) is offset by .+ of memory allocated by",
104 r".*: warning: Attempt to .+ released memory"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700105 { 'category':'C/C++', 'severity':severity.HIGH,
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700106 'description':'Use transient memory for control value',
107 'patterns':[r".*: warning: .+Using such transient memory for the control value is .*dangerous."] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700108 { 'category':'C/C++', 'severity':severity.HIGH,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700109 'description':'Return address of stack memory',
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700110 'patterns':[r".*: warning: Address of stack memory .+ returned to caller",
111 r".*: warning: Address of stack memory .+ will be a dangling reference"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700112 { 'category':'C/C++', 'severity':severity.HIGH,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700113 'description':'Problem with vfork',
114 'patterns':[r".*: warning: This .+ is prohibited after a successful vfork",
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700115 r".*: warning: Call to function '.+' is insecure "] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700116 { 'category':'C/C++', 'severity':severity.HIGH, 'option':'infinite-recursion',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700117 'description':'Infinite recursion',
118 'patterns':[r".*: warning: all paths through this function will call itself"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700119 { 'category':'C/C++', 'severity':severity.HIGH,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700120 'description':'Potential buffer overflow',
121 'patterns':[r".*: warning: Size argument is greater than .+ the destination buffer",
122 r".*: warning: Potential buffer overflow.",
123 r".*: warning: String copy function overflows destination buffer"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700124 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -0700125 'description':'Incompatible pointer types',
126 'patterns':[r".*: warning: assignment from incompatible pointer type",
Marco Nelissen8e201962010-03-10 16:16:02 -0800127 r".*: warning: return from incompatible pointer type",
Marco Nelissen594375d2009-07-14 09:04:04 -0700128 r".*: warning: passing argument [0-9]+ of '.*' from incompatible pointer type",
129 r".*: warning: initialization from incompatible pointer type"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700130 { 'category':'C/C++', 'severity':severity.HIGH, 'option':'-fno-builtin',
Marco Nelissen594375d2009-07-14 09:04:04 -0700131 'description':'Incompatible declaration of built in function',
132 'patterns':[r".*: warning: incompatible implicit declaration of built-in function .+"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700133 { 'category':'C/C++', 'severity':severity.HIGH, 'option':'-Wincompatible-library-redeclaration',
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -0700134 'description':'Incompatible redeclaration of library function',
135 'patterns':[r".*: warning: incompatible redeclaration of library function .+"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700136 { 'category':'C/C++', 'severity':severity.HIGH,
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700137 'description':'Null passed as non-null argument',
Chih-Hung Hsiehc21ddbd2016-07-20 10:08:51 -0700138 'patterns':[r".*: warning: Null passed to a callee that requires a non-null"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700139 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wunused-parameter',
Marco Nelissen594375d2009-07-14 09:04:04 -0700140 'description':'Unused parameter',
141 'patterns':[r".*: warning: unused parameter '.*'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700142 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wunused',
Marco Nelissen594375d2009-07-14 09:04:04 -0700143 'description':'Unused function, variable or label',
Marco Nelissen8e201962010-03-10 16:16:02 -0800144 'patterns':[r".*: warning: '.+' defined but not used",
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700145 r".*: warning: unused function '.+'",
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -0700146 r".*: warning: private field '.+' is not used",
Marco Nelissen8e201962010-03-10 16:16:02 -0800147 r".*: warning: unused variable '.+'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700148 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wunused-value',
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -0700149 'description':'Statement with no effect or result unused',
150 'patterns':[r".*: warning: statement with no effect",
151 r".*: warning: expression result unused"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700152 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wunused-result',
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -0700153 'description':'Ignoreing return value of function',
154 'patterns':[r".*: warning: ignoring return value of function .+Wunused-result"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700155 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wmissing-field-initializers',
Marco Nelissen594375d2009-07-14 09:04:04 -0700156 'description':'Missing initializer',
157 'patterns':[r".*: warning: missing initializer"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700158 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wdelete-non-virtual-dtor',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700159 'description':'Need virtual destructor',
160 'patterns':[r".*: warning: delete called .* has virtual functions but non-virtual destructor"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700161 { 'category':'cont.', 'severity':severity.SKIP,
Marco Nelissen594375d2009-07-14 09:04:04 -0700162 'description':'',
163 'patterns':[r".*: warning: \(near initialization for '.+'\)"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700164 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wdate-time',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700165 'description':'Expansion of data or time macro',
166 'patterns':[r".*: warning: expansion of date or time macro is not reproducible"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700167 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wformat',
Marco Nelissen594375d2009-07-14 09:04:04 -0700168 'description':'Format string does not match arguments',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700169 'patterns':[r".*: warning: format '.+' expects type '.+', but argument [0-9]+ has type '.+'",
170 r".*: warning: more '%' conversions than data arguments",
171 r".*: warning: data argument not used by format string",
172 r".*: warning: incomplete format specifier",
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700173 r".*: warning: unknown conversion type .* in format",
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700174 r".*: warning: format .+ expects .+ but argument .+Wformat=",
175 r".*: warning: field precision should have .+ but argument has .+Wformat",
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700176 r".*: warning: format specifies type .+ but the argument has .*type .+Wformat"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700177 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wformat-extra-args',
Marco Nelissen594375d2009-07-14 09:04:04 -0700178 'description':'Too many arguments for format string',
179 'patterns':[r".*: warning: too many arguments for format"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700180 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wformat-invalid-specifier',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700181 'description':'Invalid format specifier',
182 'patterns':[r".*: warning: invalid .+ specifier '.+'.+format-invalid-specifier"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700183 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wsign-compare',
Marco Nelissen594375d2009-07-14 09:04:04 -0700184 'description':'Comparison between signed and unsigned',
185 'patterns':[r".*: warning: comparison between signed and unsigned",
186 r".*: warning: comparison of promoted \~unsigned with unsigned",
187 r".*: warning: signed and unsigned type in conditional expression"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700188 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen8e201962010-03-10 16:16:02 -0800189 'description':'Comparison between enum and non-enum',
190 'patterns':[r".*: warning: enumeral and non-enumeral type in conditional expression"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700191 { 'category':'libpng', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -0700192 'description':'libpng: zero area',
193 'patterns':[r".*libpng warning: Ignoring attempt to set cHRM RGB triangle with zero area"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700194 { 'category':'aapt', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -0700195 'description':'aapt: no comment for public symbol',
196 'patterns':[r".*: warning: No comment for public symbol .+"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700197 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wmissing-braces',
Marco Nelissen594375d2009-07-14 09:04:04 -0700198 'description':'Missing braces around initializer',
199 'patterns':[r".*: warning: missing braces around initializer.*"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700200 { 'category':'C/C++', 'severity':severity.HARMLESS,
Marco Nelissen594375d2009-07-14 09:04:04 -0700201 'description':'No newline at end of file',
202 'patterns':[r".*: warning: no newline at end of file"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700203 { 'category':'C/C++', 'severity':severity.HARMLESS,
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700204 'description':'Missing space after macro name',
205 'patterns':[r".*: warning: missing whitespace after the macro name"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700206 { 'category':'C/C++', 'severity':severity.LOW, 'option':'-Wcast-align',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700207 'description':'Cast increases required alignment',
208 'patterns':[r".*: warning: cast from .* to .* increases required alignment .*"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700209 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wcast-qual',
Marco Nelissen594375d2009-07-14 09:04:04 -0700210 'description':'Qualifier discarded',
211 'patterns':[r".*: warning: passing argument [0-9]+ of '.+' discards qualifiers from pointer target type",
212 r".*: warning: assignment discards qualifiers from pointer target type",
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700213 r".*: warning: passing .+ to parameter of type .+ discards qualifiers",
214 r".*: warning: assigning to .+ from .+ discards qualifiers",
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700215 r".*: warning: initializing .+ discards qualifiers .+types-discards-qualifiers",
Marco Nelissen594375d2009-07-14 09:04:04 -0700216 r".*: warning: return discards qualifiers from pointer target type"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700217 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wunknown-attributes',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700218 'description':'Unknown attribute',
219 'patterns':[r".*: warning: unknown attribute '.+'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700220 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wignored-attributes',
Marco Nelissen594375d2009-07-14 09:04:04 -0700221 'description':'Attribute ignored',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700222 'patterns':[r".*: warning: '_*packed_*' attribute ignored",
223 r".*: warning: attribute declaration must precede definition .+ignored-attributes"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700224 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wvisibility',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700225 'description':'Visibility problem',
226 'patterns':[r".*: warning: declaration of '.+' will not be visible outside of this function"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700227 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wattributes',
Marco Nelissen594375d2009-07-14 09:04:04 -0700228 'description':'Visibility mismatch',
229 'patterns':[r".*: warning: '.+' declared with greater visibility than the type of its field '.+'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700230 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -0700231 'description':'Shift count greater than width of type',
232 'patterns':[r".*: warning: (left|right) shift count >= width of type"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700233 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wextern-initializer',
Marco Nelissen594375d2009-07-14 09:04:04 -0700234 'description':'extern <foo> is initialized',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700235 'patterns':[r".*: warning: '.+' initialized and declared 'extern'",
236 r".*: warning: 'extern' variable has an initializer"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700237 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wold-style-declaration',
Marco Nelissen594375d2009-07-14 09:04:04 -0700238 'description':'Old style declaration',
239 'patterns':[r".*: warning: 'static' is not at beginning of declaration"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700240 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wreturn-type',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700241 'description':'Missing return value',
242 'patterns':[r".*: warning: control reaches end of non-void function"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700243 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wimplicit-int',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700244 'description':'Implicit int type',
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -0700245 'patterns':[r".*: warning: type specifier missing, defaults to 'int'",
246 r".*: warning: type defaults to 'int' in declaration of '.+'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700247 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wmain-return-type',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700248 'description':'Main function should return int',
249 'patterns':[r".*: warning: return type of 'main' is not 'int'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700250 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wuninitialized',
Marco Nelissen594375d2009-07-14 09:04:04 -0700251 'description':'Variable may be used uninitialized',
252 'patterns':[r".*: warning: '.+' may be used uninitialized in this function"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700253 { 'category':'C/C++', 'severity':severity.HIGH, 'option':'-Wuninitialized',
Marco Nelissen594375d2009-07-14 09:04:04 -0700254 'description':'Variable is used uninitialized',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700255 'patterns':[r".*: warning: '.+' is used uninitialized in this function",
256 r".*: warning: variable '.+' is uninitialized when used here"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700257 { 'category':'ld', 'severity':severity.MEDIUM, 'option':'-fshort-enums',
Marco Nelissen594375d2009-07-14 09:04:04 -0700258 'description':'ld: possible enum size mismatch',
259 '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 -0700260 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wpointer-sign',
Marco Nelissen594375d2009-07-14 09:04:04 -0700261 'description':'Pointer targets differ in signedness',
262 'patterns':[r".*: warning: pointer targets in initialization differ in signedness",
263 r".*: warning: pointer targets in assignment differ in signedness",
264 r".*: warning: pointer targets in return differ in signedness",
265 r".*: warning: pointer targets in passing argument [0-9]+ of '.+' differ in signedness"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700266 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wstrict-overflow',
Marco Nelissen594375d2009-07-14 09:04:04 -0700267 'description':'Assuming overflow does not occur',
268 'patterns':[r".*: warning: assuming signed overflow does not occur when assuming that .* is always (true|false)"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700269 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wempty-body',
Marco Nelissen594375d2009-07-14 09:04:04 -0700270 'description':'Suggest adding braces around empty body',
271 'patterns':[r".*: warning: suggest braces around empty body in an 'if' statement",
272 r".*: warning: empty body in an if-statement",
273 r".*: warning: suggest braces around empty body in an 'else' statement",
274 r".*: warning: empty body in an else-statement"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700275 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wparentheses',
Marco Nelissen594375d2009-07-14 09:04:04 -0700276 'description':'Suggest adding parentheses',
277 'patterns':[r".*: warning: suggest explicit braces to avoid ambiguous 'else'",
278 r".*: warning: suggest parentheses around arithmetic in operand of '.+'",
279 r".*: warning: suggest parentheses around comparison in operand of '.+'",
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700280 r".*: warning: logical not is only applied to the left hand side of this comparison",
281 r".*: warning: using the result of an assignment as a condition without parentheses",
282 r".*: warning: .+ has lower precedence than .+ be evaluated first .+Wparentheses",
Marco Nelissen594375d2009-07-14 09:04:04 -0700283 r".*: warning: suggest parentheses around '.+?' .+ '.+?'",
284 r".*: warning: suggest parentheses around assignment used as truth value"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700285 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -0700286 'description':'Static variable used in non-static inline function',
287 'patterns':[r".*: warning: '.+' is static but used in inline function '.+' which is not static"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700288 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wimplicit int',
Marco Nelissen594375d2009-07-14 09:04:04 -0700289 'description':'No type or storage class (will default to int)',
290 'patterns':[r".*: warning: data definition has no type or storage class"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700291 { 'category':'C/C++', 'severity':severity.MEDIUM,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700292 'description':'Null pointer',
293 'patterns':[r".*: warning: Dereference of null pointer",
294 r".*: warning: Called .+ pointer is null",
295 r".*: warning: Forming reference to null pointer",
296 r".*: warning: Returning null reference",
297 r".*: warning: Null pointer passed as an argument to a 'nonnull' parameter",
298 r".*: warning: .+ results in a null pointer dereference",
299 r".*: warning: Access to .+ results in a dereference of a null pointer",
300 r".*: warning: Null pointer argument in"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700301 { 'category':'cont.', 'severity':severity.SKIP,
Marco Nelissen594375d2009-07-14 09:04:04 -0700302 'description':'',
Marco Nelissen594375d2009-07-14 09:04:04 -0700303 'patterns':[r".*: warning: parameter names \(without types\) in function declaration"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700304 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wstrict-aliasing',
Marco Nelissen594375d2009-07-14 09:04:04 -0700305 'description':'Dereferencing <foo> breaks strict aliasing rules',
306 'patterns':[r".*: warning: dereferencing .* break strict-aliasing rules"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700307 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wpointer-to-int-cast',
Marco Nelissen594375d2009-07-14 09:04:04 -0700308 'description':'Cast from pointer to integer of different size',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -0700309 'patterns':[r".*: warning: cast from pointer to integer of different size",
310 r".*: warning: initialization makes pointer from integer without a cast"] } ,
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700311 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wint-to-pointer-cast',
Marco Nelissen594375d2009-07-14 09:04:04 -0700312 'description':'Cast to pointer from integer of different size',
313 'patterns':[r".*: warning: cast to pointer from integer of different size"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700314 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -0700315 'description':'Symbol redefined',
316 'patterns':[r".*: warning: "".+"" redefined"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700317 { 'category':'cont.', 'severity':severity.SKIP,
Marco Nelissen594375d2009-07-14 09:04:04 -0700318 'description':'',
319 'patterns':[r".*: warning: this is the location of the previous definition"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700320 { 'category':'ld', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -0700321 'description':'ld: type and size of dynamic symbol are not defined',
322 'patterns':[r".*: warning: type and size of dynamic symbol `.+' are not defined"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700323 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -0700324 'description':'Pointer from integer without cast',
325 'patterns':[r".*: warning: assignment makes pointer from integer without a cast"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700326 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -0700327 'description':'Pointer from integer without cast',
328 'patterns':[r".*: warning: passing argument [0-9]+ of '.+' makes pointer from integer without a cast"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700329 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -0700330 'description':'Integer from pointer without cast',
331 'patterns':[r".*: warning: assignment makes integer from pointer without a cast"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700332 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -0700333 'description':'Integer from pointer without cast',
334 'patterns':[r".*: warning: passing argument [0-9]+ of '.+' makes integer from pointer without a cast"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700335 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -0700336 'description':'Integer from pointer without cast',
337 'patterns':[r".*: warning: return makes integer from pointer without a cast"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700338 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wunknown-pragmas',
Marco Nelissen594375d2009-07-14 09:04:04 -0700339 'description':'Ignoring pragma',
340 'patterns':[r".*: warning: ignoring #pragma .+"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700341 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wclobbered',
Marco Nelissen594375d2009-07-14 09:04:04 -0700342 'description':'Variable might be clobbered by longjmp or vfork',
343 'patterns':[r".*: warning: variable '.+' might be clobbered by 'longjmp' or 'vfork'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700344 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wclobbered',
Marco Nelissen594375d2009-07-14 09:04:04 -0700345 'description':'Argument might be clobbered by longjmp or vfork',
346 'patterns':[r".*: warning: argument '.+' might be clobbered by 'longjmp' or 'vfork'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700347 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wredundant-decls',
Marco Nelissen594375d2009-07-14 09:04:04 -0700348 'description':'Redundant declaration',
349 'patterns':[r".*: warning: redundant redeclaration of '.+'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700350 { 'category':'cont.', 'severity':severity.SKIP,
Marco Nelissen594375d2009-07-14 09:04:04 -0700351 'description':'',
352 'patterns':[r".*: warning: previous declaration of '.+' was here"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700353 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wswitch-enum',
Marco Nelissen594375d2009-07-14 09:04:04 -0700354 'description':'Enum value not handled in switch',
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700355 'patterns':[r".*: warning: .*enumeration value.* not handled in switch.+Wswitch"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700356 { 'category':'java', 'severity':severity.MEDIUM, 'option':'-encoding',
Marco Nelissen594375d2009-07-14 09:04:04 -0700357 'description':'Java: Non-ascii characters used, but ascii encoding specified',
358 'patterns':[r".*: warning: unmappable character for encoding ascii"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700359 { 'category':'java', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -0700360 'description':'Java: Non-varargs call of varargs method with inexact argument type for last parameter',
361 'patterns':[r".*: warning: non-varargs call of varargs method with inexact argument type for last parameter"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700362 { 'category':'java', 'severity':severity.MEDIUM,
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700363 'description':'Java: Unchecked method invocation',
364 'patterns':[r".*: warning: \[unchecked\] unchecked method invocation: .+ in class .+"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700365 { 'category':'java', 'severity':severity.MEDIUM,
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700366 'description':'Java: Unchecked conversion',
367 'patterns':[r".*: warning: \[unchecked\] unchecked conversion"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700368 { 'category':'java', 'severity':severity.MEDIUM,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -0700369 'description':'_ used as an identifier',
370 'patterns':[r".*: warning: '_' used as an identifier"] },
Ian Rogers32bb9bd2016-05-09 23:19:42 -0700371
Ian Rogers6e520032016-05-13 08:59:00 -0700372 # Warnings from Error Prone.
373 {'category': 'java',
374 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700375 'description': 'Java: Use of deprecated member',
376 'patterns': [r'.*: warning: \[deprecation\] .+']},
377 {'category': 'java',
378 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700379 'description': 'Java: Unchecked conversion',
380 'patterns': [r'.*: warning: \[unchecked\] .+']},
Ian Rogers32bb9bd2016-05-09 23:19:42 -0700381
Ian Rogers6e520032016-05-13 08:59:00 -0700382 # Warnings from Error Prone (auto generated list).
383 {'category': 'java',
384 'severity': severity.LOW,
Ian Rogers6e520032016-05-13 08:59:00 -0700385 'description':
386 'Java: Deprecated item is not annotated with @Deprecated',
387 'patterns': [r".*: warning: \[DepAnn\] .+"]},
388 {'category': 'java',
389 'severity': severity.LOW,
Ian Rogers6e520032016-05-13 08:59:00 -0700390 'description':
391 'Java: Fallthrough warning suppression has no effect if warning is suppressed',
392 'patterns': [r".*: warning: \[FallthroughSuppression\] .+"]},
393 {'category': 'java',
394 'severity': severity.LOW,
Ian Rogers6e520032016-05-13 08:59:00 -0700395 'description':
396 'Java: Prefer \'L\' to \'l\' for the suffix to long literals',
397 'patterns': [r".*: warning: \[LongLiteralLowerCaseSuffix\] .+"]},
398 {'category': 'java',
399 'severity': severity.LOW,
Ian Rogers6e520032016-05-13 08:59:00 -0700400 'description':
401 'Java: @Binds is a more efficient and declaritive mechanism for delegating a binding.',
402 'patterns': [r".*: warning: \[UseBinds\] .+"]},
403 {'category': 'java',
404 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700405 'description':
406 'Java: Assertions may be disabled at runtime and do not guarantee that execution will halt here; consider throwing an exception instead',
407 'patterns': [r".*: warning: \[AssertFalse\] .+"]},
408 {'category': 'java',
409 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700410 'description':
411 'Java: Classes that implement Annotation must override equals and hashCode. Consider using AutoAnnotation instead of implementing Annotation by hand.',
412 'patterns': [r".*: warning: \[BadAnnotationImplementation\] .+"]},
413 {'category': 'java',
414 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700415 'description':
416 'Java: BigDecimal(double) and BigDecimal.valueOf(double) may lose precision, prefer BigDecimal(String) or BigDecimal(long)',
417 'patterns': [r".*: warning: \[BigDecimalLiteralDouble\] .+"]},
418 {'category': 'java',
419 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700420 'description':
421 'Java: Mockito cannot mock final classes',
422 'patterns': [r".*: warning: \[CannotMockFinalClass\] .+"]},
423 {'category': 'java',
424 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700425 'description':
426 'Java: This code, which counts elements using a loop, can be replaced by a simpler library method',
427 'patterns': [r".*: warning: \[ElementsCountedInLoop\] .+"]},
428 {'category': 'java',
429 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700430 'description':
431 'Java: Empty top-level type declaration',
432 'patterns': [r".*: warning: \[EmptyTopLevelDeclaration\] .+"]},
433 {'category': 'java',
434 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700435 'description':
436 'Java: Classes that override equals should also override hashCode.',
437 'patterns': [r".*: warning: \[EqualsHashCode\] .+"]},
438 {'category': 'java',
439 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700440 'description':
441 'Java: An equality test between objects with incompatible types always returns false',
442 'patterns': [r".*: warning: \[EqualsIncompatibleType\] .+"]},
443 {'category': 'java',
444 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700445 'description':
446 '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.',
447 'patterns': [r".*: warning: \[Finally\] .+"]},
448 {'category': 'java',
449 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700450 'description':
451 'Java: This annotation has incompatible modifiers as specified by its @IncompatibleModifiers annotation',
452 'patterns': [r".*: warning: \[IncompatibleModifiers\] .+"]},
453 {'category': 'java',
454 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700455 'description':
456 'Java: Class should not implement both `Iterable` and `Iterator`',
457 'patterns': [r".*: warning: \[IterableAndIterator\] .+"]},
458 {'category': 'java',
459 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700460 'description':
461 'Java: Floating-point comparison without error tolerance',
462 'patterns': [r".*: warning: \[JUnit3FloatingPointComparisonWithoutDelta\] .+"]},
463 {'category': 'java',
464 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700465 'description':
466 'Java: Test class inherits from JUnit 3\'s TestCase but has JUnit 4 @Test annotations.',
467 'patterns': [r".*: warning: \[JUnitAmbiguousTestClass\] .+"]},
468 {'category': 'java',
469 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700470 'description':
471 'Java: Enum switch statement is missing cases',
472 'patterns': [r".*: warning: \[MissingCasesInEnumSwitch\] .+"]},
473 {'category': 'java',
474 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700475 'description':
476 'Java: Not calling fail() when expecting an exception masks bugs',
477 'patterns': [r".*: warning: \[MissingFail\] .+"]},
478 {'category': 'java',
479 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700480 'description':
481 'Java: method overrides method in supertype; expected @Override',
482 'patterns': [r".*: warning: \[MissingOverride\] .+"]},
483 {'category': 'java',
484 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700485 'description':
486 'Java: Source files should not contain multiple top-level class declarations',
487 'patterns': [r".*: warning: \[MultipleTopLevelClasses\] .+"]},
488 {'category': 'java',
489 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700490 'description':
491 'Java: This update of a volatile variable is non-atomic',
492 'patterns': [r".*: warning: \[NonAtomicVolatileUpdate\] .+"]},
493 {'category': 'java',
494 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700495 'description':
496 'Java: Static import of member uses non-canonical name',
497 'patterns': [r".*: warning: \[NonCanonicalStaticMemberImport\] .+"]},
498 {'category': 'java',
499 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700500 'description':
501 'Java: equals method doesn\'t override Object.equals',
502 'patterns': [r".*: warning: \[NonOverridingEquals\] .+"]},
503 {'category': 'java',
504 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700505 'description':
506 'Java: Constructors should not be annotated with @Nullable since they cannot return null',
507 'patterns': [r".*: warning: \[NullableConstructor\] .+"]},
508 {'category': 'java',
509 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700510 'description':
511 'Java: @Nullable should not be used for primitive types since they cannot be null',
512 'patterns': [r".*: warning: \[NullablePrimitive\] .+"]},
513 {'category': 'java',
514 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700515 'description':
516 'Java: void-returning methods should not be annotated with @Nullable, since they cannot return null',
517 'patterns': [r".*: warning: \[NullableVoid\] .+"]},
518 {'category': 'java',
519 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700520 'description':
521 'Java: Package names should match the directory they are declared in',
522 'patterns': [r".*: warning: \[PackageLocation\] .+"]},
523 {'category': 'java',
524 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700525 'description':
526 'Java: Second argument to Preconditions.* is a call to String.format(), which can be unwrapped',
527 'patterns': [r".*: warning: \[PreconditionsErrorMessageEagerEvaluation\] .+"]},
528 {'category': 'java',
529 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700530 'description':
531 'Java: Preconditions only accepts the %s placeholder in error message strings',
532 'patterns': [r".*: warning: \[PreconditionsInvalidPlaceholder\] .+"]},
533 {'category': 'java',
534 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700535 'description':
536 'Java: Passing a primitive array to a varargs method is usually wrong',
537 'patterns': [r".*: warning: \[PrimitiveArrayPassedToVarargsMethod\] .+"]},
538 {'category': 'java',
539 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700540 'description':
541 'Java: Protobuf fields cannot be null, so this check is redundant',
542 'patterns': [r".*: warning: \[ProtoFieldPreconditionsCheckNotNull\] .+"]},
543 {'category': 'java',
544 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700545 'description':
546 'Java: This annotation is missing required modifiers as specified by its @RequiredModifiers annotation',
547 'patterns': [r".*: warning: \[RequiredModifiers\] .+"]},
548 {'category': 'java',
549 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700550 'description':
551 'Java: A static variable or method should not be accessed from an object instance',
552 'patterns': [r".*: warning: \[StaticAccessedFromInstance\] .+"]},
553 {'category': 'java',
554 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700555 'description':
556 'Java: String comparison using reference equality instead of value equality',
557 'patterns': [r".*: warning: \[StringEquality\] .+"]},
558 {'category': 'java',
559 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700560 'description':
561 '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.',
562 'patterns': [r".*: warning: \[TypeParameterUnusedInFormals\] .+"]},
563 {'category': 'java',
564 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700565 'description':
566 'Java: Using static imports for types is unnecessary',
567 'patterns': [r".*: warning: \[UnnecessaryStaticImport\] .+"]},
568 {'category': 'java',
569 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700570 'description':
571 'Java: Unsynchronized method overrides a synchronized method.',
572 'patterns': [r".*: warning: \[UnsynchronizedOverridesSynchronized\] .+"]},
573 {'category': 'java',
574 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700575 'description':
576 'Java: Non-constant variable missing @Var annotation',
577 'patterns': [r".*: warning: \[Var\] .+"]},
578 {'category': 'java',
579 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700580 'description':
581 'Java: Because of spurious wakeups, Object.wait() and Condition.await() must always be called in a loop',
582 'patterns': [r".*: warning: \[WaitNotInLoop\] .+"]},
583 {'category': 'java',
584 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700585 'description':
586 'Java: Subclasses of Fragment must be instantiable via Class#newInstance(): the class must be public, static and have a public nullary constructor',
587 'patterns': [r".*: warning: \[FragmentNotInstantiable\] .+"]},
588 {'category': 'java',
589 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700590 'description':
591 'Java: Hardcoded reference to /sdcard',
592 'patterns': [r".*: warning: \[HardCodedSdCardPath\] .+"]},
593 {'category': 'java',
594 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700595 'description':
596 'Java: Incompatible type as argument to Object-accepting Java collections method',
597 'patterns': [r".*: warning: \[CollectionIncompatibleType\] .+"]},
598 {'category': 'java',
599 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700600 'description':
601 'Java: @AssistedInject and @Inject should not be used on different constructors in the same class.',
602 'patterns': [r".*: warning: \[AssistedInjectAndInjectOnConstructors\] .+"]},
603 {'category': 'java',
604 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700605 'description':
606 'Java: Although Guice allows injecting final fields, doing so is not recommended because the injected value may not be visible to other threads.',
607 'patterns': [r".*: warning: \[GuiceInjectOnFinalField\] .+"]},
608 {'category': 'java',
609 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700610 'description':
611 '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.',
612 'patterns': [r".*: warning: \[OverridesGuiceInjectableMethod\] .+"]},
613 {'category': 'java',
614 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700615 'description':
616 'Java: Double-checked locking on non-volatile fields is unsafe',
617 'patterns': [r".*: warning: \[DoubleCheckedLocking\] .+"]},
618 {'category': 'java',
619 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700620 'description':
621 'Java: Writes to static fields should not be guarded by instance locks',
622 'patterns': [r".*: warning: \[StaticGuardedByInstance\] .+"]},
623 {'category': 'java',
624 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700625 'description':
626 'Java: Synchronizing on non-final fields is not safe: if the field is ever updated, different threads may end up locking on different objects.',
627 'patterns': [r".*: warning: \[SynchronizeOnNonFinalField\] .+"]},
628 {'category': 'java',
629 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700630 'description':
631 'Java: Reference equality used to compare arrays',
632 'patterns': [r".*: warning: \[ArrayEquals\] .+"]},
633 {'category': 'java',
634 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700635 'description':
636 'Java: hashcode method on array does not hash array contents',
637 'patterns': [r".*: warning: \[ArrayHashCode\] .+"]},
638 {'category': 'java',
639 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700640 'description':
641 'Java: Calling toString on an array does not provide useful information',
642 'patterns': [r".*: warning: \[ArrayToString.*\] .+"]},
643 {'category': 'java',
644 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700645 'description':
646 'Java: Arrays.asList does not autobox primitive arrays, as one might expect.',
647 'patterns': [r".*: warning: \[ArraysAsListPrimitiveArray\] .+"]},
648 {'category': 'java',
649 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700650 'description':
651 'Java: AsyncCallable should not return a null Future, only a Future whose result is null.',
652 'patterns': [r".*: warning: \[AsyncCallableReturnsNull\] .+"]},
653 {'category': 'java',
654 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700655 'description':
656 'Java: AsyncFunction should not return a null Future, only a Future whose result is null.',
657 'patterns': [r".*: warning: \[AsyncFunctionReturnsNull\] .+"]},
658 {'category': 'java',
659 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700660 'description':
661 'Java: Possible sign flip from narrowing conversion',
662 'patterns': [r".*: warning: \[BadComparable\] .+"]},
663 {'category': 'java',
664 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700665 'description':
666 'Java: Shift by an amount that is out of range',
667 'patterns': [r".*: warning: \[BadShiftAmount\] .+"]},
668 {'category': 'java',
669 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700670 'description':
671 'Java: valueOf provides better time and space performance',
672 'patterns': [r".*: warning: \[BoxedPrimitiveConstructor\] .+"]},
673 {'category': 'java',
674 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700675 'description':
676 '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.',
677 'patterns': [r".*: warning: \[ChainingConstructorIgnoresParameter\] .+"]},
678 {'category': 'java',
679 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700680 'description':
681 'Java: Ignored return value of method that is annotated with @CheckReturnValue',
682 'patterns': [r".*: warning: \[CheckReturnValue\] .+"]},
683 {'category': 'java',
684 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700685 'description':
686 'Java: Inner class is non-static but does not reference enclosing class',
687 'patterns': [r".*: warning: \[ClassCanBeStatic\] .+"]},
688 {'category': 'java',
689 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700690 'description':
691 'Java: The source file name should match the name of the top-level class it contains',
692 'patterns': [r".*: warning: \[ClassName\] .+"]},
693 {'category': 'java',
694 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700695 'description':
696 'Java: This comparison method violates the contract',
697 'patterns': [r".*: warning: \[ComparisonContractViolated\] .+"]},
698 {'category': 'java',
699 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700700 'description':
701 'Java: Comparison to value that is out of range for the compared type',
702 'patterns': [r".*: warning: \[ComparisonOutOfRange\] .+"]},
703 {'category': 'java',
704 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700705 'description':
706 'Java: Non-compile-time constant expression passed to parameter with @CompileTimeConstant type annotation.',
707 'patterns': [r".*: warning: \[CompileTimeConstant\] .+"]},
708 {'category': 'java',
709 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700710 'description':
711 'Java: Exception created but not thrown',
712 'patterns': [r".*: warning: \[DeadException\] .+"]},
713 {'category': 'java',
714 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700715 'description':
716 'Java: Division by integer literal zero',
717 'patterns': [r".*: warning: \[DivZero\] .+"]},
718 {'category': 'java',
719 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700720 'description':
721 'Java: Empty statement after if',
722 'patterns': [r".*: warning: \[EmptyIf\] .+"]},
723 {'category': 'java',
724 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700725 'description':
726 'Java: == NaN always returns false; use the isNaN methods instead',
727 'patterns': [r".*: warning: \[EqualsNaN\] .+"]},
728 {'category': 'java',
729 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700730 'description':
731 'Java: Method annotated @ForOverride must be protected or package-private and only invoked from declaring class',
732 'patterns': [r".*: warning: \[ForOverride\] .+"]},
733 {'category': 'java',
734 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700735 'description':
736 'Java: Futures.getChecked requires a checked exception type with a standard constructor.',
737 'patterns': [r".*: warning: \[FuturesGetCheckedIllegalExceptionType\] .+"]},
738 {'category': 'java',
739 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700740 'description':
741 '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',
742 'patterns': [r".*: warning: \[GetClassOnClass\] .+"]},
743 {'category': 'java',
744 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700745 'description':
746 'Java: An object is tested for equality to itself using Guava Libraries',
747 'patterns': [r".*: warning: \[GuavaSelfEquals\] .+"]},
748 {'category': 'java',
749 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700750 'description':
751 'Java: contains() is a legacy method that is equivalent to containsValue()',
752 'patterns': [r".*: warning: \[HashtableContains\] .+"]},
753 {'category': 'java',
754 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700755 'description':
756 'Java: Cipher.getInstance() is invoked using either the default settings or ECB mode',
757 'patterns': [r".*: warning: \[InsecureCipherMode\] .+"]},
758 {'category': 'java',
759 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700760 'description':
761 'Java: Invalid syntax used for a regular expression',
762 'patterns': [r".*: warning: \[InvalidPatternSyntax\] .+"]},
763 {'category': 'java',
764 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700765 'description':
766 'Java: The argument to Class#isInstance(Object) should not be a Class',
767 'patterns': [r".*: warning: \[IsInstanceOfClass\] .+"]},
768 {'category': 'java',
769 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700770 'description':
771 'Java: jMock tests must have a @RunWith(JMock.class) annotation, or the Mockery field must have a @Rule JUnit annotation',
772 'patterns': [r".*: warning: \[JMockTestWithoutRunWithOrRuleAnnotation\] .+"]},
773 {'category': 'java',
774 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700775 'description':
776 'Java: Test method will not be run; please prefix name with "test"',
777 'patterns': [r".*: warning: \[JUnit3TestNotRun\] .+"]},
778 {'category': 'java',
779 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700780 'description':
781 'Java: setUp() method will not be run; Please add a @Before annotation',
782 'patterns': [r".*: warning: \[JUnit4SetUpNotRun\] .+"]},
783 {'category': 'java',
784 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700785 'description':
786 'Java: tearDown() method will not be run; Please add an @After annotation',
787 'patterns': [r".*: warning: \[JUnit4TearDownNotRun\] .+"]},
788 {'category': 'java',
789 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700790 'description':
791 'Java: Test method will not be run; please add @Test annotation',
792 'patterns': [r".*: warning: \[JUnit4TestNotRun\] .+"]},
793 {'category': 'java',
794 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700795 'description':
796 'Java: Printf-like format string does not match its arguments',
797 'patterns': [r".*: warning: \[MalformedFormatString\] .+"]},
798 {'category': 'java',
799 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700800 'description':
801 'Java: Use of "YYYY" (week year) in a date pattern without "ww" (week in year). You probably meant to use "yyyy" (year) instead.',
802 'patterns': [r".*: warning: \[MisusedWeekYear\] .+"]},
803 {'category': 'java',
804 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700805 'description':
806 'Java: A bug in Mockito will cause this test to fail at runtime with a ClassCastException',
807 'patterns': [r".*: warning: \[MockitoCast\] .+"]},
808 {'category': 'java',
809 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700810 'description':
811 'Java: Missing method call for verify(mock) here',
812 'patterns': [r".*: warning: \[MockitoUsage\] .+"]},
813 {'category': 'java',
814 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700815 'description':
816 'Java: Modifying a collection with itself',
817 'patterns': [r".*: warning: \[ModifyingCollectionWithItself\] .+"]},
818 {'category': 'java',
819 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700820 'description':
821 'Java: Compound assignments to bytes, shorts, chars, and floats hide dangerous casts',
822 'patterns': [r".*: warning: \[NarrowingCompoundAssignment\] .+"]},
823 {'category': 'java',
824 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700825 'description':
826 'Java: @NoAllocation was specified on this method, but something was found that would trigger an allocation',
827 'patterns': [r".*: warning: \[NoAllocation\] .+"]},
828 {'category': 'java',
829 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700830 'description':
831 'Java: Static import of type uses non-canonical name',
832 'patterns': [r".*: warning: \[NonCanonicalStaticImport\] .+"]},
833 {'category': 'java',
834 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700835 'description':
836 'Java: @CompileTimeConstant parameters should be final',
837 'patterns': [r".*: warning: \[NonFinalCompileTimeConstant\] .+"]},
838 {'category': 'java',
839 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700840 'description':
841 'Java: Calling getAnnotation on an annotation that is not retained at runtime.',
842 'patterns': [r".*: warning: \[NonRuntimeAnnotation\] .+"]},
843 {'category': 'java',
844 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700845 'description':
846 'Java: Numeric comparison using reference equality instead of value equality',
847 'patterns': [r".*: warning: \[NumericEquality\] .+"]},
848 {'category': 'java',
849 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700850 'description':
851 'Java: Comparison using reference equality instead of value equality',
852 'patterns': [r".*: warning: \[OptionalEquality\] .+"]},
853 {'category': 'java',
854 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700855 'description':
856 'Java: Varargs doesn\'t agree for overridden method',
857 'patterns': [r".*: warning: \[Overrides\] .+"]},
858 {'category': 'java',
859 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700860 'description':
861 'Java: Literal passed as first argument to Preconditions.checkNotNull() can never be null',
862 'patterns': [r".*: warning: \[PreconditionsCheckNotNull\] .+"]},
863 {'category': 'java',
864 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700865 'description':
866 'Java: First argument to `Preconditions.checkNotNull()` is a primitive rather than an object reference',
867 'patterns': [r".*: warning: \[PreconditionsCheckNotNullPrimitive\] .+"]},
868 {'category': 'java',
869 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700870 'description':
871 'Java: Protobuf fields cannot be null',
872 'patterns': [r".*: warning: \[ProtoFieldNullComparison\] .+"]},
873 {'category': 'java',
874 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700875 'description':
876 'Java: Comparing protobuf fields of type String using reference equality',
877 'patterns': [r".*: warning: \[ProtoStringFieldReferenceEquality\] .+"]},
878 {'category': 'java',
879 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700880 'description':
881 'Java: Check for non-whitelisted callers to RestrictedApiChecker.',
882 'patterns': [r".*: warning: \[RestrictedApiChecker\] .+"]},
883 {'category': 'java',
884 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700885 'description':
886 'Java: Return value of this method must be used',
887 'patterns': [r".*: warning: \[ReturnValueIgnored\] .+"]},
888 {'category': 'java',
889 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700890 'description':
891 'Java: Variable assigned to itself',
892 'patterns': [r".*: warning: \[SelfAssignment\] .+"]},
893 {'category': 'java',
894 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700895 'description':
896 'Java: An object is compared to itself',
897 'patterns': [r".*: warning: \[SelfComparision\] .+"]},
898 {'category': 'java',
899 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700900 'description':
901 'Java: Variable compared to itself',
902 'patterns': [r".*: warning: \[SelfEquality\] .+"]},
903 {'category': 'java',
904 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700905 'description':
906 'Java: An object is tested for equality to itself',
907 'patterns': [r".*: warning: \[SelfEquals\] .+"]},
908 {'category': 'java',
909 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700910 'description':
911 'Java: Comparison of a size >= 0 is always true, did you intend to check for non-emptiness?',
912 'patterns': [r".*: warning: \[SizeGreaterThanOrEqualsZero\] .+"]},
913 {'category': 'java',
914 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700915 'description':
916 'Java: Calling toString on a Stream does not provide useful information',
917 'patterns': [r".*: warning: \[StreamToString\] .+"]},
918 {'category': 'java',
919 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700920 'description':
921 'Java: StringBuilder does not have a char constructor; this invokes the int constructor.',
922 'patterns': [r".*: warning: \[StringBuilderInitWithChar\] .+"]},
923 {'category': 'java',
924 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700925 'description':
926 'Java: Suppressing "deprecated" is probably a typo for "deprecation"',
927 'patterns': [r".*: warning: \[SuppressWarningsDeprecated\] .+"]},
928 {'category': 'java',
929 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700930 'description':
931 'Java: throwIfUnchecked(knownCheckedException) is a no-op.',
932 'patterns': [r".*: warning: \[ThrowIfUncheckedKnownChecked\] .+"]},
933 {'category': 'java',
934 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700935 'description':
936 'Java: Catching Throwable/Error masks failures from fail() or assert*() in the try block',
937 'patterns': [r".*: warning: \[TryFailThrowable\] .+"]},
938 {'category': 'java',
939 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700940 'description':
941 'Java: Type parameter used as type qualifier',
942 'patterns': [r".*: warning: \[TypeParameterQualifier\] .+"]},
943 {'category': 'java',
944 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700945 'description':
946 'Java: Non-generic methods should not be invoked with type arguments',
947 'patterns': [r".*: warning: \[UnnecessaryTypeArgument\] .+"]},
948 {'category': 'java',
949 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700950 'description':
951 'Java: Instance created but never used',
952 'patterns': [r".*: warning: \[UnusedAnonymousClass\] .+"]},
953 {'category': 'java',
954 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700955 'description':
956 'Java: Use of wildcard imports is forbidden',
957 'patterns': [r".*: warning: \[WildcardImport\] .+"]},
958 {'category': 'java',
959 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700960 'description':
961 'Java: Method parameter has wrong package',
962 'patterns': [r".*: warning: \[ParameterPackage\] .+"]},
963 {'category': 'java',
964 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700965 'description':
966 'Java: Certain resources in `android.R.string` have names that do not match their content',
967 'patterns': [r".*: warning: \[MislabeledAndroidString\] .+"]},
968 {'category': 'java',
969 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700970 'description':
971 'Java: Return value of android.graphics.Rect.intersect() must be checked',
972 'patterns': [r".*: warning: \[RectIntersectReturnValueIgnored\] .+"]},
973 {'category': 'java',
974 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700975 'description':
976 'Java: Invalid printf-style format string',
977 'patterns': [r".*: warning: \[FormatString\] .+"]},
978 {'category': 'java',
979 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700980 'description':
981 'Java: @AssistedInject and @Inject cannot be used on the same constructor.',
982 'patterns': [r".*: warning: \[AssistedInjectAndInjectOnSameConstructor\] .+"]},
983 {'category': 'java',
984 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700985 'description':
986 'Java: Injected constructors cannot be optional nor have binding annotations',
987 'patterns': [r".*: warning: \[InjectedConstructorAnnotations\] .+"]},
988 {'category': 'java',
989 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700990 'description':
991 'Java: The target of a scoping annotation must be set to METHOD and/or TYPE.',
992 'patterns': [r".*: warning: \[InjectInvalidTargetingOnScopingAnnotation\] .+"]},
993 {'category': 'java',
994 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700995 'description':
996 'Java: Abstract methods are not injectable with javax.inject.Inject.',
997 'patterns': [r".*: warning: \[JavaxInjectOnAbstractMethod\] .+"]},
998 {'category': 'java',
999 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001000 'description':
1001 'Java: @javax.inject.Inject cannot be put on a final field.',
1002 'patterns': [r".*: warning: \[JavaxInjectOnFinalField\] .+"]},
1003 {'category': 'java',
1004 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001005 'description':
1006 'Java: A class may not have more than one injectable constructor.',
1007 'patterns': [r".*: warning: \[MoreThanOneInjectableConstructor\] .+"]},
1008 {'category': 'java',
1009 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001010 'description':
1011 'Java: Using more than one qualifier annotation on the same element is not allowed.',
1012 'patterns': [r".*: warning: \[InjectMoreThanOneQualifier\] .+"]},
1013 {'category': 'java',
1014 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001015 'description':
1016 'Java: A class can be annotated with at most one scope annotation',
1017 'patterns': [r".*: warning: \[InjectMoreThanOneScopeAnnotationOnClass\] .+"]},
1018 {'category': 'java',
1019 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001020 'description':
1021 'Java: Annotations cannot be both Qualifiers/BindingAnnotations and Scopes',
1022 'patterns': [r".*: warning: \[OverlappingQualifierAndScopeAnnotation\] .+"]},
1023 {'category': 'java',
1024 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001025 'description':
1026 'Java: Scope annotation on an interface or abstact class is not allowed',
1027 'patterns': [r".*: warning: \[InjectScopeAnnotationOnInterfaceOrAbstractClass\] .+"]},
1028 {'category': 'java',
1029 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001030 'description':
1031 'Java: Scoping and qualifier annotations must have runtime retention.',
1032 'patterns': [r".*: warning: \[InjectScopeOrQualifierAnnotationRetention\] .+"]},
1033 {'category': 'java',
1034 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001035 'description':
1036 'Java: Dagger @Provides methods may not return null unless annotated with @Nullable',
1037 'patterns': [r".*: warning: \[DaggerProvidesNull\] .+"]},
1038 {'category': 'java',
1039 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001040 'description':
1041 'Java: Scope annotation on implementation class of AssistedInject factory is not allowed',
1042 'patterns': [r".*: warning: \[GuiceAssistedInjectScoping\] .+"]},
1043 {'category': 'java',
1044 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001045 'description':
1046 'Java: A constructor cannot have two @Assisted parameters of the same type unless they are disambiguated with named @Assisted annotations. ',
1047 'patterns': [r".*: warning: \[GuiceAssistedParameters\] .+"]},
1048 {'category': 'java',
1049 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001050 'description':
1051 'Java: This method is not annotated with @Inject, but it overrides a method that is annotated with @javax.inject.Inject.',
1052 'patterns': [r".*: warning: \[OverridesJavaxInjectableMethod\] .+"]},
1053 {'category': 'java',
1054 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001055 'description':
1056 'Java: Checks for unguarded accesses to fields and methods with @GuardedBy annotations',
1057 'patterns': [r".*: warning: \[GuardedByChecker\] .+"]},
1058 {'category': 'java',
1059 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001060 'description':
1061 'Java: Invalid @GuardedBy expression',
1062 'patterns': [r".*: warning: \[GuardedByValidator\] .+"]},
1063 {'category': 'java',
1064 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001065 'description':
1066 'Java: Type declaration annotated with @Immutable is not immutable',
1067 'patterns': [r".*: warning: \[Immutable\] .+"]},
1068 {'category': 'java',
1069 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001070 'description':
1071 'Java: This method does not acquire the locks specified by its @LockMethod annotation',
1072 'patterns': [r".*: warning: \[LockMethodChecker\] .+"]},
1073 {'category': 'java',
1074 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001075 'description':
1076 'Java: This method does not acquire the locks specified by its @UnlockMethod annotation',
1077 'patterns': [r".*: warning: \[UnlockMethod\] .+"]},
Ian Rogers32bb9bd2016-05-09 23:19:42 -07001078
Ian Rogers6e520032016-05-13 08:59:00 -07001079 {'category': 'java',
1080 'severity': severity.UNKNOWN,
Ian Rogers6e520032016-05-13 08:59:00 -07001081 'description': 'Java: Unclassified/unrecognized warnings',
1082 'patterns': [r".*: warning: \[.+\] .+"]},
Ian Rogers32bb9bd2016-05-09 23:19:42 -07001083
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001084 { 'category':'aapt', 'severity':severity.MEDIUM,
Marco Nelissen8e201962010-03-10 16:16:02 -08001085 'description':'aapt: No default translation',
1086 'patterns':[r".*: warning: string '.+' has no default translation in .*"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001087 { 'category':'aapt', 'severity':severity.MEDIUM,
Marco Nelissen8e201962010-03-10 16:16:02 -08001088 'description':'aapt: Missing default or required localization',
1089 'patterns':[r".*: warning: \*\*\*\* string '.+' has no default or required localization for '.+' in .+"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001090 { 'category':'aapt', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -07001091 'description':'aapt: String marked untranslatable, but translation exists',
1092 'patterns':[r".*: warning: string '.+' in .* marked untranslatable but exists in locale '??_??'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001093 { 'category':'aapt', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -07001094 'description':'aapt: empty span in string',
1095 'patterns':[r".*: warning: empty '.+' span found in text '.+"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001096 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -07001097 'description':'Taking address of temporary',
1098 'patterns':[r".*: warning: taking address of temporary"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001099 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -07001100 'description':'Possible broken line continuation',
1101 'patterns':[r".*: warning: backslash and newline separated by space"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001102 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wundefined-var-template',
Chih-Hung Hsiehc21ddbd2016-07-20 10:08:51 -07001103 'description':'Undefined variable template',
1104 'patterns':[r".*: warning: instantiation of variable .* no definition is available"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001105 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wundefined-inline',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001106 'description':'Inline function is not defined',
1107 'patterns':[r".*: warning: inline function '.*' is not defined"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001108 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Warray-bounds',
Marco Nelissen594375d2009-07-14 09:04:04 -07001109 'description':'Array subscript out of bounds',
Marco Nelissen8e201962010-03-10 16:16:02 -08001110 'patterns':[r".*: warning: array subscript is above array bounds",
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001111 r".*: warning: Array subscript is undefined",
Marco Nelissen8e201962010-03-10 16:16:02 -08001112 r".*: warning: array subscript is below array bounds"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001113 { 'category':'C/C++', 'severity':severity.MEDIUM,
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001114 'description':'Excess elements in initializer',
1115 'patterns':[r".*: warning: excess elements in .+ initializer"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001116 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -07001117 'description':'Decimal constant is unsigned only in ISO C90',
1118 'patterns':[r".*: warning: this decimal constant is unsigned only in ISO C90"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001119 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wmain',
Marco Nelissen594375d2009-07-14 09:04:04 -07001120 'description':'main is usually a function',
1121 'patterns':[r".*: warning: 'main' is usually a function"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001122 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -07001123 'description':'Typedef ignored',
1124 'patterns':[r".*: warning: 'typedef' was ignored in this declaration"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001125 { 'category':'C/C++', 'severity':severity.HIGH, 'option':'-Waddress',
Marco Nelissen594375d2009-07-14 09:04:04 -07001126 'description':'Address always evaluates to true',
1127 'patterns':[r".*: warning: the address of '.+' will always evaluate as 'true'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001128 { 'category':'C/C++', 'severity':severity.FIXMENOW,
Marco Nelissen594375d2009-07-14 09:04:04 -07001129 'description':'Freeing a non-heap object',
1130 'patterns':[r".*: warning: attempt to free a non-heap object '.+'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001131 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wchar-subscripts',
Marco Nelissen594375d2009-07-14 09:04:04 -07001132 'description':'Array subscript has type char',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001133 'patterns':[r".*: warning: array subscript .+ type 'char'.+Wchar-subscripts"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001134 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -07001135 'description':'Constant too large for type',
1136 'patterns':[r".*: warning: integer constant is too large for '.+' type"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001137 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Woverflow',
Marco Nelissen594375d2009-07-14 09:04:04 -07001138 'description':'Constant too large for type, truncated',
1139 'patterns':[r".*: warning: large integer implicitly truncated to unsigned type"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001140 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Winteger-overflow',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001141 'description':'Overflow in expression',
1142 'patterns':[r".*: warning: overflow in expression; .*Winteger-overflow"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001143 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Woverflow',
Marco Nelissen594375d2009-07-14 09:04:04 -07001144 'description':'Overflow in implicit constant conversion',
1145 'patterns':[r".*: warning: overflow in implicit constant conversion"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001146 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -07001147 'description':'Declaration does not declare anything',
1148 'patterns':[r".*: warning: declaration 'class .+' does not declare anything"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001149 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wreorder',
Marco Nelissen594375d2009-07-14 09:04:04 -07001150 'description':'Initialization order will be different',
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001151 'patterns':[r".*: warning: '.+' will be initialized after",
1152 r".*: warning: field .+ will be initialized after .+Wreorder"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001153 { 'category':'cont.', 'severity':severity.SKIP,
Marco Nelissen594375d2009-07-14 09:04:04 -07001154 'description':'',
1155 'patterns':[r".*: warning: '.+'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001156 { 'category':'cont.', 'severity':severity.SKIP,
Marco Nelissen594375d2009-07-14 09:04:04 -07001157 'description':'',
Marco Nelissen8e201962010-03-10 16:16:02 -08001158 'patterns':[r".*: warning: base '.+'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001159 { 'category':'cont.', 'severity':severity.SKIP,
Marco Nelissen8e201962010-03-10 16:16:02 -08001160 'description':'',
Marco Nelissen594375d2009-07-14 09:04:04 -07001161 'patterns':[r".*: warning: when initialized here"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001162 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wmissing-parameter-type',
Marco Nelissen594375d2009-07-14 09:04:04 -07001163 'description':'Parameter type not specified',
1164 'patterns':[r".*: warning: type of '.+' defaults to 'int'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001165 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wmissing-declarations',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001166 'description':'Missing declarations',
1167 'patterns':[r".*: warning: declaration does not declare anything"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001168 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wmissing-noreturn',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001169 'description':'Missing noreturn',
1170 'patterns':[r".*: warning: function '.*' could be declared with attribute 'noreturn'"] },
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001171 # pylint:disable=anomalous-backslash-in-string
1172 # TODO(chh): fix the backslash pylint warning.
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001173 { 'category':'gcc', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -07001174 'description':'Invalid option for C file',
1175 'patterns':[r".*: warning: command line option "".+"" is valid for C\+\+\/ObjC\+\+ but not for C"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001176 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -07001177 'description':'User warning',
1178 'patterns':[r".*: warning: #warning "".+"""] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001179 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wvexing-parse',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001180 'description':'Vexing parsing problem',
1181 'patterns':[r".*: warning: empty parentheses interpreted as a function declaration"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001182 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wextra',
Marco Nelissen594375d2009-07-14 09:04:04 -07001183 'description':'Dereferencing void*',
1184 'patterns':[r".*: warning: dereferencing 'void \*' pointer"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001185 { 'category':'C/C++', 'severity':severity.MEDIUM,
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001186 'description':'Comparison of pointer and integer',
1187 'patterns':[r".*: warning: ordered comparison of pointer with integer zero",
1188 r".*: warning: .*comparison between pointer and integer"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001189 { 'category':'C/C++', 'severity':severity.MEDIUM,
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001190 'description':'Use of error-prone unary operator',
1191 'patterns':[r".*: warning: use of unary operator that may be intended as compound assignment"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001192 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wwrite-strings',
Marco Nelissen594375d2009-07-14 09:04:04 -07001193 'description':'Conversion of string constant to non-const char*',
1194 'patterns':[r".*: warning: deprecated conversion from string constant to '.+'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001195 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wstrict-prototypes',
Marco Nelissen594375d2009-07-14 09:04:04 -07001196 'description':'Function declaration isn''t a prototype',
1197 'patterns':[r".*: warning: function declaration isn't a prototype"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001198 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wignored-qualifiers',
Marco Nelissen594375d2009-07-14 09:04:04 -07001199 'description':'Type qualifiers ignored on function return value',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001200 'patterns':[r".*: warning: type qualifiers ignored on function return type",
1201 r".*: warning: .+ type qualifier .+ has no effect .+Wignored-qualifiers"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001202 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -07001203 'description':'<foo> declared inside parameter list, scope limited to this definition',
1204 'patterns':[r".*: warning: '.+' declared inside parameter list"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001205 { 'category':'cont.', 'severity':severity.SKIP,
Marco Nelissen594375d2009-07-14 09:04:04 -07001206 'description':'',
1207 '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 -07001208 { 'category':'C/C++', 'severity':severity.LOW, 'option':'-Wcomment',
Marco Nelissen594375d2009-07-14 09:04:04 -07001209 'description':'Line continuation inside comment',
1210 'patterns':[r".*: warning: multi-line comment"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001211 { 'category':'C/C++', 'severity':severity.LOW, 'option':'-Wcomment',
Marco Nelissen8e201962010-03-10 16:16:02 -08001212 'description':'Comment inside comment',
1213 'patterns':[r".*: warning: "".+"" within comment"] },
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001214 # Warning "value stored is never read" could be from clang-tidy or clang static analyzer.
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001215 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001216 'description':'clang-tidy Value stored is never read',
1217 'patterns':[r".*: warning: Value stored to .+ is never read.*clang-analyzer-deadcode.DeadStores"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001218 { 'category':'C/C++', 'severity':severity.LOW,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001219 'description':'Value stored is never read',
1220 'patterns':[r".*: warning: Value stored to .+ is never read"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001221 { 'category':'C/C++', 'severity':severity.LOW, 'option':'-Wdeprecated-declarations',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001222 'description':'Deprecated declarations',
1223 'patterns':[r".*: warning: .+ is deprecated.+deprecated-declarations"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001224 { 'category':'C/C++', 'severity':severity.LOW, 'option':'-Wdeprecated-register',
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001225 'description':'Deprecated register',
1226 'patterns':[r".*: warning: 'register' storage class specifier is deprecated"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001227 { 'category':'C/C++', 'severity':severity.LOW, 'option':'-Wpointer-sign',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001228 'description':'Converts between pointers to integer types with different sign',
1229 'patterns':[r".*: warning: .+ converts between pointers to integer types with different sign"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001230 { 'category':'C/C++', 'severity':severity.HARMLESS,
Marco Nelissen594375d2009-07-14 09:04:04 -07001231 'description':'Extra tokens after #endif',
1232 'patterns':[r".*: warning: extra tokens at end of #endif directive"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001233 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wenum-compare',
Marco Nelissen594375d2009-07-14 09:04:04 -07001234 'description':'Comparison between different enums',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001235 'patterns':[r".*: warning: comparison between '.+' and '.+'.+Wenum-compare"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001236 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wconversion',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001237 'description':'Conversion may change value',
1238 'patterns':[r".*: warning: converting negative value '.+' to '.+'",
Chih-Hung Hsieh01530a62016-08-24 12:24:32 -07001239 r".*: warning: conversion to '.+' .+ may (alter|change)"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001240 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wconversion-null',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001241 'description':'Converting to non-pointer type from NULL',
1242 'patterns':[r".*: warning: converting to non-pointer type '.+' from NULL"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001243 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wnull-conversion',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001244 'description':'Converting NULL to non-pointer type',
1245 'patterns':[r".*: warning: implicit conversion of NULL constant to '.+'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001246 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wnon-literal-null-conversion',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001247 'description':'Zero used as null pointer',
1248 'patterns':[r".*: warning: expression .* zero treated as a null pointer constant"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001249 { 'category':'C/C++', 'severity':severity.MEDIUM,
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001250 'description':'Implicit conversion changes value',
Chih-Hung Hsiehc21ddbd2016-07-20 10:08:51 -07001251 'patterns':[r".*: warning: implicit conversion .* changes value from .* to .*-conversion"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001252 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -07001253 'description':'Passing NULL as non-pointer argument',
Marco Nelissen5236fbd2009-07-31 08:30:34 -07001254 'patterns':[r".*: warning: passing NULL to non-pointer argument [0-9]+ of '.+'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001255 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wctor-dtor-privacy',
Marco Nelissen594375d2009-07-14 09:04:04 -07001256 'description':'Class seems unusable because of private ctor/dtor' ,
1257 'patterns':[r".*: warning: all member functions in class '.+' are private"] },
1258 # 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 -07001259 { 'category':'C/C++', 'severity':severity.SKIP, 'option':'-Wctor-dtor-privacy',
Marco Nelissen594375d2009-07-14 09:04:04 -07001260 'description':'Class seems unusable because of private ctor/dtor' ,
1261 'patterns':[r".*: warning: 'class .+' only defines a private destructor and has no friends"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001262 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wctor-dtor-privacy',
Marco Nelissen594375d2009-07-14 09:04:04 -07001263 'description':'Class seems unusable because of private ctor/dtor' ,
1264 'patterns':[r".*: warning: 'class .+' only defines private constructors and has no friends"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001265 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wgnu-static-float-init',
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001266 'description':'In-class initializer for static const float/double' ,
1267 'patterns':[r".*: warning: in-class initializer for static data member of .+const (float|double)"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001268 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wpointer-arith',
Marco Nelissen594375d2009-07-14 09:04:04 -07001269 'description':'void* used in arithmetic' ,
1270 'patterns':[r".*: warning: pointer of type 'void \*' used in (arithmetic|subtraction)",
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001271 r".*: warning: arithmetic on .+ to void is a GNU extension.*Wpointer-arith",
Marco Nelissen594375d2009-07-14 09:04:04 -07001272 r".*: warning: wrong type argument to increment"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001273 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wsign-promo',
Marco Nelissen594375d2009-07-14 09:04:04 -07001274 'description':'Overload resolution chose to promote from unsigned or enum to signed type' ,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001275 'patterns':[r".*: warning: passing '.+' chooses '.+' over '.+'.*Wsign-promo"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001276 { 'category':'cont.', 'severity':severity.SKIP,
Marco Nelissen594375d2009-07-14 09:04:04 -07001277 'description':'',
1278 'patterns':[r".*: warning: in call to '.+'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001279 { 'category':'C/C++', 'severity':severity.HIGH, 'option':'-Wextra',
Marco Nelissen5236fbd2009-07-31 08:30:34 -07001280 'description':'Base should be explicitly initialized in copy constructor',
1281 'patterns':[r".*: warning: base class '.+' should be explicitly initialized in the copy constructor"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001282 { 'category':'C/C++', 'severity':severity.MEDIUM,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001283 'description':'VLA has zero or negative size',
1284 'patterns':[r".*: warning: Declared variable-length array \(VLA\) has .+ size"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001285 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen8e201962010-03-10 16:16:02 -08001286 'description':'Return value from void function',
1287 'patterns':[r".*: warning: 'return' with a value, in function returning void"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001288 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'multichar',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001289 'description':'Multi-character character constant',
1290 'patterns':[r".*: warning: multi-character character constant"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001291 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'writable-strings',
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001292 'description':'Conversion from string literal to char*',
1293 'patterns':[r".*: warning: .+ does not allow conversion from string literal to 'char \*'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001294 { 'category':'C/C++', 'severity':severity.LOW, 'option':'-Wextra-semi',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001295 'description':'Extra \';\'',
1296 'patterns':[r".*: warning: extra ';' .+extra-semi"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001297 { 'category':'C/C++', 'severity':severity.LOW,
Marco Nelissen8e201962010-03-10 16:16:02 -08001298 'description':'Useless specifier',
1299 'patterns':[r".*: warning: useless storage class specifier in empty declaration"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001300 { 'category':'C/C++', 'severity':severity.LOW, 'option':'-Wduplicate-decl-specifier',
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001301 'description':'Duplicate declaration specifier',
1302 'patterns':[r".*: warning: duplicate '.+' declaration specifier"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001303 { 'category':'logtags', 'severity':severity.LOW,
Marco Nelissen8e201962010-03-10 16:16:02 -08001304 'description':'Duplicate logtag',
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001305 'patterns':[r".*: warning: tag \".+\" \(.+\) duplicated in .+"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001306 { 'category':'logtags', 'severity':severity.LOW, 'option':'typedef-redefinition',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001307 'description':'Typedef redefinition',
1308 'patterns':[r".*: warning: redefinition of typedef '.+' is a C11 feature"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001309 { 'category':'logtags', 'severity':severity.LOW, 'option':'gnu-designator',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001310 'description':'GNU old-style field designator',
1311 'patterns':[r".*: warning: use of GNU old-style field designator extension"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001312 { 'category':'logtags', 'severity':severity.LOW, 'option':'missing-field-initializers',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001313 'description':'Missing field initializers',
1314 'patterns':[r".*: warning: missing field '.+' initializer"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001315 { 'category':'logtags', 'severity':severity.LOW, 'option':'missing-braces',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001316 'description':'Missing braces',
1317 'patterns':[r".*: warning: suggest braces around initialization of",
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001318 r".*: warning: too many braces around scalar initializer .+Wmany-braces-around-scalar-init",
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001319 r".*: warning: braces around scalar initializer"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001320 { 'category':'logtags', 'severity':severity.LOW, 'option':'sign-compare',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001321 'description':'Comparison of integers of different signs',
1322 'patterns':[r".*: warning: comparison of integers of different signs.+sign-compare"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001323 { 'category':'logtags', 'severity':severity.LOW, 'option':'dangling-else',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001324 'description':'Add braces to avoid dangling else',
1325 'patterns':[r".*: warning: add explicit braces to avoid dangling else"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001326 { 'category':'logtags', 'severity':severity.LOW, 'option':'initializer-overrides',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001327 'description':'Initializer overrides prior initialization',
1328 'patterns':[r".*: warning: initializer overrides prior initialization of this subobject"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001329 { 'category':'logtags', 'severity':severity.LOW, 'option':'self-assign',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001330 'description':'Assigning value to self',
1331 'patterns':[r".*: warning: explicitly assigning value of .+ to itself"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001332 { 'category':'logtags', 'severity':severity.LOW, 'option':'gnu-variable-sized-type-not-at-end',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001333 'description':'GNU extension, variable sized type not at end',
1334 '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 -07001335 { 'category':'logtags', 'severity':severity.LOW, 'option':'tautological-constant-out-of-range-compare',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001336 'description':'Comparison of constant is always false/true',
1337 'patterns':[r".*: comparison of .+ is always .+Wtautological-constant-out-of-range-compare"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001338 { 'category':'logtags', 'severity':severity.LOW, 'option':'overloaded-virtual',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001339 'description':'Hides overloaded virtual function',
1340 'patterns':[r".*: '.+' hides overloaded virtual function"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001341 { 'category':'logtags', 'severity':severity.LOW, 'option':'incompatible-pointer-types',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001342 'description':'Incompatible pointer types',
1343 'patterns':[r".*: warning: incompatible pointer types .+Wincompatible-pointer-types"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001344 { 'category':'logtags', 'severity':severity.LOW, 'option':'asm-operand-widths',
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001345 'description':'ASM value size does not match register size',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001346 'patterns':[r".*: warning: value size does not match register size specified by the constraint and modifier"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001347 { 'category':'C/C++', 'severity':severity.LOW, 'option':'tautological-compare',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001348 'description':'Comparison of self is always false',
1349 'patterns':[r".*: self-comparison always evaluates to false"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001350 { 'category':'C/C++', 'severity':severity.LOW, 'option':'constant-logical-operand',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001351 'description':'Logical op with constant operand',
1352 'patterns':[r".*: use of logical '.+' with constant operand"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001353 { 'category':'C/C++', 'severity':severity.LOW, 'option':'literal-suffix',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001354 'description':'Needs a space between literal and string macro',
1355 'patterns':[r".*: warning: invalid suffix on literal.+ requires a space .+Wliteral-suffix"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001356 { 'category':'C/C++', 'severity':severity.LOW, 'option':'#warnings',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001357 'description':'Warnings from #warning',
1358 'patterns':[r".*: warning: .+-W#warnings"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001359 { 'category':'C/C++', 'severity':severity.LOW, 'option':'absolute-value',
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001360 'description':'Using float/int absolute value function with int/float argument',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001361 'patterns':[r".*: warning: using .+ absolute value function .+ when argument is .+ type .+Wabsolute-value",
1362 r".*: warning: absolute value function '.+' given .+ which may cause truncation .+Wabsolute-value"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001363 { 'category':'C/C++', 'severity':severity.LOW, 'option':'-Wc++11-extensions',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001364 'description':'Using C++11 extensions',
1365 'patterns':[r".*: warning: 'auto' type specifier is a C\+\+11 extension"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001366 { 'category':'C/C++', 'severity':severity.LOW,
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001367 'description':'Refers to implicitly defined namespace',
1368 'patterns':[r".*: warning: using directive refers to implicitly-defined namespace .+"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001369 { 'category':'C/C++', 'severity':severity.LOW, 'option':'-Winvalid-pp-token',
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001370 'description':'Invalid pp token',
1371 'patterns':[r".*: warning: missing .+Winvalid-pp-token"] },
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001372
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001373 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen8e201962010-03-10 16:16:02 -08001374 'description':'Operator new returns NULL',
1375 'patterns':[r".*: warning: 'operator new' must not return NULL unless it is declared 'throw\(\)' .+"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001376 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wnull-arithmetic',
Marco Nelissen8e201962010-03-10 16:16:02 -08001377 'description':'NULL used in arithmetic',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001378 'patterns':[r".*: warning: NULL used in arithmetic",
1379 r".*: warning: comparison between NULL and non-pointer"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001380 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'header-guard',
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001381 'description':'Misspelled header guard',
1382 'patterns':[r".*: warning: '.+' is used as a header guard .+ followed by .+ different macro"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001383 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'empty-body',
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001384 'description':'Empty loop body',
1385 'patterns':[r".*: warning: .+ loop has empty body"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001386 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'enum-conversion',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001387 'description':'Implicit conversion from enumeration type',
1388 'patterns':[r".*: warning: implicit conversion from enumeration type '.+'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001389 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'switch',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001390 'description':'case value not in enumerated type',
1391 'patterns':[r".*: warning: case value not in enumerated type '.+'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001392 { 'category':'C/C++', 'severity':severity.MEDIUM,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001393 'description':'Undefined result',
1394 'patterns':[r".*: warning: The result of .+ is undefined",
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07001395 r".*: warning: passing an object that .+ has undefined behavior \[-Wvarargs\]",
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001396 r".*: warning: 'this' pointer cannot be null in well-defined C\+\+ code;",
1397 r".*: warning: shifting a negative signed value is undefined"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001398 { 'category':'C/C++', 'severity':severity.MEDIUM,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001399 'description':'Division by zero',
1400 'patterns':[r".*: warning: Division by zero"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001401 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen8e201962010-03-10 16:16:02 -08001402 'description':'Use of deprecated method',
1403 'patterns':[r".*: warning: '.+' is deprecated .+"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001404 { 'category':'C/C++', 'severity':severity.MEDIUM,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001405 'description':'Use of garbage or uninitialized value',
1406 'patterns':[r".*: warning: .+ is a garbage value",
1407 r".*: warning: Function call argument is an uninitialized value",
1408 r".*: warning: Undefined or garbage value returned to caller",
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001409 r".*: warning: Called .+ pointer is.+uninitialized",
1410 r".*: warning: Called .+ pointer is.+uninitalized", # match a typo in compiler message
1411 r".*: warning: Use of zero-allocated memory",
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001412 r".*: warning: Dereference of undefined pointer value",
1413 r".*: warning: Passed-by-value .+ contains uninitialized data",
1414 r".*: warning: Branch condition evaluates to a garbage value",
1415 r".*: warning: The .+ of .+ is an uninitialized value.",
1416 r".*: warning: .+ is used uninitialized whenever .+sometimes-uninitialized",
1417 r".*: warning: Assigned value is garbage or undefined"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001418 { 'category':'C/C++', 'severity':severity.MEDIUM,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001419 'description':'Result of malloc type incompatible with sizeof operand type',
1420 'patterns':[r".*: warning: Result of '.+' is converted to .+ incompatible with sizeof operand type"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001421 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wsizeof-array-argument',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001422 'description':'Sizeof on array argument',
1423 'patterns':[r".*: warning: sizeof on array function parameter will return"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001424 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wsizeof-pointer-memacces',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001425 'description':'Bad argument size of memory access functions',
1426 'patterns':[r".*: warning: .+\[-Wsizeof-pointer-memaccess\]"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001427 { 'category':'C/C++', 'severity':severity.MEDIUM,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001428 'description':'Return value not checked',
1429 'patterns':[r".*: warning: The return value from .+ is not checked"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001430 { 'category':'C/C++', 'severity':severity.MEDIUM,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001431 'description':'Possible heap pollution',
1432 'patterns':[r".*: warning: .*Possible heap pollution from .+ type .+"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001433 { 'category':'C/C++', 'severity':severity.MEDIUM,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001434 'description':'Allocation size of 0 byte',
1435 'patterns':[r".*: warning: Call to .+ has an allocation size of 0 byte"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001436 { 'category':'C/C++', 'severity':severity.MEDIUM,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001437 'description':'Result of malloc type incompatible with sizeof operand type',
1438 'patterns':[r".*: warning: Result of '.+' is converted to .+ incompatible with sizeof operand type"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001439 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wfor-loop-analysis',
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001440 'description':'Variable used in loop condition not modified in loop body',
1441 'patterns':[r".*: warning: variable '.+' used in loop condition.*Wfor-loop-analysis"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001442 { 'category':'C/C++', 'severity':severity.MEDIUM,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001443 'description':'Closing a previously closed file',
1444 'patterns':[r".*: warning: Closing a previously closed file"] },
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001445
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001446 { 'category':'C/C++', 'severity':severity.HARMLESS,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001447 'description':'Discarded qualifier from pointer target type',
1448 'patterns':[r".*: warning: .+ discards '.+' qualifier from pointer target type"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001449 { 'category':'C/C++', 'severity':severity.HARMLESS,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001450 'description':'Use snprintf instead of sprintf',
1451 'patterns':[r".*: warning: .*sprintf is often misused; please use snprintf"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001452 { 'category':'C/C++', 'severity':severity.HARMLESS,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001453 'description':'Unsupported optimizaton flag',
1454 'patterns':[r".*: warning: optimization flag '.+' is not supported"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001455 { 'category':'C/C++', 'severity':severity.HARMLESS,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001456 'description':'Extra or missing parentheses',
1457 'patterns':[r".*: warning: equality comparison with extraneous parentheses",
1458 r".*: warning: .+ within .+Wlogical-op-parentheses"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001459 { 'category':'C/C++', 'severity':severity.HARMLESS, 'option':'mismatched-tags',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001460 'description':'Mismatched class vs struct tags',
1461 'patterns':[r".*: warning: '.+' defined as a .+ here but previously declared as a .+mismatched-tags",
1462 r".*: warning: .+ was previously declared as a .+mismatched-tags"] },
Marco Nelissen594375d2009-07-14 09:04:04 -07001463
1464 # 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 -07001465 { 'category':'C/C++', 'severity':severity.SKIP,
Marco Nelissen594375d2009-07-14 09:04:04 -07001466 'description':'',
1467 'patterns':[r".*: warning: ,$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001468 { 'category':'C/C++', 'severity':severity.SKIP,
Marco Nelissen594375d2009-07-14 09:04:04 -07001469 'description':'',
1470 'patterns':[r".*: warning: $"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001471 { 'category':'C/C++', 'severity':severity.SKIP,
Marco Nelissen594375d2009-07-14 09:04:04 -07001472 'description':'',
1473 'patterns':[r".*: warning: In file included from .+,"] },
1474
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001475 # warnings from clang-tidy
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001476 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001477 'description':'clang-tidy readability',
1478 'patterns':[r".*: .+\[readability-.+\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001479 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001480 'description':'clang-tidy c++ core guidelines',
1481 'patterns':[r".*: .+\[cppcoreguidelines-.+\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001482 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsiehc21ddbd2016-07-20 10:08:51 -07001483 'description':'clang-tidy google-default-arguments',
1484 'patterns':[r".*: .+\[google-default-arguments\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001485 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsiehc21ddbd2016-07-20 10:08:51 -07001486 'description':'clang-tidy google-runtime-int',
1487 'patterns':[r".*: .+\[google-runtime-int\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001488 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsiehc21ddbd2016-07-20 10:08:51 -07001489 'description':'clang-tidy google-runtime-operator',
1490 'patterns':[r".*: .+\[google-runtime-operator\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001491 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsiehc21ddbd2016-07-20 10:08:51 -07001492 'description':'clang-tidy google-runtime-references',
1493 'patterns':[r".*: .+\[google-runtime-references\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001494 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001495 'description':'clang-tidy google-build',
1496 'patterns':[r".*: .+\[google-build-.+\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001497 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001498 'description':'clang-tidy google-explicit',
1499 'patterns':[r".*: .+\[google-explicit-.+\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001500 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsiehd742e902016-03-31 16:14:55 -07001501 'description':'clang-tidy google-readability',
1502 'patterns':[r".*: .+\[google-readability-.+\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001503 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsiehd742e902016-03-31 16:14:55 -07001504 'description':'clang-tidy google-global',
1505 'patterns':[r".*: .+\[google-global-.+\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001506 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsiehc21ddbd2016-07-20 10:08:51 -07001507 'description':'clang-tidy google- other',
1508 'patterns':[r".*: .+\[google-.+\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001509 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001510 'description':'clang-tidy modernize',
1511 'patterns':[r".*: .+\[modernize-.+\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001512 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001513 'description':'clang-tidy misc',
1514 'patterns':[r".*: .+\[misc-.+\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001515 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsiehc8682932016-07-26 14:27:03 -07001516 'description':'clang-tidy performance-faster-string-find',
1517 'patterns':[r".*: .+\[performance-faster-string-find\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001518 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsiehc8682932016-07-26 14:27:03 -07001519 'description':'clang-tidy performance-for-range-copy',
1520 'patterns':[r".*: .+\[performance-for-range-copy\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001521 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsiehc8682932016-07-26 14:27:03 -07001522 'description':'clang-tidy performance-implicit-cast-in-loop',
1523 'patterns':[r".*: .+\[performance-implicit-cast-in-loop\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001524 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsiehc8682932016-07-26 14:27:03 -07001525 'description':'clang-tidy performance-unnecessary-copy-initialization',
1526 'patterns':[r".*: .+\[performance-unnecessary-copy-initialization\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001527 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsiehc8682932016-07-26 14:27:03 -07001528 'description':'clang-tidy performance-unnecessary-value-param',
1529 'patterns':[r".*: .+\[performance-unnecessary-value-param\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001530 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001531 'description':'clang-analyzer Unreachable code',
1532 'patterns':[r".*: warning: This statement is never executed.*UnreachableCode"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001533 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001534 'description':'clang-analyzer Size of malloc may overflow',
1535 'patterns':[r".*: warning: .* size of .* may overflow .*MallocOverflow"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001536 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001537 'description':'clang-analyzer Stream pointer might be NULL',
1538 'patterns':[r".*: warning: Stream pointer might be NULL .*unix.Stream"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001539 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001540 'description':'clang-analyzer Opened file never closed',
1541 'patterns':[r".*: warning: Opened File never closed.*unix.Stream"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001542 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001543 'description':'clang-analyzer sozeof() on a pointer type',
1544 'patterns':[r".*: warning: .*calls sizeof.* on a pointer type.*SizeofPtr"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001545 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001546 'description':'clang-analyzer Pointer arithmetic on non-array variables',
1547 'patterns':[r".*: warning: Pointer arithmetic on non-array variables .*PointerArithm"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001548 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001549 'description':'clang-analyzer Subtraction of pointers of different memory chunks',
1550 'patterns':[r".*: warning: Subtraction of two pointers .*PointerSub"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001551 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001552 'description':'clang-analyzer Access out-of-bound array element',
1553 'patterns':[r".*: warning: Access out-of-bound array element .*ArrayBound"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001554 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001555 'description':'clang-analyzer Out of bound memory access',
1556 'patterns':[r".*: warning: Out of bound memory access .*ArrayBoundV2"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001557 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001558 'description':'clang-analyzer Possible lock order reversal',
1559 'patterns':[r".*: warning: .* Possible lock order reversal.*PthreadLock"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001560 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001561 'description':'clang-analyzer Argument is a pointer to uninitialized value',
1562 'patterns':[r".*: warning: .* argument is a pointer to uninitialized value .*CallAndMessage"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001563 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001564 'description':'clang-analyzer cast to struct',
1565 'patterns':[r".*: warning: Casting a non-structure type to a structure type .*CastToStruct"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001566 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001567 'description':'clang-analyzer call path problems',
1568 'patterns':[r".*: warning: Call Path : .+"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001569 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001570 'description':'clang-analyzer other',
1571 'patterns':[r".*: .+\[clang-analyzer-.+\]$",
1572 r".*: Call Path : .+$"] },
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 CERT',
1575 'patterns':[r".*: .+\[cert-.+\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001576 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001577 'description':'clang-tidy llvm',
1578 'patterns':[r".*: .+\[llvm-.+\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001579 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001580 'description':'clang-diagnostic',
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001581 'patterns':[r".*: .+\[clang-diagnostic-.+\]$"] },
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001582
Marco Nelissen594375d2009-07-14 09:04:04 -07001583 # catch-all for warnings this script doesn't know about yet
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001584 { 'category':'C/C++', 'severity':severity.UNKNOWN,
Marco Nelissen594375d2009-07-14 09:04:04 -07001585 'description':'Unclassified/unrecognized warnings',
1586 'patterns':[r".*: warning: .+"] },
1587]
1588
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001589
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001590# A list of [project_name, file_path_pattern].
1591# project_name should not contain comma, to be used in CSV output.
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001592project_list = [
1593 # pylint:disable=bad-whitespace,g-inconsistent-quotes,line-too-long
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07001594 ['art', r"(^|.*/)art/.*: warning:"],
1595 ['bionic', r"(^|.*/)bionic/.*: warning:"],
1596 ['bootable', r"(^|.*/)bootable/.*: warning:"],
1597 ['build', r"(^|.*/)build/.*: warning:"],
1598 ['cts', r"(^|.*/)cts/.*: warning:"],
1599 ['dalvik', r"(^|.*/)dalvik/.*: warning:"],
1600 ['developers', r"(^|.*/)developers/.*: warning:"],
1601 ['development', r"(^|.*/)development/.*: warning:"],
1602 ['device', r"(^|.*/)device/.*: warning:"],
1603 ['doc', r"(^|.*/)doc/.*: warning:"],
1604 # match external/google* before external/
1605 ['external/google', r"(^|.*/)external/google.*: warning:"],
1606 ['external/non-google', r"(^|.*/)external/.*: warning:"],
1607 ['frameworks', r"(^|.*/)frameworks/.*: warning:"],
1608 ['hardware', r"(^|.*/)hardware/.*: warning:"],
1609 ['kernel', r"(^|.*/)kernel/.*: warning:"],
1610 ['libcore', r"(^|.*/)libcore/.*: warning:"],
1611 ['libnativehelper', r"(^|.*/)libnativehelper/.*: warning:"],
1612 ['ndk', r"(^|.*/)ndk/.*: warning:"],
1613 ['packages', r"(^|.*/)packages/.*: warning:"],
1614 ['pdk', r"(^|.*/)pdk/.*: warning:"],
1615 ['prebuilts', r"(^|.*/)prebuilts/.*: warning:"],
1616 ['system', r"(^|.*/)system/.*: warning:"],
1617 ['toolchain', r"(^|.*/)toolchain/.*: warning:"],
1618 ['test', r"(^|.*/)test/.*: warning:"],
1619 ['tools', r"(^|.*/)tools/.*: warning:"],
1620 # match vendor/google* before vendor/
1621 ['vendor/google', r"(^|.*/)vendor/google.*: warning:"],
1622 ['vendor/non-google', r"(^|.*/)vendor/.*: warning:"],
1623 # keep out/obj and other patterns at the end.
1624 ['out/obj', r".*/(gen|obj[^/]*)/(include|EXECUTABLES|SHARED_LIBRARIES|STATIC_LIBRARIES)/.*: warning:"],
1625 ['other', r".*: warning:"],
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001626]
1627
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001628project_patterns = []
1629project_names = []
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001630
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001631
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001632def initialize_arrays():
1633 """Complete global arrays before they are used."""
1634 global project_names
1635 project_names = [p[0] for p in project_list]
1636 for p in project_list:
1637 project_patterns.append({'description': p[0],
1638 'members': [],
1639 'pattern': re.compile(p[1])})
1640 # Each warning pattern has 3 dictionaries:
1641 # (1) 'projects' maps a project name to number of warnings in that project.
1642 # (2) 'project_anchor' maps a project name to its anchor number for HTML.
1643 # (3) 'project_warnings' maps a project name to a list of warning messages.
1644 for w in warn_patterns:
1645 w['members'] = []
1646 if 'option' not in w:
1647 w['option'] = ''
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001648 w['projects'] = {}
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001649 w['project_anchor'] = {}
1650 w['project_warnings'] = {}
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001651
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001652
1653initialize_arrays()
1654
1655
1656platform_version = 'unknown'
1657target_product = 'unknown'
1658target_variant = 'unknown'
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001659
1660
1661##### Data and functions to dump html file. ##################################
1662
Marco Nelissen594375d2009-07-14 09:04:04 -07001663anchor = 0
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07001664cur_row_class = 0
1665
1666html_script_style = """\
1667 <script type="text/javascript">
1668 function expand(id) {
1669 var e = document.getElementById(id);
1670 var f = document.getElementById(id + "_mark");
1671 if (e.style.display == 'block') {
1672 e.style.display = 'none';
1673 f.innerHTML = '&#x2295';
1674 }
1675 else {
1676 e.style.display = 'block';
1677 f.innerHTML = '&#x2296';
1678 }
1679 };
1680 function expand_collapse(show) {
1681 for (var id = 1; ; id++) {
1682 var e = document.getElementById(id + "");
1683 var f = document.getElementById(id + "_mark");
1684 if (!e || !f) break;
1685 e.style.display = (show ? 'block' : 'none');
1686 f.innerHTML = (show ? '&#x2296' : '&#x2295');
1687 }
1688 };
1689 </script>
1690 <style type="text/css">
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001691 th,td{border-collapse:collapse; border:1px solid black;}
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07001692 .button{color:blue;font-size:110%;font-weight:bolder;}
1693 .bt{color:black;background-color:transparent;border:none;outline:none;
1694 font-size:140%;font-weight:bolder;}
1695 .c0{background-color:#e0e0e0;}
1696 .c1{background-color:#d0d0d0;}
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001697 .t1{border-collapse:collapse; width:100%; border:1px solid black;}
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07001698 </style>\n"""
1699
Marco Nelissen594375d2009-07-14 09:04:04 -07001700
1701def output(text):
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001702 print text,
Marco Nelissen594375d2009-07-14 09:04:04 -07001703
Marco Nelissen594375d2009-07-14 09:04:04 -07001704
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001705def html_big(param):
1706 return '<font size="+2">' + param + '</font>'
Marco Nelissen594375d2009-07-14 09:04:04 -07001707
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07001708
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001709def dump_html_prologue(title):
1710 output('<html>\n<head>\n')
1711 output('<title>' + title + '</title>\n')
1712 output(html_script_style)
1713 output('</head>\n<body>\n')
1714 output(html_big(title))
1715 output('<p>\n')
Marco Nelissen594375d2009-07-14 09:04:04 -07001716
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001717
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001718def dump_html_epilogue():
1719 output('</body>\n</head>\n</html>\n')
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001720
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001721
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001722def table_row(text):
1723 global cur_row_class
1724 cur_row_class = 1 - cur_row_class
1725 # remove last '\n'
1726 t = text[:-1] if text[-1] == '\n' else text
1727 output('<tr><td class="c' + str(cur_row_class) + '">' + t + '</td></tr>\n')
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001728
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001729
1730def sort_warnings():
1731 for i in warn_patterns:
1732 i['members'] = sorted(set(i['members']))
1733
1734
1735def dump_stats_by_project():
1736 """Dump a table of warnings per project and severity."""
1737 # warnings[p][s] is number of warnings in project p of severity s.
1738 warnings = {p: {s: 0 for s in severity.kinds} for p in project_names}
1739 for i in warn_patterns:
1740 s = i['severity']
1741 for p in i['projects']:
1742 warnings[p][s] += i['projects'][p]
1743
1744 # total_by_project[p] is number of warnings in project p.
1745 total_by_project = {p: sum(warnings[p][s] for s in severity.kinds)
1746 for p in project_names}
1747
1748 # total_by_severity[s] is number of warnings of severity s.
1749 total_by_severity = {s: sum(warnings[p][s] for p in project_names)
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001750 for s in severity.kinds}
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001751
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001752 # emit table header
1753 output('<blockquote><table border=1>\n<tr><th>Project</th>\n')
1754 for s in severity.kinds:
1755 if total_by_severity[s]:
1756 output('<th width="8%"><span style="background-color:{}">{}</span></th>'.
1757 format(severity.color[s], severity.column_headers[s]))
1758 output('<th>TOTAL</th></tr>\n')
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001759
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001760 # emit a row of warning counts per project, skip no-warning projects
1761 total_all_projects = 0
1762 for p in project_names:
1763 if total_by_project[p]:
1764 output('<tr><td align="left">{}</td>'.format(p))
1765 for s in severity.kinds:
1766 if total_by_severity[s]:
1767 output('<td align="right">{}</td>'.format(warnings[p][s]))
1768 output('<td align="right">{}</td>'.format(total_by_project[p]))
1769 total_all_projects += total_by_project[p]
1770 output('</tr>\n')
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001771
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001772 # emit a row of warning counts per severity
1773 total_all_severities = 0
1774 output('<tr><td align="right">TOTAL</td>')
1775 for s in severity.kinds:
1776 if total_by_severity[s]:
1777 output('<td align="right">{}</td>'.format(total_by_severity[s]))
1778 total_all_severities += total_by_severity[s]
1779 output('<td align="right">{}</td></tr>\n'.format(total_all_projects))
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001780
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001781 # at the end of table, verify total counts
1782 output('</table></blockquote><br>\n')
1783 if total_all_projects != total_all_severities:
1784 output('<h3>ERROR: Sum of warnings by project '
1785 '!= Sum of warnings by severity.</h3>\n')
Marco Nelissen594375d2009-07-14 09:04:04 -07001786
1787
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001788def dump_stats():
1789 """Dump some stats about total number of warnings and such."""
1790 known = 0
1791 skipped = 0
1792 unknown = 0
1793 sort_warnings()
1794 for i in warn_patterns:
1795 if i['severity'] == severity.UNKNOWN:
1796 unknown += len(i['members'])
1797 elif i['severity'] == severity.SKIP:
1798 skipped += len(i['members'])
Ian Rogersf3829732016-05-10 12:06:01 -07001799 else:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001800 known += len(i['members'])
1801 output('\nNumber of classified warnings: <b>' + str(known) + '</b><br>')
1802 output('\nNumber of skipped warnings: <b>' + str(skipped) + '</b><br>')
1803 output('\nNumber of unclassified warnings: <b>' + str(unknown) + '</b><br>')
1804 total = unknown + known + skipped
1805 output('\nTotal number of warnings: <b>' + str(total) + '</b>')
1806 if total < 1000:
1807 output('(low count may indicate incremental build)')
1808 output('<br><br>\n')
Marco Nelissen594375d2009-07-14 09:04:04 -07001809
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07001810
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001811def emit_buttons():
1812 output('<button class="button" onclick="expand_collapse(1);">'
1813 'Expand all warnings</button>\n'
1814 '<button class="button" onclick="expand_collapse(0);">'
1815 'Collapse all warnings</button><br>\n')
Marco Nelissen594375d2009-07-14 09:04:04 -07001816
1817
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001818def dump_severity(sev):
1819 """Dump everything for a given severity."""
1820 global anchor
1821 total = 0
1822 for i in warn_patterns:
1823 if i['severity'] == sev:
1824 total += len(i['members'])
1825 output('\n<br><span style="background-color:' + severity.color[sev] +
1826 '"><b>' + severity.header[sev] + ': ' + str(total) + '</b></span>\n')
1827 output('<blockquote>\n')
1828 for i in warn_patterns:
1829 if i['severity'] == sev and i['members']:
1830 anchor += 1
1831 i['anchor'] = str(anchor)
1832 if args.byproject:
1833 dump_category_by_project(sev, i)
1834 else:
1835 dump_category(sev, i)
1836 output('</blockquote>\n')
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001837
Marco Nelissen594375d2009-07-14 09:04:04 -07001838
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001839def dump_skipped_anchors():
1840 """emit all skipped project anchors for expand_collapse."""
1841 output('<div style="display:none;">\n') # hide these fake elements
1842 for i in warn_patterns:
1843 if i['severity'] == severity.SKIP and i['members']:
1844 projects = i['project_warnings'].keys()
1845 for p in projects:
1846 output('<div id="' + i['project_anchor'][p] + '"></div>' +
1847 '<div id="' + i['project_anchor'][p] + '_mark"></div>\n')
1848 output('</div>\n')
Marco Nelissen594375d2009-07-14 09:04:04 -07001849
Marco Nelissen594375d2009-07-14 09:04:04 -07001850
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001851def all_patterns(cat):
1852 pats = ''
1853 for i in cat['patterns']:
1854 pats += i
1855 pats += ' / '
1856 return pats
Marco Nelissen594375d2009-07-14 09:04:04 -07001857
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001858
1859def description_for(cat):
1860 if cat['description']:
1861 return cat['description']
1862 return all_patterns(cat)
1863
1864
1865def dump_fixed():
1866 """Show which warnings no longer occur."""
1867 global anchor
1868 anchor += 1
1869 mark = str(anchor) + '_mark'
1870 output('\n<br><p style="background-color:lightblue"><b>'
1871 '<button id="' + mark + '" '
1872 'class="bt" onclick="expand(' + str(anchor) + ');">'
1873 '&#x2295</button> Fixed warnings. '
1874 'No more occurrences. Please consider turning these into '
1875 'errors if possible, before they are reintroduced in to the build'
1876 ':</b></p>\n')
1877 output('<blockquote>\n')
1878 fixed_patterns = []
1879 for i in warn_patterns:
1880 if not i['members']:
1881 fixed_patterns.append(i['description'] + ' (' +
1882 all_patterns(i) + ')')
1883 if i['option']:
1884 fixed_patterns.append(' ' + i['option'])
1885 fixed_patterns.sort()
1886 output('<div id="' + str(anchor) + '" style="display:none;"><table>\n')
1887 for i in fixed_patterns:
1888 table_row(i)
1889 output('</table></div>\n')
1890 output('</blockquote>\n')
1891
1892
1893def warning_with_url(line):
1894 """Returns a warning message line with HTML link to given args.url."""
1895 if not args.url:
1896 return line
1897 m = re.search(r'^([^ :]+):(\d+):(.+)', line, re.M|re.I)
1898 if not m:
1899 return line
1900 file_path = m.group(1)
1901 line_number = m.group(2)
1902 warning = m.group(3)
1903 prefix = '<a href="' + args.url + '/' + file_path
1904 if args.separator:
1905 return (prefix + args.separator + line_number + '">' + file_path +
1906 ':' + line_number + '</a>:' + warning)
1907 else:
1908 return prefix + '">' + file_path + '</a>:' + line_number + ':' + warning
1909
1910
1911def dump_group(sev, anchor_str, description, warnings):
1912 """Dump warnings of given severity, anchor_str, and description."""
1913 mark = anchor_str + '_mark'
1914 output('\n<table class="t1">\n')
1915 output('<tr bgcolor="' + severity.color[sev] + '">' +
1916 '<td><button class="bt" id="' + mark +
1917 '" onclick="expand(\'' + anchor_str + '\');">' +
1918 '&#x2295</button> ' + description + '</td></tr>\n')
1919 output('</table>\n')
1920 output('<div id="' + anchor_str + '" style="display:none;">')
1921 output('<table class="t1">\n')
1922 for i in warnings:
1923 table_row(warning_with_url(i))
1924 output('</table></div>\n')
1925
1926
1927def dump_category(sev, cat):
1928 """Dump warnings in a category."""
1929 description = description_for(cat) + ' (' + str(len(cat['members'])) + ')'
1930 dump_group(sev, cat['anchor'], description, cat['members'])
1931
1932
1933def dump_category_by_project(sev, cat):
1934 """Similar to dump_category but output one table per project."""
1935 warning = description_for(cat)
1936 projects = cat['project_warnings'].keys()
1937 projects.sort()
1938 for p in projects:
1939 anchor_str = cat['project_anchor'][p]
1940 project_warnings = cat['project_warnings'][p]
1941 description = '{}, in {} ({})'.format(warning, p, len(project_warnings))
1942 dump_group(sev, anchor_str, description, project_warnings)
1943
1944
1945def find_project(line):
1946 for p in project_patterns:
1947 if p['pattern'].match(line):
1948 return p['description']
1949 return '???'
1950
1951
1952def classify_warning(line):
1953 global anchor
1954 for i in warn_patterns:
1955 for cpat in i['compiled_patterns']:
1956 if cpat.match(line):
1957 i['members'].append(line)
1958 pname = find_project(line)
1959 # Count warnings by project.
1960 if pname in i['projects']:
1961 i['projects'][pname] += 1
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001962 else:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001963 i['projects'][pname] = 1
1964 # Collect warnings by project.
1965 if args.byproject:
1966 if pname in i['project_warnings']:
1967 i['project_warnings'][pname].append(line)
1968 else:
1969 i['project_warnings'][pname] = [line]
1970 if pname not in i['project_anchor']:
1971 anchor += 1
1972 i['project_anchor'][pname] = str(anchor)
1973 return
1974 else:
1975 # If we end up here, there was a problem parsing the log
1976 # probably caused by 'make -j' mixing the output from
1977 # 2 or more concurrent compiles
1978 pass
Marco Nelissen594375d2009-07-14 09:04:04 -07001979
1980
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001981def compile_patterns():
1982 """Precompiling every pattern speeds up parsing by about 30x."""
1983 for i in warn_patterns:
1984 i['compiled_patterns'] = []
1985 for pat in i['patterns']:
1986 i['compiled_patterns'].append(re.compile(pat))
1987
1988
1989def parse_input_file():
1990 """Parse input file, match warning lines."""
1991 global platform_version
1992 global target_product
1993 global target_variant
1994 infile = open(args.buildlog, 'r')
1995 line_counter = 0
1996
1997 warning_pattern = re.compile('.* warning:.*')
1998 compile_patterns()
1999
2000 # read the log file and classify all the warnings
2001 warning_lines = set()
2002 for line in infile:
2003 # replace fancy quotes with plain ol' quotes
2004 line = line.replace('‘', "'")
2005 line = line.replace('’', "'")
2006 if warning_pattern.match(line):
2007 if line not in warning_lines:
2008 classify_warning(line)
2009 warning_lines.add(line)
2010 else:
2011 # save a little bit of time by only doing this for the first few lines
2012 if line_counter < 50:
2013 line_counter += 1
2014 m = re.search('(?<=^PLATFORM_VERSION=).*', line)
2015 if m is not None:
2016 platform_version = m.group(0)
2017 m = re.search('(?<=^TARGET_PRODUCT=).*', line)
2018 if m is not None:
2019 target_product = m.group(0)
2020 m = re.search('(?<=^TARGET_BUILD_VARIANT=).*', line)
2021 if m is not None:
2022 target_variant = m.group(0)
2023
2024
2025def dump_html():
2026 """Dump the html output to stdout."""
2027 dump_html_prologue('Warnings for ' + platform_version + ' - ' +
2028 target_product + ' - ' + target_variant)
2029 dump_stats()
2030 dump_stats_by_project()
2031 emit_buttons()
2032 # sort table based on number of members once dump_stats has de-duplicated the
2033 # members.
2034 warn_patterns.sort(reverse=True, key=lambda i: len(i['members']))
2035 # Dump warnings by severity. If severity.SKIP warnings are not dumped,
2036 # the project anchors should be dumped through dump_skipped_anchors.
2037 for s in severity.kinds:
2038 dump_severity(s)
2039 dump_fixed()
2040 dump_html_epilogue()
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002041
2042
2043##### Functions to count warnings and dump csv file. #########################
2044
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002045
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002046def description_for_csv(cat):
2047 if not cat['description']:
2048 return '?'
2049 return cat['description']
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002050
2051
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002052def string_for_csv(s):
2053 if ',' in s:
2054 return '"{}"'.format(s)
2055 return s
2056
2057
2058def count_severity(sev, kind):
2059 """Count warnings of given severity."""
2060 total = 0
2061 for i in warn_patterns:
2062 if i['severity'] == sev and i['members']:
2063 n = len(i['members'])
2064 total += n
2065 warning = string_for_csv(kind + ': ' + description_for_csv(i))
2066 print '{},,{}'.format(n, warning)
2067 # print number of warnings for each project, ordered by project name.
2068 projects = i['projects'].keys()
2069 projects.sort()
2070 for p in projects:
2071 print '{},{},{}'.format(i['projects'][p], p, warning)
2072 print '{},,{}'.format(total, kind + ' warnings')
2073 return total
2074
2075
2076def dump_csv():
2077 """Dump number of warnings in csv format to stdout."""
2078 sort_warnings()
2079 total = 0
2080 for s in severity.kinds:
2081 total += count_severity(s, severity.column_headers[s])
2082 print '{},,{}'.format(total, 'All warnings')
2083
2084
2085parse_input_file()
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002086if args.gencsv:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002087 dump_csv()
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002088else:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002089 dump_html()