From c90e4a727ed73f0ea6b4e5fc5d2ff17dc9b3c4df Mon Sep 17 00:00:00 2001 From: Alexander Shaduri Date: Sun, 25 Oct 2026 19:22:56 +0100 Subject: [PATCH] CI: Keep the CodeQL category; fix Codacy findings in the report script - Use the full category of the previous CodeQL configuration (.github/workflows/codeql-analysis.yml:analyze/language:cpp), so the existing analysis keeps receiving results and its alerts get closed. - warnings_report.py: rename the Warning tuple to CompilerWarning (it shadowed the built-in), add docstrings for the __init__ methods and start the module docstring on its first line. Co-Authored-By: Claude Opus 5.5 --- .github/scripts/warnings_report.py | 15 ++++++++++----- .github/workflows/codeql-analysis.yml | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.github/scripts/warnings_report.py b/.github/scripts/warnings_report.py index fb38bf0..39a21c7 100644 --- a/.github/scripts/warnings_report.py +++ b/.github/scripts/warnings_report.py @@ -5,8 +5,7 @@ # (C) 2026 Alexander Shaduri ############################################################################### -""" -Generate a Markdown report of compiler / clang-tidy warnings from CI build logs. +"""Generate a Markdown report of compiler / clang-tidy warnings from CI build logs. Each build log directory (as saved by .github/actions/save-build-log) contains: build.log - Build output. @@ -51,14 +50,17 @@ COMPILER = "compiler" CLANG_TIDY = "clang-tidy" -Warning = collections.namedtuple("Warning", "file line col msg flag") +CompilerWarning = collections.namedtuple("CompilerWarning", "file line col msg flag") class BuildLog: + """Warnings parsed from one build log.""" + def __init__(self, title, category, warnings): + """Store the build title, category and warnings (None if the log is missing).""" self.title = title self.category = category - self.warnings = warnings # set of Warning, or None if the log is missing + self.warnings = warnings # set of CompilerWarning, or None if the log is missing def normalize_path(path): @@ -104,7 +106,7 @@ def parse_log(log_dir): flag = (m.group("flag") or "").replace(",-warnings-as-errors", "") if category == CLANG_TIDY and (flag.startswith("-W") or flag.startswith("clang-diagnostic-")): continue # compiler diagnostics; these are reported by the compiler builds - found.add(Warning(file, int(m.group("line")), int(m.group("col")), m.group("msg").strip(), flag)) + found.add(CompilerWarning(file, int(m.group("line")), int(m.group("col")), m.group("msg").strip(), flag)) return BuildLog(title, category, found) @@ -117,7 +119,10 @@ def plural(n, word): class Report: + """Markdown warnings report for a set of build logs.""" + def __init__(self, logs, changed, repo, sha, run_url): + """Index the warnings of all logs by category.""" self.logs = logs self.changed = changed self.repo = repo diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 9a40560..af68af1 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -54,4 +54,4 @@ jobs: uses: github/codeql-action/analyze@v4 with: # Keep the category of the previous (autobuild) configuration, so that existing alerts carry over. - category: "/language:cpp" + category: ".github/workflows/codeql-analysis.yml:analyze/language:cpp"