blob: 45d14dc5e72b6dff5492f3409244bd01a00e7a00 [file] [log] [blame]
Chih-Hung Hsieh888d1432019-12-09 19:32:03 -08001#
2# Copyright (C) 2019 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16"""Warning patterns from other tools."""
17
18from severity import Severity
19
20
21def warn(name, severity, description, pattern_list):
22 return {
23 'category': name,
24 'severity': severity,
25 'description': name + ': ' + description,
26 'patterns': pattern_list
27 }
28
29
30def aapt(description, pattern_list):
31 return warn('aapt', Severity.MEDIUM, description, pattern_list)
32
33
34def misc(description, pattern_list):
35 return warn('logtags', Severity.LOW, description, pattern_list)
36
37
38def asm(description, pattern_list):
39 return warn('asm', Severity.MEDIUM, description, pattern_list)
40
41
42patterns = [
43 # pylint:disable=line-too-long,g-inconsistent-quotes
44 # aapt warnings
45 aapt('No default translation',
46 [r".*: warning: string '.+' has no default translation in .*"]),
47 aapt('Missing default or required localization',
48 [r".*: warning: \*\*\*\* string '.+' has no default or required localization for '.+' in .+"]),
49 aapt('String marked untranslatable, but translation exists',
50 [r".*: warning: string '.+' in .* marked untranslatable but exists in locale '??_??'"]),
51 aapt('empty span in string',
52 [r".*: warning: empty '.+' span found in text '.+"]),
53 # misc warnings
54 misc('Duplicate logtag',
55 [r".*: warning: tag \".+\" \(.+\) duplicated in .+"]),
56 misc('Typedef redefinition',
57 [r".*: warning: redefinition of typedef '.+' is a C11 feature"]),
58 misc('GNU old-style field designator',
59 [r".*: warning: use of GNU old-style field designator extension"]),
60 misc('Missing field initializers',
61 [r".*: warning: missing field '.+' initializer"]),
62 misc('Missing braces',
63 [r".*: warning: suggest braces around initialization of",
64 r".*: warning: too many braces around scalar initializer .+Wmany-braces-around-scalar-init",
65 r".*: warning: braces around scalar initializer"]),
66 misc('Comparison of integers of different signs',
67 [r".*: warning: comparison of integers of different signs.+sign-compare"]),
68 misc('Add braces to avoid dangling else',
69 [r".*: warning: add explicit braces to avoid dangling else"]),
70 misc('Initializer overrides prior initialization',
71 [r".*: warning: initializer overrides prior initialization of this subobject"]),
72 misc('Assigning value to self',
73 [r".*: warning: explicitly assigning value of .+ to itself"]),
74 misc('GNU extension, variable sized type not at end',
75 [r".*: warning: field '.+' with variable sized type '.+' not at the end of a struct or class"]),
76 misc('Comparison of constant is always false/true',
77 [r".*: comparison of .+ is always .+Wtautological-constant-out-of-range-compare"]),
78 misc('Hides overloaded virtual function',
79 [r".*: '.+' hides overloaded virtual function"]),
80 misc('Incompatible pointer types',
81 [r".*: warning: incompatible .*pointer types .*-Wincompatible-.*pointer-types"]),
82 # Assembler warnings
83 asm('ASM value size does not match register size',
84 [r".*: warning: value size does not match register size specified by the constraint and modifier"]),
85 asm('IT instruction is deprecated',
86 [r".*: warning: applying IT instruction .* is deprecated"]),
87 # NDK warnings
88 {'category': 'NDK', 'severity': Severity.HIGH,
89 'description': 'NDK: Generate guard with empty availability, obsoleted',
90 'patterns': [r".*: warning: .* generate guard with empty availability: obsoleted ="]},
91 # Protoc warnings
92 {'category': 'Protoc', 'severity': Severity.MEDIUM,
93 'description': 'Proto: Enum name colision after strip',
94 'patterns': [r".*: warning: Enum .* has the same name .* ignore case and strip"]},
95 {'category': 'Protoc', 'severity': Severity.MEDIUM,
96 'description': 'Proto: Import not used',
97 'patterns': [r".*: warning: Import .*/.*\.proto but not used.$"]},
98 # Kotlin warnings
99 {'category': 'Kotlin', 'severity': Severity.MEDIUM,
100 'description': 'Kotlin: never used parameter or variable',
101 'patterns': [r".*: warning: (parameter|variable) '.*' is never used$"]},
102 {'category': 'Kotlin', 'severity': Severity.MEDIUM,
103 'description': 'Kotlin: Deprecated in Java',
104 'patterns': [r".*: warning: '.*' is deprecated. Deprecated in Java"]},
105 {'category': 'Kotlin', 'severity': Severity.MEDIUM,
106 'description': 'Kotlin: library has Kotlin runtime',
107 'patterns': [r".*: warning: library has Kotlin runtime bundled into it",
108 r".*: warning: some JAR files .* have the Kotlin Runtime library"]},
109 # Rust warnings
110 {'category': 'Rust', 'severity': Severity.HIGH,
111 'description': 'Rust: Does not derive Copy',
112 'patterns': [r".*: warning: .+ does not derive Copy"]},
113 {'category': 'Rust', 'severity': Severity.MEDIUM,
114 'description': 'Rust: Deprecated range pattern',
115 'patterns': [r".*: warning: .+ range patterns are deprecated"]},
116 {'category': 'Rust', 'severity': Severity.MEDIUM,
117 'description': 'Rust: Deprecated missing explicit \'dyn\'',
118 'patterns': [r".*: warning: .+ without an explicit `dyn` are deprecated"]},
119 # Broken/partial warning messages will be skipped.
120 {'category': 'Misc', 'severity': Severity.SKIP,
121 'description': 'skip, ,',
122 'patterns': [r".*: warning: ,?$"]},
123 {'category': 'C/C++', 'severity': Severity.SKIP,
124 'description': 'skip, In file included from ...',
125 'patterns': [r".*: warning: In file included from .+,"]},
126 # catch-all for warnings this script doesn't know about yet
127 {'category': 'C/C++', 'severity': Severity.UNKNOWN,
128 'description': 'Unclassified/unrecognized warnings',
129 'patterns': [r".*: warning: .+"]},
130]