From 845d4d0522f063dde7e84b281c0b191de1a43dee Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Mon, 18 May 2026 13:50:49 +0200 Subject: ci: enable code quality reporting --- scripts/ci/parse_clang_tidy.py | 47 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 scripts/ci/parse_clang_tidy.py (limited to 'scripts') diff --git a/scripts/ci/parse_clang_tidy.py b/scripts/ci/parse_clang_tidy.py new file mode 100644 index 0000000..48596de --- /dev/null +++ b/scripts/ci/parse_clang_tidy.py @@ -0,0 +1,47 @@ +import hashlib +import json +import re +import sys + + +def parse_clang_tidy(log_file_path: str) -> list[dict]: + issues = [] + pattern = re.compile( + r"^(.*?):(\d+):(\d+):\s+(warning|error|note):\s+(.*?)\s+\[(.*?)\]$" + ) + + with open(log_file_path, "r") as f: + for line in f: + match = pattern.match(line) + if not match: + continue + + path, line, column, severity, message, name = match.groups() + severity = "minor" if severity == "warning" else "major" + + fingerprint_data = f"{path}:{line}:{name}" + fingerprint = hashlib.sha256(fingerprint_data.encode()).hexdigest() + + issues.append( + { + "description": f"{message} ({name})", + "fingerprint": fingerprint, + "severity": severity, + "location": { + "path": path, + "lines": { + "begin": int(line), + }, + }, + } + ) + + return issues + + +if __name__ == "__main__": + if len(sys.argv) < 2: + sys.exit("Usage: python3 parse_clang_tidy.py ") + + issues = parse_clang_tidy(sys.argv[1]) + print(json.dumps(issues, indent=2)) -- cgit v1.2.3 From de8efd2af75a8d8d5dd4b0b5c125d006bf7f1ba9 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Mon, 18 May 2026 14:26:52 +0200 Subject: ci: fix code quality file paths --- scripts/ci/parse_clang_tidy.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/ci/parse_clang_tidy.py b/scripts/ci/parse_clang_tidy.py index 48596de..6167c99 100644 --- a/scripts/ci/parse_clang_tidy.py +++ b/scripts/ci/parse_clang_tidy.py @@ -1,5 +1,6 @@ import hashlib import json +import os import re import sys @@ -9,6 +10,7 @@ def parse_clang_tidy(log_file_path: str) -> list[dict]: pattern = re.compile( r"^(.*?):(\d+):(\d+):\s+(warning|error|note):\s+(.*?)\s+\[(.*?)\]$" ) + repo_root = os.environ.get("CI_PROJECT_DIR", os.getcwd()) with open(log_file_path, "r") as f: for line in f: @@ -19,7 +21,12 @@ def parse_clang_tidy(log_file_path: str) -> list[dict]: path, line, column, severity, message, name = match.groups() severity = "minor" if severity == "warning" else "major" - fingerprint_data = f"{path}:{line}:{name}" + try: + path = os.path.relpath(path, repo_root) + except ValueError: + pass + + fingerprint_data = f"{path}:{line}:{name}:{message}" fingerprint = hashlib.sha256(fingerprint_data.encode()).hexdigest() issues.append( -- cgit v1.2.3 From a7ba17a11c17c9975e7dc2233264913aa2e79538 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Mon, 18 May 2026 14:31:17 +0200 Subject: ci: improve code quality fingerprints --- scripts/ci/parse_clang_tidy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/ci/parse_clang_tidy.py b/scripts/ci/parse_clang_tidy.py index 6167c99..ec51d77 100644 --- a/scripts/ci/parse_clang_tidy.py +++ b/scripts/ci/parse_clang_tidy.py @@ -26,7 +26,7 @@ def parse_clang_tidy(log_file_path: str) -> list[dict]: except ValueError: pass - fingerprint_data = f"{path}:{line}:{name}:{message}" + fingerprint_data = f"{path}:{line}:{column}:{message}:{name}" fingerprint = hashlib.sha256(fingerprint_data.encode()).hexdigest() issues.append( -- cgit v1.2.3