blob: c223d9ee73d1a79b4ce995178d130ab2170f784e [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 Hsieh0a192072016-09-21 14:00:23 -0700341 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-W#pragma-messages',
342 'description':'Pragma warning messages',
343 'patterns':[r".*: warning: .+W#pragma-messages"] },
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':'Variable might be clobbered by longjmp or vfork',
346 'patterns':[r".*: warning: variable '.+' might be clobbered by 'longjmp' or 'vfork'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700347 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wclobbered',
Marco Nelissen594375d2009-07-14 09:04:04 -0700348 'description':'Argument might be clobbered by longjmp or vfork',
349 'patterns':[r".*: warning: argument '.+' might be clobbered by 'longjmp' or 'vfork'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700350 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wredundant-decls',
Marco Nelissen594375d2009-07-14 09:04:04 -0700351 'description':'Redundant declaration',
352 'patterns':[r".*: warning: redundant redeclaration of '.+'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700353 { 'category':'cont.', 'severity':severity.SKIP,
Marco Nelissen594375d2009-07-14 09:04:04 -0700354 'description':'',
355 'patterns':[r".*: warning: previous declaration of '.+' was here"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700356 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wswitch-enum',
Marco Nelissen594375d2009-07-14 09:04:04 -0700357 'description':'Enum value not handled in switch',
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700358 'patterns':[r".*: warning: .*enumeration value.* not handled in switch.+Wswitch"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700359 { 'category':'java', 'severity':severity.MEDIUM, 'option':'-encoding',
Marco Nelissen594375d2009-07-14 09:04:04 -0700360 'description':'Java: Non-ascii characters used, but ascii encoding specified',
361 'patterns':[r".*: warning: unmappable character for encoding ascii"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700362 { 'category':'java', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -0700363 'description':'Java: Non-varargs call of varargs method with inexact argument type for last parameter',
364 'patterns':[r".*: warning: non-varargs call of varargs method with inexact argument type for last parameter"] },
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 method invocation',
367 'patterns':[r".*: warning: \[unchecked\] unchecked method invocation: .+ in class .+"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700368 { 'category':'java', 'severity':severity.MEDIUM,
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700369 'description':'Java: Unchecked conversion',
370 'patterns':[r".*: warning: \[unchecked\] unchecked conversion"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -0700371 { 'category':'java', 'severity':severity.MEDIUM,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -0700372 'description':'_ used as an identifier',
373 'patterns':[r".*: warning: '_' used as an identifier"] },
Ian Rogers32bb9bd2016-05-09 23:19:42 -0700374
Ian Rogers6e520032016-05-13 08:59:00 -0700375 # Warnings from Error Prone.
376 {'category': 'java',
377 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700378 'description': 'Java: Use of deprecated member',
379 'patterns': [r'.*: warning: \[deprecation\] .+']},
380 {'category': 'java',
381 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700382 'description': 'Java: Unchecked conversion',
383 'patterns': [r'.*: warning: \[unchecked\] .+']},
Ian Rogers32bb9bd2016-05-09 23:19:42 -0700384
Ian Rogers6e520032016-05-13 08:59:00 -0700385 # Warnings from Error Prone (auto generated list).
386 {'category': 'java',
387 'severity': severity.LOW,
Ian Rogers6e520032016-05-13 08:59:00 -0700388 'description':
389 'Java: Deprecated item is not annotated with @Deprecated',
390 'patterns': [r".*: warning: \[DepAnn\] .+"]},
391 {'category': 'java',
392 'severity': severity.LOW,
Ian Rogers6e520032016-05-13 08:59:00 -0700393 'description':
394 'Java: Fallthrough warning suppression has no effect if warning is suppressed',
395 'patterns': [r".*: warning: \[FallthroughSuppression\] .+"]},
396 {'category': 'java',
397 'severity': severity.LOW,
Ian Rogers6e520032016-05-13 08:59:00 -0700398 'description':
399 'Java: Prefer \'L\' to \'l\' for the suffix to long literals',
400 'patterns': [r".*: warning: \[LongLiteralLowerCaseSuffix\] .+"]},
401 {'category': 'java',
402 'severity': severity.LOW,
Ian Rogers6e520032016-05-13 08:59:00 -0700403 'description':
404 'Java: @Binds is a more efficient and declaritive mechanism for delegating a binding.',
405 'patterns': [r".*: warning: \[UseBinds\] .+"]},
406 {'category': 'java',
407 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700408 'description':
409 'Java: Assertions may be disabled at runtime and do not guarantee that execution will halt here; consider throwing an exception instead',
410 'patterns': [r".*: warning: \[AssertFalse\] .+"]},
411 {'category': 'java',
412 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700413 'description':
414 'Java: Classes that implement Annotation must override equals and hashCode. Consider using AutoAnnotation instead of implementing Annotation by hand.',
415 'patterns': [r".*: warning: \[BadAnnotationImplementation\] .+"]},
416 {'category': 'java',
417 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700418 'description':
419 'Java: BigDecimal(double) and BigDecimal.valueOf(double) may lose precision, prefer BigDecimal(String) or BigDecimal(long)',
420 'patterns': [r".*: warning: \[BigDecimalLiteralDouble\] .+"]},
421 {'category': 'java',
422 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700423 'description':
424 'Java: Mockito cannot mock final classes',
425 'patterns': [r".*: warning: \[CannotMockFinalClass\] .+"]},
426 {'category': 'java',
427 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700428 'description':
429 'Java: This code, which counts elements using a loop, can be replaced by a simpler library method',
430 'patterns': [r".*: warning: \[ElementsCountedInLoop\] .+"]},
431 {'category': 'java',
432 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700433 'description':
434 'Java: Empty top-level type declaration',
435 'patterns': [r".*: warning: \[EmptyTopLevelDeclaration\] .+"]},
436 {'category': 'java',
437 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700438 'description':
439 'Java: Classes that override equals should also override hashCode.',
440 'patterns': [r".*: warning: \[EqualsHashCode\] .+"]},
441 {'category': 'java',
442 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700443 'description':
444 'Java: An equality test between objects with incompatible types always returns false',
445 'patterns': [r".*: warning: \[EqualsIncompatibleType\] .+"]},
446 {'category': 'java',
447 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700448 'description':
449 '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.',
450 'patterns': [r".*: warning: \[Finally\] .+"]},
451 {'category': 'java',
452 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700453 'description':
454 'Java: This annotation has incompatible modifiers as specified by its @IncompatibleModifiers annotation',
455 'patterns': [r".*: warning: \[IncompatibleModifiers\] .+"]},
456 {'category': 'java',
457 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700458 'description':
459 'Java: Class should not implement both `Iterable` and `Iterator`',
460 'patterns': [r".*: warning: \[IterableAndIterator\] .+"]},
461 {'category': 'java',
462 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700463 'description':
464 'Java: Floating-point comparison without error tolerance',
465 'patterns': [r".*: warning: \[JUnit3FloatingPointComparisonWithoutDelta\] .+"]},
466 {'category': 'java',
467 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700468 'description':
469 'Java: Test class inherits from JUnit 3\'s TestCase but has JUnit 4 @Test annotations.',
470 'patterns': [r".*: warning: \[JUnitAmbiguousTestClass\] .+"]},
471 {'category': 'java',
472 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700473 'description':
474 'Java: Enum switch statement is missing cases',
475 'patterns': [r".*: warning: \[MissingCasesInEnumSwitch\] .+"]},
476 {'category': 'java',
477 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700478 'description':
479 'Java: Not calling fail() when expecting an exception masks bugs',
480 'patterns': [r".*: warning: \[MissingFail\] .+"]},
481 {'category': 'java',
482 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700483 'description':
484 'Java: method overrides method in supertype; expected @Override',
485 'patterns': [r".*: warning: \[MissingOverride\] .+"]},
486 {'category': 'java',
487 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700488 'description':
489 'Java: Source files should not contain multiple top-level class declarations',
490 'patterns': [r".*: warning: \[MultipleTopLevelClasses\] .+"]},
491 {'category': 'java',
492 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700493 'description':
494 'Java: This update of a volatile variable is non-atomic',
495 'patterns': [r".*: warning: \[NonAtomicVolatileUpdate\] .+"]},
496 {'category': 'java',
497 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700498 'description':
499 'Java: Static import of member uses non-canonical name',
500 'patterns': [r".*: warning: \[NonCanonicalStaticMemberImport\] .+"]},
501 {'category': 'java',
502 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700503 'description':
504 'Java: equals method doesn\'t override Object.equals',
505 'patterns': [r".*: warning: \[NonOverridingEquals\] .+"]},
506 {'category': 'java',
507 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700508 'description':
509 'Java: Constructors should not be annotated with @Nullable since they cannot return null',
510 'patterns': [r".*: warning: \[NullableConstructor\] .+"]},
511 {'category': 'java',
512 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700513 'description':
514 'Java: @Nullable should not be used for primitive types since they cannot be null',
515 'patterns': [r".*: warning: \[NullablePrimitive\] .+"]},
516 {'category': 'java',
517 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700518 'description':
519 'Java: void-returning methods should not be annotated with @Nullable, since they cannot return null',
520 'patterns': [r".*: warning: \[NullableVoid\] .+"]},
521 {'category': 'java',
522 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700523 'description':
524 'Java: Package names should match the directory they are declared in',
525 'patterns': [r".*: warning: \[PackageLocation\] .+"]},
526 {'category': 'java',
527 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700528 'description':
529 'Java: Second argument to Preconditions.* is a call to String.format(), which can be unwrapped',
530 'patterns': [r".*: warning: \[PreconditionsErrorMessageEagerEvaluation\] .+"]},
531 {'category': 'java',
532 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700533 'description':
534 'Java: Preconditions only accepts the %s placeholder in error message strings',
535 'patterns': [r".*: warning: \[PreconditionsInvalidPlaceholder\] .+"]},
536 {'category': 'java',
537 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700538 'description':
539 'Java: Passing a primitive array to a varargs method is usually wrong',
540 'patterns': [r".*: warning: \[PrimitiveArrayPassedToVarargsMethod\] .+"]},
541 {'category': 'java',
542 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700543 'description':
544 'Java: Protobuf fields cannot be null, so this check is redundant',
545 'patterns': [r".*: warning: \[ProtoFieldPreconditionsCheckNotNull\] .+"]},
546 {'category': 'java',
547 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700548 'description':
549 'Java: This annotation is missing required modifiers as specified by its @RequiredModifiers annotation',
550 'patterns': [r".*: warning: \[RequiredModifiers\] .+"]},
551 {'category': 'java',
552 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700553 'description':
554 'Java: A static variable or method should not be accessed from an object instance',
555 'patterns': [r".*: warning: \[StaticAccessedFromInstance\] .+"]},
556 {'category': 'java',
557 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700558 'description':
559 'Java: String comparison using reference equality instead of value equality',
560 'patterns': [r".*: warning: \[StringEquality\] .+"]},
561 {'category': 'java',
562 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700563 'description':
564 '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.',
565 'patterns': [r".*: warning: \[TypeParameterUnusedInFormals\] .+"]},
566 {'category': 'java',
567 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700568 'description':
569 'Java: Using static imports for types is unnecessary',
570 'patterns': [r".*: warning: \[UnnecessaryStaticImport\] .+"]},
571 {'category': 'java',
572 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700573 'description':
574 'Java: Unsynchronized method overrides a synchronized method.',
575 'patterns': [r".*: warning: \[UnsynchronizedOverridesSynchronized\] .+"]},
576 {'category': 'java',
577 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700578 'description':
579 'Java: Non-constant variable missing @Var annotation',
580 'patterns': [r".*: warning: \[Var\] .+"]},
581 {'category': 'java',
582 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700583 'description':
584 'Java: Because of spurious wakeups, Object.wait() and Condition.await() must always be called in a loop',
585 'patterns': [r".*: warning: \[WaitNotInLoop\] .+"]},
586 {'category': 'java',
587 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700588 'description':
589 'Java: Subclasses of Fragment must be instantiable via Class#newInstance(): the class must be public, static and have a public nullary constructor',
590 'patterns': [r".*: warning: \[FragmentNotInstantiable\] .+"]},
591 {'category': 'java',
592 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700593 'description':
594 'Java: Hardcoded reference to /sdcard',
595 'patterns': [r".*: warning: \[HardCodedSdCardPath\] .+"]},
596 {'category': 'java',
597 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700598 'description':
599 'Java: Incompatible type as argument to Object-accepting Java collections method',
600 'patterns': [r".*: warning: \[CollectionIncompatibleType\] .+"]},
601 {'category': 'java',
602 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700603 'description':
604 'Java: @AssistedInject and @Inject should not be used on different constructors in the same class.',
605 'patterns': [r".*: warning: \[AssistedInjectAndInjectOnConstructors\] .+"]},
606 {'category': 'java',
607 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700608 'description':
609 'Java: Although Guice allows injecting final fields, doing so is not recommended because the injected value may not be visible to other threads.',
610 'patterns': [r".*: warning: \[GuiceInjectOnFinalField\] .+"]},
611 {'category': 'java',
612 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700613 'description':
614 '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.',
615 'patterns': [r".*: warning: \[OverridesGuiceInjectableMethod\] .+"]},
616 {'category': 'java',
617 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700618 'description':
619 'Java: Double-checked locking on non-volatile fields is unsafe',
620 'patterns': [r".*: warning: \[DoubleCheckedLocking\] .+"]},
621 {'category': 'java',
622 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700623 'description':
624 'Java: Writes to static fields should not be guarded by instance locks',
625 'patterns': [r".*: warning: \[StaticGuardedByInstance\] .+"]},
626 {'category': 'java',
627 'severity': severity.MEDIUM,
Ian Rogers6e520032016-05-13 08:59:00 -0700628 'description':
629 'Java: Synchronizing on non-final fields is not safe: if the field is ever updated, different threads may end up locking on different objects.',
630 'patterns': [r".*: warning: \[SynchronizeOnNonFinalField\] .+"]},
631 {'category': 'java',
632 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700633 'description':
634 'Java: Reference equality used to compare arrays',
635 'patterns': [r".*: warning: \[ArrayEquals\] .+"]},
636 {'category': 'java',
637 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700638 'description':
639 'Java: hashcode method on array does not hash array contents',
640 'patterns': [r".*: warning: \[ArrayHashCode\] .+"]},
641 {'category': 'java',
642 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700643 'description':
644 'Java: Calling toString on an array does not provide useful information',
645 'patterns': [r".*: warning: \[ArrayToString.*\] .+"]},
646 {'category': 'java',
647 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700648 'description':
649 'Java: Arrays.asList does not autobox primitive arrays, as one might expect.',
650 'patterns': [r".*: warning: \[ArraysAsListPrimitiveArray\] .+"]},
651 {'category': 'java',
652 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700653 'description':
654 'Java: AsyncCallable should not return a null Future, only a Future whose result is null.',
655 'patterns': [r".*: warning: \[AsyncCallableReturnsNull\] .+"]},
656 {'category': 'java',
657 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700658 'description':
659 'Java: AsyncFunction should not return a null Future, only a Future whose result is null.',
660 'patterns': [r".*: warning: \[AsyncFunctionReturnsNull\] .+"]},
661 {'category': 'java',
662 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700663 'description':
664 'Java: Possible sign flip from narrowing conversion',
665 'patterns': [r".*: warning: \[BadComparable\] .+"]},
666 {'category': 'java',
667 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700668 'description':
669 'Java: Shift by an amount that is out of range',
670 'patterns': [r".*: warning: \[BadShiftAmount\] .+"]},
671 {'category': 'java',
672 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700673 'description':
674 'Java: valueOf provides better time and space performance',
675 'patterns': [r".*: warning: \[BoxedPrimitiveConstructor\] .+"]},
676 {'category': 'java',
677 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700678 'description':
679 '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.',
680 'patterns': [r".*: warning: \[ChainingConstructorIgnoresParameter\] .+"]},
681 {'category': 'java',
682 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700683 'description':
684 'Java: Ignored return value of method that is annotated with @CheckReturnValue',
685 'patterns': [r".*: warning: \[CheckReturnValue\] .+"]},
686 {'category': 'java',
687 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700688 'description':
689 'Java: Inner class is non-static but does not reference enclosing class',
690 'patterns': [r".*: warning: \[ClassCanBeStatic\] .+"]},
691 {'category': 'java',
692 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700693 'description':
694 'Java: The source file name should match the name of the top-level class it contains',
695 'patterns': [r".*: warning: \[ClassName\] .+"]},
696 {'category': 'java',
697 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700698 'description':
699 'Java: This comparison method violates the contract',
700 'patterns': [r".*: warning: \[ComparisonContractViolated\] .+"]},
701 {'category': 'java',
702 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700703 'description':
704 'Java: Comparison to value that is out of range for the compared type',
705 'patterns': [r".*: warning: \[ComparisonOutOfRange\] .+"]},
706 {'category': 'java',
707 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700708 'description':
709 'Java: Non-compile-time constant expression passed to parameter with @CompileTimeConstant type annotation.',
710 'patterns': [r".*: warning: \[CompileTimeConstant\] .+"]},
711 {'category': 'java',
712 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700713 'description':
714 'Java: Exception created but not thrown',
715 'patterns': [r".*: warning: \[DeadException\] .+"]},
716 {'category': 'java',
717 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700718 'description':
719 'Java: Division by integer literal zero',
720 'patterns': [r".*: warning: \[DivZero\] .+"]},
721 {'category': 'java',
722 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700723 'description':
724 'Java: Empty statement after if',
725 'patterns': [r".*: warning: \[EmptyIf\] .+"]},
726 {'category': 'java',
727 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700728 'description':
729 'Java: == NaN always returns false; use the isNaN methods instead',
730 'patterns': [r".*: warning: \[EqualsNaN\] .+"]},
731 {'category': 'java',
732 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700733 'description':
734 'Java: Method annotated @ForOverride must be protected or package-private and only invoked from declaring class',
735 'patterns': [r".*: warning: \[ForOverride\] .+"]},
736 {'category': 'java',
737 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700738 'description':
739 'Java: Futures.getChecked requires a checked exception type with a standard constructor.',
740 'patterns': [r".*: warning: \[FuturesGetCheckedIllegalExceptionType\] .+"]},
741 {'category': 'java',
742 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700743 'description':
744 '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',
745 'patterns': [r".*: warning: \[GetClassOnClass\] .+"]},
746 {'category': 'java',
747 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700748 'description':
749 'Java: An object is tested for equality to itself using Guava Libraries',
750 'patterns': [r".*: warning: \[GuavaSelfEquals\] .+"]},
751 {'category': 'java',
752 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700753 'description':
754 'Java: contains() is a legacy method that is equivalent to containsValue()',
755 'patterns': [r".*: warning: \[HashtableContains\] .+"]},
756 {'category': 'java',
757 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700758 'description':
759 'Java: Cipher.getInstance() is invoked using either the default settings or ECB mode',
760 'patterns': [r".*: warning: \[InsecureCipherMode\] .+"]},
761 {'category': 'java',
762 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700763 'description':
764 'Java: Invalid syntax used for a regular expression',
765 'patterns': [r".*: warning: \[InvalidPatternSyntax\] .+"]},
766 {'category': 'java',
767 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700768 'description':
769 'Java: The argument to Class#isInstance(Object) should not be a Class',
770 'patterns': [r".*: warning: \[IsInstanceOfClass\] .+"]},
771 {'category': 'java',
772 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700773 'description':
774 'Java: jMock tests must have a @RunWith(JMock.class) annotation, or the Mockery field must have a @Rule JUnit annotation',
775 'patterns': [r".*: warning: \[JMockTestWithoutRunWithOrRuleAnnotation\] .+"]},
776 {'category': 'java',
777 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700778 'description':
779 'Java: Test method will not be run; please prefix name with "test"',
780 'patterns': [r".*: warning: \[JUnit3TestNotRun\] .+"]},
781 {'category': 'java',
782 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700783 'description':
784 'Java: setUp() method will not be run; Please add a @Before annotation',
785 'patterns': [r".*: warning: \[JUnit4SetUpNotRun\] .+"]},
786 {'category': 'java',
787 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700788 'description':
789 'Java: tearDown() method will not be run; Please add an @After annotation',
790 'patterns': [r".*: warning: \[JUnit4TearDownNotRun\] .+"]},
791 {'category': 'java',
792 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700793 'description':
794 'Java: Test method will not be run; please add @Test annotation',
795 'patterns': [r".*: warning: \[JUnit4TestNotRun\] .+"]},
796 {'category': 'java',
797 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700798 'description':
799 'Java: Printf-like format string does not match its arguments',
800 'patterns': [r".*: warning: \[MalformedFormatString\] .+"]},
801 {'category': 'java',
802 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700803 'description':
804 'Java: Use of "YYYY" (week year) in a date pattern without "ww" (week in year). You probably meant to use "yyyy" (year) instead.',
805 'patterns': [r".*: warning: \[MisusedWeekYear\] .+"]},
806 {'category': 'java',
807 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700808 'description':
809 'Java: A bug in Mockito will cause this test to fail at runtime with a ClassCastException',
810 'patterns': [r".*: warning: \[MockitoCast\] .+"]},
811 {'category': 'java',
812 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700813 'description':
814 'Java: Missing method call for verify(mock) here',
815 'patterns': [r".*: warning: \[MockitoUsage\] .+"]},
816 {'category': 'java',
817 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700818 'description':
819 'Java: Modifying a collection with itself',
820 'patterns': [r".*: warning: \[ModifyingCollectionWithItself\] .+"]},
821 {'category': 'java',
822 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700823 'description':
824 'Java: Compound assignments to bytes, shorts, chars, and floats hide dangerous casts',
825 'patterns': [r".*: warning: \[NarrowingCompoundAssignment\] .+"]},
826 {'category': 'java',
827 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700828 'description':
829 'Java: @NoAllocation was specified on this method, but something was found that would trigger an allocation',
830 'patterns': [r".*: warning: \[NoAllocation\] .+"]},
831 {'category': 'java',
832 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700833 'description':
834 'Java: Static import of type uses non-canonical name',
835 'patterns': [r".*: warning: \[NonCanonicalStaticImport\] .+"]},
836 {'category': 'java',
837 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700838 'description':
839 'Java: @CompileTimeConstant parameters should be final',
840 'patterns': [r".*: warning: \[NonFinalCompileTimeConstant\] .+"]},
841 {'category': 'java',
842 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700843 'description':
844 'Java: Calling getAnnotation on an annotation that is not retained at runtime.',
845 'patterns': [r".*: warning: \[NonRuntimeAnnotation\] .+"]},
846 {'category': 'java',
847 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700848 'description':
849 'Java: Numeric comparison using reference equality instead of value equality',
850 'patterns': [r".*: warning: \[NumericEquality\] .+"]},
851 {'category': 'java',
852 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700853 'description':
854 'Java: Comparison using reference equality instead of value equality',
855 'patterns': [r".*: warning: \[OptionalEquality\] .+"]},
856 {'category': 'java',
857 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700858 'description':
859 'Java: Varargs doesn\'t agree for overridden method',
860 'patterns': [r".*: warning: \[Overrides\] .+"]},
861 {'category': 'java',
862 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700863 'description':
864 'Java: Literal passed as first argument to Preconditions.checkNotNull() can never be null',
865 'patterns': [r".*: warning: \[PreconditionsCheckNotNull\] .+"]},
866 {'category': 'java',
867 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700868 'description':
869 'Java: First argument to `Preconditions.checkNotNull()` is a primitive rather than an object reference',
870 'patterns': [r".*: warning: \[PreconditionsCheckNotNullPrimitive\] .+"]},
871 {'category': 'java',
872 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700873 'description':
874 'Java: Protobuf fields cannot be null',
875 'patterns': [r".*: warning: \[ProtoFieldNullComparison\] .+"]},
876 {'category': 'java',
877 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700878 'description':
879 'Java: Comparing protobuf fields of type String using reference equality',
880 'patterns': [r".*: warning: \[ProtoStringFieldReferenceEquality\] .+"]},
881 {'category': 'java',
882 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700883 'description':
884 'Java: Check for non-whitelisted callers to RestrictedApiChecker.',
885 'patterns': [r".*: warning: \[RestrictedApiChecker\] .+"]},
886 {'category': 'java',
887 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700888 'description':
889 'Java: Return value of this method must be used',
890 'patterns': [r".*: warning: \[ReturnValueIgnored\] .+"]},
891 {'category': 'java',
892 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700893 'description':
894 'Java: Variable assigned to itself',
895 'patterns': [r".*: warning: \[SelfAssignment\] .+"]},
896 {'category': 'java',
897 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700898 'description':
899 'Java: An object is compared to itself',
900 'patterns': [r".*: warning: \[SelfComparision\] .+"]},
901 {'category': 'java',
902 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700903 'description':
904 'Java: Variable compared to itself',
905 'patterns': [r".*: warning: \[SelfEquality\] .+"]},
906 {'category': 'java',
907 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700908 'description':
909 'Java: An object is tested for equality to itself',
910 'patterns': [r".*: warning: \[SelfEquals\] .+"]},
911 {'category': 'java',
912 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700913 'description':
914 'Java: Comparison of a size >= 0 is always true, did you intend to check for non-emptiness?',
915 'patterns': [r".*: warning: \[SizeGreaterThanOrEqualsZero\] .+"]},
916 {'category': 'java',
917 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700918 'description':
919 'Java: Calling toString on a Stream does not provide useful information',
920 'patterns': [r".*: warning: \[StreamToString\] .+"]},
921 {'category': 'java',
922 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700923 'description':
924 'Java: StringBuilder does not have a char constructor; this invokes the int constructor.',
925 'patterns': [r".*: warning: \[StringBuilderInitWithChar\] .+"]},
926 {'category': 'java',
927 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700928 'description':
929 'Java: Suppressing "deprecated" is probably a typo for "deprecation"',
930 'patterns': [r".*: warning: \[SuppressWarningsDeprecated\] .+"]},
931 {'category': 'java',
932 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700933 'description':
934 'Java: throwIfUnchecked(knownCheckedException) is a no-op.',
935 'patterns': [r".*: warning: \[ThrowIfUncheckedKnownChecked\] .+"]},
936 {'category': 'java',
937 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700938 'description':
939 'Java: Catching Throwable/Error masks failures from fail() or assert*() in the try block',
940 'patterns': [r".*: warning: \[TryFailThrowable\] .+"]},
941 {'category': 'java',
942 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700943 'description':
944 'Java: Type parameter used as type qualifier',
945 'patterns': [r".*: warning: \[TypeParameterQualifier\] .+"]},
946 {'category': 'java',
947 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700948 'description':
949 'Java: Non-generic methods should not be invoked with type arguments',
950 'patterns': [r".*: warning: \[UnnecessaryTypeArgument\] .+"]},
951 {'category': 'java',
952 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700953 'description':
954 'Java: Instance created but never used',
955 'patterns': [r".*: warning: \[UnusedAnonymousClass\] .+"]},
956 {'category': 'java',
957 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700958 'description':
959 'Java: Use of wildcard imports is forbidden',
960 'patterns': [r".*: warning: \[WildcardImport\] .+"]},
961 {'category': 'java',
962 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700963 'description':
964 'Java: Method parameter has wrong package',
965 'patterns': [r".*: warning: \[ParameterPackage\] .+"]},
966 {'category': 'java',
967 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700968 'description':
969 'Java: Certain resources in `android.R.string` have names that do not match their content',
970 'patterns': [r".*: warning: \[MislabeledAndroidString\] .+"]},
971 {'category': 'java',
972 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700973 'description':
974 'Java: Return value of android.graphics.Rect.intersect() must be checked',
975 'patterns': [r".*: warning: \[RectIntersectReturnValueIgnored\] .+"]},
976 {'category': 'java',
977 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700978 'description':
979 'Java: Invalid printf-style format string',
980 'patterns': [r".*: warning: \[FormatString\] .+"]},
981 {'category': 'java',
982 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700983 'description':
984 'Java: @AssistedInject and @Inject cannot be used on the same constructor.',
985 'patterns': [r".*: warning: \[AssistedInjectAndInjectOnSameConstructor\] .+"]},
986 {'category': 'java',
987 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700988 'description':
989 'Java: Injected constructors cannot be optional nor have binding annotations',
990 'patterns': [r".*: warning: \[InjectedConstructorAnnotations\] .+"]},
991 {'category': 'java',
992 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700993 'description':
994 'Java: The target of a scoping annotation must be set to METHOD and/or TYPE.',
995 'patterns': [r".*: warning: \[InjectInvalidTargetingOnScopingAnnotation\] .+"]},
996 {'category': 'java',
997 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -0700998 'description':
999 'Java: Abstract methods are not injectable with javax.inject.Inject.',
1000 'patterns': [r".*: warning: \[JavaxInjectOnAbstractMethod\] .+"]},
1001 {'category': 'java',
1002 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001003 'description':
1004 'Java: @javax.inject.Inject cannot be put on a final field.',
1005 'patterns': [r".*: warning: \[JavaxInjectOnFinalField\] .+"]},
1006 {'category': 'java',
1007 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001008 'description':
1009 'Java: A class may not have more than one injectable constructor.',
1010 'patterns': [r".*: warning: \[MoreThanOneInjectableConstructor\] .+"]},
1011 {'category': 'java',
1012 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001013 'description':
1014 'Java: Using more than one qualifier annotation on the same element is not allowed.',
1015 'patterns': [r".*: warning: \[InjectMoreThanOneQualifier\] .+"]},
1016 {'category': 'java',
1017 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001018 'description':
1019 'Java: A class can be annotated with at most one scope annotation',
1020 'patterns': [r".*: warning: \[InjectMoreThanOneScopeAnnotationOnClass\] .+"]},
1021 {'category': 'java',
1022 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001023 'description':
1024 'Java: Annotations cannot be both Qualifiers/BindingAnnotations and Scopes',
1025 'patterns': [r".*: warning: \[OverlappingQualifierAndScopeAnnotation\] .+"]},
1026 {'category': 'java',
1027 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001028 'description':
1029 'Java: Scope annotation on an interface or abstact class is not allowed',
1030 'patterns': [r".*: warning: \[InjectScopeAnnotationOnInterfaceOrAbstractClass\] .+"]},
1031 {'category': 'java',
1032 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001033 'description':
1034 'Java: Scoping and qualifier annotations must have runtime retention.',
1035 'patterns': [r".*: warning: \[InjectScopeOrQualifierAnnotationRetention\] .+"]},
1036 {'category': 'java',
1037 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001038 'description':
1039 'Java: Dagger @Provides methods may not return null unless annotated with @Nullable',
1040 'patterns': [r".*: warning: \[DaggerProvidesNull\] .+"]},
1041 {'category': 'java',
1042 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001043 'description':
1044 'Java: Scope annotation on implementation class of AssistedInject factory is not allowed',
1045 'patterns': [r".*: warning: \[GuiceAssistedInjectScoping\] .+"]},
1046 {'category': 'java',
1047 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001048 'description':
1049 'Java: A constructor cannot have two @Assisted parameters of the same type unless they are disambiguated with named @Assisted annotations. ',
1050 'patterns': [r".*: warning: \[GuiceAssistedParameters\] .+"]},
1051 {'category': 'java',
1052 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001053 'description':
1054 'Java: This method is not annotated with @Inject, but it overrides a method that is annotated with @javax.inject.Inject.',
1055 'patterns': [r".*: warning: \[OverridesJavaxInjectableMethod\] .+"]},
1056 {'category': 'java',
1057 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001058 'description':
1059 'Java: Checks for unguarded accesses to fields and methods with @GuardedBy annotations',
1060 'patterns': [r".*: warning: \[GuardedByChecker\] .+"]},
1061 {'category': 'java',
1062 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001063 'description':
1064 'Java: Invalid @GuardedBy expression',
1065 'patterns': [r".*: warning: \[GuardedByValidator\] .+"]},
1066 {'category': 'java',
1067 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001068 'description':
1069 'Java: Type declaration annotated with @Immutable is not immutable',
1070 'patterns': [r".*: warning: \[Immutable\] .+"]},
1071 {'category': 'java',
1072 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001073 'description':
1074 'Java: This method does not acquire the locks specified by its @LockMethod annotation',
1075 'patterns': [r".*: warning: \[LockMethodChecker\] .+"]},
1076 {'category': 'java',
1077 'severity': severity.HIGH,
Ian Rogers6e520032016-05-13 08:59:00 -07001078 'description':
1079 'Java: This method does not acquire the locks specified by its @UnlockMethod annotation',
1080 'patterns': [r".*: warning: \[UnlockMethod\] .+"]},
Ian Rogers32bb9bd2016-05-09 23:19:42 -07001081
Ian Rogers6e520032016-05-13 08:59:00 -07001082 {'category': 'java',
1083 'severity': severity.UNKNOWN,
Ian Rogers6e520032016-05-13 08:59:00 -07001084 'description': 'Java: Unclassified/unrecognized warnings',
1085 'patterns': [r".*: warning: \[.+\] .+"]},
Ian Rogers32bb9bd2016-05-09 23:19:42 -07001086
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001087 { 'category':'aapt', 'severity':severity.MEDIUM,
Marco Nelissen8e201962010-03-10 16:16:02 -08001088 'description':'aapt: No default translation',
1089 'patterns':[r".*: warning: string '.+' has no default translation in .*"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001090 { 'category':'aapt', 'severity':severity.MEDIUM,
Marco Nelissen8e201962010-03-10 16:16:02 -08001091 'description':'aapt: Missing default or required localization',
1092 'patterns':[r".*: warning: \*\*\*\* string '.+' has no default or required localization for '.+' in .+"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001093 { 'category':'aapt', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -07001094 'description':'aapt: String marked untranslatable, but translation exists',
1095 'patterns':[r".*: warning: string '.+' in .* marked untranslatable but exists in locale '??_??'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001096 { 'category':'aapt', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -07001097 'description':'aapt: empty span in string',
1098 'patterns':[r".*: warning: empty '.+' span found in text '.+"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001099 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -07001100 'description':'Taking address of temporary',
1101 'patterns':[r".*: warning: taking address of temporary"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001102 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -07001103 'description':'Possible broken line continuation',
1104 'patterns':[r".*: warning: backslash and newline separated by space"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001105 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wundefined-var-template',
Chih-Hung Hsiehc21ddbd2016-07-20 10:08:51 -07001106 'description':'Undefined variable template',
1107 'patterns':[r".*: warning: instantiation of variable .* no definition is available"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001108 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wundefined-inline',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001109 'description':'Inline function is not defined',
1110 'patterns':[r".*: warning: inline function '.*' is not defined"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001111 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Warray-bounds',
Marco Nelissen594375d2009-07-14 09:04:04 -07001112 'description':'Array subscript out of bounds',
Marco Nelissen8e201962010-03-10 16:16:02 -08001113 'patterns':[r".*: warning: array subscript is above array bounds",
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001114 r".*: warning: Array subscript is undefined",
Marco Nelissen8e201962010-03-10 16:16:02 -08001115 r".*: warning: array subscript is below array bounds"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001116 { 'category':'C/C++', 'severity':severity.MEDIUM,
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001117 'description':'Excess elements in initializer',
1118 'patterns':[r".*: warning: excess elements in .+ initializer"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001119 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -07001120 'description':'Decimal constant is unsigned only in ISO C90',
1121 'patterns':[r".*: warning: this decimal constant is unsigned only in ISO C90"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001122 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wmain',
Marco Nelissen594375d2009-07-14 09:04:04 -07001123 'description':'main is usually a function',
1124 'patterns':[r".*: warning: 'main' is usually a function"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001125 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -07001126 'description':'Typedef ignored',
1127 'patterns':[r".*: warning: 'typedef' was ignored in this declaration"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001128 { 'category':'C/C++', 'severity':severity.HIGH, 'option':'-Waddress',
Marco Nelissen594375d2009-07-14 09:04:04 -07001129 'description':'Address always evaluates to true',
1130 'patterns':[r".*: warning: the address of '.+' will always evaluate as 'true'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001131 { 'category':'C/C++', 'severity':severity.FIXMENOW,
Marco Nelissen594375d2009-07-14 09:04:04 -07001132 'description':'Freeing a non-heap object',
1133 'patterns':[r".*: warning: attempt to free a non-heap object '.+'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001134 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wchar-subscripts',
Marco Nelissen594375d2009-07-14 09:04:04 -07001135 'description':'Array subscript has type char',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001136 'patterns':[r".*: warning: array subscript .+ type 'char'.+Wchar-subscripts"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001137 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -07001138 'description':'Constant too large for type',
1139 'patterns':[r".*: warning: integer constant is too large for '.+' type"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001140 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Woverflow',
Marco Nelissen594375d2009-07-14 09:04:04 -07001141 'description':'Constant too large for type, truncated',
1142 'patterns':[r".*: warning: large integer implicitly truncated to unsigned type"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001143 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Winteger-overflow',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001144 'description':'Overflow in expression',
1145 'patterns':[r".*: warning: overflow in expression; .*Winteger-overflow"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001146 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Woverflow',
Marco Nelissen594375d2009-07-14 09:04:04 -07001147 'description':'Overflow in implicit constant conversion',
1148 'patterns':[r".*: warning: overflow in implicit constant conversion"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001149 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -07001150 'description':'Declaration does not declare anything',
1151 'patterns':[r".*: warning: declaration 'class .+' does not declare anything"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001152 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wreorder',
Marco Nelissen594375d2009-07-14 09:04:04 -07001153 'description':'Initialization order will be different',
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001154 'patterns':[r".*: warning: '.+' will be initialized after",
1155 r".*: warning: field .+ will be initialized after .+Wreorder"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001156 { 'category':'cont.', 'severity':severity.SKIP,
Marco Nelissen594375d2009-07-14 09:04:04 -07001157 'description':'',
1158 'patterns':[r".*: warning: '.+'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001159 { 'category':'cont.', 'severity':severity.SKIP,
Marco Nelissen594375d2009-07-14 09:04:04 -07001160 'description':'',
Marco Nelissen8e201962010-03-10 16:16:02 -08001161 'patterns':[r".*: warning: base '.+'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001162 { 'category':'cont.', 'severity':severity.SKIP,
Marco Nelissen8e201962010-03-10 16:16:02 -08001163 'description':'',
Marco Nelissen594375d2009-07-14 09:04:04 -07001164 'patterns':[r".*: warning: when initialized here"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001165 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wmissing-parameter-type',
Marco Nelissen594375d2009-07-14 09:04:04 -07001166 'description':'Parameter type not specified',
1167 'patterns':[r".*: warning: type of '.+' defaults to 'int'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001168 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wmissing-declarations',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001169 'description':'Missing declarations',
1170 'patterns':[r".*: warning: declaration does not declare anything"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001171 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wmissing-noreturn',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001172 'description':'Missing noreturn',
1173 'patterns':[r".*: warning: function '.*' could be declared with attribute 'noreturn'"] },
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001174 # pylint:disable=anomalous-backslash-in-string
1175 # TODO(chh): fix the backslash pylint warning.
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001176 { 'category':'gcc', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -07001177 'description':'Invalid option for C file',
1178 'patterns':[r".*: warning: command line option "".+"" is valid for C\+\+\/ObjC\+\+ but not for C"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001179 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -07001180 'description':'User warning',
1181 'patterns':[r".*: warning: #warning "".+"""] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001182 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wvexing-parse',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001183 'description':'Vexing parsing problem',
1184 'patterns':[r".*: warning: empty parentheses interpreted as a function declaration"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001185 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wextra',
Marco Nelissen594375d2009-07-14 09:04:04 -07001186 'description':'Dereferencing void*',
1187 'patterns':[r".*: warning: dereferencing 'void \*' pointer"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001188 { 'category':'C/C++', 'severity':severity.MEDIUM,
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001189 'description':'Comparison of pointer and integer',
1190 'patterns':[r".*: warning: ordered comparison of pointer with integer zero",
1191 r".*: warning: .*comparison between pointer and integer"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001192 { 'category':'C/C++', 'severity':severity.MEDIUM,
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001193 'description':'Use of error-prone unary operator',
1194 'patterns':[r".*: warning: use of unary operator that may be intended as compound assignment"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001195 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wwrite-strings',
Marco Nelissen594375d2009-07-14 09:04:04 -07001196 'description':'Conversion of string constant to non-const char*',
1197 'patterns':[r".*: warning: deprecated conversion from string constant to '.+'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001198 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wstrict-prototypes',
Marco Nelissen594375d2009-07-14 09:04:04 -07001199 'description':'Function declaration isn''t a prototype',
1200 'patterns':[r".*: warning: function declaration isn't a prototype"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001201 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wignored-qualifiers',
Marco Nelissen594375d2009-07-14 09:04:04 -07001202 'description':'Type qualifiers ignored on function return value',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001203 'patterns':[r".*: warning: type qualifiers ignored on function return type",
1204 r".*: warning: .+ type qualifier .+ has no effect .+Wignored-qualifiers"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001205 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -07001206 'description':'<foo> declared inside parameter list, scope limited to this definition',
1207 'patterns':[r".*: warning: '.+' declared inside parameter list"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001208 { 'category':'cont.', 'severity':severity.SKIP,
Marco Nelissen594375d2009-07-14 09:04:04 -07001209 'description':'',
1210 '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 -07001211 { 'category':'C/C++', 'severity':severity.LOW, 'option':'-Wcomment',
Marco Nelissen594375d2009-07-14 09:04:04 -07001212 'description':'Line continuation inside comment',
1213 'patterns':[r".*: warning: multi-line comment"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001214 { 'category':'C/C++', 'severity':severity.LOW, 'option':'-Wcomment',
Marco Nelissen8e201962010-03-10 16:16:02 -08001215 'description':'Comment inside comment',
1216 'patterns':[r".*: warning: "".+"" within comment"] },
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001217 # Warning "value stored is never read" could be from clang-tidy or clang static analyzer.
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001218 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001219 'description':'clang-tidy Value stored is never read',
1220 'patterns':[r".*: warning: Value stored to .+ is never read.*clang-analyzer-deadcode.DeadStores"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001221 { 'category':'C/C++', 'severity':severity.LOW,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001222 'description':'Value stored is never read',
1223 'patterns':[r".*: warning: Value stored to .+ is never read"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001224 { 'category':'C/C++', 'severity':severity.LOW, 'option':'-Wdeprecated-declarations',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001225 'description':'Deprecated declarations',
1226 'patterns':[r".*: warning: .+ is deprecated.+deprecated-declarations"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001227 { 'category':'C/C++', 'severity':severity.LOW, 'option':'-Wdeprecated-register',
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001228 'description':'Deprecated register',
1229 'patterns':[r".*: warning: 'register' storage class specifier is deprecated"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001230 { 'category':'C/C++', 'severity':severity.LOW, 'option':'-Wpointer-sign',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001231 'description':'Converts between pointers to integer types with different sign',
1232 'patterns':[r".*: warning: .+ converts between pointers to integer types with different sign"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001233 { 'category':'C/C++', 'severity':severity.HARMLESS,
Marco Nelissen594375d2009-07-14 09:04:04 -07001234 'description':'Extra tokens after #endif',
1235 'patterns':[r".*: warning: extra tokens at end of #endif directive"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001236 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wenum-compare',
Marco Nelissen594375d2009-07-14 09:04:04 -07001237 'description':'Comparison between different enums',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001238 'patterns':[r".*: warning: comparison between '.+' and '.+'.+Wenum-compare"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001239 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wconversion',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001240 'description':'Conversion may change value',
1241 'patterns':[r".*: warning: converting negative value '.+' to '.+'",
Chih-Hung Hsieh01530a62016-08-24 12:24:32 -07001242 r".*: warning: conversion to '.+' .+ may (alter|change)"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001243 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wconversion-null',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001244 'description':'Converting to non-pointer type from NULL',
1245 'patterns':[r".*: warning: converting to non-pointer type '.+' from NULL"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001246 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wnull-conversion',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001247 'description':'Converting NULL to non-pointer type',
1248 'patterns':[r".*: warning: implicit conversion of NULL constant to '.+'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001249 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wnon-literal-null-conversion',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001250 'description':'Zero used as null pointer',
1251 'patterns':[r".*: warning: expression .* zero treated as a null pointer constant"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001252 { 'category':'C/C++', 'severity':severity.MEDIUM,
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001253 'description':'Implicit conversion changes value',
Chih-Hung Hsiehc21ddbd2016-07-20 10:08:51 -07001254 'patterns':[r".*: warning: implicit conversion .* changes value from .* to .*-conversion"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001255 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen594375d2009-07-14 09:04:04 -07001256 'description':'Passing NULL as non-pointer argument',
Marco Nelissen5236fbd2009-07-31 08:30:34 -07001257 'patterns':[r".*: warning: passing NULL to non-pointer argument [0-9]+ of '.+'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001258 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wctor-dtor-privacy',
Marco Nelissen594375d2009-07-14 09:04:04 -07001259 'description':'Class seems unusable because of private ctor/dtor' ,
1260 'patterns':[r".*: warning: all member functions in class '.+' are private"] },
1261 # 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 -07001262 { 'category':'C/C++', 'severity':severity.SKIP, '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 a private destructor and has no friends"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001265 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wctor-dtor-privacy',
Marco Nelissen594375d2009-07-14 09:04:04 -07001266 'description':'Class seems unusable because of private ctor/dtor' ,
1267 'patterns':[r".*: warning: 'class .+' only defines private constructors and has no friends"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001268 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wgnu-static-float-init',
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001269 'description':'In-class initializer for static const float/double' ,
1270 'patterns':[r".*: warning: in-class initializer for static data member of .+const (float|double)"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001271 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wpointer-arith',
Marco Nelissen594375d2009-07-14 09:04:04 -07001272 'description':'void* used in arithmetic' ,
1273 'patterns':[r".*: warning: pointer of type 'void \*' used in (arithmetic|subtraction)",
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001274 r".*: warning: arithmetic on .+ to void is a GNU extension.*Wpointer-arith",
Marco Nelissen594375d2009-07-14 09:04:04 -07001275 r".*: warning: wrong type argument to increment"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001276 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wsign-promo',
Marco Nelissen594375d2009-07-14 09:04:04 -07001277 'description':'Overload resolution chose to promote from unsigned or enum to signed type' ,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001278 'patterns':[r".*: warning: passing '.+' chooses '.+' over '.+'.*Wsign-promo"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001279 { 'category':'cont.', 'severity':severity.SKIP,
Marco Nelissen594375d2009-07-14 09:04:04 -07001280 'description':'',
1281 'patterns':[r".*: warning: in call to '.+'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001282 { 'category':'C/C++', 'severity':severity.HIGH, 'option':'-Wextra',
Marco Nelissen5236fbd2009-07-31 08:30:34 -07001283 'description':'Base should be explicitly initialized in copy constructor',
1284 'patterns':[r".*: warning: base class '.+' should be explicitly initialized in the copy constructor"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001285 { 'category':'C/C++', 'severity':severity.MEDIUM,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001286 'description':'VLA has zero or negative size',
1287 'patterns':[r".*: warning: Declared variable-length array \(VLA\) has .+ size"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001288 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen8e201962010-03-10 16:16:02 -08001289 'description':'Return value from void function',
1290 'patterns':[r".*: warning: 'return' with a value, in function returning void"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001291 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'multichar',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001292 'description':'Multi-character character constant',
1293 'patterns':[r".*: warning: multi-character character constant"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001294 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'writable-strings',
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001295 'description':'Conversion from string literal to char*',
1296 'patterns':[r".*: warning: .+ does not allow conversion from string literal to 'char \*'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001297 { 'category':'C/C++', 'severity':severity.LOW, 'option':'-Wextra-semi',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001298 'description':'Extra \';\'',
1299 'patterns':[r".*: warning: extra ';' .+extra-semi"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001300 { 'category':'C/C++', 'severity':severity.LOW,
Marco Nelissen8e201962010-03-10 16:16:02 -08001301 'description':'Useless specifier',
1302 'patterns':[r".*: warning: useless storage class specifier in empty declaration"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001303 { 'category':'C/C++', 'severity':severity.LOW, 'option':'-Wduplicate-decl-specifier',
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001304 'description':'Duplicate declaration specifier',
1305 'patterns':[r".*: warning: duplicate '.+' declaration specifier"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001306 { 'category':'logtags', 'severity':severity.LOW,
Marco Nelissen8e201962010-03-10 16:16:02 -08001307 'description':'Duplicate logtag',
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001308 'patterns':[r".*: warning: tag \".+\" \(.+\) duplicated in .+"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001309 { 'category':'logtags', 'severity':severity.LOW, 'option':'typedef-redefinition',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001310 'description':'Typedef redefinition',
1311 'patterns':[r".*: warning: redefinition of typedef '.+' is a C11 feature"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001312 { 'category':'logtags', 'severity':severity.LOW, 'option':'gnu-designator',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001313 'description':'GNU old-style field designator',
1314 'patterns':[r".*: warning: use of GNU old-style field designator extension"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001315 { 'category':'logtags', 'severity':severity.LOW, 'option':'missing-field-initializers',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001316 'description':'Missing field initializers',
1317 'patterns':[r".*: warning: missing field '.+' initializer"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001318 { 'category':'logtags', 'severity':severity.LOW, 'option':'missing-braces',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001319 'description':'Missing braces',
1320 'patterns':[r".*: warning: suggest braces around initialization of",
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001321 r".*: warning: too many braces around scalar initializer .+Wmany-braces-around-scalar-init",
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001322 r".*: warning: braces around scalar initializer"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001323 { 'category':'logtags', 'severity':severity.LOW, 'option':'sign-compare',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001324 'description':'Comparison of integers of different signs',
1325 'patterns':[r".*: warning: comparison of integers of different signs.+sign-compare"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001326 { 'category':'logtags', 'severity':severity.LOW, 'option':'dangling-else',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001327 'description':'Add braces to avoid dangling else',
1328 'patterns':[r".*: warning: add explicit braces to avoid dangling else"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001329 { 'category':'logtags', 'severity':severity.LOW, 'option':'initializer-overrides',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001330 'description':'Initializer overrides prior initialization',
1331 'patterns':[r".*: warning: initializer overrides prior initialization of this subobject"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001332 { 'category':'logtags', 'severity':severity.LOW, 'option':'self-assign',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001333 'description':'Assigning value to self',
1334 'patterns':[r".*: warning: explicitly assigning value of .+ to itself"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001335 { 'category':'logtags', 'severity':severity.LOW, 'option':'gnu-variable-sized-type-not-at-end',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001336 'description':'GNU extension, variable sized type not at end',
1337 '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 -07001338 { 'category':'logtags', 'severity':severity.LOW, 'option':'tautological-constant-out-of-range-compare',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001339 'description':'Comparison of constant is always false/true',
1340 'patterns':[r".*: comparison of .+ is always .+Wtautological-constant-out-of-range-compare"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001341 { 'category':'logtags', 'severity':severity.LOW, 'option':'overloaded-virtual',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001342 'description':'Hides overloaded virtual function',
1343 'patterns':[r".*: '.+' hides overloaded virtual function"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001344 { 'category':'logtags', 'severity':severity.LOW, 'option':'incompatible-pointer-types',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001345 'description':'Incompatible pointer types',
1346 'patterns':[r".*: warning: incompatible pointer types .+Wincompatible-pointer-types"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001347 { 'category':'logtags', 'severity':severity.LOW, 'option':'asm-operand-widths',
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001348 'description':'ASM value size does not match register size',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001349 'patterns':[r".*: warning: value size does not match register size specified by the constraint and modifier"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001350 { 'category':'C/C++', 'severity':severity.LOW, 'option':'tautological-compare',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001351 'description':'Comparison of self is always false',
1352 'patterns':[r".*: self-comparison always evaluates to false"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001353 { 'category':'C/C++', 'severity':severity.LOW, 'option':'constant-logical-operand',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001354 'description':'Logical op with constant operand',
1355 'patterns':[r".*: use of logical '.+' with constant operand"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001356 { 'category':'C/C++', 'severity':severity.LOW, 'option':'literal-suffix',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001357 'description':'Needs a space between literal and string macro',
1358 'patterns':[r".*: warning: invalid suffix on literal.+ requires a space .+Wliteral-suffix"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001359 { 'category':'C/C++', 'severity':severity.LOW, 'option':'#warnings',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001360 'description':'Warnings from #warning',
1361 'patterns':[r".*: warning: .+-W#warnings"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001362 { 'category':'C/C++', 'severity':severity.LOW, 'option':'absolute-value',
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001363 'description':'Using float/int absolute value function with int/float argument',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001364 'patterns':[r".*: warning: using .+ absolute value function .+ when argument is .+ type .+Wabsolute-value",
1365 r".*: warning: absolute value function '.+' given .+ which may cause truncation .+Wabsolute-value"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001366 { 'category':'C/C++', 'severity':severity.LOW, 'option':'-Wc++11-extensions',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001367 'description':'Using C++11 extensions',
1368 'patterns':[r".*: warning: 'auto' type specifier is a C\+\+11 extension"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001369 { 'category':'C/C++', 'severity':severity.LOW,
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001370 'description':'Refers to implicitly defined namespace',
1371 'patterns':[r".*: warning: using directive refers to implicitly-defined namespace .+"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001372 { 'category':'C/C++', 'severity':severity.LOW, 'option':'-Winvalid-pp-token',
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001373 'description':'Invalid pp token',
1374 'patterns':[r".*: warning: missing .+Winvalid-pp-token"] },
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001375
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001376 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen8e201962010-03-10 16:16:02 -08001377 'description':'Operator new returns NULL',
1378 'patterns':[r".*: warning: 'operator new' must not return NULL unless it is declared 'throw\(\)' .+"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001379 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wnull-arithmetic',
Marco Nelissen8e201962010-03-10 16:16:02 -08001380 'description':'NULL used in arithmetic',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001381 'patterns':[r".*: warning: NULL used in arithmetic",
1382 r".*: warning: comparison between NULL and non-pointer"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001383 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'header-guard',
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001384 'description':'Misspelled header guard',
1385 'patterns':[r".*: warning: '.+' is used as a header guard .+ followed by .+ different macro"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001386 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'empty-body',
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001387 'description':'Empty loop body',
1388 'patterns':[r".*: warning: .+ loop has empty body"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001389 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'enum-conversion',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001390 'description':'Implicit conversion from enumeration type',
1391 'patterns':[r".*: warning: implicit conversion from enumeration type '.+'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001392 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'switch',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001393 'description':'case value not in enumerated type',
1394 'patterns':[r".*: warning: case value not in enumerated type '.+'"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001395 { 'category':'C/C++', 'severity':severity.MEDIUM,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001396 'description':'Undefined result',
1397 'patterns':[r".*: warning: The result of .+ is undefined",
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07001398 r".*: warning: passing an object that .+ has undefined behavior \[-Wvarargs\]",
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001399 r".*: warning: 'this' pointer cannot be null in well-defined C\+\+ code;",
1400 r".*: warning: shifting a negative signed value is undefined"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001401 { 'category':'C/C++', 'severity':severity.MEDIUM,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001402 'description':'Division by zero',
1403 'patterns':[r".*: warning: Division by zero"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001404 { 'category':'C/C++', 'severity':severity.MEDIUM,
Marco Nelissen8e201962010-03-10 16:16:02 -08001405 'description':'Use of deprecated method',
1406 'patterns':[r".*: warning: '.+' is deprecated .+"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001407 { 'category':'C/C++', 'severity':severity.MEDIUM,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001408 'description':'Use of garbage or uninitialized value',
1409 'patterns':[r".*: warning: .+ is a garbage value",
1410 r".*: warning: Function call argument is an uninitialized value",
1411 r".*: warning: Undefined or garbage value returned to caller",
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -07001412 r".*: warning: Called .+ pointer is.+uninitialized",
1413 r".*: warning: Called .+ pointer is.+uninitalized", # match a typo in compiler message
1414 r".*: warning: Use of zero-allocated memory",
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001415 r".*: warning: Dereference of undefined pointer value",
1416 r".*: warning: Passed-by-value .+ contains uninitialized data",
1417 r".*: warning: Branch condition evaluates to a garbage value",
1418 r".*: warning: The .+ of .+ is an uninitialized value.",
1419 r".*: warning: .+ is used uninitialized whenever .+sometimes-uninitialized",
1420 r".*: warning: Assigned value is garbage or undefined"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001421 { 'category':'C/C++', 'severity':severity.MEDIUM,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001422 'description':'Result of malloc type incompatible with sizeof operand type',
1423 'patterns':[r".*: warning: Result of '.+' is converted to .+ incompatible with sizeof operand type"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001424 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wsizeof-array-argument',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001425 'description':'Sizeof on array argument',
1426 'patterns':[r".*: warning: sizeof on array function parameter will return"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001427 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wsizeof-pointer-memacces',
Chih-Hung Hsieh8d145432016-07-01 15:48:06 -07001428 'description':'Bad argument size of memory access functions',
1429 'patterns':[r".*: warning: .+\[-Wsizeof-pointer-memaccess\]"] },
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':'Return value not checked',
1432 'patterns':[r".*: warning: The return value from .+ is not checked"] },
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':'Possible heap pollution',
1435 'patterns':[r".*: warning: .*Possible heap pollution from .+ type .+"] },
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':'Allocation size of 0 byte',
1438 'patterns':[r".*: warning: Call to .+ has an allocation size of 0 byte"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001439 { 'category':'C/C++', 'severity':severity.MEDIUM,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001440 'description':'Result of malloc type incompatible with sizeof operand type',
1441 'patterns':[r".*: warning: Result of '.+' is converted to .+ incompatible with sizeof operand type"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001442 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wfor-loop-analysis',
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001443 'description':'Variable used in loop condition not modified in loop body',
1444 'patterns':[r".*: warning: variable '.+' used in loop condition.*Wfor-loop-analysis"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001445 { 'category':'C/C++', 'severity':severity.MEDIUM,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001446 'description':'Closing a previously closed file',
1447 'patterns':[r".*: warning: Closing a previously closed file"] },
Chih-Hung Hsieh0a192072016-09-21 14:00:23 -07001448 { 'category':'C/C++', 'severity':severity.MEDIUM, 'option':'-Wunnamed-type-template-args',
1449 'description':'Unnamed template type argument',
1450 'patterns':[r".*: warning: template argument.+Wunnamed-type-template-args"] },
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001451
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':'Discarded qualifier from pointer target type',
1454 'patterns':[r".*: warning: .+ discards '.+' qualifier from pointer target type"] },
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':'Use snprintf instead of sprintf',
1457 'patterns':[r".*: warning: .*sprintf is often misused; please use snprintf"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001458 { 'category':'C/C++', 'severity':severity.HARMLESS,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001459 'description':'Unsupported optimizaton flag',
1460 'patterns':[r".*: warning: optimization flag '.+' is not supported"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001461 { 'category':'C/C++', 'severity':severity.HARMLESS,
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001462 'description':'Extra or missing parentheses',
1463 'patterns':[r".*: warning: equality comparison with extraneous parentheses",
1464 r".*: warning: .+ within .+Wlogical-op-parentheses"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001465 { 'category':'C/C++', 'severity':severity.HARMLESS, 'option':'mismatched-tags',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -07001466 'description':'Mismatched class vs struct tags',
1467 'patterns':[r".*: warning: '.+' defined as a .+ here but previously declared as a .+mismatched-tags",
1468 r".*: warning: .+ was previously declared as a .+mismatched-tags"] },
Marco Nelissen594375d2009-07-14 09:04:04 -07001469
1470 # 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 -07001471 { 'category':'C/C++', 'severity':severity.SKIP,
Marco Nelissen594375d2009-07-14 09:04:04 -07001472 'description':'',
1473 'patterns':[r".*: warning: ,$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001474 { 'category':'C/C++', 'severity':severity.SKIP,
Marco Nelissen594375d2009-07-14 09:04:04 -07001475 'description':'',
1476 'patterns':[r".*: warning: $"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001477 { 'category':'C/C++', 'severity':severity.SKIP,
Marco Nelissen594375d2009-07-14 09:04:04 -07001478 'description':'',
1479 'patterns':[r".*: warning: In file included from .+,"] },
1480
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001481 # warnings from clang-tidy
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001482 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001483 'description':'clang-tidy readability',
1484 'patterns':[r".*: .+\[readability-.+\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001485 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001486 'description':'clang-tidy c++ core guidelines',
1487 'patterns':[r".*: .+\[cppcoreguidelines-.+\]$"] },
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-default-arguments',
1490 'patterns':[r".*: .+\[google-default-arguments\]$"] },
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-int',
1493 'patterns':[r".*: .+\[google-runtime-int\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001494 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsiehc21ddbd2016-07-20 10:08:51 -07001495 'description':'clang-tidy google-runtime-operator',
1496 'patterns':[r".*: .+\[google-runtime-operator\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001497 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsiehc21ddbd2016-07-20 10:08:51 -07001498 'description':'clang-tidy google-runtime-references',
1499 'patterns':[r".*: .+\[google-runtime-references\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001500 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001501 'description':'clang-tidy google-build',
1502 'patterns':[r".*: .+\[google-build-.+\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001503 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001504 'description':'clang-tidy google-explicit',
1505 'patterns':[r".*: .+\[google-explicit-.+\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001506 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsiehd742e902016-03-31 16:14:55 -07001507 'description':'clang-tidy google-readability',
1508 'patterns':[r".*: .+\[google-readability-.+\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001509 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsiehd742e902016-03-31 16:14:55 -07001510 'description':'clang-tidy google-global',
1511 'patterns':[r".*: .+\[google-global-.+\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001512 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsiehc21ddbd2016-07-20 10:08:51 -07001513 'description':'clang-tidy google- other',
1514 'patterns':[r".*: .+\[google-.+\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001515 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001516 'description':'clang-tidy modernize',
1517 'patterns':[r".*: .+\[modernize-.+\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001518 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001519 'description':'clang-tidy misc',
1520 'patterns':[r".*: .+\[misc-.+\]$"] },
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-faster-string-find',
1523 'patterns':[r".*: .+\[performance-faster-string-find\]$"] },
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-for-range-copy',
1526 'patterns':[r".*: .+\[performance-for-range-copy\]$"] },
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-implicit-cast-in-loop',
1529 'patterns':[r".*: .+\[performance-implicit-cast-in-loop\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001530 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsiehc8682932016-07-26 14:27:03 -07001531 'description':'clang-tidy performance-unnecessary-copy-initialization',
1532 'patterns':[r".*: .+\[performance-unnecessary-copy-initialization\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001533 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsiehc8682932016-07-26 14:27:03 -07001534 'description':'clang-tidy performance-unnecessary-value-param',
1535 'patterns':[r".*: .+\[performance-unnecessary-value-param\]$"] },
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 Unreachable code',
1538 'patterns':[r".*: warning: This statement is never executed.*UnreachableCode"] },
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 Size of malloc may overflow',
1541 'patterns':[r".*: warning: .* size of .* may overflow .*MallocOverflow"] },
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 Stream pointer might be NULL',
1544 'patterns':[r".*: warning: Stream pointer might be NULL .*unix.Stream"] },
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 Opened file never closed',
1547 'patterns':[r".*: warning: Opened File never closed.*unix.Stream"] },
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 sozeof() on a pointer type',
1550 'patterns':[r".*: warning: .*calls sizeof.* on a pointer type.*SizeofPtr"] },
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 Pointer arithmetic on non-array variables',
1553 'patterns':[r".*: warning: Pointer arithmetic on non-array variables .*PointerArithm"] },
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 Subtraction of pointers of different memory chunks',
1556 'patterns':[r".*: warning: Subtraction of two pointers .*PointerSub"] },
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 Access out-of-bound array element',
1559 'patterns':[r".*: warning: Access out-of-bound array element .*ArrayBound"] },
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 Out of bound memory access',
1562 'patterns':[r".*: warning: Out of bound memory access .*ArrayBoundV2"] },
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 Possible lock order reversal',
1565 'patterns':[r".*: warning: .* Possible lock order reversal.*PthreadLock"] },
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 Argument is a pointer to uninitialized value',
1568 'patterns':[r".*: warning: .* argument is a pointer to uninitialized value .*CallAndMessage"] },
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 cast to struct',
1571 'patterns':[r".*: warning: Casting a non-structure type to a structure type .*CastToStruct"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001572 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001573 'description':'clang-analyzer call path problems',
1574 'patterns':[r".*: warning: Call Path : .+"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001575 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001576 'description':'clang-analyzer other',
1577 'patterns':[r".*: .+\[clang-analyzer-.+\]$",
1578 r".*: Call Path : .+$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001579 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001580 'description':'clang-tidy CERT',
1581 'patterns':[r".*: .+\[cert-.+\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001582 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001583 'description':'clang-tidy llvm',
1584 'patterns':[r".*: .+\[llvm-.+\]$"] },
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001585 { 'category':'C/C++', 'severity':severity.TIDY,
Chih-Hung Hsieh0862c482016-09-06 16:26:46 -07001586 'description':'clang-diagnostic',
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001587 'patterns':[r".*: .+\[clang-diagnostic-.+\]$"] },
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -07001588
Marco Nelissen594375d2009-07-14 09:04:04 -07001589 # catch-all for warnings this script doesn't know about yet
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001590 { 'category':'C/C++', 'severity':severity.UNKNOWN,
Marco Nelissen594375d2009-07-14 09:04:04 -07001591 'description':'Unclassified/unrecognized warnings',
1592 'patterns':[r".*: warning: .+"] },
1593]
1594
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001595
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001596# A list of [project_name, file_path_pattern].
1597# project_name should not contain comma, to be used in CSV output.
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001598project_list = [
1599 # pylint:disable=bad-whitespace,g-inconsistent-quotes,line-too-long
Chih-Hung Hsieh4354a332016-07-22 14:09:31 -07001600 ['art', r"(^|.*/)art/.*: warning:"],
1601 ['bionic', r"(^|.*/)bionic/.*: warning:"],
1602 ['bootable', r"(^|.*/)bootable/.*: warning:"],
1603 ['build', r"(^|.*/)build/.*: warning:"],
1604 ['cts', r"(^|.*/)cts/.*: warning:"],
1605 ['dalvik', r"(^|.*/)dalvik/.*: warning:"],
1606 ['developers', r"(^|.*/)developers/.*: warning:"],
1607 ['development', r"(^|.*/)development/.*: warning:"],
1608 ['device', r"(^|.*/)device/.*: warning:"],
1609 ['doc', r"(^|.*/)doc/.*: warning:"],
1610 # match external/google* before external/
1611 ['external/google', r"(^|.*/)external/google.*: warning:"],
1612 ['external/non-google', r"(^|.*/)external/.*: warning:"],
1613 ['frameworks', r"(^|.*/)frameworks/.*: warning:"],
1614 ['hardware', r"(^|.*/)hardware/.*: warning:"],
1615 ['kernel', r"(^|.*/)kernel/.*: warning:"],
1616 ['libcore', r"(^|.*/)libcore/.*: warning:"],
1617 ['libnativehelper', r"(^|.*/)libnativehelper/.*: warning:"],
1618 ['ndk', r"(^|.*/)ndk/.*: warning:"],
1619 ['packages', r"(^|.*/)packages/.*: warning:"],
1620 ['pdk', r"(^|.*/)pdk/.*: warning:"],
1621 ['prebuilts', r"(^|.*/)prebuilts/.*: warning:"],
1622 ['system', r"(^|.*/)system/.*: warning:"],
1623 ['toolchain', r"(^|.*/)toolchain/.*: warning:"],
1624 ['test', r"(^|.*/)test/.*: warning:"],
1625 ['tools', r"(^|.*/)tools/.*: warning:"],
1626 # match vendor/google* before vendor/
1627 ['vendor/google', r"(^|.*/)vendor/google.*: warning:"],
1628 ['vendor/non-google', r"(^|.*/)vendor/.*: warning:"],
1629 # keep out/obj and other patterns at the end.
1630 ['out/obj', r".*/(gen|obj[^/]*)/(include|EXECUTABLES|SHARED_LIBRARIES|STATIC_LIBRARIES)/.*: warning:"],
1631 ['other', r".*: warning:"],
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001632]
1633
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001634project_patterns = []
1635project_names = []
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001636
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001637
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001638def initialize_arrays():
1639 """Complete global arrays before they are used."""
1640 global project_names
1641 project_names = [p[0] for p in project_list]
1642 for p in project_list:
1643 project_patterns.append({'description': p[0],
1644 'members': [],
1645 'pattern': re.compile(p[1])})
1646 # Each warning pattern has 3 dictionaries:
1647 # (1) 'projects' maps a project name to number of warnings in that project.
1648 # (2) 'project_anchor' maps a project name to its anchor number for HTML.
1649 # (3) 'project_warnings' maps a project name to a list of warning messages.
1650 for w in warn_patterns:
1651 w['members'] = []
1652 if 'option' not in w:
1653 w['option'] = ''
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001654 w['projects'] = {}
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001655 w['project_anchor'] = {}
1656 w['project_warnings'] = {}
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001657
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001658
1659initialize_arrays()
1660
1661
1662platform_version = 'unknown'
1663target_product = 'unknown'
1664target_variant = 'unknown'
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001665
1666
1667##### Data and functions to dump html file. ##################################
1668
Marco Nelissen594375d2009-07-14 09:04:04 -07001669anchor = 0
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07001670cur_row_class = 0
1671
1672html_script_style = """\
1673 <script type="text/javascript">
1674 function expand(id) {
1675 var e = document.getElementById(id);
1676 var f = document.getElementById(id + "_mark");
1677 if (e.style.display == 'block') {
1678 e.style.display = 'none';
1679 f.innerHTML = '&#x2295';
1680 }
1681 else {
1682 e.style.display = 'block';
1683 f.innerHTML = '&#x2296';
1684 }
1685 };
1686 function expand_collapse(show) {
1687 for (var id = 1; ; id++) {
1688 var e = document.getElementById(id + "");
1689 var f = document.getElementById(id + "_mark");
1690 if (!e || !f) break;
1691 e.style.display = (show ? 'block' : 'none');
1692 f.innerHTML = (show ? '&#x2296' : '&#x2295');
1693 }
1694 };
1695 </script>
1696 <style type="text/css">
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001697 th,td{border-collapse:collapse; border:1px solid black;}
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07001698 .button{color:blue;font-size:110%;font-weight:bolder;}
1699 .bt{color:black;background-color:transparent;border:none;outline:none;
1700 font-size:140%;font-weight:bolder;}
1701 .c0{background-color:#e0e0e0;}
1702 .c1{background-color:#d0d0d0;}
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001703 .t1{border-collapse:collapse; width:100%; border:1px solid black;}
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07001704 </style>\n"""
1705
Marco Nelissen594375d2009-07-14 09:04:04 -07001706
1707def output(text):
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001708 print text,
Marco Nelissen594375d2009-07-14 09:04:04 -07001709
Marco Nelissen594375d2009-07-14 09:04:04 -07001710
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001711def html_big(param):
1712 return '<font size="+2">' + param + '</font>'
Marco Nelissen594375d2009-07-14 09:04:04 -07001713
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07001714
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001715def dump_html_prologue(title):
1716 output('<html>\n<head>\n')
1717 output('<title>' + title + '</title>\n')
1718 output(html_script_style)
1719 output('</head>\n<body>\n')
1720 output(html_big(title))
1721 output('<p>\n')
Marco Nelissen594375d2009-07-14 09:04:04 -07001722
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001723
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001724def dump_html_epilogue():
1725 output('</body>\n</head>\n</html>\n')
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001726
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001727
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001728def table_row(text):
1729 global cur_row_class
1730 cur_row_class = 1 - cur_row_class
1731 # remove last '\n'
1732 t = text[:-1] if text[-1] == '\n' else text
1733 output('<tr><td class="c' + str(cur_row_class) + '">' + t + '</td></tr>\n')
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001734
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001735
1736def sort_warnings():
1737 for i in warn_patterns:
1738 i['members'] = sorted(set(i['members']))
1739
1740
1741def dump_stats_by_project():
1742 """Dump a table of warnings per project and severity."""
1743 # warnings[p][s] is number of warnings in project p of severity s.
1744 warnings = {p: {s: 0 for s in severity.kinds} for p in project_names}
1745 for i in warn_patterns:
1746 s = i['severity']
1747 for p in i['projects']:
1748 warnings[p][s] += i['projects'][p]
1749
1750 # total_by_project[p] is number of warnings in project p.
1751 total_by_project = {p: sum(warnings[p][s] for s in severity.kinds)
1752 for p in project_names}
1753
1754 # total_by_severity[s] is number of warnings of severity s.
1755 total_by_severity = {s: sum(warnings[p][s] for p in project_names)
Chih-Hung Hsieh99459fc2016-09-22 13:43:12 -07001756 for s in severity.kinds}
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001757
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001758 # emit table header
1759 output('<blockquote><table border=1>\n<tr><th>Project</th>\n')
1760 for s in severity.kinds:
1761 if total_by_severity[s]:
1762 output('<th width="8%"><span style="background-color:{}">{}</span></th>'.
1763 format(severity.color[s], severity.column_headers[s]))
1764 output('<th>TOTAL</th></tr>\n')
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001765
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001766 # emit a row of warning counts per project, skip no-warning projects
1767 total_all_projects = 0
1768 for p in project_names:
1769 if total_by_project[p]:
1770 output('<tr><td align="left">{}</td>'.format(p))
1771 for s in severity.kinds:
1772 if total_by_severity[s]:
1773 output('<td align="right">{}</td>'.format(warnings[p][s]))
1774 output('<td align="right">{}</td>'.format(total_by_project[p]))
1775 total_all_projects += total_by_project[p]
1776 output('</tr>\n')
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001777
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001778 # emit a row of warning counts per severity
1779 total_all_severities = 0
1780 output('<tr><td align="right">TOTAL</td>')
1781 for s in severity.kinds:
1782 if total_by_severity[s]:
1783 output('<td align="right">{}</td>'.format(total_by_severity[s]))
1784 total_all_severities += total_by_severity[s]
1785 output('<td align="right">{}</td></tr>\n'.format(total_all_projects))
Chih-Hung Hsiehe41c99b2016-09-12 16:20:49 -07001786
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001787 # at the end of table, verify total counts
1788 output('</table></blockquote><br>\n')
1789 if total_all_projects != total_all_severities:
1790 output('<h3>ERROR: Sum of warnings by project '
1791 '!= Sum of warnings by severity.</h3>\n')
Marco Nelissen594375d2009-07-14 09:04:04 -07001792
1793
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001794def dump_stats():
1795 """Dump some stats about total number of warnings and such."""
1796 known = 0
1797 skipped = 0
1798 unknown = 0
1799 sort_warnings()
1800 for i in warn_patterns:
1801 if i['severity'] == severity.UNKNOWN:
1802 unknown += len(i['members'])
1803 elif i['severity'] == severity.SKIP:
1804 skipped += len(i['members'])
Ian Rogersf3829732016-05-10 12:06:01 -07001805 else:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001806 known += len(i['members'])
1807 output('\nNumber of classified warnings: <b>' + str(known) + '</b><br>')
1808 output('\nNumber of skipped warnings: <b>' + str(skipped) + '</b><br>')
1809 output('\nNumber of unclassified warnings: <b>' + str(unknown) + '</b><br>')
1810 total = unknown + known + skipped
1811 output('\nTotal number of warnings: <b>' + str(total) + '</b>')
1812 if total < 1000:
1813 output('(low count may indicate incremental build)')
1814 output('<br><br>\n')
Marco Nelissen594375d2009-07-14 09:04:04 -07001815
Chih-Hung Hsieh465b6102016-06-22 19:15:12 -07001816
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001817def emit_buttons():
1818 output('<button class="button" onclick="expand_collapse(1);">'
1819 'Expand all warnings</button>\n'
1820 '<button class="button" onclick="expand_collapse(0);">'
1821 'Collapse all warnings</button><br>\n')
Marco Nelissen594375d2009-07-14 09:04:04 -07001822
1823
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001824def dump_severity(sev):
1825 """Dump everything for a given severity."""
1826 global anchor
1827 total = 0
1828 for i in warn_patterns:
1829 if i['severity'] == sev:
1830 total += len(i['members'])
1831 output('\n<br><span style="background-color:' + severity.color[sev] +
1832 '"><b>' + severity.header[sev] + ': ' + str(total) + '</b></span>\n')
1833 output('<blockquote>\n')
1834 for i in warn_patterns:
1835 if i['severity'] == sev and i['members']:
1836 anchor += 1
1837 i['anchor'] = str(anchor)
1838 if args.byproject:
1839 dump_category_by_project(sev, i)
1840 else:
1841 dump_category(sev, i)
1842 output('</blockquote>\n')
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001843
Marco Nelissen594375d2009-07-14 09:04:04 -07001844
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001845def dump_skipped_anchors():
1846 """emit all skipped project anchors for expand_collapse."""
1847 output('<div style="display:none;">\n') # hide these fake elements
1848 for i in warn_patterns:
1849 if i['severity'] == severity.SKIP and i['members']:
1850 projects = i['project_warnings'].keys()
1851 for p in projects:
1852 output('<div id="' + i['project_anchor'][p] + '"></div>' +
1853 '<div id="' + i['project_anchor'][p] + '_mark"></div>\n')
1854 output('</div>\n')
Marco Nelissen594375d2009-07-14 09:04:04 -07001855
Marco Nelissen594375d2009-07-14 09:04:04 -07001856
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001857def all_patterns(cat):
1858 pats = ''
1859 for i in cat['patterns']:
1860 pats += i
1861 pats += ' / '
1862 return pats
Marco Nelissen594375d2009-07-14 09:04:04 -07001863
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001864
1865def description_for(cat):
1866 if cat['description']:
1867 return cat['description']
1868 return all_patterns(cat)
1869
1870
1871def dump_fixed():
1872 """Show which warnings no longer occur."""
1873 global anchor
1874 anchor += 1
1875 mark = str(anchor) + '_mark'
1876 output('\n<br><p style="background-color:lightblue"><b>'
1877 '<button id="' + mark + '" '
1878 'class="bt" onclick="expand(' + str(anchor) + ');">'
1879 '&#x2295</button> Fixed warnings. '
1880 'No more occurrences. Please consider turning these into '
1881 'errors if possible, before they are reintroduced in to the build'
1882 ':</b></p>\n')
1883 output('<blockquote>\n')
1884 fixed_patterns = []
1885 for i in warn_patterns:
1886 if not i['members']:
1887 fixed_patterns.append(i['description'] + ' (' +
1888 all_patterns(i) + ')')
1889 if i['option']:
1890 fixed_patterns.append(' ' + i['option'])
1891 fixed_patterns.sort()
1892 output('<div id="' + str(anchor) + '" style="display:none;"><table>\n')
1893 for i in fixed_patterns:
1894 table_row(i)
1895 output('</table></div>\n')
1896 output('</blockquote>\n')
1897
1898
1899def warning_with_url(line):
1900 """Returns a warning message line with HTML link to given args.url."""
1901 if not args.url:
1902 return line
1903 m = re.search(r'^([^ :]+):(\d+):(.+)', line, re.M|re.I)
1904 if not m:
1905 return line
1906 file_path = m.group(1)
1907 line_number = m.group(2)
1908 warning = m.group(3)
1909 prefix = '<a href="' + args.url + '/' + file_path
1910 if args.separator:
1911 return (prefix + args.separator + line_number + '">' + file_path +
1912 ':' + line_number + '</a>:' + warning)
1913 else:
1914 return prefix + '">' + file_path + '</a>:' + line_number + ':' + warning
1915
1916
1917def dump_group(sev, anchor_str, description, warnings):
1918 """Dump warnings of given severity, anchor_str, and description."""
1919 mark = anchor_str + '_mark'
1920 output('\n<table class="t1">\n')
1921 output('<tr bgcolor="' + severity.color[sev] + '">' +
1922 '<td><button class="bt" id="' + mark +
1923 '" onclick="expand(\'' + anchor_str + '\');">' +
1924 '&#x2295</button> ' + description + '</td></tr>\n')
1925 output('</table>\n')
1926 output('<div id="' + anchor_str + '" style="display:none;">')
1927 output('<table class="t1">\n')
1928 for i in warnings:
1929 table_row(warning_with_url(i))
1930 output('</table></div>\n')
1931
1932
1933def dump_category(sev, cat):
1934 """Dump warnings in a category."""
1935 description = description_for(cat) + ' (' + str(len(cat['members'])) + ')'
1936 dump_group(sev, cat['anchor'], description, cat['members'])
1937
1938
1939def dump_category_by_project(sev, cat):
1940 """Similar to dump_category but output one table per project."""
1941 warning = description_for(cat)
1942 projects = cat['project_warnings'].keys()
1943 projects.sort()
1944 for p in projects:
1945 anchor_str = cat['project_anchor'][p]
1946 project_warnings = cat['project_warnings'][p]
1947 description = '{}, in {} ({})'.format(warning, p, len(project_warnings))
1948 dump_group(sev, anchor_str, description, project_warnings)
1949
1950
1951def find_project(line):
1952 for p in project_patterns:
1953 if p['pattern'].match(line):
1954 return p['description']
1955 return '???'
1956
1957
1958def classify_warning(line):
1959 global anchor
1960 for i in warn_patterns:
1961 for cpat in i['compiled_patterns']:
1962 if cpat.match(line):
1963 i['members'].append(line)
1964 pname = find_project(line)
1965 # Count warnings by project.
1966 if pname in i['projects']:
1967 i['projects'][pname] += 1
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07001968 else:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001969 i['projects'][pname] = 1
1970 # Collect warnings by project.
1971 if args.byproject:
1972 if pname in i['project_warnings']:
1973 i['project_warnings'][pname].append(line)
1974 else:
1975 i['project_warnings'][pname] = [line]
1976 if pname not in i['project_anchor']:
1977 anchor += 1
1978 i['project_anchor'][pname] = str(anchor)
1979 return
1980 else:
1981 # If we end up here, there was a problem parsing the log
1982 # probably caused by 'make -j' mixing the output from
1983 # 2 or more concurrent compiles
1984 pass
Marco Nelissen594375d2009-07-14 09:04:04 -07001985
1986
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07001987def compile_patterns():
1988 """Precompiling every pattern speeds up parsing by about 30x."""
1989 for i in warn_patterns:
1990 i['compiled_patterns'] = []
1991 for pat in i['patterns']:
1992 i['compiled_patterns'].append(re.compile(pat))
1993
1994
1995def parse_input_file():
1996 """Parse input file, match warning lines."""
1997 global platform_version
1998 global target_product
1999 global target_variant
2000 infile = open(args.buildlog, 'r')
2001 line_counter = 0
2002
2003 warning_pattern = re.compile('.* warning:.*')
2004 compile_patterns()
2005
2006 # read the log file and classify all the warnings
2007 warning_lines = set()
2008 for line in infile:
2009 # replace fancy quotes with plain ol' quotes
2010 line = line.replace('‘', "'")
2011 line = line.replace('’', "'")
2012 if warning_pattern.match(line):
2013 if line not in warning_lines:
2014 classify_warning(line)
2015 warning_lines.add(line)
2016 else:
2017 # save a little bit of time by only doing this for the first few lines
2018 if line_counter < 50:
2019 line_counter += 1
2020 m = re.search('(?<=^PLATFORM_VERSION=).*', line)
2021 if m is not None:
2022 platform_version = m.group(0)
2023 m = re.search('(?<=^TARGET_PRODUCT=).*', line)
2024 if m is not None:
2025 target_product = m.group(0)
2026 m = re.search('(?<=^TARGET_BUILD_VARIANT=).*', line)
2027 if m is not None:
2028 target_variant = m.group(0)
2029
2030
2031def dump_html():
2032 """Dump the html output to stdout."""
2033 dump_html_prologue('Warnings for ' + platform_version + ' - ' +
2034 target_product + ' - ' + target_variant)
2035 dump_stats()
2036 dump_stats_by_project()
2037 emit_buttons()
2038 # sort table based on number of members once dump_stats has de-duplicated the
2039 # members.
2040 warn_patterns.sort(reverse=True, key=lambda i: len(i['members']))
2041 # Dump warnings by severity. If severity.SKIP warnings are not dumped,
2042 # the project anchors should be dumped through dump_skipped_anchors.
2043 for s in severity.kinds:
2044 dump_severity(s)
2045 dump_fixed()
2046 dump_html_epilogue()
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002047
2048
2049##### Functions to count warnings and dump csv file. #########################
2050
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002051
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002052def description_for_csv(cat):
2053 if not cat['description']:
2054 return '?'
2055 return cat['description']
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002056
2057
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002058def string_for_csv(s):
2059 if ',' in s:
2060 return '"{}"'.format(s)
2061 return s
2062
2063
2064def count_severity(sev, kind):
2065 """Count warnings of given severity."""
2066 total = 0
2067 for i in warn_patterns:
2068 if i['severity'] == sev and i['members']:
2069 n = len(i['members'])
2070 total += n
2071 warning = string_for_csv(kind + ': ' + description_for_csv(i))
2072 print '{},,{}'.format(n, warning)
2073 # print number of warnings for each project, ordered by project name.
2074 projects = i['projects'].keys()
2075 projects.sort()
2076 for p in projects:
2077 print '{},{},{}'.format(i['projects'][p], p, warning)
2078 print '{},,{}'.format(total, kind + ' warnings')
2079 return total
2080
2081
2082def dump_csv():
2083 """Dump number of warnings in csv format to stdout."""
2084 sort_warnings()
2085 total = 0
2086 for s in severity.kinds:
2087 total += count_severity(s, severity.column_headers[s])
2088 print '{},,{}'.format(total, 'All warnings')
2089
2090
2091parse_input_file()
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002092if args.gencsv:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002093 dump_csv()
Chih-Hung Hsieh48a16ba2016-07-21 14:22:53 -07002094else:
Chih-Hung Hsieh6c0fdbb2016-09-26 10:56:43 -07002095 dump_html()