From 1cf624be6dab5170f4ee40dfce729df7de1d5056 Mon Sep 17 00:00:00 2001 From: Nate Ohlson Date: Wed, 14 Aug 2024 16:03:53 -0500 Subject: gh-112301: Add warning count to warning check tooling (#122711) Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> --- .../2024-08-06-00-06-23.gh-issue-112301.4k4lw6.rst | 2 + Tools/build/.warningignore_macos | 2 + Tools/build/.warningignore_ubuntu | 2 + Tools/build/check_warnings.py | 54 ++++++++++++++++------ 4 files changed, 46 insertions(+), 14 deletions(-) create mode 100644 Misc/NEWS.d/next/Security/2024-08-06-00-06-23.gh-issue-112301.4k4lw6.rst diff --git a/Misc/NEWS.d/next/Security/2024-08-06-00-06-23.gh-issue-112301.4k4lw6.rst b/Misc/NEWS.d/next/Security/2024-08-06-00-06-23.gh-issue-112301.4k4lw6.rst new file mode 100644 index 0000000..0bd2f4d --- /dev/null +++ b/Misc/NEWS.d/next/Security/2024-08-06-00-06-23.gh-issue-112301.4k4lw6.rst @@ -0,0 +1,2 @@ +Add ability to ignore warnings per file with warning count in warning checking tooling. +Patch by Nate Ohlson. diff --git a/Tools/build/.warningignore_macos b/Tools/build/.warningignore_macos index 1b504df..67f5011 100644 --- a/Tools/build/.warningignore_macos +++ b/Tools/build/.warningignore_macos @@ -1,3 +1,5 @@ # Files listed will be ignored by the compiler warning checker # for the macOS/build and test job. # Keep lines sorted lexicographically to help avoid merge conflicts. +# Format example: +# /path/to/file (number of warnings in file) diff --git a/Tools/build/.warningignore_ubuntu b/Tools/build/.warningignore_ubuntu index 8242c8d..469c727 100644 --- a/Tools/build/.warningignore_ubuntu +++ b/Tools/build/.warningignore_ubuntu @@ -1,3 +1,5 @@ # Files listed will be ignored by the compiler warning checker # for the Ubuntu/build and test job. # Keep lines sorted lexicographically to help avoid merge conflicts. +# Format example: +# /path/to/file (number of warnings in file) diff --git a/Tools/build/check_warnings.py b/Tools/build/check_warnings.py index 3125893..1ed8344 100644 --- a/Tools/build/check_warnings.py +++ b/Tools/build/check_warnings.py @@ -9,6 +9,11 @@ import json import re import sys from pathlib import Path +from typing import NamedTuple + +class FileWarnings(NamedTuple): + name: str + count: int def extract_warnings_from_compiler_output_clang( @@ -19,7 +24,8 @@ def extract_warnings_from_compiler_output_clang( """ # Regex to find warnings in the compiler output clang_warning_regex = re.compile( - r"(?P.*):(?P\d+):(?P\d+): warning: (?P.*)" + r"(?P.*):(?P\d+):(?P\d+): warning: " + r"(?P.*) (?P