Chih-Hung Hsieh | 949205a | 2020-01-10 10:33:40 -0800 | [diff] [blame] | 1 | # python3 |
Chih-Hung Hsieh | 888d143 | 2019-12-09 19:32:03 -0800 | [diff] [blame] | 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 | |
Chih-Hung Hsieh | 949205a | 2020-01-10 10:33:40 -0800 | [diff] [blame] | 16 | """Clang_Tidy_Warn Severity class definition. |
| 17 | |
| 18 | This file stores definition for class Severity that is used in warn_patterns. |
| 19 | """ |
Chih-Hung Hsieh | 888d143 | 2019-12-09 19:32:03 -0800 | [diff] [blame] | 20 | |
| 21 | |
Chih-Hung Hsieh | 949205a | 2020-01-10 10:33:40 -0800 | [diff] [blame] | 22 | # pylint:disable=old-style-class |
| 23 | class Severity: |
| 24 | """Class of Severity levels where each level is a SeverityInfo.""" |
| 25 | |
| 26 | class SeverityInfo: |
| 27 | |
| 28 | def __init__(self, value, color, column_header, header): |
| 29 | self.value = value |
| 30 | self.color = color |
| 31 | self.column_header = column_header |
| 32 | self.header = header |
| 33 | |
| 34 | # SEVERITY_UNKNOWN should never occur since every warn_pattern listed has |
| 35 | # a specified severity. It exists for protobuf, the other values must |
| 36 | # map to non-zero values (since 0 is reserved for a default UNKNOWN), but |
| 37 | # logic in clang_tidy_warn.py assumes severity level values are consecutive |
| 38 | # ints starting with 0. |
| 39 | SEVERITY_UNKNOWN = SeverityInfo(0, 'blueviolet', 'Errors of unknown severity', |
| 40 | 'Unknown severity (should not occur)') |
| 41 | FIXMENOW = SeverityInfo(1, 'fuschia', 'FixNow', |
| 42 | 'Critical warnings, fix me now') |
| 43 | HIGH = SeverityInfo(2, 'red', 'High', 'High severity warnings') |
| 44 | MEDIUM = SeverityInfo(3, 'orange', 'Medium', 'Medium severity warnings') |
| 45 | LOW = SeverityInfo(4, 'yellow', 'Low', 'Low severity warnings') |
| 46 | ANALYZER = SeverityInfo(5, 'hotpink', 'Analyzer', 'Clang-Analyzer warnings') |
| 47 | TIDY = SeverityInfo(6, 'peachpuff', 'Tidy', 'Clang-Tidy warnings') |
| 48 | HARMLESS = SeverityInfo(7, 'limegreen', 'Harmless', 'Harmless warnings') |
| 49 | UNMATCHED = SeverityInfo(8, 'lightblue', 'Unmatched', 'Unmatched warnings') |
| 50 | SKIP = SeverityInfo(9, 'grey', 'Unhandled', 'Unhandled warnings') |
| 51 | |
| 52 | levels = [ |
| 53 | SEVERITY_UNKNOWN, FIXMENOW, HIGH, MEDIUM, LOW, ANALYZER, TIDY, HARMLESS, |
| 54 | UNMATCHED, SKIP |
Chih-Hung Hsieh | 888d143 | 2019-12-09 19:32:03 -0800 | [diff] [blame] | 55 | ] |
Chih-Hung Hsieh | 949205a | 2020-01-10 10:33:40 -0800 | [diff] [blame] | 56 | # HTML relies on ordering by value. Sort here to ensure that this is proper |
| 57 | levels = sorted(levels, key=lambda severity: severity.value) |