1# python3 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"""Clang_Tidy_Warn Severity class definition. 17 18This file stores definition for class Severity that is used in warn_patterns. 19""" 20 21 22# pylint:disable=old-style-class 23class 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 33class Severity: 34 """Class of Severity levels where each level is a SeverityInfo.""" 35 36 # 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. 41 SEVERITY_UNKNOWN = SeverityInfo(0, 'blueviolet', 'Unknown', 42 'Unknown-severity warnings)') 43 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 57 ] 58 # HTML relies on ordering by value. Sort here to ensure that this is proper 59 levels = sorted(levels, key=lambda severity: severity.value) 60