1*9e94795aSAndroid Build Coastguard Worker# python3 2*9e94795aSAndroid Build Coastguard Worker# Copyright (C) 2019 The Android Open Source Project 3*9e94795aSAndroid Build Coastguard Worker# 4*9e94795aSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License"); 5*9e94795aSAndroid Build Coastguard Worker# you may not use this file except in compliance with the License. 6*9e94795aSAndroid Build Coastguard Worker# You may obtain a copy of the License at 7*9e94795aSAndroid Build Coastguard Worker# 8*9e94795aSAndroid Build Coastguard Worker# http://www.apache.org/licenses/LICENSE-2.0 9*9e94795aSAndroid Build Coastguard Worker# 10*9e94795aSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software 11*9e94795aSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS, 12*9e94795aSAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*9e94795aSAndroid Build Coastguard Worker# See the License for the specific language governing permissions and 14*9e94795aSAndroid Build Coastguard Worker# limitations under the License. 15*9e94795aSAndroid Build Coastguard Worker 16*9e94795aSAndroid Build Coastguard Worker"""Clang_Tidy_Warn Severity class definition. 17*9e94795aSAndroid Build Coastguard Worker 18*9e94795aSAndroid Build Coastguard WorkerThis file stores definition for class Severity that is used in warn_patterns. 19*9e94795aSAndroid Build Coastguard Worker""" 20*9e94795aSAndroid Build Coastguard Worker 21*9e94795aSAndroid Build Coastguard Worker 22*9e94795aSAndroid Build Coastguard Worker# pylint:disable=too-few-public-methods 23*9e94795aSAndroid Build Coastguard Workerclass SeverityInfo: 24*9e94795aSAndroid Build Coastguard Worker """Class of Severity Info, part of a Severity object.""" 25*9e94795aSAndroid Build Coastguard Worker 26*9e94795aSAndroid Build Coastguard Worker def __init__(self, value, color, column_header, header): 27*9e94795aSAndroid Build Coastguard Worker self.value = value 28*9e94795aSAndroid Build Coastguard Worker self.color = color 29*9e94795aSAndroid Build Coastguard Worker self.column_header = column_header 30*9e94795aSAndroid Build Coastguard Worker self.header = header 31*9e94795aSAndroid Build Coastguard Worker 32*9e94795aSAndroid Build Coastguard Worker 33*9e94795aSAndroid Build Coastguard Worker# pylint:disable=too-few-public-methods 34*9e94795aSAndroid Build Coastguard Workerclass Severity: 35*9e94795aSAndroid Build Coastguard Worker """Class of Severity levels where each level is a SeverityInfo.""" 36*9e94795aSAndroid Build Coastguard Worker 37*9e94795aSAndroid Build Coastguard Worker # SEVERITY_UNKNOWN should never occur since every warn_pattern listed has 38*9e94795aSAndroid Build Coastguard Worker # a specified severity. It exists for protobuf, the other values must 39*9e94795aSAndroid Build Coastguard Worker # map to non-zero values (since 0 is reserved for a default UNKNOWN), but 40*9e94795aSAndroid Build Coastguard Worker # logic in clang_tidy_warn.py assumes severity level values are consecutive 41*9e94795aSAndroid Build Coastguard Worker # ints starting with 0. 42*9e94795aSAndroid Build Coastguard Worker SEVERITY_UNKNOWN = SeverityInfo(0, 'blueviolet', 'Unknown', 43*9e94795aSAndroid Build Coastguard Worker 'Unknown-severity warnings)') 44*9e94795aSAndroid Build Coastguard Worker FIXMENOW = SeverityInfo(1, 'fuschia', 'FixNow', 45*9e94795aSAndroid Build Coastguard Worker 'Critical warnings, fix me now') 46*9e94795aSAndroid Build Coastguard Worker HIGH = SeverityInfo(2, 'red', 'High', 'High severity warnings') 47*9e94795aSAndroid Build Coastguard Worker MEDIUM = SeverityInfo(3, 'orange', 'Medium', 'Medium severity warnings') 48*9e94795aSAndroid Build Coastguard Worker LOW = SeverityInfo(4, 'yellow', 'Low', 'Low severity warnings') 49*9e94795aSAndroid Build Coastguard Worker ANALYZER = SeverityInfo(5, 'hotpink', 'Analyzer', 'Clang-Analyzer warnings') 50*9e94795aSAndroid Build Coastguard Worker TIDY = SeverityInfo(6, 'peachpuff', 'Tidy', 'Clang-Tidy warnings') 51*9e94795aSAndroid Build Coastguard Worker HARMLESS = SeverityInfo(7, 'limegreen', 'Harmless', 'Harmless warnings') 52*9e94795aSAndroid Build Coastguard Worker UNMATCHED = SeverityInfo(8, 'lightblue', 'Unmatched', 'Unmatched warnings') 53*9e94795aSAndroid Build Coastguard Worker SKIP = SeverityInfo(9, 'grey', 'Unhandled', 'Unhandled warnings') 54*9e94795aSAndroid Build Coastguard Worker 55*9e94795aSAndroid Build Coastguard Worker levels = [ 56*9e94795aSAndroid Build Coastguard Worker SEVERITY_UNKNOWN, FIXMENOW, HIGH, MEDIUM, LOW, ANALYZER, TIDY, HARMLESS, 57*9e94795aSAndroid Build Coastguard Worker UNMATCHED, SKIP 58*9e94795aSAndroid Build Coastguard Worker ] 59*9e94795aSAndroid Build Coastguard Worker # HTML relies on ordering by value. Sort here to ensure that this is proper 60*9e94795aSAndroid Build Coastguard Worker levels = sorted(levels, key=lambda severity: severity.value) 61