未验证 提交 a8bb416f 编写于 作者: G gouzil 提交者: GitHub

[tools][clang-tidy] add skip file (#56632)

* [clang-tidy]add skip

* fix compatibility

* fix
上级 b702d2ae
......@@ -93,6 +93,53 @@ def make_absolute(f, directory):
return os.path.normpath(os.path.join(directory, f))
def analysis_gitignore(path, filename=".gitignore"):
"""Analysis gitignore file and return ignore file list"""
with open(path + "/" + filename, "r") as f:
lines = f.readlines()
ignore_file_list = []
for line in lines:
# Blank row
if line == "\n" or line == "\r\n":
continue
# explanatory note
line = line.replace("\n", "").strip()
if "#" in line:
if not line.startswith("#"):
ignore_file_list.append(
line[: line.index("#")].replace(" ", "")
)
continue
# TODO(gouzil): support more gitignore rules
if "*" in line:
continue
ignore_file_list.append(line.replace(" ", ""))
return ignore_file_list
def skip_check_file(database, build_path):
"""Skip checking some files"""
skip_file_list = []
skip_file_list.append(".cu")
skip_file_list.append(os.path.join(os.getcwd(), build_path))
skip_file_list += analysis_gitignore(os.getcwd())
res_list = []
for entry in database:
write_in = True
for ignore_file in skip_file_list:
if ignore_file in entry["file"]:
write_in = False
break
if write_in:
res_list.append(entry)
return res_list
def get_tidy_invocation(
f,
clang_tidy_binary,
......@@ -348,6 +395,7 @@ def main():
# Load the database and extract all files.
database = json.load(open(os.path.join(build_path, db_path)))
database = skip_check_file(database, build_path)
files = [
make_absolute(entry['file'], entry['directory']) for entry in database
]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册