================
@@ -18,98 +18,65 @@
"""
import argparse
+import github
+import json
import os
import subprocess
import sys
-from typing import List, Optional
+from typing import Any, Dict, Final, List, Sequence
class LintArgs:
- start_rev: str = None
- end_rev: str = None
- repo: str = None
- changed_files: List[str] = []
- token: str = None
+ start_rev: str
+ end_rev: str
+ repo: str
+ changed_files: Sequence[str]
+ token: str
verbose: bool = True
issue_number: int = 0
build_path: str = "build"
clang_tidy_binary: str = "clang-tidy"
- def __init__(self, args: argparse.Namespace = None) -> None:
+ def __init__(self, args: argparse.Namespace) -> None:
if not args is None:
self.start_rev = args.start_rev
self.end_rev = args.end_rev
self.repo = args.repo
self.token = args.token
- self.changed_files = args.changed_files
+ self.changed_files = (
+ args.changed_files.split(",") if args.changed_files else []
+ )
self.issue_number = args.issue_number
self.verbose = args.verbose
self.build_path = args.build_path
self.clang_tidy_binary = args.clang_tidy_binary
-COMMENT_TAG = "<!--LLVM CODE LINT COMMENT: clang-tidy-->"
-
-
-def get_instructions(cpp_files: List[str]) -> str:
- files_str = " ".join(cpp_files)
- return f"""
-git diff -U0 origin/main...HEAD -- {files_str} |
-python3 clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py \\
- -path build -p1 -quiet"""
-
-
-def clean_clang_tidy_output(output: str) -> Optional[str]:
- """
- - Remove 'Running clang-tidy in X threads...' line
- - Remove 'N warnings generated.' line
- - Strip leading workspace path from file paths
- """
- if not output or output == "No relevant changes found.":
- return None
-
- lines = output.split("\n")
- cleaned_lines = []
-
- for line in lines:
- if line.startswith("Running clang-tidy in") or
line.endswith("generated."):
- continue
-
- # Remove everything up to rightmost "llvm-project/" for correct files
names
- idx = line.rfind("llvm-project/")
- if idx != -1:
- line = line[idx + len("llvm-project/") :]
-
- cleaned_lines.append(line)
+class LintHelper:
+ COMMENT_TAG = "<!--LLVM CODE LINT COMMENT: {linter}-->"
----------------
EugeneZelenko wrote:
```suggestion
COMMENT_TAG: Final = "<!--LLVM CODE LINT COMMENT: {linter}-->"
```
https://github.com/llvm/llvm-project/pull/168827
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits