2019-11-07 14:51:23 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
echo "Doing clang-tidy..."
|
|
|
|
bool=false
|
|
|
|
# explicitly set IFS to contain only a line feed
|
|
|
|
IFS='
|
|
|
|
'
|
2019-11-12 15:23:14 +01:00
|
|
|
filelist="$(find . -not \( -path './*build*' -prune \) -type f ! -name "$(printf "*\n*")")"
|
2019-11-07 14:51:23 +01:00
|
|
|
for file in $filelist; do
|
2019-11-12 15:23:14 +01:00
|
|
|
if echo "$file" | grep -q -E ".*(\.cpp|\.h|\.hpp)$" ; then
|
2019-11-07 14:51:23 +01:00
|
|
|
#Extra check missing dependencies due to clang-tidy doesn't toggle exit code.
|
2019-11-16 19:29:00 +01:00
|
|
|
clang_tidy_lib_check="$(clang-tidy -warnings-as-errors='*' -header-filter='.*,-cpptoml.hpp' "$file" -- -I. -std=c++14 2>&1)"
|
2019-11-07 14:51:23 +01:00
|
|
|
for tidy_line in $clang_tidy_lib_check; do
|
|
|
|
echo "$tidy_line" | grep -q -v -E "^Error while processing*"
|
|
|
|
if [ $? -eq 1 ]; then
|
|
|
|
bool=true
|
|
|
|
fi
|
|
|
|
echo "$tidy_line" | grep -q -v -E ".* error: .*"
|
|
|
|
if [ $? -eq 1 ]; then
|
|
|
|
bool=true
|
|
|
|
fi
|
|
|
|
echo "$tidy_line"
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if $bool; then
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "No clang-tidy errors found."
|
|
|
|
fi
|
|
|
|
|
|
|
|
exit 0
|