Home | History | Annotate | Download | only in tools
      1 #!/usr/bin/python
      2 # This file uses the following encoding: utf-8
      3 
      4 """Grep warnings messages and output HTML tables or warning counts in CSV.
      5 
      6 Default is to output warnings in HTML tables grouped by warning severity.
      7 Use option --byproject to output tables grouped by source file projects.
      8 Use option --gencsv to output warning counts in CSV format.
      9 """
     10 
     11 # List of important data structures and functions in this script.
     12 #
     13 # To parse and keep warning message in the input file:
     14 #   severity:                classification of message severity
     15 #   severity.range           [0, 1, ... last_severity_level]
     16 #   severity.colors          for header background
     17 #   severity.column_headers  for the warning count table
     18 #   severity.headers         for warning message tables
     19 #   warn_patterns:
     20 #   warn_patterns[w]['category']     tool that issued the warning, not used now
     21 #   warn_patterns[w]['description']  table heading
     22 #   warn_patterns[w]['members']      matched warnings from input
     23 #   warn_patterns[w]['option']       compiler flag to control the warning
     24 #   warn_patterns[w]['patterns']     regular expressions to match warnings
     25 #   warn_patterns[w]['projects'][p]  number of warnings of pattern w in p
     26 #   warn_patterns[w]['severity']     severity level
     27 #   project_list[p][0]               project name
     28 #   project_list[p][1]               regular expression to match a project path
     29 #   project_patterns[p]              re.compile(project_list[p][1])
     30 #   project_names[p]                 project_list[p][0]
     31 #   warning_messages     array of each warning message, without source url
     32 #   warning_records      array of [idx to warn_patterns,
     33 #                                  idx to project_names,
     34 #                                  idx to warning_messages]
     35 #   android_root
     36 #   platform_version
     37 #   target_product
     38 #   target_variant
     39 #   compile_patterns, parse_input_file
     40 #
     41 # To emit html page of warning messages:
     42 #   flags: --byproject, --url, --separator
     43 # Old stuff for static html components:
     44 #   html_script_style:  static html scripts and styles
     45 #   htmlbig:
     46 #   dump_stats, dump_html_prologue, dump_html_epilogue:
     47 #   emit_buttons:
     48 #   dump_fixed
     49 #   sort_warnings:
     50 #   emit_stats_by_project:
     51 #   all_patterns,
     52 #   findproject, classify_warning
     53 #   dump_html
     54 #
     55 # New dynamic HTML page's static JavaScript data:
     56 #   Some data are copied from Python to JavaScript, to generate HTML elements.
     57 #   FlagURL                args.url
     58 #   FlagSeparator          args.separator
     59 #   SeverityColors:        severity.colors
     60 #   SeverityHeaders:       severity.headers
     61 #   SeverityColumnHeaders: severity.column_headers
     62 #   ProjectNames:          project_names, or project_list[*][0]
     63 #   WarnPatternsSeverity:     warn_patterns[*]['severity']
     64 #   WarnPatternsDescription:  warn_patterns[*]['description']
     65 #   WarnPatternsOption:       warn_patterns[*]['option']
     66 #   WarningMessages:          warning_messages
     67 #   Warnings:                 warning_records
     68 #   StatsHeader:           warning count table header row
     69 #   StatsRows:             array of warning count table rows
     70 #
     71 # New dynamic HTML page's dynamic JavaScript data:
     72 #
     73 # New dynamic HTML related function to emit data:
     74 #   escape_string, strip_escape_string, emit_warning_arrays
     75 #   emit_js_data():
     76 #
     77 # To emit csv files of warning message counts:
     78 #   flag --gencsv
     79 #   description_for_csv, string_for_csv:
     80 #   count_severity(sev, kind):
     81 #   dump_csv():
     82 
     83 import argparse
     84 import multiprocessing
     85 import os
     86 import re
     87 import signal
     88 import sys
     89 
     90 parser = argparse.ArgumentParser(description='Convert a build log into HTML')
     91 parser.add_argument('--gencsv',
     92                     help='Generate a CSV file with number of various warnings',
     93                     action='store_true',
     94                     default=False)
     95 parser.add_argument('--byproject',
     96                     help='Separate warnings in HTML output by project names',
     97                     action='store_true',
     98                     default=False)
     99 parser.add_argument('--url',
    100                     help='Root URL of an Android source code tree prefixed '
    101                     'before files in warnings')
    102 parser.add_argument('--separator',
    103                     help='Separator between the end of a URL and the line '
    104                     'number argument. e.g. #')
    105 parser.add_argument('--processes',
    106                     type=int,
    107                     default=multiprocessing.cpu_count(),
    108                     help='Number of parallel processes to process warnings')
    109 parser.add_argument(dest='buildlog', metavar='build.log',
    110                     help='Path to build.log file')
    111 args = parser.parse_args()
    112 
    113 
    114 class Severity(object):
    115   """Severity levels and attributes."""
    116   # numbered by dump order
    117   FIXMENOW = 0
    118   HIGH = 1
    119   MEDIUM = 2
    120   LOW = 3
    121   ANALYZER = 4
    122   TIDY = 5
    123   HARMLESS = 6
    124   UNKNOWN = 7
    125   SKIP = 8
    126   range = range(SKIP + 1)
    127   attributes = [
    128       # pylint:disable=bad-whitespace
    129       ['fuchsia',   'FixNow',    'Critical warnings, fix me now'],
    130       ['red',       'High',      'High severity warnings'],
    131       ['orange',    'Medium',    'Medium severity warnings'],
    132       ['yellow',    'Low',       'Low severity warnings'],
    133       ['hotpink',   'Analyzer',  'Clang-Analyzer warnings'],
    134       ['peachpuff', 'Tidy',      'Clang-Tidy warnings'],
    135       ['limegreen', 'Harmless',  'Harmless warnings'],
    136       ['lightblue', 'Unknown',   'Unknown warnings'],
    137       ['grey',      'Unhandled', 'Unhandled warnings']
    138   ]
    139   colors = [a[0] for a in attributes]
    140   column_headers = [a[1] for a in attributes]
    141   headers = [a[2] for a in attributes]
    142 
    143 warn_patterns = [
    144     # pylint:disable=line-too-long,g-inconsistent-quotes
    145     {'category': 'C/C++', 'severity': Severity.ANALYZER,
    146      'description': 'clang-analyzer Security warning',
    147      'patterns': [r".*: warning: .+\[clang-analyzer-security.*\]"]},
    148     {'category': 'make', 'severity': Severity.MEDIUM,
    149      'description': 'make: overriding commands/ignoring old commands',
    150      'patterns': [r".*: warning: overriding commands for target .+",
    151                   r".*: warning: ignoring old commands for target .+"]},
    152     {'category': 'make', 'severity': Severity.HIGH,
    153      'description': 'make: LOCAL_CLANG is false',
    154      'patterns': [r".*: warning: LOCAL_CLANG is set to false"]},
    155     {'category': 'make', 'severity': Severity.HIGH,
    156      'description': 'SDK App using platform shared library',
    157      'patterns': [r".*: warning: .+ \(.*app:sdk.*\) should not link to .+ \(native:platform\)"]},
    158     {'category': 'make', 'severity': Severity.HIGH,
    159      'description': 'System module linking to a vendor module',
    160      'patterns': [r".*: warning: .+ \(.+\) should not link to .+ \(partition:.+\)"]},
    161     {'category': 'make', 'severity': Severity.MEDIUM,
    162      'description': 'Invalid SDK/NDK linking',
    163      'patterns': [r".*: warning: .+ \(.+\) should not link to .+ \(.+\)"]},
    164     {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wimplicit-function-declaration',
    165      'description': 'Implicit function declaration',
    166      'patterns': [r".*: warning: implicit declaration of function .+",
    167                   r".*: warning: implicitly declaring library function"]},
    168     {'category': 'C/C++', 'severity': Severity.SKIP,
    169      'description': 'skip, conflicting types for ...',
    170      'patterns': [r".*: warning: conflicting types for '.+'"]},
    171     {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wtype-limits',
    172      'description': 'Expression always evaluates to true or false',
    173      'patterns': [r".*: warning: comparison is always .+ due to limited range of data type",
    174                   r".*: warning: comparison of unsigned .*expression .+ is always true",
    175                   r".*: warning: comparison of unsigned .*expression .+ is always false"]},
    176     {'category': 'C/C++', 'severity': Severity.HIGH,
    177      'description': 'Potential leak of memory, bad free, use after free',
    178      'patterns': [r".*: warning: Potential leak of memory",
    179                   r".*: warning: Potential memory leak",
    180                   r".*: warning: Memory allocated by alloca\(\) should not be deallocated",
    181                   r".*: warning: Memory allocated by .+ should be deallocated by .+ not .+",
    182                   r".*: warning: 'delete' applied to a pointer that was allocated",
    183                   r".*: warning: Use of memory after it is freed",
    184                   r".*: warning: Argument to .+ is the address of .+ variable",
    185                   r".*: warning: Argument to free\(\) is offset by .+ of memory allocated by",
    186                   r".*: warning: Attempt to .+ released memory"]},
    187     {'category': 'C/C++', 'severity': Severity.HIGH,
    188      'description': 'Use transient memory for control value',
    189      'patterns': [r".*: warning: .+Using such transient memory for the control value is .*dangerous."]},
    190     {'category': 'C/C++', 'severity': Severity.HIGH,
    191      'description': 'Return address of stack memory',
    192      'patterns': [r".*: warning: Address of stack memory .+ returned to caller",
    193                   r".*: warning: Address of stack memory .+ will be a dangling reference"]},
    194     {'category': 'C/C++', 'severity': Severity.HIGH,
    195      'description': 'Problem with vfork',
    196      'patterns': [r".*: warning: This .+ is prohibited after a successful vfork",
    197                   r".*: warning: Call to function '.+' is insecure "]},
    198     {'category': 'C/C++', 'severity': Severity.HIGH, 'option': 'infinite-recursion',
    199      'description': 'Infinite recursion',
    200      'patterns': [r".*: warning: all paths through this function will call itself"]},
    201     {'category': 'C/C++', 'severity': Severity.HIGH,
    202      'description': 'Potential buffer overflow',
    203      'patterns': [r".*: warning: Size argument is greater than .+ the destination buffer",
    204                   r".*: warning: Potential buffer overflow.",
    205                   r".*: warning: String copy function overflows destination buffer"]},
    206     {'category': 'C/C++', 'severity': Severity.MEDIUM,
    207      'description': 'Incompatible pointer types',
    208      'patterns': [r".*: warning: assignment from incompatible pointer type",
    209                   r".*: warning: return from incompatible pointer type",
    210                   r".*: warning: passing argument [0-9]+ of '.*' from incompatible pointer type",
    211                   r".*: warning: initialization from incompatible pointer type"]},
    212     {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-fno-builtin',
    213      'description': 'Incompatible declaration of built in function',
    214      'patterns': [r".*: warning: incompatible implicit declaration of built-in function .+"]},
    215     {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wincompatible-library-redeclaration',
    216      'description': 'Incompatible redeclaration of library function',
    217      'patterns': [r".*: warning: incompatible redeclaration of library function .+"]},
    218     {'category': 'C/C++', 'severity': Severity.HIGH,
    219      'description': 'Null passed as non-null argument',
    220      'patterns': [r".*: warning: Null passed to a callee that requires a non-null"]},
    221     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused-parameter',
    222      'description': 'Unused parameter',
    223      'patterns': [r".*: warning: unused parameter '.*'"]},
    224     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused',
    225      'description': 'Unused function, variable or label',
    226      'patterns': [r".*: warning: '.+' defined but not used",
    227                   r".*: warning: unused function '.+'",
    228                   r".*: warning: private field '.+' is not used",
    229                   r".*: warning: unused variable '.+'"]},
    230     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused-value',
    231      'description': 'Statement with no effect or result unused',
    232      'patterns': [r".*: warning: statement with no effect",
    233                   r".*: warning: expression result unused"]},
    234     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused-result',
    235      'description': 'Ignoreing return value of function',
    236      'patterns': [r".*: warning: ignoring return value of function .+Wunused-result"]},
    237     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-field-initializers',
    238      'description': 'Missing initializer',
    239      'patterns': [r".*: warning: missing initializer"]},
    240     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wdelete-non-virtual-dtor',
    241      'description': 'Need virtual destructor',
    242      'patterns': [r".*: warning: delete called .* has virtual functions but non-virtual destructor"]},
    243     {'category': 'cont.', 'severity': Severity.SKIP,
    244      'description': 'skip, near initialization for ...',
    245      'patterns': [r".*: warning: \(near initialization for '.+'\)"]},
    246     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wdate-time',
    247      'description': 'Expansion of data or time macro',
    248      'patterns': [r".*: warning: expansion of date or time macro is not reproducible"]},
    249     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wformat',
    250      'description': 'Format string does not match arguments',
    251      'patterns': [r".*: warning: format '.+' expects type '.+', but argument [0-9]+ has type '.+'",
    252                   r".*: warning: more '%' conversions than data arguments",
    253                   r".*: warning: data argument not used by format string",
    254                   r".*: warning: incomplete format specifier",
    255                   r".*: warning: unknown conversion type .* in format",
    256                   r".*: warning: format .+ expects .+ but argument .+Wformat=",
    257                   r".*: warning: field precision should have .+ but argument has .+Wformat",
    258                   r".*: warning: format specifies type .+ but the argument has .*type .+Wformat"]},
    259     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wformat-extra-args',
    260      'description': 'Too many arguments for format string',
    261      'patterns': [r".*: warning: too many arguments for format"]},
    262     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wformat-invalid-specifier',
    263      'description': 'Invalid format specifier',
    264      'patterns': [r".*: warning: invalid .+ specifier '.+'.+format-invalid-specifier"]},
    265     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsign-compare',
    266      'description': 'Comparison between signed and unsigned',
    267      'patterns': [r".*: warning: comparison between signed and unsigned",
    268                   r".*: warning: comparison of promoted \~unsigned with unsigned",
    269                   r".*: warning: signed and unsigned type in conditional expression"]},
    270     {'category': 'C/C++', 'severity': Severity.MEDIUM,
    271      'description': 'Comparison between enum and non-enum',
    272      'patterns': [r".*: warning: enumeral and non-enumeral type in conditional expression"]},
    273     {'category': 'libpng', 'severity': Severity.MEDIUM,
    274      'description': 'libpng: zero area',
    275      'patterns': [r".*libpng warning: Ignoring attempt to set cHRM RGB triangle with zero area"]},
    276     {'category': 'aapt', 'severity': Severity.MEDIUM,
    277      'description': 'aapt: no comment for public symbol',
    278      'patterns': [r".*: warning: No comment for public symbol .+"]},
    279     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-braces',
    280      'description': 'Missing braces around initializer',
    281      'patterns': [r".*: warning: missing braces around initializer.*"]},
    282     {'category': 'C/C++', 'severity': Severity.HARMLESS,
    283      'description': 'No newline at end of file',
    284      'patterns': [r".*: warning: no newline at end of file"]},
    285     {'category': 'C/C++', 'severity': Severity.HARMLESS,
    286      'description': 'Missing space after macro name',
    287      'patterns': [r".*: warning: missing whitespace after the macro name"]},
    288     {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wcast-align',
    289      'description': 'Cast increases required alignment',
    290      'patterns': [r".*: warning: cast from .* to .* increases required alignment .*"]},
    291     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wcast-qual',
    292      'description': 'Qualifier discarded',
    293      'patterns': [r".*: warning: passing argument [0-9]+ of '.+' discards qualifiers from pointer target type",
    294                   r".*: warning: assignment discards qualifiers from pointer target type",
    295                   r".*: warning: passing .+ to parameter of type .+ discards qualifiers",
    296                   r".*: warning: assigning to .+ from .+ discards qualifiers",
    297                   r".*: warning: initializing .+ discards qualifiers .+types-discards-qualifiers",
    298                   r".*: warning: return discards qualifiers from pointer target type"]},
    299     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunknown-attributes',
    300      'description': 'Unknown attribute',
    301      'patterns': [r".*: warning: unknown attribute '.+'"]},
    302     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wignored-attributes',
    303      'description': 'Attribute ignored',
    304      'patterns': [r".*: warning: '_*packed_*' attribute ignored",
    305                   r".*: warning: attribute declaration must precede definition .+ignored-attributes"]},
    306     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wvisibility',
    307      'description': 'Visibility problem',
    308      'patterns': [r".*: warning: declaration of '.+' will not be visible outside of this function"]},
    309     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wattributes',
    310      'description': 'Visibility mismatch',
    311      'patterns': [r".*: warning: '.+' declared with greater visibility than the type of its field '.+'"]},
    312     {'category': 'C/C++', 'severity': Severity.MEDIUM,
    313      'description': 'Shift count greater than width of type',
    314      'patterns': [r".*: warning: (left|right) shift count >= width of type"]},
    315     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wextern-initializer',
    316      'description': 'extern <foo> is initialized',
    317      'patterns': [r".*: warning: '.+' initialized and declared 'extern'",
    318                   r".*: warning: 'extern' variable has an initializer"]},
    319     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wold-style-declaration',
    320      'description': 'Old style declaration',
    321      'patterns': [r".*: warning: 'static' is not at beginning of declaration"]},
    322     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wreturn-type',
    323      'description': 'Missing return value',
    324      'patterns': [r".*: warning: control reaches end of non-void function"]},
    325     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wimplicit-int',
    326      'description': 'Implicit int type',
    327      'patterns': [r".*: warning: type specifier missing, defaults to 'int'",
    328                   r".*: warning: type defaults to 'int' in declaration of '.+'"]},
    329     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmain-return-type',
    330      'description': 'Main function should return int',
    331      'patterns': [r".*: warning: return type of 'main' is not 'int'"]},
    332     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wuninitialized',
    333      'description': 'Variable may be used uninitialized',
    334      'patterns': [r".*: warning: '.+' may be used uninitialized in this function"]},
    335     {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wuninitialized',
    336      'description': 'Variable is used uninitialized',
    337      'patterns': [r".*: warning: '.+' is used uninitialized in this function",
    338                   r".*: warning: variable '.+' is uninitialized when used here"]},
    339     {'category': 'ld', 'severity': Severity.MEDIUM, 'option': '-fshort-enums',
    340      'description': 'ld: possible enum size mismatch',
    341      'patterns': [r".*: warning: .* uses variable-size enums yet the output is to use 32-bit enums; use of enum values across objects may fail"]},
    342     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wpointer-sign',
    343      'description': 'Pointer targets differ in signedness',
    344      'patterns': [r".*: warning: pointer targets in initialization differ in signedness",
    345                   r".*: warning: pointer targets in assignment differ in signedness",
    346                   r".*: warning: pointer targets in return differ in signedness",
    347                   r".*: warning: pointer targets in passing argument [0-9]+ of '.+' differ in signedness"]},
    348     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wstrict-overflow',
    349      'description': 'Assuming overflow does not occur',
    350      'patterns': [r".*: warning: assuming signed overflow does not occur when assuming that .* is always (true|false)"]},
    351     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wempty-body',
    352      'description': 'Suggest adding braces around empty body',
    353      'patterns': [r".*: warning: suggest braces around empty body in an 'if' statement",
    354                   r".*: warning: empty body in an if-statement",
    355                   r".*: warning: suggest braces around empty body in an 'else' statement",
    356                   r".*: warning: empty body in an else-statement"]},
    357     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wparentheses',
    358      'description': 'Suggest adding parentheses',
    359      'patterns': [r".*: warning: suggest explicit braces to avoid ambiguous 'else'",
    360                   r".*: warning: suggest parentheses around arithmetic in operand of '.+'",
    361                   r".*: warning: suggest parentheses around comparison in operand of '.+'",
    362                   r".*: warning: logical not is only applied to the left hand side of this comparison",
    363                   r".*: warning: using the result of an assignment as a condition without parentheses",
    364                   r".*: warning: .+ has lower precedence than .+ be evaluated first .+Wparentheses",
    365                   r".*: warning: suggest parentheses around '.+?' .+ '.+?'",
    366                   r".*: warning: suggest parentheses around assignment used as truth value"]},
    367     {'category': 'C/C++', 'severity': Severity.MEDIUM,
    368      'description': 'Static variable used in non-static inline function',
    369      'patterns': [r".*: warning: '.+' is static but used in inline function '.+' which is not static"]},
    370     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wimplicit int',
    371      'description': 'No type or storage class (will default to int)',
    372      'patterns': [r".*: warning: data definition has no type or storage class"]},
    373     {'category': 'C/C++', 'severity': Severity.MEDIUM,
    374      'description': 'Null pointer',
    375      'patterns': [r".*: warning: Dereference of null pointer",
    376                   r".*: warning: Called .+ pointer is null",
    377                   r".*: warning: Forming reference to null pointer",
    378                   r".*: warning: Returning null reference",
    379                   r".*: warning: Null pointer passed as an argument to a 'nonnull' parameter",
    380                   r".*: warning: .+ results in a null pointer dereference",
    381                   r".*: warning: Access to .+ results in a dereference of a null pointer",
    382                   r".*: warning: Null pointer argument in"]},
    383     {'category': 'cont.', 'severity': Severity.SKIP,
    384      'description': 'skip, parameter name (without types) in function declaration',
    385      'patterns': [r".*: warning: parameter names \(without types\) in function declaration"]},
    386     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wstrict-aliasing',
    387      'description': 'Dereferencing <foo> breaks strict aliasing rules',
    388      'patterns': [r".*: warning: dereferencing .* break strict-aliasing rules"]},
    389     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wpointer-to-int-cast',
    390      'description': 'Cast from pointer to integer of different size',
    391      'patterns': [r".*: warning: cast from pointer to integer of different size",
    392                   r".*: warning: initialization makes pointer from integer without a cast"]},
    393     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wint-to-pointer-cast',
    394      'description': 'Cast to pointer from integer of different size',
    395      'patterns': [r".*: warning: cast to pointer from integer of different size"]},
    396     {'category': 'C/C++', 'severity': Severity.MEDIUM,
    397      'description': 'Symbol redefined',
    398      'patterns': [r".*: warning: "".+"" redefined"]},
    399     {'category': 'cont.', 'severity': Severity.SKIP,
    400      'description': 'skip, ... location of the previous definition',
    401      'patterns': [r".*: warning: this is the location of the previous definition"]},
    402     {'category': 'ld', 'severity': Severity.MEDIUM,
    403      'description': 'ld: type and size of dynamic symbol are not defined',
    404      'patterns': [r".*: warning: type and size of dynamic symbol `.+' are not defined"]},
    405     {'category': 'C/C++', 'severity': Severity.MEDIUM,
    406      'description': 'Pointer from integer without cast',
    407      'patterns': [r".*: warning: assignment makes pointer from integer without a cast"]},
    408     {'category': 'C/C++', 'severity': Severity.MEDIUM,
    409      'description': 'Pointer from integer without cast',
    410      'patterns': [r".*: warning: passing argument [0-9]+ of '.+' makes pointer from integer without a cast"]},
    411     {'category': 'C/C++', 'severity': Severity.MEDIUM,
    412      'description': 'Integer from pointer without cast',
    413      'patterns': [r".*: warning: assignment makes integer from pointer without a cast"]},
    414     {'category': 'C/C++', 'severity': Severity.MEDIUM,
    415      'description': 'Integer from pointer without cast',
    416      'patterns': [r".*: warning: passing argument [0-9]+ of '.+' makes integer from pointer without a cast"]},
    417     {'category': 'C/C++', 'severity': Severity.MEDIUM,
    418      'description': 'Integer from pointer without cast',
    419      'patterns': [r".*: warning: return makes integer from pointer without a cast"]},
    420     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunknown-pragmas',
    421      'description': 'Ignoring pragma',
    422      'patterns': [r".*: warning: ignoring #pragma .+"]},
    423     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-W#pragma-messages',
    424      'description': 'Pragma warning messages',
    425      'patterns': [r".*: warning: .+W#pragma-messages"]},
    426     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wclobbered',
    427      'description': 'Variable might be clobbered by longjmp or vfork',
    428      'patterns': [r".*: warning: variable '.+' might be clobbered by 'longjmp' or 'vfork'"]},
    429     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wclobbered',
    430      'description': 'Argument might be clobbered by longjmp or vfork',
    431      'patterns': [r".*: warning: argument '.+' might be clobbered by 'longjmp' or 'vfork'"]},
    432     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wredundant-decls',
    433      'description': 'Redundant declaration',
    434      'patterns': [r".*: warning: redundant redeclaration of '.+'"]},
    435     {'category': 'cont.', 'severity': Severity.SKIP,
    436      'description': 'skip, previous declaration ... was here',
    437      'patterns': [r".*: warning: previous declaration of '.+' was here"]},
    438     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wswitch-enum',
    439      'description': 'Enum value not handled in switch',
    440      'patterns': [r".*: warning: .*enumeration value.* not handled in switch.+Wswitch"]},
    441     {'category': 'java', 'severity': Severity.MEDIUM, 'option': '-encoding',
    442      'description': 'Java: Non-ascii characters used, but ascii encoding specified',
    443      'patterns': [r".*: warning: unmappable character for encoding ascii"]},
    444     {'category': 'java', 'severity': Severity.MEDIUM,
    445      'description': 'Java: Non-varargs call of varargs method with inexact argument type for last parameter',
    446      'patterns': [r".*: warning: non-varargs call of varargs method with inexact argument type for last parameter"]},
    447     {'category': 'java', 'severity': Severity.MEDIUM,
    448      'description': 'Java: Unchecked method invocation',
    449      'patterns': [r".*: warning: \[unchecked\] unchecked method invocation: .+ in class .+"]},
    450     {'category': 'java', 'severity': Severity.MEDIUM,
    451      'description': 'Java: Unchecked conversion',
    452      'patterns': [r".*: warning: \[unchecked\] unchecked conversion"]},
    453     {'category': 'java', 'severity': Severity.MEDIUM,
    454      'description': '_ used as an identifier',
    455      'patterns': [r".*: warning: '_' used as an identifier"]},
    456 
    457     # Warnings from Javac
    458     {'category': 'java',
    459      'severity': Severity.MEDIUM,
    460      'description': 'Java: Use of deprecated member',
    461      'patterns': [r'.*: warning: \[deprecation\] .+']},
    462     {'category': 'java',
    463      'severity': Severity.MEDIUM,
    464      'description': 'Java: Unchecked conversion',
    465      'patterns': [r'.*: warning: \[unchecked\] .+']},
    466 
    467     # Begin warnings generated by Error Prone
    468     {'category': 'java',
    469      'severity': Severity.LOW,
    470      'description':
    471          'Java: @Multibinds is a more efficient and declarative mechanism for ensuring that a set multibinding is present in the graph.',
    472      'patterns': [r".*: warning: \[EmptySetMultibindingContributions\] .+"]},
    473     {'category': 'java',
    474      'severity': Severity.LOW,
    475      'description':
    476          'Java: Add a private constructor to modules that will not be instantiated by Dagger.',
    477      'patterns': [r".*: warning: \[PrivateConstructorForNoninstantiableModuleTest\] .+"]},
    478     {'category': 'java',
    479      'severity': Severity.LOW,
    480      'description':
    481          'Java: @Binds is a more efficient and declarative mechanism for delegating a binding.',
    482      'patterns': [r".*: warning: \[UseBinds\] .+"]},
    483     {'category': 'java',
    484      'severity': Severity.LOW,
    485      'description':
    486          'Java: Field name is CONSTANT CASE, but field is not static and final',
    487      'patterns': [r".*: warning: \[ConstantField\] .+"]},
    488     {'category': 'java',
    489      'severity': Severity.LOW,
    490      'description':
    491          'Java: Deprecated item is not annotated with @Deprecated',
    492      'patterns': [r".*: warning: \[DepAnn\] .+"]},
    493     {'category': 'java',
    494      'severity': Severity.LOW,
    495      'description':
    496          'Java: Prefer \'L\' to \'l\' for the suffix to long literals',
    497      'patterns': [r".*: warning: \[LongLiteralLowerCaseSuffix\] .+"]},
    498     {'category': 'java',
    499      'severity': Severity.LOW,
    500      'description':
    501          'Java: C-style array declarations should not be used',
    502      'patterns': [r".*: warning: \[MixedArrayDimensions\] .+"]},
    503     {'category': 'java',
    504      'severity': Severity.LOW,
    505      'description':
    506          'Java: Variable declarations should declare only one variable',
    507      'patterns': [r".*: warning: \[MultiVariableDeclaration\] .+"]},
    508     {'category': 'java',
    509      'severity': Severity.LOW,
    510      'description':
    511          'Java: Source files should not contain multiple top-level class declarations',
    512      'patterns': [r".*: warning: \[MultipleTopLevelClasses\] .+"]},
    513     {'category': 'java',
    514      'severity': Severity.LOW,
    515      'description':
    516          'Java: Package names should match the directory they are declared in',
    517      'patterns': [r".*: warning: \[PackageLocation\] .+"]},
    518     {'category': 'java',
    519      'severity': Severity.LOW,
    520      'description':
    521          'Java: Utility classes (only static members) are not designed to be instantiated and should be made noninstantiable with a default constructor.',
    522      'patterns': [r".*: warning: \[PrivateConstructorForUtilityClass\] .+"]},
    523     {'category': 'java',
    524      'severity': Severity.LOW,
    525      'description':
    526          'Java: Unused imports',
    527      'patterns': [r".*: warning: \[RemoveUnusedImports\] .+"]},
    528     {'category': 'java',
    529      'severity': Severity.LOW,
    530      'description':
    531          'Java: Unchecked exceptions do not need to be declared in the method signature.',
    532      'patterns': [r".*: warning: \[ThrowsUncheckedException\] .+"]},
    533     {'category': 'java',
    534      'severity': Severity.LOW,
    535      'description':
    536          'Java: Using static imports for types is unnecessary',
    537      'patterns': [r".*: warning: \[UnnecessaryStaticImport\] .+"]},
    538     {'category': 'java',
    539      'severity': Severity.LOW,
    540      'description':
    541          'Java: Wildcard imports, static or otherwise, should not be used',
    542      'patterns': [r".*: warning: \[WildcardImport\] .+"]},
    543     {'category': 'java',
    544      'severity': Severity.MEDIUM,
    545      'description':
    546          'Java: Subclasses of Fragment must be instantiable via Class#newInstance(): the class must be public, static and have a public nullary constructor',
    547      'patterns': [r".*: warning: \[FragmentNotInstantiable\] .+"]},
    548     {'category': 'java',
    549      'severity': Severity.MEDIUM,
    550      'description':
    551          'Java: Hardcoded reference to /sdcard',
    552      'patterns': [r".*: warning: \[HardCodedSdCardPath\] .+"]},
    553     {'category': 'java',
    554      'severity': Severity.MEDIUM,
    555      'description':
    556          'Java: @AssistedInject and @Inject should not be used on different constructors in the same class.',
    557      'patterns': [r".*: warning: \[AssistedInjectAndInjectOnConstructors\] .+"]},
    558     {'category': 'java',
    559      'severity': Severity.MEDIUM,
    560      'description':
    561          'Java: Constructors on abstract classes are never directly @Injected, only the constructors of their subclasses can be @Inject\'ed.',
    562      'patterns': [r".*: warning: \[InjectOnConstructorOfAbstractClass\] .+"]},
    563     {'category': 'java',
    564      'severity': Severity.MEDIUM,
    565      'description':
    566          'Java: Injection frameworks currently don\'t understand Qualifiers in TYPE PARAMETER or TYPE USE contexts.',
    567      'patterns': [r".*: warning: \[QualifierWithTypeUse\] .+"]},
    568     {'category': 'java',
    569      'severity': Severity.MEDIUM,
    570      'description':
    571          'Java: This code declares a binding for a common value type without a Qualifier annotation.',
    572      'patterns': [r".*: warning: \[BindingToUnqualifiedCommonType\] .+"]},
    573     {'category': 'java',
    574      'severity': Severity.MEDIUM,
    575      'description':
    576          '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.',
    577      'patterns': [r".*: warning: \[OverridesGuiceInjectableMethod\] .+"]},
    578     {'category': 'java',
    579      'severity': Severity.MEDIUM,
    580      'description':
    581          'Java: Double-checked locking on non-volatile fields is unsafe',
    582      'patterns': [r".*: warning: \[DoubleCheckedLocking\] .+"]},
    583     {'category': 'java',
    584      'severity': Severity.MEDIUM,
    585      'description':
    586          'Java: Enums should always be immutable',
    587      'patterns': [r".*: warning: \[ImmutableEnumChecker\] .+"]},
    588     {'category': 'java',
    589      'severity': Severity.MEDIUM,
    590      'description':
    591          'Java: Writes to static fields should not be guarded by instance locks',
    592      'patterns': [r".*: warning: \[StaticGuardedByInstance\] .+"]},
    593     {'category': 'java',
    594      'severity': Severity.MEDIUM,
    595      'description':
    596          'Java: Synchronizing on non-final fields is not safe: if the field is ever updated, different threads may end up locking on different objects.',
    597      'patterns': [r".*: warning: \[SynchronizeOnNonFinalField\] .+"]},
    598     {'category': 'java',
    599      'severity': Severity.MEDIUM,
    600      'description':
    601          'Java: Method reference is ambiguous',
    602      'patterns': [r".*: warning: \[AmbiguousMethodReference\] .+"]},
    603     {'category': 'java',
    604      'severity': Severity.MEDIUM,
    605      'description':
    606          'Java: A different potential argument is more similar to the name of the parameter than the existing argument; this may be an error',
    607      'patterns': [r".*: warning: \[ArgumentParameterMismatch\] .+"]},
    608     {'category': 'java',
    609      'severity': Severity.MEDIUM,
    610      'description':
    611          'Java: Assertions may be disabled at runtime and do not guarantee that execution will halt here; consider throwing an exception instead',
    612      'patterns': [r".*: warning: \[AssertFalse\] .+"]},
    613     {'category': 'java',
    614      'severity': Severity.MEDIUM,
    615      'description':
    616          'Java: Classes that implement Annotation must override equals and hashCode. Consider using AutoAnnotation instead of implementing Annotation by hand.',
    617      'patterns': [r".*: warning: \[BadAnnotationImplementation\] .+"]},
    618     {'category': 'java',
    619      'severity': Severity.MEDIUM,
    620      'description':
    621          'Java: Possible sign flip from narrowing conversion',
    622      'patterns': [r".*: warning: \[BadComparable\] .+"]},
    623     {'category': 'java',
    624      'severity': Severity.MEDIUM,
    625      'description':
    626          'Java: BigDecimal(double) and BigDecimal.valueOf(double) may lose precision, prefer BigDecimal(String) or BigDecimal(long)',
    627      'patterns': [r".*: warning: \[BigDecimalLiteralDouble\] .+"]},
    628     {'category': 'java',
    629      'severity': Severity.MEDIUM,
    630      'description':
    631          'Java: valueOf or autoboxing provides better time and space performance',
    632      'patterns': [r".*: warning: \[BoxedPrimitiveConstructor\] .+"]},
    633     {'category': 'java',
    634      'severity': Severity.MEDIUM,
    635      'description':
    636          'Java: Mockito cannot mock final classes',
    637      'patterns': [r".*: warning: \[CannotMockFinalClass\] .+"]},
    638     {'category': 'java',
    639      'severity': Severity.MEDIUM,
    640      'description':
    641          'Java: Inner class is non-static but does not reference enclosing class',
    642      'patterns': [r".*: warning: \[ClassCanBeStatic\] .+"]},
    643     {'category': 'java',
    644      'severity': Severity.MEDIUM,
    645      'description':
    646          'Java: Class.newInstance() bypasses exception checking; prefer getConstructor().newInstance()',
    647      'patterns': [r".*: warning: \[ClassNewInstance\] .+"]},
    648     {'category': 'java',
    649      'severity': Severity.MEDIUM,
    650      'description':
    651          'Java: Implicit use of the platform default charset, which can result in e.g. non-ASCII characters being silently replaced with \'?\' in many environments',
    652      'patterns': [r".*: warning: \[DefaultCharset\] .+"]},
    653     {'category': 'java',
    654      'severity': Severity.MEDIUM,
    655      'description':
    656          'Java: This code, which counts elements using a loop, can be replaced by a simpler library method',
    657      'patterns': [r".*: warning: \[ElementsCountedInLoop\] .+"]},
    658     {'category': 'java',
    659      'severity': Severity.MEDIUM,
    660      'description':
    661          'Java: Empty top-level type declaration',
    662      'patterns': [r".*: warning: \[EmptyTopLevelDeclaration\] .+"]},
    663     {'category': 'java',
    664      'severity': Severity.MEDIUM,
    665      'description':
    666          'Java: Classes that override equals should also override hashCode.',
    667      'patterns': [r".*: warning: \[EqualsHashCode\] .+"]},
    668     {'category': 'java',
    669      'severity': Severity.MEDIUM,
    670      'description':
    671          'Java: An equality test between objects with incompatible types always returns false',
    672      'patterns': [r".*: warning: \[EqualsIncompatibleType\] .+"]},
    673     {'category': 'java',
    674      'severity': Severity.MEDIUM,
    675      'description':
    676          '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.',
    677      'patterns': [r".*: warning: \[Finally\] .+"]},
    678     {'category': 'java',
    679      'severity': Severity.MEDIUM,
    680      'description':
    681          'Java: Overloads will be ambiguous when passing lambda arguments',
    682      'patterns': [r".*: warning: \[FunctionalInterfaceClash\] .+"]},
    683     {'category': 'java',
    684      'severity': Severity.MEDIUM,
    685      'description':
    686          'Java: Calling getClass() on an enum may return a subclass of the enum type',
    687      'patterns': [r".*: warning: \[GetClassOnEnum\] .+"]},
    688     {'category': 'java',
    689      'severity': Severity.MEDIUM,
    690      'description':
    691          'Java: This annotation has incompatible modifiers as specified by its @IncompatibleModifiers annotation',
    692      'patterns': [r".*: warning: \[IncompatibleModifiers\] .+"]},
    693     {'category': 'java',
    694      'severity': Severity.MEDIUM,
    695      'description':
    696          'Java: Please also override int read(byte[], int, int), otherwise multi-byte reads from this input stream are likely to be slow.',
    697      'patterns': [r".*: warning: \[InputStreamSlowMultibyteRead\] .+"]},
    698     {'category': 'java',
    699      'severity': Severity.MEDIUM,
    700      'description':
    701          'Java: Class should not implement both `Iterable` and `Iterator`',
    702      'patterns': [r".*: warning: \[IterableAndIterator\] .+"]},
    703     {'category': 'java',
    704      'severity': Severity.MEDIUM,
    705      'description':
    706          'Java: Floating-point comparison without error tolerance',
    707      'patterns': [r".*: warning: \[JUnit3FloatingPointComparisonWithoutDelta\] .+"]},
    708     {'category': 'java',
    709      'severity': Severity.MEDIUM,
    710      'description':
    711          'Java: Test class inherits from JUnit 3\'s TestCase but has JUnit 4 @Test annotations.',
    712      'patterns': [r".*: warning: \[JUnitAmbiguousTestClass\] .+"]},
    713     {'category': 'java',
    714      'severity': Severity.MEDIUM,
    715      'description':
    716          'Java: The Google Java Style Guide requires switch statements to have an explicit default',
    717      'patterns': [r".*: warning: \[MissingCasesInEnumSwitch\] .+"]},
    718     {'category': 'java',
    719      'severity': Severity.MEDIUM,
    720      'description':
    721          'Java: Not calling fail() when expecting an exception masks bugs',
    722      'patterns': [r".*: warning: \[MissingFail\] .+"]},
    723     {'category': 'java',
    724      'severity': Severity.MEDIUM,
    725      'description':
    726          'Java: method overrides method in supertype; expected @Override',
    727      'patterns': [r".*: warning: \[MissingOverride\] .+"]},
    728     {'category': 'java',
    729      'severity': Severity.MEDIUM,
    730      'description':
    731          'Java: Compound assignments to bytes, shorts, chars, and floats hide dangerous casts',
    732      'patterns': [r".*: warning: \[NarrowingCompoundAssignment\] .+"]},
    733     {'category': 'java',
    734      'severity': Severity.MEDIUM,
    735      'description':
    736          'Java: This update of a volatile variable is non-atomic',
    737      'patterns': [r".*: warning: \[NonAtomicVolatileUpdate\] .+"]},
    738     {'category': 'java',
    739      'severity': Severity.MEDIUM,
    740      'description':
    741          'Java: Static import of member uses non-canonical name',
    742      'patterns': [r".*: warning: \[NonCanonicalStaticMemberImport\] .+"]},
    743     {'category': 'java',
    744      'severity': Severity.MEDIUM,
    745      'description':
    746          'Java: equals method doesn\'t override Object.equals',
    747      'patterns': [r".*: warning: \[NonOverridingEquals\] .+"]},
    748     {'category': 'java',
    749      'severity': Severity.MEDIUM,
    750      'description':
    751          'Java: Constructors should not be annotated with @Nullable since they cannot return null',
    752      'patterns': [r".*: warning: \[NullableConstructor\] .+"]},
    753     {'category': 'java',
    754      'severity': Severity.MEDIUM,
    755      'description':
    756          'Java: @Nullable should not be used for primitive types since they cannot be null',
    757      'patterns': [r".*: warning: \[NullablePrimitive\] .+"]},
    758     {'category': 'java',
    759      'severity': Severity.MEDIUM,
    760      'description':
    761          'Java: void-returning methods should not be annotated with @Nullable, since they cannot return null',
    762      'patterns': [r".*: warning: \[NullableVoid\] .+"]},
    763     {'category': 'java',
    764      'severity': Severity.MEDIUM,
    765      'description':
    766          'Java: Use grouping parenthesis to make the operator precedence explicit',
    767      'patterns': [r".*: warning: \[OperatorPrecedence\] .+"]},
    768     {'category': 'java',
    769      'severity': Severity.MEDIUM,
    770      'description':
    771          'Java: Preconditions only accepts the %s placeholder in error message strings',
    772      'patterns': [r".*: warning: \[PreconditionsInvalidPlaceholder\] .+"]},
    773     {'category': 'java',
    774      'severity': Severity.MEDIUM,
    775      'description':
    776          'Java: Passing a primitive array to a varargs method is usually wrong',
    777      'patterns': [r".*: warning: \[PrimitiveArrayPassedToVarargsMethod\] .+"]},
    778     {'category': 'java',
    779      'severity': Severity.MEDIUM,
    780      'description':
    781          'Java: Protobuf fields cannot be null, so this check is redundant',
    782      'patterns': [r".*: warning: \[ProtoFieldPreconditionsCheckNotNull\] .+"]},
    783     {'category': 'java',
    784      'severity': Severity.MEDIUM,
    785      'description':
    786          'Java: Thrown exception is a subtype of another',
    787      'patterns': [r".*: warning: \[RedundantThrows\] .+"]},
    788     {'category': 'java',
    789      'severity': Severity.MEDIUM,
    790      'description':
    791          'Java: Comparison using reference equality instead of value equality',
    792      'patterns': [r".*: warning: \[ReferenceEquality\] .+"]},
    793     {'category': 'java',
    794      'severity': Severity.MEDIUM,
    795      'description':
    796          'Java: This annotation is missing required modifiers as specified by its @RequiredModifiers annotation',
    797      'patterns': [r".*: warning: \[RequiredModifiers\] .+"]},
    798     {'category': 'java',
    799      'severity': Severity.MEDIUM,
    800      'description':
    801          'Java: A static variable or method should not be accessed from an object instance',
    802      'patterns': [r".*: warning: \[StaticAccessedFromInstance\] .+"]},
    803     {'category': 'java',
    804      'severity': Severity.MEDIUM,
    805      'description':
    806          'Java: String comparison using reference equality instead of value equality',
    807      'patterns': [r".*: warning: \[StringEquality\] .+"]},
    808     {'category': 'java',
    809      'severity': Severity.MEDIUM,
    810      'description':
    811          'Java: Truth Library assert is called on a constant.',
    812      'patterns': [r".*: warning: \[TruthConstantAsserts\] .+"]},
    813     {'category': 'java',
    814      'severity': Severity.MEDIUM,
    815      'description':
    816          'Java: An object is tested for equality to itself using Truth Libraries.',
    817      'patterns': [r".*: warning: \[TruthSelfEquals\] .+"]},
    818     {'category': 'java',
    819      'severity': Severity.MEDIUM,
    820      'description':
    821          '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.',
    822      'patterns': [r".*: warning: \[TypeParameterUnusedInFormals\] .+"]},
    823     {'category': 'java',
    824      'severity': Severity.MEDIUM,
    825      'description':
    826          'Java: Unsynchronized method overrides a synchronized method.',
    827      'patterns': [r".*: warning: \[UnsynchronizedOverridesSynchronized\] .+"]},
    828     {'category': 'java',
    829      'severity': Severity.MEDIUM,
    830      'description':
    831          'Java: Non-constant variable missing @Var annotation',
    832      'patterns': [r".*: warning: \[Var\] .+"]},
    833     {'category': 'java',
    834      'severity': Severity.MEDIUM,
    835      'description':
    836          'Java: Because of spurious wakeups, Object.wait() and Condition.await() must always be called in a loop',
    837      'patterns': [r".*: warning: \[WaitNotInLoop\] .+"]},
    838     {'category': 'java',
    839      'severity': Severity.HIGH,
    840      'description':
    841          'Java: Log tag too long, cannot exceed 23 characters.',
    842      'patterns': [r".*: warning: \[IsLoggableTagLength\] .+"]},
    843     {'category': 'java',
    844      'severity': Severity.HIGH,
    845      'description':
    846          'Java: Certain resources in `android.R.string` have names that do not match their content',
    847      'patterns': [r".*: warning: \[MislabeledAndroidString\] .+"]},
    848     {'category': 'java',
    849      'severity': Severity.HIGH,
    850      'description':
    851          'Java: Return value of android.graphics.Rect.intersect() must be checked',
    852      'patterns': [r".*: warning: \[RectIntersectReturnValueIgnored\] .+"]},
    853     {'category': 'java',
    854      'severity': Severity.HIGH,
    855      'description':
    856          'Java: Static and default methods in interfaces are not allowed in android builds.',
    857      'patterns': [r".*: warning: \[StaticOrDefaultInterfaceMethod\] .+"]},
    858     {'category': 'java',
    859      'severity': Severity.HIGH,
    860      'description':
    861          'Java: Incompatible type as argument to Object-accepting Java collections method',
    862      'patterns': [r".*: warning: \[CollectionIncompatibleType\] .+"]},
    863     {'category': 'java',
    864      'severity': Severity.HIGH,
    865      'description':
    866          'Java: @CompatibleWith\'s value is not a type argument.',
    867      'patterns': [r".*: warning: \[CompatibleWithAnnotationMisuse\] .+"]},
    868     {'category': 'java',
    869      'severity': Severity.HIGH,
    870      'description':
    871          'Java: Passing argument to a generic method with an incompatible type.',
    872      'patterns': [r".*: warning: \[IncompatibleArgumentType\] .+"]},
    873     {'category': 'java',
    874      'severity': Severity.HIGH,
    875      'description':
    876          'Java: Invalid printf-style format string',
    877      'patterns': [r".*: warning: \[FormatString\] .+"]},
    878     {'category': 'java',
    879      'severity': Severity.HIGH,
    880      'description':
    881          'Java: Invalid format string passed to formatting method.',
    882      'patterns': [r".*: warning: \[FormatStringAnnotation\] .+"]},
    883     {'category': 'java',
    884      'severity': Severity.HIGH,
    885      'description':
    886          'Java: @AssistedInject and @Inject cannot be used on the same constructor.',
    887      'patterns': [r".*: warning: \[AssistedInjectAndInjectOnSameConstructor\] .+"]},
    888     {'category': 'java',
    889      'severity': Severity.HIGH,
    890      'description':
    891          'Java: @AutoFactory and @Inject should not be used in the same type.',
    892      'patterns': [r".*: warning: \[AutoFactoryAtInject\] .+"]},
    893     {'category': 'java',
    894      'severity': Severity.HIGH,
    895      'description':
    896          'Java: Injected constructors cannot be optional nor have binding annotations',
    897      'patterns': [r".*: warning: \[InjectedConstructorAnnotations\] .+"]},
    898     {'category': 'java',
    899      'severity': Severity.HIGH,
    900      'description':
    901          'Java: A scoping annotation\'s Target should include TYPE and METHOD.',
    902      'patterns': [r".*: warning: \[InjectInvalidTargetingOnScopingAnnotation\] .+"]},
    903     {'category': 'java',
    904      'severity': Severity.HIGH,
    905      'description':
    906          'Java: Abstract and default methods are not injectable with javax.inject.Inject',
    907      'patterns': [r".*: warning: \[JavaxInjectOnAbstractMethod\] .+"]},
    908     {'category': 'java',
    909      'severity': Severity.HIGH,
    910      'description':
    911          'Java: @javax.inject.Inject cannot be put on a final field.',
    912      'patterns': [r".*: warning: \[JavaxInjectOnFinalField\] .+"]},
    913     {'category': 'java',
    914      'severity': Severity.HIGH,
    915      'description':
    916          'Java: This class has more than one @Inject-annotated constructor. Please remove the @Inject annotation from all but one of them.',
    917      'patterns': [r".*: warning: \[MoreThanOneInjectableConstructor\] .+"]},
    918     {'category': 'java',
    919      'severity': Severity.HIGH,
    920      'description':
    921          'Java: Using more than one qualifier annotation on the same element is not allowed.',
    922      'patterns': [r".*: warning: \[InjectMoreThanOneQualifier\] .+"]},
    923     {'category': 'java',
    924      'severity': Severity.HIGH,
    925      'description':
    926          'Java: A class can be annotated with at most one scope annotation.',
    927      'patterns': [r".*: warning: \[InjectMoreThanOneScopeAnnotationOnClass\] .+"]},
    928     {'category': 'java',
    929      'severity': Severity.HIGH,
    930      'description':
    931          'Java: Annotations cannot be both Scope annotations and Qualifier annotations: this causes confusion when trying to use them.',
    932      'patterns': [r".*: warning: \[OverlappingQualifierAndScopeAnnotation\] .+"]},
    933     {'category': 'java',
    934      'severity': Severity.HIGH,
    935      'description':
    936          'Java: Qualifier applied to a method that isn\'t a @Provides method. This method won\'t be used for dependency injection',
    937      'patterns': [r".*: warning: \[QualifierOnMethodWithoutProvides\] .+"]},
    938     {'category': 'java',
    939      'severity': Severity.HIGH,
    940      'description':
    941          'Java: Scope annotation on an interface or abstact class is not allowed',
    942      'patterns': [r".*: warning: \[InjectScopeAnnotationOnInterfaceOrAbstractClass\] .+"]},
    943     {'category': 'java',
    944      'severity': Severity.HIGH,
    945      'description':
    946          'Java: Scoping and qualifier annotations must have runtime retention.',
    947      'patterns': [r".*: warning: \[InjectScopeOrQualifierAnnotationRetention\] .+"]},
    948     {'category': 'java',
    949      'severity': Severity.HIGH,
    950      'description':
    951          'Java: `@Multibinds` is the new way to declare multibindings.',
    952      'patterns': [r".*: warning: \[MultibindsInsteadOfMultibindings\] .+"]},
    953     {'category': 'java',
    954      'severity': Severity.HIGH,
    955      'description':
    956          'Java: Dagger @Provides methods may not return null unless annotated with @Nullable',
    957      'patterns': [r".*: warning: \[DaggerProvidesNull\] .+"]},
    958     {'category': 'java',
    959      'severity': Severity.HIGH,
    960      'description':
    961          'Java: Scope annotation on implementation class of AssistedInject factory is not allowed',
    962      'patterns': [r".*: warning: \[GuiceAssistedInjectScoping\] .+"]},
    963     {'category': 'java',
    964      'severity': Severity.HIGH,
    965      'description':
    966          'Java: A constructor cannot have two @Assisted parameters of the same type unless they are disambiguated with named @Assisted annotations.',
    967      'patterns': [r".*: warning: \[GuiceAssistedParameters\] .+"]},
    968     {'category': 'java',
    969      'severity': Severity.HIGH,
    970      'description':
    971          'Java: Although Guice allows injecting final fields, doing so is disallowed because the injected value may not be visible to other threads.',
    972      'patterns': [r".*: warning: \[GuiceInjectOnFinalField\] .+"]},
    973     {'category': 'java',
    974      'severity': Severity.HIGH,
    975      'description':
    976          'Java: This method is not annotated with @Inject, but it overrides a method that is  annotated with @javax.inject.Inject. The method will not be Injected.',
    977      'patterns': [r".*: warning: \[OverridesJavaxInjectableMethod\] .+"]},
    978     {'category': 'java',
    979      'severity': Severity.HIGH,
    980      'description':
    981          'Java: @Provides methods need to be declared in a Module to have any effect.',
    982      'patterns': [r".*: warning: \[ProvidesMethodOutsideOfModule\] .+"]},
    983     {'category': 'java',
    984      'severity': Severity.HIGH,
    985      'description':
    986          'Java: Checks for unguarded accesses to fields and methods with @GuardedBy annotations',
    987      'patterns': [r".*: warning: \[GuardedByChecker\] .+"]},
    988     {'category': 'java',
    989      'severity': Severity.HIGH,
    990      'description':
    991          'Java: Invalid @GuardedBy expression',
    992      'patterns': [r".*: warning: \[GuardedByValidator\] .+"]},
    993     {'category': 'java',
    994      'severity': Severity.HIGH,
    995      'description':
    996          'Java: Type declaration annotated with @Immutable is not immutable',
    997      'patterns': [r".*: warning: \[Immutable\] .+"]},
    998     {'category': 'java',
    999      'severity': Severity.HIGH,
   1000      'description':
   1001          'Java: This method does not acquire the locks specified by its @LockMethod annotation',
   1002      'patterns': [r".*: warning: \[LockMethodChecker\] .+"]},
   1003     {'category': 'java',
   1004      'severity': Severity.HIGH,
   1005      'description':
   1006          'Java: This method does not acquire the locks specified by its @UnlockMethod annotation',
   1007      'patterns': [r".*: warning: \[UnlockMethod\] .+"]},
   1008     {'category': 'java',
   1009      'severity': Severity.HIGH,
   1010      'description':
   1011          'Java: An argument is more similar to a different parameter; the arguments may have been swapped.',
   1012      'patterns': [r".*: warning: \[ArgumentParameterSwap\] .+"]},
   1013     {'category': 'java',
   1014      'severity': Severity.HIGH,
   1015      'description':
   1016          'Java: Reference equality used to compare arrays',
   1017      'patterns': [r".*: warning: \[ArrayEquals\] .+"]},
   1018     {'category': 'java',
   1019      'severity': Severity.HIGH,
   1020      'description':
   1021          'Java: hashcode method on array does not hash array contents',
   1022      'patterns': [r".*: warning: \[ArrayHashCode\] .+"]},
   1023     {'category': 'java',
   1024      'severity': Severity.HIGH,
   1025      'description':
   1026          'Java: Calling toString on an array does not provide useful information',
   1027      'patterns': [r".*: warning: \[ArrayToString\] .+"]},
   1028     {'category': 'java',
   1029      'severity': Severity.HIGH,
   1030      'description':
   1031          'Java: Arrays.asList does not autobox primitive arrays, as one might expect.',
   1032      'patterns': [r".*: warning: \[ArraysAsListPrimitiveArray\] .+"]},
   1033     {'category': 'java',
   1034      'severity': Severity.HIGH,
   1035      'description':
   1036          'Java: AsyncCallable should not return a null Future, only a Future whose result is null.',
   1037      'patterns': [r".*: warning: \[AsyncCallableReturnsNull\] .+"]},
   1038     {'category': 'java',
   1039      'severity': Severity.HIGH,
   1040      'description':
   1041          'Java: AsyncFunction should not return a null Future, only a Future whose result is null.',
   1042      'patterns': [r".*: warning: \[AsyncFunctionReturnsNull\] .+"]},
   1043     {'category': 'java',
   1044      'severity': Severity.HIGH,
   1045      'description':
   1046          'Java: Shift by an amount that is out of range',
   1047      'patterns': [r".*: warning: \[BadShiftAmount\] .+"]},
   1048     {'category': 'java',
   1049      'severity': Severity.HIGH,
   1050      'description':
   1051          '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.',
   1052      'patterns': [r".*: warning: \[ChainingConstructorIgnoresParameter\] .+"]},
   1053     {'category': 'java',
   1054      'severity': Severity.HIGH,
   1055      'description':
   1056          'Java: Ignored return value of method that is annotated with @CheckReturnValue',
   1057      'patterns': [r".*: warning: \[CheckReturnValue\] .+"]},
   1058     {'category': 'java',
   1059      'severity': Severity.HIGH,
   1060      'description':
   1061          'Java: The source file name should match the name of the top-level class it contains',
   1062      'patterns': [r".*: warning: \[ClassName\] .+"]},
   1063     {'category': 'java',
   1064      'severity': Severity.HIGH,
   1065      'description':
   1066          'Java: This comparison method violates the contract',
   1067      'patterns': [r".*: warning: \[ComparisonContractViolated\] .+"]},
   1068     {'category': 'java',
   1069      'severity': Severity.HIGH,
   1070      'description':
   1071          'Java: Comparison to value that is out of range for the compared type',
   1072      'patterns': [r".*: warning: \[ComparisonOutOfRange\] .+"]},
   1073     {'category': 'java',
   1074      'severity': Severity.HIGH,
   1075      'description':
   1076          'Java: Non-compile-time constant expression passed to parameter with @CompileTimeConstant type annotation.',
   1077      'patterns': [r".*: warning: \[CompileTimeConstant\] .+"]},
   1078     {'category': 'java',
   1079      'severity': Severity.HIGH,
   1080      'description':
   1081          'Java: Compile-time constant expression overflows',
   1082      'patterns': [r".*: warning: \[ConstantOverflow\] .+"]},
   1083     {'category': 'java',
   1084      'severity': Severity.HIGH,
   1085      'description':
   1086          'Java: Exception created but not thrown',
   1087      'patterns': [r".*: warning: \[DeadException\] .+"]},
   1088     {'category': 'java',
   1089      'severity': Severity.HIGH,
   1090      'description':
   1091          'Java: Division by integer literal zero',
   1092      'patterns': [r".*: warning: \[DivZero\] .+"]},
   1093     {'category': 'java',
   1094      'severity': Severity.HIGH,
   1095      'description':
   1096          'Java: Empty statement after if',
   1097      'patterns': [r".*: warning: \[EmptyIf\] .+"]},
   1098     {'category': 'java',
   1099      'severity': Severity.HIGH,
   1100      'description':
   1101          'Java: == NaN always returns false; use the isNaN methods instead',
   1102      'patterns': [r".*: warning: \[EqualsNaN\] .+"]},
   1103     {'category': 'java',
   1104      'severity': Severity.HIGH,
   1105      'description':
   1106          'Java: Method annotated @ForOverride must be protected or package-private and only invoked from declaring class',
   1107      'patterns': [r".*: warning: \[ForOverride\] .+"]},
   1108     {'category': 'java',
   1109      'severity': Severity.HIGH,
   1110      'description':
   1111          'Java: Casting a lambda to this @FunctionalInterface can cause a behavior change from casting to a functional superinterface, which is surprising to users.  Prefer decorator methods to this surprising behavior.',
   1112      'patterns': [r".*: warning: \[FunctionalInterfaceMethodChanged\] .+"]},
   1113     {'category': 'java',
   1114      'severity': Severity.HIGH,
   1115      'description':
   1116          'Java: Futures.getChecked requires a checked exception type with a standard constructor.',
   1117      'patterns': [r".*: warning: \[FuturesGetCheckedIllegalExceptionType\] .+"]},
   1118     {'category': 'java',
   1119      'severity': Severity.HIGH,
   1120      'description':
   1121          'Java: Calling getClass() on an annotation may return a proxy class',
   1122      'patterns': [r".*: warning: \[GetClassOnAnnotation\] .+"]},
   1123     {'category': 'java',
   1124      'severity': Severity.HIGH,
   1125      'description':
   1126          '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',
   1127      'patterns': [r".*: warning: \[GetClassOnClass\] .+"]},
   1128     {'category': 'java',
   1129      'severity': Severity.HIGH,
   1130      'description':
   1131          'Java: An object is tested for equality to itself using Guava Libraries',
   1132      'patterns': [r".*: warning: \[GuavaSelfEquals\] .+"]},
   1133     {'category': 'java',
   1134      'severity': Severity.HIGH,
   1135      'description':
   1136          'Java: contains() is a legacy method that is equivalent to containsValue()',
   1137      'patterns': [r".*: warning: \[HashtableContains\] .+"]},
   1138     {'category': 'java',
   1139      'severity': Severity.HIGH,
   1140      'description':
   1141          'Java: Writing "a && a", "a || a", "a & a", or "a | a" is equivalent to "a".',
   1142      'patterns': [r".*: warning: \[IdentityBinaryExpression\] .+"]},
   1143     {'category': 'java',
   1144      'severity': Severity.HIGH,
   1145      'description':
   1146          'Java: Modifying an immutable collection is guaranteed to throw an exception and leave the collection unmodified',
   1147      'patterns': [r".*: warning: \[ImmutableModification\] .+"]},
   1148     {'category': 'java',
   1149      'severity': Severity.HIGH,
   1150      'description':
   1151          'Java: This method always recurses, and will cause a StackOverflowError',
   1152      'patterns': [r".*: warning: \[InfiniteRecursion\] .+"]},
   1153     {'category': 'java',
   1154      'severity': Severity.HIGH,
   1155      'description':
   1156          'Java: A standard cryptographic operation is used in a mode that is prone to vulnerabilities',
   1157      'patterns': [r".*: warning: \[InsecureCryptoUsage\] .+"]},
   1158     {'category': 'java',
   1159      'severity': Severity.HIGH,
   1160      'description':
   1161          'Java: Invalid syntax used for a regular expression',
   1162      'patterns': [r".*: warning: \[InvalidPatternSyntax\] .+"]},
   1163     {'category': 'java',
   1164      'severity': Severity.HIGH,
   1165      'description':
   1166          'Java: The argument to Class#isInstance(Object) should not be a Class',
   1167      'patterns': [r".*: warning: \[IsInstanceOfClass\] .+"]},
   1168     {'category': 'java',
   1169      'severity': Severity.HIGH,
   1170      'description':
   1171          'Java: jMock tests must have a @RunWith(JMock.class) annotation, or the Mockery field must have a @Rule JUnit annotation',
   1172      'patterns': [r".*: warning: \[JMockTestWithoutRunWithOrRuleAnnotation\] .+"]},
   1173     {'category': 'java',
   1174      'severity': Severity.HIGH,
   1175      'description':
   1176          'Java: Test method will not be run; please prefix name with "test"',
   1177      'patterns': [r".*: warning: \[JUnit3TestNotRun\] .+"]},
   1178     {'category': 'java',
   1179      'severity': Severity.HIGH,
   1180      'description':
   1181          'Java: setUp() method will not be run; Please add a @Before annotation',
   1182      'patterns': [r".*: warning: \[JUnit4SetUpNotRun\] .+"]},
   1183     {'category': 'java',
   1184      'severity': Severity.HIGH,
   1185      'description':
   1186          'Java: tearDown() method will not be run; Please add an @After annotation',
   1187      'patterns': [r".*: warning: \[JUnit4TearDownNotRun\] .+"]},
   1188     {'category': 'java',
   1189      'severity': Severity.HIGH,
   1190      'description':
   1191          'Java: Test method will not be run; please add @Test annotation',
   1192      'patterns': [r".*: warning: \[JUnit4TestNotRun\] .+"]},
   1193     {'category': 'java',
   1194      'severity': Severity.HIGH,
   1195      'description':
   1196          'Java: Use of "YYYY" (week year) in a date pattern without "ww" (week in year). You probably meant to use "yyyy" (year) instead.',
   1197      'patterns': [r".*: warning: \[MisusedWeekYear\] .+"]},
   1198     {'category': 'java',
   1199      'severity': Severity.HIGH,
   1200      'description':
   1201          'Java: A bug in Mockito will cause this test to fail at runtime with a ClassCastException',
   1202      'patterns': [r".*: warning: \[MockitoCast\] .+"]},
   1203     {'category': 'java',
   1204      'severity': Severity.HIGH,
   1205      'description':
   1206          'Java: Missing method call for verify(mock) here',
   1207      'patterns': [r".*: warning: \[MockitoUsage\] .+"]},
   1208     {'category': 'java',
   1209      'severity': Severity.HIGH,
   1210      'description':
   1211          'Java: Using a collection function with itself as the argument.',
   1212      'patterns': [r".*: warning: \[ModifyingCollectionWithItself\] .+"]},
   1213     {'category': 'java',
   1214      'severity': Severity.HIGH,
   1215      'description':
   1216          'Java: @NoAllocation was specified on this method, but something was found that would trigger an allocation',
   1217      'patterns': [r".*: warning: \[NoAllocation\] .+"]},
   1218     {'category': 'java',
   1219      'severity': Severity.HIGH,
   1220      'description':
   1221          'Java: Static import of type uses non-canonical name',
   1222      'patterns': [r".*: warning: \[NonCanonicalStaticImport\] .+"]},
   1223     {'category': 'java',
   1224      'severity': Severity.HIGH,
   1225      'description':
   1226          'Java: @CompileTimeConstant parameters should be final or effectively final',
   1227      'patterns': [r".*: warning: \[NonFinalCompileTimeConstant\] .+"]},
   1228     {'category': 'java',
   1229      'severity': Severity.HIGH,
   1230      'description':
   1231          'Java: Calling getAnnotation on an annotation that is not retained at runtime.',
   1232      'patterns': [r".*: warning: \[NonRuntimeAnnotation\] .+"]},
   1233     {'category': 'java',
   1234      'severity': Severity.HIGH,
   1235      'description':
   1236          'Java: Numeric comparison using reference equality instead of value equality',
   1237      'patterns': [r".*: warning: \[NumericEquality\] .+"]},
   1238     {'category': 'java',
   1239      'severity': Severity.HIGH,
   1240      'description':
   1241          'Java: Comparison using reference equality instead of value equality',
   1242      'patterns': [r".*: warning: \[OptionalEquality\] .+"]},
   1243     {'category': 'java',
   1244      'severity': Severity.HIGH,
   1245      'description':
   1246          'Java: Varargs doesn\'t agree for overridden method',
   1247      'patterns': [r".*: warning: \[Overrides\] .+"]},
   1248     {'category': 'java',
   1249      'severity': Severity.HIGH,
   1250      'description':
   1251          'Java: Declaring types inside package-info.java files is very bad form',
   1252      'patterns': [r".*: warning: \[PackageInfo\] .+"]},
   1253     {'category': 'java',
   1254      'severity': Severity.HIGH,
   1255      'description':
   1256          'Java: Literal passed as first argument to Preconditions.checkNotNull() can never be null',
   1257      'patterns': [r".*: warning: \[PreconditionsCheckNotNull\] .+"]},
   1258     {'category': 'java',
   1259      'severity': Severity.HIGH,
   1260      'description':
   1261          'Java: First argument to `Preconditions.checkNotNull()` is a primitive rather than an object reference',
   1262      'patterns': [r".*: warning: \[PreconditionsCheckNotNullPrimitive\] .+"]},
   1263     {'category': 'java',
   1264      'severity': Severity.HIGH,
   1265      'description':
   1266          'Java: Protobuf fields cannot be null',
   1267      'patterns': [r".*: warning: \[ProtoFieldNullComparison\] .+"]},
   1268     {'category': 'java',
   1269      'severity': Severity.HIGH,
   1270      'description':
   1271          'Java: Comparing protobuf fields of type String using reference equality',
   1272      'patterns': [r".*: warning: \[ProtoStringFieldReferenceEquality\] .+"]},
   1273     {'category': 'java',
   1274      'severity': Severity.HIGH,
   1275      'description':
   1276          'Java: Use Random.nextInt(int).  Random.nextInt() % n can have negative results',
   1277      'patterns': [r".*: warning: \[RandomModInteger\] .+"]},
   1278     {'category': 'java',
   1279      'severity': Severity.HIGH,
   1280      'description':
   1281          'Java:  Check for non-whitelisted callers to RestrictedApiChecker.',
   1282      'patterns': [r".*: warning: \[RestrictedApiChecker\] .+"]},
   1283     {'category': 'java',
   1284      'severity': Severity.HIGH,
   1285      'description':
   1286          'Java: Return value of this method must be used',
   1287      'patterns': [r".*: warning: \[ReturnValueIgnored\] .+"]},
   1288     {'category': 'java',
   1289      'severity': Severity.HIGH,
   1290      'description':
   1291          'Java: Variable assigned to itself',
   1292      'patterns': [r".*: warning: \[SelfAssignment\] .+"]},
   1293     {'category': 'java',
   1294      'severity': Severity.HIGH,
   1295      'description':
   1296          'Java: An object is compared to itself',
   1297      'patterns': [r".*: warning: \[SelfComparison\] .+"]},
   1298     {'category': 'java',
   1299      'severity': Severity.HIGH,
   1300      'description':
   1301          'Java: Variable compared to itself',
   1302      'patterns': [r".*: warning: \[SelfEquality\] .+"]},
   1303     {'category': 'java',
   1304      'severity': Severity.HIGH,
   1305      'description':
   1306          'Java: An object is tested for equality to itself',
   1307      'patterns': [r".*: warning: \[SelfEquals\] .+"]},
   1308     {'category': 'java',
   1309      'severity': Severity.HIGH,
   1310      'description':
   1311          'Java: Comparison of a size >= 0 is always true, did you intend to check for non-emptiness?',
   1312      'patterns': [r".*: warning: \[SizeGreaterThanOrEqualsZero\] .+"]},
   1313     {'category': 'java',
   1314      'severity': Severity.HIGH,
   1315      'description':
   1316          'Java: Calling toString on a Stream does not provide useful information',
   1317      'patterns': [r".*: warning: \[StreamToString\] .+"]},
   1318     {'category': 'java',
   1319      'severity': Severity.HIGH,
   1320      'description':
   1321          'Java: StringBuilder does not have a char constructor; this invokes the int constructor.',
   1322      'patterns': [r".*: warning: \[StringBuilderInitWithChar\] .+"]},
   1323     {'category': 'java',
   1324      'severity': Severity.HIGH,
   1325      'description':
   1326          'Java: Suppressing "deprecated" is probably a typo for "deprecation"',
   1327      'patterns': [r".*: warning: \[SuppressWarningsDeprecated\] .+"]},
   1328     {'category': 'java',
   1329      'severity': Severity.HIGH,
   1330      'description':
   1331          'Java: throwIfUnchecked(knownCheckedException) is a no-op.',
   1332      'patterns': [r".*: warning: \[ThrowIfUncheckedKnownChecked\] .+"]},
   1333     {'category': 'java',
   1334      'severity': Severity.HIGH,
   1335      'description':
   1336          'Java: Catching Throwable/Error masks failures from fail() or assert*() in the try block',
   1337      'patterns': [r".*: warning: \[TryFailThrowable\] .+"]},
   1338     {'category': 'java',
   1339      'severity': Severity.HIGH,
   1340      'description':
   1341          'Java: Type parameter used as type qualifier',
   1342      'patterns': [r".*: warning: \[TypeParameterQualifier\] .+"]},
   1343     {'category': 'java',
   1344      'severity': Severity.HIGH,
   1345      'description':
   1346          'Java: Non-generic methods should not be invoked with type arguments',
   1347      'patterns': [r".*: warning: \[UnnecessaryTypeArgument\] .+"]},
   1348     {'category': 'java',
   1349      'severity': Severity.HIGH,
   1350      'description':
   1351          'Java: Instance created but never used',
   1352      'patterns': [r".*: warning: \[UnusedAnonymousClass\] .+"]},
   1353     {'category': 'java',
   1354      'severity': Severity.HIGH,
   1355      'description':
   1356          'Java: Collection is modified in place, but the result is not used',
   1357      'patterns': [r".*: warning: \[UnusedCollectionModifiedInPlace\] .+"]},
   1358     {'category': 'java',
   1359      'severity': Severity.HIGH,
   1360      'description':
   1361          'Java: Method parameter has wrong package',
   1362      'patterns': [r".*: warning: \[ParameterPackage\] .+"]},
   1363 
   1364     # End warnings generated by Error Prone
   1365 
   1366     {'category': 'java',
   1367      'severity': Severity.UNKNOWN,
   1368      'description': 'Java: Unclassified/unrecognized warnings',
   1369      'patterns': [r".*: warning: \[.+\] .+"]},
   1370 
   1371     {'category': 'aapt', 'severity': Severity.MEDIUM,
   1372      'description': 'aapt: No default translation',
   1373      'patterns': [r".*: warning: string '.+' has no default translation in .*"]},
   1374     {'category': 'aapt', 'severity': Severity.MEDIUM,
   1375      'description': 'aapt: Missing default or required localization',
   1376      'patterns': [r".*: warning: \*\*\*\* string '.+' has no default or required localization for '.+' in .+"]},
   1377     {'category': 'aapt', 'severity': Severity.MEDIUM,
   1378      'description': 'aapt: String marked untranslatable, but translation exists',
   1379      'patterns': [r".*: warning: string '.+' in .* marked untranslatable but exists in locale '??_??'"]},
   1380     {'category': 'aapt', 'severity': Severity.MEDIUM,
   1381      'description': 'aapt: empty span in string',
   1382      'patterns': [r".*: warning: empty '.+' span found in text '.+"]},
   1383     {'category': 'C/C++', 'severity': Severity.MEDIUM,
   1384      'description': 'Taking address of temporary',
   1385      'patterns': [r".*: warning: taking address of temporary"]},
   1386     {'category': 'C/C++', 'severity': Severity.MEDIUM,
   1387      'description': 'Possible broken line continuation',
   1388      'patterns': [r".*: warning: backslash and newline separated by space"]},
   1389     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wundefined-var-template',
   1390      'description': 'Undefined variable template',
   1391      'patterns': [r".*: warning: instantiation of variable .* no definition is available"]},
   1392     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wundefined-inline',
   1393      'description': 'Inline function is not defined',
   1394      'patterns': [r".*: warning: inline function '.*' is not defined"]},
   1395     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Warray-bounds',
   1396      'description': 'Array subscript out of bounds',
   1397      'patterns': [r".*: warning: array subscript is above array bounds",
   1398                   r".*: warning: Array subscript is undefined",
   1399                   r".*: warning: array subscript is below array bounds"]},
   1400     {'category': 'C/C++', 'severity': Severity.MEDIUM,
   1401      'description': 'Excess elements in initializer',
   1402      'patterns': [r".*: warning: excess elements in .+ initializer"]},
   1403     {'category': 'C/C++', 'severity': Severity.MEDIUM,
   1404      'description': 'Decimal constant is unsigned only in ISO C90',
   1405      'patterns': [r".*: warning: this decimal constant is unsigned only in ISO C90"]},
   1406     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmain',
   1407      'description': 'main is usually a function',
   1408      'patterns': [r".*: warning: 'main' is usually a function"]},
   1409     {'category': 'C/C++', 'severity': Severity.MEDIUM,
   1410      'description': 'Typedef ignored',
   1411      'patterns': [r".*: warning: 'typedef' was ignored in this declaration"]},
   1412     {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Waddress',
   1413      'description': 'Address always evaluates to true',
   1414      'patterns': [r".*: warning: the address of '.+' will always evaluate as 'true'"]},
   1415     {'category': 'C/C++', 'severity': Severity.FIXMENOW,
   1416      'description': 'Freeing a non-heap object',
   1417      'patterns': [r".*: warning: attempt to free a non-heap object '.+'"]},
   1418     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wchar-subscripts',
   1419      'description': 'Array subscript has type char',
   1420      'patterns': [r".*: warning: array subscript .+ type 'char'.+Wchar-subscripts"]},
   1421     {'category': 'C/C++', 'severity': Severity.MEDIUM,
   1422      'description': 'Constant too large for type',
   1423      'patterns': [r".*: warning: integer constant is too large for '.+' type"]},
   1424     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Woverflow',
   1425      'description': 'Constant too large for type, truncated',
   1426      'patterns': [r".*: warning: large integer implicitly truncated to unsigned type"]},
   1427     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Winteger-overflow',
   1428      'description': 'Overflow in expression',
   1429      'patterns': [r".*: warning: overflow in expression; .*Winteger-overflow"]},
   1430     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Woverflow',
   1431      'description': 'Overflow in implicit constant conversion',
   1432      'patterns': [r".*: warning: overflow in implicit constant conversion"]},
   1433     {'category': 'C/C++', 'severity': Severity.MEDIUM,
   1434      'description': 'Declaration does not declare anything',
   1435      'patterns': [r".*: warning: declaration 'class .+' does not declare anything"]},
   1436     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wreorder',
   1437      'description': 'Initialization order will be different',
   1438      'patterns': [r".*: warning: '.+' will be initialized after",
   1439                   r".*: warning: field .+ will be initialized after .+Wreorder"]},
   1440     {'category': 'cont.', 'severity': Severity.SKIP,
   1441      'description': 'skip,   ....',
   1442      'patterns': [r".*: warning:   '.+'"]},
   1443     {'category': 'cont.', 'severity': Severity.SKIP,
   1444      'description': 'skip,   base ...',
   1445      'patterns': [r".*: warning:   base '.+'"]},
   1446     {'category': 'cont.', 'severity': Severity.SKIP,
   1447      'description': 'skip,   when initialized here',
   1448      'patterns': [r".*: warning:   when initialized here"]},
   1449     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-parameter-type',
   1450      'description': 'Parameter type not specified',
   1451      'patterns': [r".*: warning: type of '.+' defaults to 'int'"]},
   1452     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-declarations',
   1453      'description': 'Missing declarations',
   1454      'patterns': [r".*: warning: declaration does not declare anything"]},
   1455     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-noreturn',
   1456      'description': 'Missing noreturn',
   1457      'patterns': [r".*: warning: function '.*' could be declared with attribute 'noreturn'"]},
   1458     # pylint:disable=anomalous-backslash-in-string
   1459     # TODO(chh): fix the backslash pylint warning.
   1460     {'category': 'gcc', 'severity': Severity.MEDIUM,
   1461      'description': 'Invalid option for C file',
   1462      'patterns': [r".*: warning: command line option "".+"" is valid for C\+\+\/ObjC\+\+ but not for C"]},
   1463     {'category': 'C/C++', 'severity': Severity.MEDIUM,
   1464      'description': 'User warning',
   1465      'patterns': [r".*: warning: #warning "".+"""]},
   1466     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wvexing-parse',
   1467      'description': 'Vexing parsing problem',
   1468      'patterns': [r".*: warning: empty parentheses interpreted as a function declaration"]},
   1469     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wextra',
   1470      'description': 'Dereferencing void*',
   1471      'patterns': [r".*: warning: dereferencing 'void \*' pointer"]},
   1472     {'category': 'C/C++', 'severity': Severity.MEDIUM,
   1473      'description': 'Comparison of pointer and integer',
   1474      'patterns': [r".*: warning: ordered comparison of pointer with integer zero",
   1475                   r".*: warning: .*comparison between pointer and integer"]},
   1476     {'category': 'C/C++', 'severity': Severity.MEDIUM,
   1477      'description': 'Use of error-prone unary operator',
   1478      'patterns': [r".*: warning: use of unary operator that may be intended as compound assignment"]},
   1479     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wwrite-strings',
   1480      'description': 'Conversion of string constant to non-const char*',
   1481      'patterns': [r".*: warning: deprecated conversion from string constant to '.+'"]},
   1482     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wstrict-prototypes',
   1483      'description': 'Function declaration isn''t a prototype',
   1484      'patterns': [r".*: warning: function declaration isn't a prototype"]},
   1485     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wignored-qualifiers',
   1486      'description': 'Type qualifiers ignored on function return value',
   1487      'patterns': [r".*: warning: type qualifiers ignored on function return type",
   1488                   r".*: warning: .+ type qualifier .+ has no effect .+Wignored-qualifiers"]},
   1489     {'category': 'C/C++', 'severity': Severity.MEDIUM,
   1490      'description': '<foo> declared inside parameter list, scope limited to this definition',
   1491      'patterns': [r".*: warning: '.+' declared inside parameter list"]},
   1492     {'category': 'cont.', 'severity': Severity.SKIP,
   1493      'description': 'skip, its scope is only this ...',
   1494      'patterns': [r".*: warning: its scope is only this definition or declaration, which is probably not what you want"]},
   1495     {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wcomment',
   1496      'description': 'Line continuation inside comment',
   1497      'patterns': [r".*: warning: multi-line comment"]},
   1498     {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wcomment',
   1499      'description': 'Comment inside comment',
   1500      'patterns': [r".*: warning: "".+"" within comment"]},
   1501     # Warning "value stored is never read" could be from clang-tidy or clang static analyzer.
   1502     {'category': 'C/C++', 'severity': Severity.ANALYZER,
   1503      'description': 'clang-analyzer Value stored is never read',
   1504      'patterns': [r".*: warning: Value stored to .+ is never read.*clang-analyzer-deadcode.DeadStores"]},
   1505     {'category': 'C/C++', 'severity': Severity.LOW,
   1506      'description': 'Value stored is never read',
   1507      'patterns': [r".*: warning: Value stored to .+ is never read"]},
   1508     {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wdeprecated-declarations',
   1509      'description': 'Deprecated declarations',
   1510      'patterns': [r".*: warning: .+ is deprecated.+deprecated-declarations"]},
   1511     {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wdeprecated-register',
   1512      'description': 'Deprecated register',
   1513      'patterns': [r".*: warning: 'register' storage class specifier is deprecated"]},
   1514     {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wpointer-sign',
   1515      'description': 'Converts between pointers to integer types with different sign',
   1516      'patterns': [r".*: warning: .+ converts between pointers to integer types with different sign"]},
   1517     {'category': 'C/C++', 'severity': Severity.HARMLESS,
   1518      'description': 'Extra tokens after #endif',
   1519      'patterns': [r".*: warning: extra tokens at end of #endif directive"]},
   1520     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wenum-compare',
   1521      'description': 'Comparison between different enums',
   1522      'patterns': [r".*: warning: comparison between '.+' and '.+'.+Wenum-compare"]},
   1523     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wconversion',
   1524      'description': 'Conversion may change value',
   1525      'patterns': [r".*: warning: converting negative value '.+' to '.+'",
   1526                   r".*: warning: conversion to '.+' .+ may (alter|change)"]},
   1527     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wconversion-null',
   1528      'description': 'Converting to non-pointer type from NULL',
   1529      'patterns': [r".*: warning: converting to non-pointer type '.+' from NULL"]},
   1530     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wnull-conversion',
   1531      'description': 'Converting NULL to non-pointer type',
   1532      'patterns': [r".*: warning: implicit conversion of NULL constant to '.+'"]},
   1533     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wnon-literal-null-conversion',
   1534      'description': 'Zero used as null pointer',
   1535      'patterns': [r".*: warning: expression .* zero treated as a null pointer constant"]},
   1536     {'category': 'C/C++', 'severity': Severity.MEDIUM,
   1537      'description': 'Implicit conversion changes value',
   1538      'patterns': [r".*: warning: implicit conversion .* changes value from .* to .*-conversion"]},
   1539     {'category': 'C/C++', 'severity': Severity.MEDIUM,
   1540      'description': 'Passing NULL as non-pointer argument',
   1541      'patterns': [r".*: warning: passing NULL to non-pointer argument [0-9]+ of '.+'"]},
   1542     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wctor-dtor-privacy',
   1543      'description': 'Class seems unusable because of private ctor/dtor',
   1544      'patterns': [r".*: warning: all member functions in class '.+' are private"]},
   1545     # skip this next one, because it only points out some RefBase-based classes where having a private destructor is perfectly fine
   1546     {'category': 'C/C++', 'severity': Severity.SKIP, 'option': '-Wctor-dtor-privacy',
   1547      'description': 'Class seems unusable because of private ctor/dtor',
   1548      'patterns': [r".*: warning: 'class .+' only defines a private destructor and has no friends"]},
   1549     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wctor-dtor-privacy',
   1550      'description': 'Class seems unusable because of private ctor/dtor',
   1551      'patterns': [r".*: warning: 'class .+' only defines private constructors and has no friends"]},
   1552     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wgnu-static-float-init',
   1553      'description': 'In-class initializer for static const float/double',
   1554      'patterns': [r".*: warning: in-class initializer for static data member of .+const (float|double)"]},
   1555     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wpointer-arith',
   1556      'description': 'void* used in arithmetic',
   1557      'patterns': [r".*: warning: pointer of type 'void \*' used in (arithmetic|subtraction)",
   1558                   r".*: warning: arithmetic on .+ to void is a GNU extension.*Wpointer-arith",
   1559                   r".*: warning: wrong type argument to increment"]},
   1560     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsign-promo',
   1561      'description': 'Overload resolution chose to promote from unsigned or enum to signed type',
   1562      'patterns': [r".*: warning: passing '.+' chooses '.+' over '.+'.*Wsign-promo"]},
   1563     {'category': 'cont.', 'severity': Severity.SKIP,
   1564      'description': 'skip,   in call to ...',
   1565      'patterns': [r".*: warning:   in call to '.+'"]},
   1566     {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wextra',
   1567      'description': 'Base should be explicitly initialized in copy constructor',
   1568      'patterns': [r".*: warning: base class '.+' should be explicitly initialized in the copy constructor"]},
   1569     {'category': 'C/C++', 'severity': Severity.MEDIUM,
   1570      'description': 'VLA has zero or negative size',
   1571      'patterns': [r".*: warning: Declared variable-length array \(VLA\) has .+ size"]},
   1572     {'category': 'C/C++', 'severity': Severity.MEDIUM,
   1573      'description': 'Return value from void function',
   1574      'patterns': [r".*: warning: 'return' with a value, in function returning void"]},
   1575     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'multichar',
   1576      'description': 'Multi-character character constant',
   1577      'patterns': [r".*: warning: multi-character character constant"]},
   1578     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'writable-strings',
   1579      'description': 'Conversion from string literal to char*',
   1580      'patterns': [r".*: warning: .+ does not allow conversion from string literal to 'char \*'"]},
   1581     {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wextra-semi',
   1582      'description': 'Extra \';\'',
   1583      'patterns': [r".*: warning: extra ';' .+extra-semi"]},
   1584     {'category': 'C/C++', 'severity': Severity.LOW,
   1585      'description': 'Useless specifier',
   1586      'patterns': [r".*: warning: useless storage class specifier in empty declaration"]},
   1587     {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wduplicate-decl-specifier',
   1588      'description': 'Duplicate declaration specifier',
   1589      'patterns': [r".*: warning: duplicate '.+' declaration specifier"]},
   1590     {'category': 'logtags', 'severity': Severity.LOW,
   1591      'description': 'Duplicate logtag',
   1592      'patterns': [r".*: warning: tag \".+\" \(.+\) duplicated in .+"]},
   1593     {'category': 'logtags', 'severity': Severity.LOW, 'option': 'typedef-redefinition',
   1594      'description': 'Typedef redefinition',
   1595      'patterns': [r".*: warning: redefinition of typedef '.+' is a C11 feature"]},
   1596     {'category': 'logtags', 'severity': Severity.LOW, 'option': 'gnu-designator',
   1597      'description': 'GNU old-style field designator',
   1598      'patterns': [r".*: warning: use of GNU old-style field designator extension"]},
   1599     {'category': 'logtags', 'severity': Severity.LOW, 'option': 'missing-field-initializers',
   1600      'description': 'Missing field initializers',
   1601      'patterns': [r".*: warning: missing field '.+' initializer"]},
   1602     {'category': 'logtags', 'severity': Severity.LOW, 'option': 'missing-braces',
   1603      'description': 'Missing braces',
   1604      'patterns': [r".*: warning: suggest braces around initialization of",
   1605                   r".*: warning: too many braces around scalar initializer .+Wmany-braces-around-scalar-init",
   1606                   r".*: warning: braces around scalar initializer"]},
   1607     {'category': 'logtags', 'severity': Severity.LOW, 'option': 'sign-compare',
   1608      'description': 'Comparison of integers of different signs',
   1609      'patterns': [r".*: warning: comparison of integers of different signs.+sign-compare"]},
   1610     {'category': 'logtags', 'severity': Severity.LOW, 'option': 'dangling-else',
   1611      'description': 'Add braces to avoid dangling else',
   1612      'patterns': [r".*: warning: add explicit braces to avoid dangling else"]},
   1613     {'category': 'logtags', 'severity': Severity.LOW, 'option': 'initializer-overrides',
   1614      'description': 'Initializer overrides prior initialization',
   1615      'patterns': [r".*: warning: initializer overrides prior initialization of this subobject"]},
   1616     {'category': 'logtags', 'severity': Severity.LOW, 'option': 'self-assign',
   1617      'description': 'Assigning value to self',
   1618      'patterns': [r".*: warning: explicitly assigning value of .+ to itself"]},
   1619     {'category': 'logtags', 'severity': Severity.LOW, 'option': 'gnu-variable-sized-type-not-at-end',
   1620      'description': 'GNU extension, variable sized type not at end',
   1621      'patterns': [r".*: warning: field '.+' with variable sized type '.+' not at the end of a struct or class"]},
   1622     {'category': 'logtags', 'severity': Severity.LOW, 'option': 'tautological-constant-out-of-range-compare',
   1623      'description': 'Comparison of constant is always false/true',
   1624      'patterns': [r".*: comparison of .+ is always .+Wtautological-constant-out-of-range-compare"]},
   1625     {'category': 'logtags', 'severity': Severity.LOW, 'option': 'overloaded-virtual',
   1626      'description': 'Hides overloaded virtual function',
   1627      'patterns': [r".*: '.+' hides overloaded virtual function"]},
   1628     {'category': 'logtags', 'severity': Severity.LOW, 'option': 'incompatible-pointer-types',
   1629      'description': 'Incompatible pointer types',
   1630      'patterns': [r".*: warning: incompatible pointer types .+Wincompatible-pointer-types"]},
   1631     {'category': 'logtags', 'severity': Severity.LOW, 'option': 'asm-operand-widths',
   1632      'description': 'ASM value size does not match register size',
   1633      'patterns': [r".*: warning: value size does not match register size specified by the constraint and modifier"]},
   1634     {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'tautological-compare',
   1635      'description': 'Comparison of self is always false',
   1636      'patterns': [r".*: self-comparison always evaluates to false"]},
   1637     {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'constant-logical-operand',
   1638      'description': 'Logical op with constant operand',
   1639      'patterns': [r".*: use of logical '.+' with constant operand"]},
   1640     {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'literal-suffix',
   1641      'description': 'Needs a space between literal and string macro',
   1642      'patterns': [r".*: warning: invalid suffix on literal.+ requires a space .+Wliteral-suffix"]},
   1643     {'category': 'C/C++', 'severity': Severity.LOW, 'option': '#warnings',
   1644      'description': 'Warnings from #warning',
   1645      'patterns': [r".*: warning: .+-W#warnings"]},
   1646     {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'absolute-value',
   1647      'description': 'Using float/int absolute value function with int/float argument',
   1648      'patterns': [r".*: warning: using .+ absolute value function .+ when argument is .+ type .+Wabsolute-value",
   1649                   r".*: warning: absolute value function '.+' given .+ which may cause truncation .+Wabsolute-value"]},
   1650     {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wc++11-extensions',
   1651      'description': 'Using C++11 extensions',
   1652      'patterns': [r".*: warning: 'auto' type specifier is a C\+\+11 extension"]},
   1653     {'category': 'C/C++', 'severity': Severity.LOW,
   1654      'description': 'Refers to implicitly defined namespace',
   1655      'patterns': [r".*: warning: using directive refers to implicitly-defined namespace .+"]},
   1656     {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Winvalid-pp-token',
   1657      'description': 'Invalid pp token',
   1658      'patterns': [r".*: warning: missing .+Winvalid-pp-token"]},
   1659 
   1660     {'category': 'C/C++', 'severity': Severity.MEDIUM,
   1661      'description': 'Operator new returns NULL',
   1662      'patterns': [r".*: warning: 'operator new' must not return NULL unless it is declared 'throw\(\)' .+"]},
   1663     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wnull-arithmetic',
   1664      'description': 'NULL used in arithmetic',
   1665      'patterns': [r".*: warning: NULL used in arithmetic",
   1666                   r".*: warning: comparison between NULL and non-pointer"]},
   1667     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'header-guard',
   1668      'description': 'Misspelled header guard',
   1669      'patterns': [r".*: warning: '.+' is used as a header guard .+ followed by .+ different macro"]},
   1670     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'empty-body',
   1671      'description': 'Empty loop body',
   1672      'patterns': [r".*: warning: .+ loop has empty body"]},
   1673     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'enum-conversion',
   1674      'description': 'Implicit conversion from enumeration type',
   1675      'patterns': [r".*: warning: implicit conversion from enumeration type '.+'"]},
   1676     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'switch',
   1677      'description': 'case value not in enumerated type',
   1678      'patterns': [r".*: warning: case value not in enumerated type '.+'"]},
   1679     {'category': 'C/C++', 'severity': Severity.MEDIUM,
   1680      'description': 'Undefined result',
   1681      'patterns': [r".*: warning: The result of .+ is undefined",
   1682                   r".*: warning: passing an object that .+ has undefined behavior \[-Wvarargs\]",
   1683                   r".*: warning: 'this' pointer cannot be null in well-defined C\+\+ code;",
   1684                   r".*: warning: shifting a negative signed value is undefined"]},
   1685     {'category': 'C/C++', 'severity': Severity.MEDIUM,
   1686      'description': 'Division by zero',
   1687      'patterns': [r".*: warning: Division by zero"]},
   1688     {'category': 'C/C++', 'severity': Severity.MEDIUM,
   1689      'description': 'Use of deprecated method',
   1690      'patterns': [r".*: warning: '.+' is deprecated .+"]},
   1691     {'category': 'C/C++', 'severity': Severity.MEDIUM,
   1692      'description': 'Use of garbage or uninitialized value',
   1693      'patterns': [r".*: warning: .+ is a garbage value",
   1694                   r".*: warning: Function call argument is an uninitialized value",
   1695                   r".*: warning: Undefined or garbage value returned to caller",
   1696                   r".*: warning: Called .+ pointer is.+uninitialized",
   1697                   r".*: warning: Called .+ pointer is.+uninitalized",  # match a typo in compiler message
   1698                   r".*: warning: Use of zero-allocated memory",
   1699                   r".*: warning: Dereference of undefined pointer value",
   1700                   r".*: warning: Passed-by-value .+ contains uninitialized data",
   1701                   r".*: warning: Branch condition evaluates to a garbage value",
   1702                   r".*: warning: The .+ of .+ is an uninitialized value.",
   1703                   r".*: warning: .+ is used uninitialized whenever .+sometimes-uninitialized",
   1704                   r".*: warning: Assigned value is garbage or undefined"]},
   1705     {'category': 'C/C++', 'severity': Severity.MEDIUM,
   1706      'description': 'Result of malloc type incompatible with sizeof operand type',
   1707      'patterns': [r".*: warning: Result of '.+' is converted to .+ incompatible with sizeof operand type"]},
   1708     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsizeof-array-argument',
   1709      'description': 'Sizeof on array argument',
   1710      'patterns': [r".*: warning: sizeof on array function parameter will return"]},
   1711     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsizeof-pointer-memacces',
   1712      'description': 'Bad argument size of memory access functions',
   1713      'patterns': [r".*: warning: .+\[-Wsizeof-pointer-memaccess\]"]},
   1714     {'category': 'C/C++', 'severity': Severity.MEDIUM,
   1715      'description': 'Return value not checked',
   1716      'patterns': [r".*: warning: The return value from .+ is not checked"]},
   1717     {'category': 'C/C++', 'severity': Severity.MEDIUM,
   1718      'description': 'Possible heap pollution',
   1719      'patterns': [r".*: warning: .*Possible heap pollution from .+ type .+"]},
   1720     {'category': 'C/C++', 'severity': Severity.MEDIUM,
   1721      'description': 'Allocation size of 0 byte',
   1722      'patterns': [r".*: warning: Call to .+ has an allocation size of 0 byte"]},
   1723     {'category': 'C/C++', 'severity': Severity.MEDIUM,
   1724      'description': 'Result of malloc type incompatible with sizeof operand type',
   1725      'patterns': [r".*: warning: Result of '.+' is converted to .+ incompatible with sizeof operand type"]},
   1726     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wfor-loop-analysis',
   1727      'description': 'Variable used in loop condition not modified in loop body',
   1728      'patterns': [r".*: warning: variable '.+' used in loop condition.*Wfor-loop-analysis"]},
   1729     {'category': 'C/C++', 'severity': Severity.MEDIUM,
   1730      'description': 'Closing a previously closed file',
   1731      'patterns': [r".*: warning: Closing a previously closed file"]},
   1732     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunnamed-type-template-args',
   1733      'description': 'Unnamed template type argument',
   1734      'patterns': [r".*: warning: template argument.+Wunnamed-type-template-args"]},
   1735 
   1736     {'category': 'C/C++', 'severity': Severity.HARMLESS,
   1737      'description': 'Discarded qualifier from pointer target type',
   1738      'patterns': [r".*: warning: .+ discards '.+' qualifier from pointer target type"]},
   1739     {'category': 'C/C++', 'severity': Severity.HARMLESS,
   1740      'description': 'Use snprintf instead of sprintf',
   1741      'patterns': [r".*: warning: .*sprintf is often misused; please use snprintf"]},
   1742     {'category': 'C/C++', 'severity': Severity.HARMLESS,
   1743      'description': 'Unsupported optimizaton flag',
   1744      'patterns': [r".*: warning: optimization flag '.+' is not supported"]},
   1745     {'category': 'C/C++', 'severity': Severity.HARMLESS,
   1746      'description': 'Extra or missing parentheses',
   1747      'patterns': [r".*: warning: equality comparison with extraneous parentheses",
   1748                   r".*: warning: .+ within .+Wlogical-op-parentheses"]},
   1749     {'category': 'C/C++', 'severity': Severity.HARMLESS, 'option': 'mismatched-tags',
   1750      'description': 'Mismatched class vs struct tags',
   1751      'patterns': [r".*: warning: '.+' defined as a .+ here but previously declared as a .+mismatched-tags",
   1752                   r".*: warning: .+ was previously declared as a .+mismatched-tags"]},
   1753 
   1754     # these next ones are to deal with formatting problems resulting from the log being mixed up by 'make -j'
   1755     {'category': 'C/C++', 'severity': Severity.SKIP,
   1756      'description': 'skip, ,',
   1757      'patterns': [r".*: warning: ,$"]},
   1758     {'category': 'C/C++', 'severity': Severity.SKIP,
   1759      'description': 'skip,',
   1760      'patterns': [r".*: warning: $"]},
   1761     {'category': 'C/C++', 'severity': Severity.SKIP,
   1762      'description': 'skip, In file included from ...',
   1763      'patterns': [r".*: warning: In file included from .+,"]},
   1764 
   1765     # warnings from clang-tidy
   1766     {'category': 'C/C++', 'severity': Severity.TIDY,
   1767      'description': 'clang-tidy readability',
   1768      'patterns': [r".*: .+\[readability-.+\]$"]},
   1769     {'category': 'C/C++', 'severity': Severity.TIDY,
   1770      'description': 'clang-tidy c++ core guidelines',
   1771      'patterns': [r".*: .+\[cppcoreguidelines-.+\]$"]},
   1772     {'category': 'C/C++', 'severity': Severity.TIDY,
   1773      'description': 'clang-tidy google-default-arguments',
   1774      'patterns': [r".*: .+\[google-default-arguments\]$"]},
   1775     {'category': 'C/C++', 'severity': Severity.TIDY,
   1776      'description': 'clang-tidy google-runtime-int',
   1777      'patterns': [r".*: .+\[google-runtime-int\]$"]},
   1778     {'category': 'C/C++', 'severity': Severity.TIDY,
   1779      'description': 'clang-tidy google-runtime-operator',
   1780      'patterns': [r".*: .+\[google-runtime-operator\]$"]},
   1781     {'category': 'C/C++', 'severity': Severity.TIDY,
   1782      'description': 'clang-tidy google-runtime-references',
   1783      'patterns': [r".*: .+\[google-runtime-references\]$"]},
   1784     {'category': 'C/C++', 'severity': Severity.TIDY,
   1785      'description': 'clang-tidy google-build',
   1786      'patterns': [r".*: .+\[google-build-.+\]$"]},
   1787     {'category': 'C/C++', 'severity': Severity.TIDY,
   1788      'description': 'clang-tidy google-explicit',
   1789      'patterns': [r".*: .+\[google-explicit-.+\]$"]},
   1790     {'category': 'C/C++', 'severity': Severity.TIDY,
   1791      'description': 'clang-tidy google-readability',
   1792      'patterns': [r".*: .+\[google-readability-.+\]$"]},
   1793     {'category': 'C/C++', 'severity': Severity.TIDY,
   1794      'description': 'clang-tidy google-global',
   1795      'patterns': [r".*: .+\[google-global-.+\]$"]},
   1796     {'category': 'C/C++', 'severity': Severity.TIDY,
   1797      'description': 'clang-tidy google- other',
   1798      'patterns': [r".*: .+\[google-.+\]$"]},
   1799     {'category': 'C/C++', 'severity': Severity.TIDY,
   1800      'description': 'clang-tidy modernize',
   1801      'patterns': [r".*: .+\[modernize-.+\]$"]},
   1802     {'category': 'C/C++', 'severity': Severity.TIDY,
   1803      'description': 'clang-tidy misc',
   1804      'patterns': [r".*: .+\[misc-.+\]$"]},
   1805     {'category': 'C/C++', 'severity': Severity.TIDY,
   1806      'description': 'clang-tidy performance-faster-string-find',
   1807      'patterns': [r".*: .+\[performance-faster-string-find\]$"]},
   1808     {'category': 'C/C++', 'severity': Severity.TIDY,
   1809      'description': 'clang-tidy performance-for-range-copy',
   1810      'patterns': [r".*: .+\[performance-for-range-copy\]$"]},
   1811     {'category': 'C/C++', 'severity': Severity.TIDY,
   1812      'description': 'clang-tidy performance-implicit-cast-in-loop',
   1813      'patterns': [r".*: .+\[performance-implicit-cast-in-loop\]$"]},
   1814     {'category': 'C/C++', 'severity': Severity.TIDY,
   1815      'description': 'clang-tidy performance-unnecessary-copy-initialization',
   1816      'patterns': [r".*: .+\[performance-unnecessary-copy-initialization\]$"]},
   1817     {'category': 'C/C++', 'severity': Severity.TIDY,
   1818      'description': 'clang-tidy performance-unnecessary-value-param',
   1819      'patterns': [r".*: .+\[performance-unnecessary-value-param\]$"]},
   1820     {'category': 'C/C++', 'severity': Severity.ANALYZER,
   1821      'description': 'clang-analyzer Unreachable code',
   1822      'patterns': [r".*: warning: This statement is never executed.*UnreachableCode"]},
   1823     {'category': 'C/C++', 'severity': Severity.ANALYZER,
   1824      'description': 'clang-analyzer Size of malloc may overflow',
   1825      'patterns': [r".*: warning: .* size of .* may overflow .*MallocOverflow"]},
   1826     {'category': 'C/C++', 'severity': Severity.ANALYZER,
   1827      'description': 'clang-analyzer Stream pointer might be NULL',
   1828      'patterns': [r".*: warning: Stream pointer might be NULL .*unix.Stream"]},
   1829     {'category': 'C/C++', 'severity': Severity.ANALYZER,
   1830      'description': 'clang-analyzer Opened file never closed',
   1831      'patterns': [r".*: warning: Opened File never closed.*unix.Stream"]},
   1832     {'category': 'C/C++', 'severity': Severity.ANALYZER,
   1833      'description': 'clang-analyzer sozeof() on a pointer type',
   1834      'patterns': [r".*: warning: .*calls sizeof.* on a pointer type.*SizeofPtr"]},
   1835     {'category': 'C/C++', 'severity': Severity.ANALYZER,
   1836      'description': 'clang-analyzer Pointer arithmetic on non-array variables',
   1837      'patterns': [r".*: warning: Pointer arithmetic on non-array variables .*PointerArithm"]},
   1838     {'category': 'C/C++', 'severity': Severity.ANALYZER,
   1839      'description': 'clang-analyzer Subtraction of pointers of different memory chunks',
   1840      'patterns': [r".*: warning: Subtraction of two pointers .*PointerSub"]},
   1841     {'category': 'C/C++', 'severity': Severity.ANALYZER,
   1842      'description': 'clang-analyzer Access out-of-bound array element',
   1843      'patterns': [r".*: warning: Access out-of-bound array element .*ArrayBound"]},
   1844     {'category': 'C/C++', 'severity': Severity.ANALYZER,
   1845      'description': 'clang-analyzer Out of bound memory access',
   1846      'patterns': [r".*: warning: Out of bound memory access .*ArrayBoundV2"]},
   1847     {'category': 'C/C++', 'severity': Severity.ANALYZER,
   1848      'description': 'clang-analyzer Possible lock order reversal',
   1849      'patterns': [r".*: warning: .* Possible lock order reversal.*PthreadLock"]},
   1850     {'category': 'C/C++', 'severity': Severity.ANALYZER,
   1851      'description': 'clang-analyzer Argument is a pointer to uninitialized value',
   1852      'patterns': [r".*: warning: .* argument is a pointer to uninitialized value .*CallAndMessage"]},
   1853     {'category': 'C/C++', 'severity': Severity.ANALYZER,
   1854      'description': 'clang-analyzer cast to struct',
   1855      'patterns': [r".*: warning: Casting a non-structure type to a structure type .*CastToStruct"]},
   1856     {'category': 'C/C++', 'severity': Severity.ANALYZER,
   1857      'description': 'clang-analyzer call path problems',
   1858      'patterns': [r".*: warning: Call Path : .+"]},
   1859     {'category': 'C/C++', 'severity': Severity.ANALYZER,
   1860      'description': 'clang-analyzer other',
   1861      'patterns': [r".*: .+\[clang-analyzer-.+\]$",
   1862                   r".*: Call Path : .+$"]},
   1863     {'category': 'C/C++', 'severity': Severity.TIDY,
   1864      'description': 'clang-tidy CERT',
   1865      'patterns': [r".*: .+\[cert-.+\]$"]},
   1866     {'category': 'C/C++', 'severity': Severity.TIDY,
   1867      'description': 'clang-tidy llvm',
   1868      'patterns': [r".*: .+\[llvm-.+\]$"]},
   1869     {'category': 'C/C++', 'severity': Severity.TIDY,
   1870      'description': 'clang-diagnostic',
   1871      'patterns': [r".*: .+\[clang-diagnostic-.+\]$"]},
   1872 
   1873     # catch-all for warnings this script doesn't know about yet
   1874     {'category': 'C/C++', 'severity': Severity.UNKNOWN,
   1875      'description': 'Unclassified/unrecognized warnings',
   1876      'patterns': [r".*: warning: .+"]},
   1877 ]
   1878 
   1879 
   1880 def project_name_and_pattern(name, pattern):
   1881   return [name, '(^|.*/)' + pattern + '/.*: warning:']
   1882 
   1883 
   1884 def simple_project_pattern(pattern):
   1885   return project_name_and_pattern(pattern, pattern)
   1886 
   1887 
   1888 # A list of [project_name, file_path_pattern].
   1889 # project_name should not contain comma, to be used in CSV output.
   1890 project_list = [
   1891     simple_project_pattern('art'),
   1892     simple_project_pattern('bionic'),
   1893     simple_project_pattern('bootable'),
   1894     simple_project_pattern('build'),
   1895     simple_project_pattern('cts'),
   1896     simple_project_pattern('dalvik'),
   1897     simple_project_pattern('developers'),
   1898     simple_project_pattern('development'),
   1899     simple_project_pattern('device'),
   1900     simple_project_pattern('doc'),
   1901     # match external/google* before external/
   1902     project_name_and_pattern('external/google', 'external/google.*'),
   1903     project_name_and_pattern('external/non-google', 'external'),
   1904     simple_project_pattern('frameworks/av/camera'),
   1905     simple_project_pattern('frameworks/av/cmds'),
   1906     simple_project_pattern('frameworks/av/drm'),
   1907     simple_project_pattern('frameworks/av/include'),
   1908     simple_project_pattern('frameworks/av/media/common_time'),
   1909     simple_project_pattern('frameworks/av/media/img_utils'),
   1910     simple_project_pattern('frameworks/av/media/libcpustats'),
   1911     simple_project_pattern('frameworks/av/media/libeffects'),
   1912     simple_project_pattern('frameworks/av/media/libmediaplayerservice'),
   1913     simple_project_pattern('frameworks/av/media/libmedia'),
   1914     simple_project_pattern('frameworks/av/media/libstagefright'),
   1915     simple_project_pattern('frameworks/av/media/mtp'),
   1916     simple_project_pattern('frameworks/av/media/ndk'),
   1917     simple_project_pattern('frameworks/av/media/utils'),
   1918     project_name_and_pattern('frameworks/av/media/Other',
   1919                              'frameworks/av/media'),
   1920     simple_project_pattern('frameworks/av/radio'),
   1921     simple_project_pattern('frameworks/av/services'),
   1922     simple_project_pattern('frameworks/av/soundtrigger'),
   1923     project_name_and_pattern('frameworks/av/Other', 'frameworks/av'),
   1924     simple_project_pattern('frameworks/base/cmds'),
   1925     simple_project_pattern('frameworks/base/core'),
   1926     simple_project_pattern('frameworks/base/drm'),
   1927     simple_project_pattern('frameworks/base/media'),
   1928     simple_project_pattern('frameworks/base/libs'),
   1929     simple_project_pattern('frameworks/base/native'),
   1930     simple_project_pattern('frameworks/base/packages'),
   1931     simple_project_pattern('frameworks/base/rs'),
   1932     simple_project_pattern('frameworks/base/services'),
   1933     simple_project_pattern('frameworks/base/tests'),
   1934     simple_project_pattern('frameworks/base/tools'),
   1935     project_name_and_pattern('frameworks/base/Other', 'frameworks/base'),
   1936     simple_project_pattern('frameworks/compile/libbcc'),
   1937     simple_project_pattern('frameworks/compile/mclinker'),
   1938     simple_project_pattern('frameworks/compile/slang'),
   1939     project_name_and_pattern('frameworks/compile/Other', 'frameworks/compile'),
   1940     simple_project_pattern('frameworks/minikin'),
   1941     simple_project_pattern('frameworks/ml'),
   1942     simple_project_pattern('frameworks/native/cmds'),
   1943     simple_project_pattern('frameworks/native/include'),
   1944     simple_project_pattern('frameworks/native/libs'),
   1945     simple_project_pattern('frameworks/native/opengl'),
   1946     simple_project_pattern('frameworks/native/services'),
   1947     simple_project_pattern('frameworks/native/vulkan'),
   1948     project_name_and_pattern('frameworks/native/Other', 'frameworks/native'),
   1949     simple_project_pattern('frameworks/opt'),
   1950     simple_project_pattern('frameworks/rs'),
   1951     simple_project_pattern('frameworks/webview'),
   1952     simple_project_pattern('frameworks/wilhelm'),
   1953     project_name_and_pattern('frameworks/Other', 'frameworks'),
   1954     simple_project_pattern('hardware/akm'),
   1955     simple_project_pattern('hardware/broadcom'),
   1956     simple_project_pattern('hardware/google'),
   1957     simple_project_pattern('hardware/intel'),
   1958     simple_project_pattern('hardware/interfaces'),
   1959     simple_project_pattern('hardware/libhardware'),
   1960     simple_project_pattern('hardware/libhardware_legacy'),
   1961     simple_project_pattern('hardware/qcom'),
   1962     simple_project_pattern('hardware/ril'),
   1963     project_name_and_pattern('hardware/Other', 'hardware'),
   1964     simple_project_pattern('kernel'),
   1965     simple_project_pattern('libcore'),
   1966     simple_project_pattern('libnativehelper'),
   1967     simple_project_pattern('ndk'),
   1968     # match vendor/unbungled_google/packages before other packages
   1969     simple_project_pattern('unbundled_google'),
   1970     simple_project_pattern('packages'),
   1971     simple_project_pattern('pdk'),
   1972     simple_project_pattern('prebuilts'),
   1973     simple_project_pattern('system/bt'),
   1974     simple_project_pattern('system/connectivity'),
   1975     simple_project_pattern('system/core/adb'),
   1976     simple_project_pattern('system/core/base'),
   1977     simple_project_pattern('system/core/debuggerd'),
   1978     simple_project_pattern('system/core/fastboot'),
   1979     simple_project_pattern('system/core/fingerprintd'),
   1980     simple_project_pattern('system/core/fs_mgr'),
   1981     simple_project_pattern('system/core/gatekeeperd'),
   1982     simple_project_pattern('system/core/healthd'),
   1983     simple_project_pattern('system/core/include'),
   1984     simple_project_pattern('system/core/init'),
   1985     simple_project_pattern('system/core/libbacktrace'),
   1986     simple_project_pattern('system/core/liblog'),
   1987     simple_project_pattern('system/core/libpixelflinger'),
   1988     simple_project_pattern('system/core/libprocessgroup'),
   1989     simple_project_pattern('system/core/libsysutils'),
   1990     simple_project_pattern('system/core/logcat'),
   1991     simple_project_pattern('system/core/logd'),
   1992     simple_project_pattern('system/core/run-as'),
   1993     simple_project_pattern('system/core/sdcard'),
   1994     simple_project_pattern('system/core/toolbox'),
   1995     project_name_and_pattern('system/core/Other', 'system/core'),
   1996     simple_project_pattern('system/extras/ANRdaemon'),
   1997     simple_project_pattern('system/extras/cpustats'),
   1998     simple_project_pattern('system/extras/crypto-perf'),
   1999     simple_project_pattern('system/extras/ext4_utils'),
   2000     simple_project_pattern('system/extras/f2fs_utils'),
   2001     simple_project_pattern('system/extras/iotop'),
   2002     simple_project_pattern('system/extras/libfec'),
   2003     simple_project_pattern('system/extras/memory_replay'),
   2004     simple_project_pattern('system/extras/micro_bench'),
   2005     simple_project_pattern('system/extras/mmap-perf'),
   2006     simple_project_pattern('system/extras/multinetwork'),
   2007     simple_project_pattern('system/extras/perfprofd'),
   2008     simple_project_pattern('system/extras/procrank'),
   2009     simple_project_pattern('system/extras/runconuid'),
   2010     simple_project_pattern('system/extras/showmap'),
   2011     simple_project_pattern('system/extras/simpleperf'),
   2012     simple_project_pattern('system/extras/su'),
   2013     simple_project_pattern('system/extras/tests'),
   2014     simple_project_pattern('system/extras/verity'),
   2015     project_name_and_pattern('system/extras/Other', 'system/extras'),
   2016     simple_project_pattern('system/gatekeeper'),
   2017     simple_project_pattern('system/keymaster'),
   2018     simple_project_pattern('system/libhidl'),
   2019     simple_project_pattern('system/libhwbinder'),
   2020     simple_project_pattern('system/media'),
   2021     simple_project_pattern('system/netd'),
   2022     simple_project_pattern('system/nvram'),
   2023     simple_project_pattern('system/security'),
   2024     simple_project_pattern('system/sepolicy'),
   2025     simple_project_pattern('system/tools'),
   2026     simple_project_pattern('system/update_engine'),
   2027     simple_project_pattern('system/vold'),
   2028     project_name_and_pattern('system/Other', 'system'),
   2029     simple_project_pattern('toolchain'),
   2030     simple_project_pattern('test'),
   2031     simple_project_pattern('tools'),
   2032     # match vendor/google* before vendor/
   2033     project_name_and_pattern('vendor/google', 'vendor/google.*'),
   2034     project_name_and_pattern('vendor/non-google', 'vendor'),
   2035     # keep out/obj and other patterns at the end.
   2036     ['out/obj',
   2037      '.*/(gen|obj[^/]*)/(include|EXECUTABLES|SHARED_LIBRARIES|'
   2038      'STATIC_LIBRARIES|NATIVE_TESTS)/.*: warning:'],
   2039     ['other', '.*']  # all other unrecognized patterns
   2040 ]
   2041 
   2042 project_patterns = []
   2043 project_names = []
   2044 warning_messages = []
   2045 warning_records = []
   2046 
   2047 
   2048 def initialize_arrays():
   2049   """Complete global arrays before they are used."""
   2050   global project_names, project_patterns
   2051   project_names = [p[0] for p in project_list]
   2052   project_patterns = [re.compile(p[1]) for p in project_list]
   2053   for w in warn_patterns:
   2054     w['members'] = []
   2055     if 'option' not in w:
   2056       w['option'] = ''
   2057     # Each warning pattern has a 'projects' dictionary, that
   2058     # maps a project name to number of warnings in that project.
   2059     w['projects'] = {}
   2060 
   2061 
   2062 initialize_arrays()
   2063 
   2064 
   2065 android_root = ''
   2066 platform_version = 'unknown'
   2067 target_product = 'unknown'
   2068 target_variant = 'unknown'
   2069 
   2070 
   2071 ##### Data and functions to dump html file. ##################################
   2072 
   2073 html_head_scripts = """\
   2074   <script type="text/javascript">
   2075   function expand(id) {
   2076     var e = document.getElementById(id);
   2077     var f = document.getElementById(id + "_mark");
   2078     if (e.style.display == 'block') {
   2079        e.style.display = 'none';
   2080        f.innerHTML = '&#x2295';
   2081     }
   2082     else {
   2083        e.style.display = 'block';
   2084        f.innerHTML = '&#x2296';
   2085     }
   2086   };
   2087   function expandCollapse(show) {
   2088     for (var id = 1; ; id++) {
   2089       var e = document.getElementById(id + "");
   2090       var f = document.getElementById(id + "_mark");
   2091       if (!e || !f) break;
   2092       e.style.display = (show ? 'block' : 'none');
   2093       f.innerHTML = (show ? '&#x2296' : '&#x2295');
   2094     }
   2095   };
   2096   </script>
   2097   <style type="text/css">
   2098   th,td{border-collapse:collapse; border:1px solid black;}
   2099   .button{color:blue;font-size:110%;font-weight:bolder;}
   2100   .bt{color:black;background-color:transparent;border:none;outline:none;
   2101       font-size:140%;font-weight:bolder;}
   2102   .c0{background-color:#e0e0e0;}
   2103   .c1{background-color:#d0d0d0;}
   2104   .t1{border-collapse:collapse; width:100%; border:1px solid black;}
   2105   </style>
   2106   <script src="https://www.gstatic.com/charts/loader.js"></script>
   2107 """
   2108 
   2109 
   2110 def html_big(param):
   2111   return '<font size="+2">' + param + '</font>'
   2112 
   2113 
   2114 def dump_html_prologue(title):
   2115   print '<html>\n<head>'
   2116   print '<title>' + title + '</title>'
   2117   print html_head_scripts
   2118   emit_stats_by_project()
   2119   print '</head>\n<body>'
   2120   print html_big(title)
   2121   print '<p>'
   2122 
   2123 
   2124 def dump_html_epilogue():
   2125   print '</body>\n</head>\n</html>'
   2126 
   2127 
   2128 def sort_warnings():
   2129   for i in warn_patterns:
   2130     i['members'] = sorted(set(i['members']))
   2131 
   2132 
   2133 def emit_stats_by_project():
   2134   """Dump a google chart table of warnings per project and severity."""
   2135   # warnings[p][s] is number of warnings in project p of severity s.
   2136   warnings = {p: {s: 0 for s in Severity.range} for p in project_names}
   2137   for i in warn_patterns:
   2138     s = i['severity']
   2139     for p in i['projects']:
   2140       warnings[p][s] += i['projects'][p]
   2141 
   2142   # total_by_project[p] is number of warnings in project p.
   2143   total_by_project = {p: sum(warnings[p][s] for s in Severity.range)
   2144                       for p in project_names}
   2145 
   2146   # total_by_severity[s] is number of warnings of severity s.
   2147   total_by_severity = {s: sum(warnings[p][s] for p in project_names)
   2148                        for s in Severity.range}
   2149 
   2150   # emit table header
   2151   stats_header = ['Project']
   2152   for s in Severity.range:
   2153     if total_by_severity[s]:
   2154       stats_header.append("<span style='background-color:{}'>{}</span>".
   2155                           format(Severity.colors[s],
   2156                                  Severity.column_headers[s]))
   2157   stats_header.append('TOTAL')
   2158 
   2159   # emit a row of warning counts per project, skip no-warning projects
   2160   total_all_projects = 0
   2161   stats_rows = []
   2162   for p in project_names:
   2163     if total_by_project[p]:
   2164       one_row = [p]
   2165       for s in Severity.range:
   2166         if total_by_severity[s]:
   2167           one_row.append(warnings[p][s])
   2168       one_row.append(total_by_project[p])
   2169       stats_rows.append(one_row)
   2170       total_all_projects += total_by_project[p]
   2171 
   2172   # emit a row of warning counts per severity
   2173   total_all_severities = 0
   2174   one_row = ['<b>TOTAL</b>']
   2175   for s in Severity.range:
   2176     if total_by_severity[s]:
   2177       one_row.append(total_by_severity[s])
   2178       total_all_severities += total_by_severity[s]
   2179   one_row.append(total_all_projects)
   2180   stats_rows.append(one_row)
   2181   print '<script>'
   2182   emit_const_string_array('StatsHeader', stats_header)
   2183   emit_const_object_array('StatsRows', stats_rows)
   2184   print draw_table_javascript
   2185   print '</script>'
   2186 
   2187 
   2188 def dump_stats():
   2189   """Dump some stats about total number of warnings and such."""
   2190   known = 0
   2191   skipped = 0
   2192   unknown = 0
   2193   sort_warnings()
   2194   for i in warn_patterns:
   2195     if i['severity'] == Severity.UNKNOWN:
   2196       unknown += len(i['members'])
   2197     elif i['severity'] == Severity.SKIP:
   2198       skipped += len(i['members'])
   2199     else:
   2200       known += len(i['members'])
   2201   print 'Number of classified warnings: <b>' + str(known) + '</b><br>'
   2202   print 'Number of skipped warnings: <b>' + str(skipped) + '</b><br>'
   2203   print 'Number of unclassified warnings: <b>' + str(unknown) + '</b><br>'
   2204   total = unknown + known + skipped
   2205   extra_msg = ''
   2206   if total < 1000:
   2207     extra_msg = ' (low count may indicate incremental build)'
   2208   print 'Total number of warnings: <b>' + str(total) + '</b>' + extra_msg
   2209 
   2210 
   2211 # New base table of warnings, [severity, warn_id, project, warning_message]
   2212 # Need buttons to show warnings in different grouping options.
   2213 # (1) Current, group by severity, id for each warning pattern
   2214 #     sort by severity, warn_id, warning_message
   2215 # (2) Current --byproject, group by severity,
   2216 #     id for each warning pattern + project name
   2217 #     sort by severity, warn_id, project, warning_message
   2218 # (3) New, group by project + severity,
   2219 #     id for each warning pattern
   2220 #     sort by project, severity, warn_id, warning_message
   2221 def emit_buttons():
   2222   print ('<button class="button" onclick="expandCollapse(1);">'
   2223          'Expand all warnings</button>\n'
   2224          '<button class="button" onclick="expandCollapse(0);">'
   2225          'Collapse all warnings</button>\n'
   2226          '<button class="button" onclick="groupBySeverity();">'
   2227          'Group warnings by severity</button>\n'
   2228          '<button class="button" onclick="groupByProject();">'
   2229          'Group warnings by project</button><br>')
   2230 
   2231 
   2232 def all_patterns(category):
   2233   patterns = ''
   2234   for i in category['patterns']:
   2235     patterns += i
   2236     patterns += ' / '
   2237   return patterns
   2238 
   2239 
   2240 def dump_fixed():
   2241   """Show which warnings no longer occur."""
   2242   anchor = 'fixed_warnings'
   2243   mark = anchor + '_mark'
   2244   print ('\n<br><p style="background-color:lightblue"><b>'
   2245          '<button id="' + mark + '" '
   2246          'class="bt" onclick="expand(\'' + anchor + '\');">'
   2247          '&#x2295</button> Fixed warnings. '
   2248          'No more occurrences. Please consider turning these into '
   2249          'errors if possible, before they are reintroduced in to the build'
   2250          ':</b></p>')
   2251   print '<blockquote>'
   2252   fixed_patterns = []
   2253   for i in warn_patterns:
   2254     if not i['members']:
   2255       fixed_patterns.append(i['description'] + ' (' +
   2256                             all_patterns(i) + ')')
   2257     if i['option']:
   2258       fixed_patterns.append(' ' + i['option'])
   2259   fixed_patterns.sort()
   2260   print '<div id="' + anchor + '" style="display:none;"><table>'
   2261   cur_row_class = 0
   2262   for text in fixed_patterns:
   2263     cur_row_class = 1 - cur_row_class
   2264     # remove last '\n'
   2265     t = text[:-1] if text[-1] == '\n' else text
   2266     print '<tr><td class="c' + str(cur_row_class) + '">' + t + '</td></tr>'
   2267   print '</table></div>'
   2268   print '</blockquote>'
   2269 
   2270 
   2271 def find_project_index(line):
   2272   for p in range(len(project_patterns)):
   2273     if project_patterns[p].match(line):
   2274       return p
   2275   return -1
   2276 
   2277 
   2278 def classify_one_warning(line, results):
   2279   for i in range(len(warn_patterns)):
   2280     w = warn_patterns[i]
   2281     for cpat in w['compiled_patterns']:
   2282       if cpat.match(line):
   2283         p = find_project_index(line)
   2284         results.append([line, i, p])
   2285         return
   2286       else:
   2287         # If we end up here, there was a problem parsing the log
   2288         # probably caused by 'make -j' mixing the output from
   2289         # 2 or more concurrent compiles
   2290         pass
   2291 
   2292 
   2293 def classify_warnings(lines):
   2294   results = []
   2295   for line in lines:
   2296     classify_one_warning(line, results)
   2297   # After the main work, ignore all other signals to a child process,
   2298   # to avoid bad warning/error messages from the exit clean-up process.
   2299   if args.processes > 1:
   2300     signal.signal(signal.SIGTERM, lambda *args: sys.exit(-signal.SIGTERM))
   2301   return results
   2302 
   2303 
   2304 def parallel_classify_warnings(warning_lines):
   2305   """Classify all warning lines with num_cpu parallel processes."""
   2306   compile_patterns()
   2307   num_cpu = args.processes
   2308   if num_cpu > 1:
   2309     groups = [[] for x in range(num_cpu)]
   2310     i = 0
   2311     for x in warning_lines:
   2312       groups[i].append(x)
   2313       i = (i + 1) % num_cpu
   2314     pool = multiprocessing.Pool(num_cpu)
   2315     group_results = pool.map(classify_warnings, groups)
   2316   else:
   2317     group_results = [classify_warnings(warning_lines)]
   2318 
   2319   for result in group_results:
   2320     for line, pattern_idx, project_idx in result:
   2321       pattern = warn_patterns[pattern_idx]
   2322       pattern['members'].append(line)
   2323       message_idx = len(warning_messages)
   2324       warning_messages.append(line)
   2325       warning_records.append([pattern_idx, project_idx, message_idx])
   2326       pname = '???' if project_idx < 0 else project_names[project_idx]
   2327       # Count warnings by project.
   2328       if pname in pattern['projects']:
   2329         pattern['projects'][pname] += 1
   2330       else:
   2331         pattern['projects'][pname] = 1
   2332 
   2333 
   2334 def compile_patterns():
   2335   """Precompiling every pattern speeds up parsing by about 30x."""
   2336   for i in warn_patterns:
   2337     i['compiled_patterns'] = []
   2338     for pat in i['patterns']:
   2339       i['compiled_patterns'].append(re.compile(pat))
   2340 
   2341 
   2342 def find_android_root(path):
   2343   """Set and return android_root path if it is found."""
   2344   global android_root
   2345   parts = path.split('/')
   2346   for idx in reversed(range(2, len(parts))):
   2347     root_path = '/'.join(parts[:idx])
   2348     # Android root directory should contain this script.
   2349     if os.path.exists(root_path + '/build/tools/warn.py'):
   2350       android_root = root_path
   2351       return root_path
   2352   return ''
   2353 
   2354 
   2355 def remove_android_root_prefix(path):
   2356   """Remove android_root prefix from path if it is found."""
   2357   if path.startswith(android_root):
   2358     return path[1 + len(android_root):]
   2359   else:
   2360     return path
   2361 
   2362 
   2363 def normalize_path(path):
   2364   """Normalize file path relative to android_root."""
   2365   # If path is not an absolute path, just normalize it.
   2366   path = os.path.normpath(path)
   2367   if path[0] != '/':
   2368     return path
   2369   # Remove known prefix of root path and normalize the suffix.
   2370   if android_root or find_android_root(path):
   2371     return remove_android_root_prefix(path)
   2372   else:
   2373     return path
   2374 
   2375 
   2376 def normalize_warning_line(line):
   2377   """Normalize file path relative to android_root in a warning line."""
   2378   # replace fancy quotes with plain ol' quotes
   2379   line = line.replace('', "'")
   2380   line = line.replace('', "'")
   2381   line = line.strip()
   2382   first_column = line.find(':')
   2383   if first_column > 0:
   2384     return normalize_path(line[:first_column]) + line[first_column:]
   2385   else:
   2386     return line
   2387 
   2388 
   2389 def parse_input_file(infile):
   2390   """Parse input file, match warning lines."""
   2391   global platform_version
   2392   global target_product
   2393   global target_variant
   2394   line_counter = 0
   2395 
   2396   # handle only warning messages with a file path
   2397   warning_pattern = re.compile('^[^ ]*/[^ ]*: warning: .*')
   2398 
   2399   # Collect all warnings into the warning_lines set.
   2400   warning_lines = set()
   2401   for line in infile:
   2402     if warning_pattern.match(line):
   2403       line = normalize_warning_line(line)
   2404       warning_lines.add(line)
   2405     elif line_counter < 50:
   2406       # save a little bit of time by only doing this for the first few lines
   2407       line_counter += 1
   2408       m = re.search('(?<=^PLATFORM_VERSION=).*', line)
   2409       if m is not None:
   2410         platform_version = m.group(0)
   2411       m = re.search('(?<=^TARGET_PRODUCT=).*', line)
   2412       if m is not None:
   2413         target_product = m.group(0)
   2414       m = re.search('(?<=^TARGET_BUILD_VARIANT=).*', line)
   2415       if m is not None:
   2416         target_variant = m.group(0)
   2417   return warning_lines
   2418 
   2419 
   2420 # Return s with escaped backslash and quotation characters.
   2421 def escape_string(s):
   2422   return s.replace('\\', '\\\\').replace('"', '\\"')
   2423 
   2424 
   2425 # Return s without trailing '\n' and escape the quotation characters.
   2426 def strip_escape_string(s):
   2427   if not s:
   2428     return s
   2429   s = s[:-1] if s[-1] == '\n' else s
   2430   return escape_string(s)
   2431 
   2432 
   2433 def emit_warning_array(name):
   2434   print 'var warning_{} = ['.format(name)
   2435   for i in range(len(warn_patterns)):
   2436     print '{},'.format(warn_patterns[i][name])
   2437   print '];'
   2438 
   2439 
   2440 def emit_warning_arrays():
   2441   emit_warning_array('severity')
   2442   print 'var warning_description = ['
   2443   for i in range(len(warn_patterns)):
   2444     if warn_patterns[i]['members']:
   2445       print '"{}",'.format(escape_string(warn_patterns[i]['description']))
   2446     else:
   2447       print '"",'  # no such warning
   2448   print '];'
   2449 
   2450 scripts_for_warning_groups = """
   2451   function compareMessages(x1, x2) { // of the same warning type
   2452     return (WarningMessages[x1[2]] <= WarningMessages[x2[2]]) ? -1 : 1;
   2453   }
   2454   function byMessageCount(x1, x2) {
   2455     return x2[2] - x1[2];  // reversed order
   2456   }
   2457   function bySeverityMessageCount(x1, x2) {
   2458     // orer by severity first
   2459     if (x1[1] != x2[1])
   2460       return  x1[1] - x2[1];
   2461     return byMessageCount(x1, x2);
   2462   }
   2463   const ParseLinePattern = /^([^ :]+):(\\d+):(.+)/;
   2464   function addURL(line) {
   2465     if (FlagURL == "") return line;
   2466     if (FlagSeparator == "") {
   2467       return line.replace(ParseLinePattern,
   2468         "<a href='" + FlagURL + "/$1'>$1</a>:$2:$3");
   2469     }
   2470     return line.replace(ParseLinePattern,
   2471       "<a href='" + FlagURL + "/$1" + FlagSeparator + "$2'>$1:$2</a>:$3");
   2472   }
   2473   function createArrayOfDictionaries(n) {
   2474     var result = [];
   2475     for (var i=0; i<n; i++) result.push({});
   2476     return result;
   2477   }
   2478   function groupWarningsBySeverity() {
   2479     // groups is an array of dictionaries,
   2480     // each dictionary maps from warning type to array of warning messages.
   2481     var groups = createArrayOfDictionaries(SeverityColors.length);
   2482     for (var i=0; i<Warnings.length; i++) {
   2483       var w = Warnings[i][0];
   2484       var s = WarnPatternsSeverity[w];
   2485       var k = w.toString();
   2486       if (!(k in groups[s]))
   2487         groups[s][k] = [];
   2488       groups[s][k].push(Warnings[i]);
   2489     }
   2490     return groups;
   2491   }
   2492   function groupWarningsByProject() {
   2493     var groups = createArrayOfDictionaries(ProjectNames.length);
   2494     for (var i=0; i<Warnings.length; i++) {
   2495       var w = Warnings[i][0];
   2496       var p = Warnings[i][1];
   2497       var k = w.toString();
   2498       if (!(k in groups[p]))
   2499         groups[p][k] = [];
   2500       groups[p][k].push(Warnings[i]);
   2501     }
   2502     return groups;
   2503   }
   2504   var GlobalAnchor = 0;
   2505   function createWarningSection(header, color, group) {
   2506     var result = "";
   2507     var groupKeys = [];
   2508     var totalMessages = 0;
   2509     for (var k in group) {
   2510        totalMessages += group[k].length;
   2511        groupKeys.push([k, WarnPatternsSeverity[parseInt(k)], group[k].length]);
   2512     }
   2513     groupKeys.sort(bySeverityMessageCount);
   2514     for (var idx=0; idx<groupKeys.length; idx++) {
   2515       var k = groupKeys[idx][0];
   2516       var messages = group[k];
   2517       var w = parseInt(k);
   2518       var wcolor = SeverityColors[WarnPatternsSeverity[w]];
   2519       var description = WarnPatternsDescription[w];
   2520       if (description.length == 0)
   2521           description = "???";
   2522       GlobalAnchor += 1;
   2523       result += "<table class='t1'><tr bgcolor='" + wcolor + "'><td>" +
   2524                 "<button class='bt' id='" + GlobalAnchor + "_mark" +
   2525                 "' onclick='expand(\\"" + GlobalAnchor + "\\");'>" +
   2526                 "&#x2295</button> " +
   2527                 description + " (" + messages.length + ")</td></tr></table>";
   2528       result += "<div id='" + GlobalAnchor +
   2529                 "' style='display:none;'><table class='t1'>";
   2530       var c = 0;
   2531       messages.sort(compareMessages);
   2532       for (var i=0; i<messages.length; i++) {
   2533         result += "<tr><td class='c" + c + "'>" +
   2534                   addURL(WarningMessages[messages[i][2]]) + "</td></tr>";
   2535         c = 1 - c;
   2536       }
   2537       result += "</table></div>";
   2538     }
   2539     if (result.length > 0) {
   2540       return "<br><span style='background-color:" + color + "'><b>" +
   2541              header + ": " + totalMessages +
   2542              "</b></span><blockquote><table class='t1'>" +
   2543              result + "</table></blockquote>";
   2544 
   2545     }
   2546     return "";  // empty section
   2547   }
   2548   function generateSectionsBySeverity() {
   2549     var result = "";
   2550     var groups = groupWarningsBySeverity();
   2551     for (s=0; s<SeverityColors.length; s++) {
   2552       result += createWarningSection(SeverityHeaders[s], SeverityColors[s], groups[s]);
   2553     }
   2554     return result;
   2555   }
   2556   function generateSectionsByProject() {
   2557     var result = "";
   2558     var groups = groupWarningsByProject();
   2559     for (i=0; i<groups.length; i++) {
   2560       result += createWarningSection(ProjectNames[i], 'lightgrey', groups[i]);
   2561     }
   2562     return result;
   2563   }
   2564   function groupWarnings(generator) {
   2565     GlobalAnchor = 0;
   2566     var e = document.getElementById("warning_groups");
   2567     e.innerHTML = generator();
   2568   }
   2569   function groupBySeverity() {
   2570     groupWarnings(generateSectionsBySeverity);
   2571   }
   2572   function groupByProject() {
   2573     groupWarnings(generateSectionsByProject);
   2574   }
   2575 """
   2576 
   2577 
   2578 # Emit a JavaScript const string
   2579 def emit_const_string(name, value):
   2580   print 'const ' + name + ' = "' + escape_string(value) + '";'
   2581 
   2582 
   2583 # Emit a JavaScript const integer array.
   2584 def emit_const_int_array(name, array):
   2585   print 'const ' + name + ' = ['
   2586   for n in array:
   2587     print str(n) + ','
   2588   print '];'
   2589 
   2590 
   2591 # Emit a JavaScript const string array.
   2592 def emit_const_string_array(name, array):
   2593   print 'const ' + name + ' = ['
   2594   for s in array:
   2595     print '"' + strip_escape_string(s) + '",'
   2596   print '];'
   2597 
   2598 
   2599 # Emit a JavaScript const object array.
   2600 def emit_const_object_array(name, array):
   2601   print 'const ' + name + ' = ['
   2602   for x in array:
   2603     print str(x) + ','
   2604   print '];'
   2605 
   2606 
   2607 def emit_js_data():
   2608   """Dump dynamic HTML page's static JavaScript data."""
   2609   emit_const_string('FlagURL', args.url if args.url else '')
   2610   emit_const_string('FlagSeparator', args.separator if args.separator else '')
   2611   emit_const_string_array('SeverityColors', Severity.colors)
   2612   emit_const_string_array('SeverityHeaders', Severity.headers)
   2613   emit_const_string_array('SeverityColumnHeaders', Severity.column_headers)
   2614   emit_const_string_array('ProjectNames', project_names)
   2615   emit_const_int_array('WarnPatternsSeverity',
   2616                        [w['severity'] for w in warn_patterns])
   2617   emit_const_string_array('WarnPatternsDescription',
   2618                           [w['description'] for w in warn_patterns])
   2619   emit_const_string_array('WarnPatternsOption',
   2620                           [w['option'] for w in warn_patterns])
   2621   emit_const_string_array('WarningMessages', warning_messages)
   2622   emit_const_object_array('Warnings', warning_records)
   2623 
   2624 draw_table_javascript = """
   2625 google.charts.load('current', {'packages':['table']});
   2626 google.charts.setOnLoadCallback(drawTable);
   2627 function drawTable() {
   2628   var data = new google.visualization.DataTable();
   2629   data.addColumn('string', StatsHeader[0]);
   2630   for (var i=1; i<StatsHeader.length; i++) {
   2631     data.addColumn('number', StatsHeader[i]);
   2632   }
   2633   data.addRows(StatsRows);
   2634   for (var i=0; i<StatsRows.length; i++) {
   2635     for (var j=0; j<StatsHeader.length; j++) {
   2636       data.setProperty(i, j, 'style', 'border:1px solid black;');
   2637     }
   2638   }
   2639   var table = new google.visualization.Table(document.getElementById('stats_table'));
   2640   table.draw(data, {allowHtml: true, alternatingRowStyle: true});
   2641 }
   2642 """
   2643 
   2644 
   2645 def dump_html():
   2646   """Dump the html output to stdout."""
   2647   dump_html_prologue('Warnings for ' + platform_version + ' - ' +
   2648                      target_product + ' - ' + target_variant)
   2649   dump_stats()
   2650   print '<br><div id="stats_table"></div><br>'
   2651   print '\n<script>'
   2652   emit_js_data()
   2653   print scripts_for_warning_groups
   2654   print '</script>'
   2655   emit_buttons()
   2656   # Warning messages are grouped by severities or project names.
   2657   print '<br><div id="warning_groups"></div>'
   2658   if args.byproject:
   2659     print '<script>groupByProject();</script>'
   2660   else:
   2661     print '<script>groupBySeverity();</script>'
   2662   dump_fixed()
   2663   dump_html_epilogue()
   2664 
   2665 
   2666 ##### Functions to count warnings and dump csv file. #########################
   2667 
   2668 
   2669 def description_for_csv(category):
   2670   if not category['description']:
   2671     return '?'
   2672   return category['description']
   2673 
   2674 
   2675 def string_for_csv(s):
   2676   # Only some Java warning desciptions have used quotation marks.
   2677   # TODO(chh): if s has double quote character, s should be quoted.
   2678   if ',' in s:
   2679     # TODO(chh): replace a double quote with two double quotes in s.
   2680     return '"{}"'.format(s)
   2681   return s
   2682 
   2683 
   2684 def count_severity(sev, kind):
   2685   """Count warnings of given severity."""
   2686   total = 0
   2687   for i in warn_patterns:
   2688     if i['severity'] == sev and i['members']:
   2689       n = len(i['members'])
   2690       total += n
   2691       warning = string_for_csv(kind + ': ' + description_for_csv(i))
   2692       print '{},,{}'.format(n, warning)
   2693       # print number of warnings for each project, ordered by project name.
   2694       projects = i['projects'].keys()
   2695       projects.sort()
   2696       for p in projects:
   2697         print '{},{},{}'.format(i['projects'][p], p, warning)
   2698   print '{},,{}'.format(total, kind + ' warnings')
   2699   return total
   2700 
   2701 
   2702 # dump number of warnings in csv format to stdout
   2703 def dump_csv():
   2704   """Dump number of warnings in csv format to stdout."""
   2705   sort_warnings()
   2706   total = 0
   2707   for s in Severity.range:
   2708     total += count_severity(s, Severity.column_headers[s])
   2709   print '{},,{}'.format(total, 'All warnings')
   2710 
   2711 
   2712 def main():
   2713   warning_lines = parse_input_file(open(args.buildlog, 'r'))
   2714   parallel_classify_warnings(warning_lines)
   2715   if args.gencsv:
   2716     dump_csv()
   2717   else:
   2718     dump_html()
   2719 
   2720 
   2721 # Run main function if warn.py is the main program.
   2722 if __name__ == '__main__':
   2723   main()
   2724