mirror of https://github.com/milvus-io/milvus.git
enable clang-tidy check (#3396)
* enable clang-tidy check Signed-off-by: yudong.cai <yudong.cai@zilliz.com> * update run_clang_tidy.py Signed-off-by: yudong.cai <yudong.cai@zilliz.com> * enable clang-tidy check Signed-off-by: yudong.cai <yudong.cai@zilliz.com> * update run_clang_tidy.py Signed-off-by: yudong.cai <yudong.cai@zilliz.com> * update run_clang_tidy.py Signed-off-by: yudong.cai <yudong.cai@zilliz.com> * update run_clang_tidy.py Signed-off-by: yudong.cai <yudong.cai@zilliz.com> * remove rule modernize-use-equals-default Signed-off-by: yudong.cai <yudong.cai@zilliz.com>pull/3411/head^2
parent
c66e40ccff
commit
21407a5ce0
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue