未验证 提交 21407a5c 编写于 作者: C Cai Yudong 提交者: GitHub

enable clang-tidy check (#3396)

* enable clang-tidy check
Signed-off-by: Nyudong.cai <yudong.cai@zilliz.com>

* update run_clang_tidy.py
Signed-off-by: Nyudong.cai <yudong.cai@zilliz.com>

* enable clang-tidy check
Signed-off-by: Nyudong.cai <yudong.cai@zilliz.com>

* update run_clang_tidy.py
Signed-off-by: Nyudong.cai <yudong.cai@zilliz.com>

* update run_clang_tidy.py
Signed-off-by: Nyudong.cai <yudong.cai@zilliz.com>

* update run_clang_tidy.py
Signed-off-by: Nyudong.cai <yudong.cai@zilliz.com>

* remove rule modernize-use-equals-default
Signed-off-by: Nyudong.cai <yudong.cai@zilliz.com>
上级 c66e40cc
......@@ -20,7 +20,7 @@ Checks: >
-*, clang-diagnostic-*, -clang-diagnostic-error,
clang-analyzer-*, -clang-analyzer-alpha*,
google-*, -google-runtime-references, -google-readability-todo,
modernize-*, -modernize-pass-by-value
modernize-*, -modernize-pass-by-value, -modernize-use-equals-default
# produce HeaderFilterRegex from core/build-support/lint_exclusions.txt with:
# echo -n '^?!('; sed -e 's/*/\.*/g' core/build-support/lint_exclusions.txt | tr '\n' '|'; echo ')$'
......
......@@ -161,13 +161,17 @@ if [[ ${RUN_CPPLINT} == "ON" ]]; then
echo "clang-format check passed!"
# clang-tidy check
# make check-clang-tidy
# if [ $? -ne 0 ]; then
# echo "ERROR! clang-tidy check failed"
# rm -f CMakeCache.txt
# exit 1
# fi
# echo "clang-tidy check passed!"
if [[ ${GPU_VERSION} == "ON" ]]; then
make check-clang-tidy
if [ $? -ne 0 ]; then
echo "ERROR! clang-tidy check failed"
rm -f CMakeCache.txt
exit 1
fi
echo "clang-tidy check passed!"
else
echo "CPU version skip clang-tidy check!"
fi
fi
if [[ ${COMPILE_BUILD} == "ON" ]];then
......
......@@ -23,12 +23,16 @@ import lintutils
from subprocess import PIPE
import sys
from functools import partial
import re
def _get_chunk_key(filenames):
# lists are not hashable so key on the first filename in a chunk
return filenames[0]
def _count_key(str, key):
m = re.findall(key, str)
return len(m)
# clang-tidy outputs complaints in '/path:line_number: complaint' format,
# so we can scan its output to get a list of files to fix
......@@ -51,14 +55,25 @@ def _check_all(cmd, filenames):
}
checker = partial(_check_some_files, completed_processes)
pool = mp.Pool()
error = False
try:
cnt_error = 0
cnt_warning = 0
cnt_ignore = 0
# check output of completed clang-tidy invocations in parallel
for problem_files, stdout in pool.imap(checker, chunks):
if problem_files:
msg = "clang-tidy suggested fixes for {}"
print("\n".join(map(msg.format, problem_files)))
print(stdout.decode("utf-8"))
error = True
# ignore thirdparty header file not found issue, such as:
# error: 'fiu.h' file not found [clang-diagnostic-error]
cnt_error += _count_key(stdout, "error:")
cnt_warning += _count_key(stdout, "warning:")
cnt_ignore += _count_key(stdout, "clang-diagnostic-error")
print("clang-tidy - error: {}, warning: {}, ignore {}".
format(cnt_error, cnt_warning, cnt_ignore))
error = error or (cnt_error > cnt_ignore or cnt_warning > 0)
except Exception:
error = True
raise
......
......@@ -144,12 +144,12 @@ if [[ ${RUN_CPPLINT} == "ON" ]]; then
echo "clang-format check passed!"
# clang-tidy check
# make check-clang-tidy
# if [ $? -ne 0 ]; then
# echo "ERROR! clang-tidy check failed"
# exit 1
# fi
# echo "clang-tidy check passed!"
make check-clang-tidy
if [ $? -ne 0 ]; then
echo "ERROR! clang-tidy check failed"
exit 1
fi
echo "clang-tidy check passed!"
else
# compile and build
make -j ${jobs} install || exit 1
......
......@@ -189,7 +189,7 @@ WalOperationCodec::IterateOperation(const WalFilePtr& file, WalOperationPtr& ope
// read partition name
int32_t part_name_length = 0;
std::string partition_name;
read_bytes = file->Read<int32_t>(&part_name_length);
file->Read<int32_t>(&part_name_length);
if (part_name_length > 0) {
read_bytes = file->ReadStr(partition_name, part_name_length);
if (read_bytes <= 0) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册