blob: 20064c379e69564e3ee6101b61f03f5b9d46f745 [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 Hsieh98b285d2021-04-28 14:49:32 -070022# pylint:disable=too-few-public-methods
Chih-Hung Hsieh5ae55192020-02-24 10:20:36 -080023class SeverityInfo:
Chih-Hung Hsieh98b285d2021-04-28 14:49:32 -070024 """Class of Severity Info, part of a Severity object."""
Chih-Hung Hsieh5ae55192020-02-24 10:20:36 -080025
26 def __init__(self, value, color, column_header, header):
27 self.value = value
28 self.color = color
29 self.column_header = column_header
30 self.header = header
31
32
Chih-Hung Hsieh98b285d2021-04-28 14:49:32 -070033# pylint:disable=too-few-public-methods
Chih-Hung Hsieh949205a2020-01-10 10:33:40 -080034class Severity:
35 """Class of Severity levels where each level is a SeverityInfo."""
36
Chih-Hung Hsieh949205a2020-01-10 10:33:40 -080037 # SEVERITY_UNKNOWN should never occur since every warn_pattern listed has
38 # a specified severity. It exists for protobuf, the other values must
39 # map to non-zero values (since 0 is reserved for a default UNKNOWN), but
40 # logic in clang_tidy_warn.py assumes severity level values are consecutive
41 # ints starting with 0.
Chih-Hung Hsieh5ae55192020-02-24 10:20:36 -080042 SEVERITY_UNKNOWN = SeverityInfo(0, 'blueviolet', 'Unknown',
43 'Unknown-severity warnings)')
Chih-Hung Hsieh949205a2020-01-10 10:33:40 -080044 FIXMENOW = SeverityInfo(1, 'fuschia', 'FixNow',
45 'Critical warnings, fix me now')
46 HIGH = SeverityInfo(2, 'red', 'High', 'High severity warnings')
47 MEDIUM = SeverityInfo(3, 'orange', 'Medium', 'Medium severity warnings')
48 LOW = SeverityInfo(4, 'yellow', 'Low', 'Low severity warnings')
49 ANALYZER = SeverityInfo(5, 'hotpink', 'Analyzer', 'Clang-Analyzer warnings')
50 TIDY = SeverityInfo(6, 'peachpuff', 'Tidy', 'Clang-Tidy warnings')
51 HARMLESS = SeverityInfo(7, 'limegreen', 'Harmless', 'Harmless warnings')
52 UNMATCHED = SeverityInfo(8, 'lightblue', 'Unmatched', 'Unmatched warnings')
53 SKIP = SeverityInfo(9, 'grey', 'Unhandled', 'Unhandled warnings')
54
55 levels = [
56 SEVERITY_UNKNOWN, FIXMENOW, HIGH, MEDIUM, LOW, ANALYZER, TIDY, HARMLESS,
57 UNMATCHED, SKIP
Chih-Hung Hsieh888d1432019-12-09 19:32:03 -080058 ]
Chih-Hung Hsieh949205a2020-01-10 10:33:40 -080059 # HTML relies on ordering by value. Sort here to ensure that this is proper
60 levels = sorted(levels, key=lambda severity: severity.value)