2020-01-10 19:33:40 +01:00
|
|
|
# python3
|
2019-12-10 04:32:03 +01:00
|
|
|
# Copyright (C) 2019 The Android Open Source Project
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
2020-01-10 19:33:40 +01:00
|
|
|
"""Clang_Tidy_Warn Severity class definition.
|
|
|
|
|
|
|
|
This file stores definition for class Severity that is used in warn_patterns.
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
2021-04-28 23:49:32 +02:00
|
|
|
# pylint:disable=too-few-public-methods
|
2020-02-24 19:20:36 +01:00
|
|
|
class SeverityInfo:
|
2021-04-28 23:49:32 +02:00
|
|
|
"""Class of Severity Info, part of a Severity object."""
|
2020-02-24 19:20:36 +01:00
|
|
|
|
|
|
|
def __init__(self, value, color, column_header, header):
|
|
|
|
self.value = value
|
|
|
|
self.color = color
|
|
|
|
self.column_header = column_header
|
|
|
|
self.header = header
|
2019-12-10 04:32:03 +01:00
|
|
|
|
2020-01-10 19:33:40 +01:00
|
|
|
|
2021-04-28 23:49:32 +02:00
|
|
|
# pylint:disable=too-few-public-methods
|
2020-02-24 19:20:36 +01:00
|
|
|
class Severity:
|
|
|
|
"""Class of Severity levels where each level is a SeverityInfo."""
|
2020-01-10 19:33:40 +01:00
|
|
|
|
|
|
|
# SEVERITY_UNKNOWN should never occur since every warn_pattern listed has
|
|
|
|
# a specified severity. It exists for protobuf, the other values must
|
|
|
|
# map to non-zero values (since 0 is reserved for a default UNKNOWN), but
|
|
|
|
# logic in clang_tidy_warn.py assumes severity level values are consecutive
|
|
|
|
# ints starting with 0.
|
2020-02-24 19:20:36 +01:00
|
|
|
SEVERITY_UNKNOWN = SeverityInfo(0, 'blueviolet', 'Unknown',
|
|
|
|
'Unknown-severity warnings)')
|
2020-01-10 19:33:40 +01:00
|
|
|
FIXMENOW = SeverityInfo(1, 'fuschia', 'FixNow',
|
|
|
|
'Critical warnings, fix me now')
|
|
|
|
HIGH = SeverityInfo(2, 'red', 'High', 'High severity warnings')
|
|
|
|
MEDIUM = SeverityInfo(3, 'orange', 'Medium', 'Medium severity warnings')
|
|
|
|
LOW = SeverityInfo(4, 'yellow', 'Low', 'Low severity warnings')
|
|
|
|
ANALYZER = SeverityInfo(5, 'hotpink', 'Analyzer', 'Clang-Analyzer warnings')
|
|
|
|
TIDY = SeverityInfo(6, 'peachpuff', 'Tidy', 'Clang-Tidy warnings')
|
|
|
|
HARMLESS = SeverityInfo(7, 'limegreen', 'Harmless', 'Harmless warnings')
|
|
|
|
UNMATCHED = SeverityInfo(8, 'lightblue', 'Unmatched', 'Unmatched warnings')
|
|
|
|
SKIP = SeverityInfo(9, 'grey', 'Unhandled', 'Unhandled warnings')
|
|
|
|
|
|
|
|
levels = [
|
|
|
|
SEVERITY_UNKNOWN, FIXMENOW, HIGH, MEDIUM, LOW, ANALYZER, TIDY, HARMLESS,
|
|
|
|
UNMATCHED, SKIP
|
|
|
|
]
|
|
|
|
# HTML relies on ordering by value. Sort here to ensure that this is proper
|
|
|
|
levels = sorted(levels, key=lambda severity: severity.value)
|