aboutsummaryrefslogtreecommitdiff
path: root/scripts/ci
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2026-05-18 14:51:19 +0200
committerFelix Morgner <felix.morgner@ost.ch>2026-05-18 14:51:19 +0200
commit1f12f7d107fb0db5ab33a92a20ee05db2489dc28 (patch)
treed3f5bb2293bbfd53ccf78ed551d9a6a8ea5f5d9e /scripts/ci
parentcb61eb0c7a2b259ebedeca78ce604742d4bbc0e8 (diff)
parente381b49caf9d29f405cb8c9d7c2b81640135d3ba (diff)
downloadkernel-1f12f7d107fb0db5ab33a92a20ee05db2489dc28.tar.xz
kernel-1f12f7d107fb0db5ab33a92a20ee05db2489dc28.zip
Merge branch 'fmorgner/develop-BA-FS26/code-quality' into 'develop-BA-FS26'
Enable code quality translation of clang-tidy data See merge request teachos/kernel!39
Diffstat (limited to 'scripts/ci')
-rw-r--r--scripts/ci/parse_clang_tidy.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/scripts/ci/parse_clang_tidy.py b/scripts/ci/parse_clang_tidy.py
new file mode 100644
index 0000000..ec51d77
--- /dev/null
+++ b/scripts/ci/parse_clang_tidy.py
@@ -0,0 +1,54 @@
+import hashlib
+import json
+import os
+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+\[(.*?)\]$"
+ )
+ repo_root = os.environ.get("CI_PROJECT_DIR", os.getcwd())
+
+ 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"
+
+ try:
+ path = os.path.relpath(path, repo_root)
+ except ValueError:
+ pass
+
+ fingerprint_data = f"{path}:{line}:{column}:{message}:{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 <CLANG_TIDY_LOG_PATH>")
+
+ issues = parse_clang_tidy(sys.argv[1])
+ print(json.dumps(issues, indent=2))