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