diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2026-05-18 13:50:49 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-05-18 13:50:49 +0200 |
| commit | 845d4d0522f063dde7e84b281c0b191de1a43dee (patch) | |
| tree | 6e419f827ef06cc0f2c3e5ed17813bf65cb35389 /scripts | |
| parent | cb61eb0c7a2b259ebedeca78ce604742d4bbc0e8 (diff) | |
| download | kernel-845d4d0522f063dde7e84b281c0b191de1a43dee.tar.xz kernel-845d4d0522f063dde7e84b281c0b191de1a43dee.zip | |
ci: enable code quality reporting
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/ci/parse_clang_tidy.py | 47 |
1 files changed, 47 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..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 <CLANG_TIDY_LOG_PATH>") + + issues = parse_clang_tidy(sys.argv[1]) + print(json.dumps(issues, indent=2)) |
