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=too-few-public-methods 23class SeverityInfo: 24 """Class of Severity Info, part of a Severity object.""" 25 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 33# pylint:disable=too-few-public-methods 34class Severity: 35 """Class of Severity levels where each level is a SeverityInfo.""" 36 37 # 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. 42 SEVERITY_UNKNOWN = SeverityInfo(0, 'blueviolet', 'Unknown', 43 'Unknown-severity warnings)') 44 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 58 ] 59 # HTML relies on ordering by value. Sort here to ensure that this is proper 60 levels = sorted(levels, key=lambda severity: severity.value) 61