aboutsummaryrefslogtreecommitdiff
path: root/scripts/ci/parse_clang_tidy.py
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2026-09-30 13:10:21 +0200
committerFelix Morgner <felix.morgner@ost.ch>2026-09-30 13:10:21 +0200
commit8bec65ba723c9c628d934ec02021d5ce09c01105 (patch)
tree2eec65a312bf523bbe94811f1b8c9f904d07327b /scripts/ci/parse_clang_tidy.py
parent83f264c22326ae37a0eb38284935a32895a48efb (diff)
downloadkernel-8bec65ba723c9c628d934ec02021d5ce09c01105.tar.xz
kernel-8bec65ba723c9c628d934ec02021d5ce09c01105.zip
chore: clean up python scripts
Diffstat (limited to 'scripts/ci/parse_clang_tidy.py')
-rw-r--r--scripts/ci/parse_clang_tidy.py56
1 files changed, 44 insertions, 12 deletions
diff --git a/scripts/ci/parse_clang_tidy.py b/scripts/ci/parse_clang_tidy.py
index ec51d777..d2155afd 100644
--- a/scripts/ci/parse_clang_tidy.py
+++ b/scripts/ci/parse_clang_tidy.py
@@ -3,9 +3,38 @@ import json
import os
import re
import sys
+from typing import Dict, List
-def parse_clang_tidy(log_file_path: str) -> list[dict]:
+class SourceRange(dict):
+ def __init__(self, begin: int, end: int, column: int):
+ super().__init__(begin=begin, end=end, column=column)
+
+
+class SourceLocation(dict):
+ def __init__(self, path: str, lines: Dict[str, int]):
+ super().__init__(path=path, lines=lines)
+
+
+class ClangTidyError(dict):
+ def __init__(
+ self,
+ description: str,
+ check_name: str,
+ fingerprint: str,
+ severity: str,
+ location: SourceLocation,
+ ):
+ super().__init__(
+ description=description,
+ check_name=check_name,
+ fingerprint=fingerprint,
+ severity=severity,
+ location=location,
+ )
+
+
+def parse_clang_tidy(log_file_path: str) -> List[ClangTidyError]:
issues = []
pattern = re.compile(
r"^(.*?):(\d+):(\d+):\s+(warning|error|note):\s+(.*?)\s+\[(.*?)\]$"
@@ -30,17 +59,20 @@ def parse_clang_tidy(log_file_path: str) -> list[dict]:
fingerprint = hashlib.sha256(fingerprint_data.encode()).hexdigest()
issues.append(
- {
- "description": f"{message} ({name})",
- "fingerprint": fingerprint,
- "severity": severity,
- "location": {
- "path": path,
- "lines": {
- "begin": int(line),
- },
- },
- }
+ ClangTidyError(
+ description=f"{message}",
+ check_name=name,
+ fingerprint=fingerprint,
+ severity=severity,
+ location=SourceLocation(
+ path=path,
+ lines=SourceRange(
+ begin=int(line),
+ end=int(line),
+ column=int(column),
+ ),
+ ),
+ )
)
return issues