2 function perform_lint() {
3 echo "Performing LINT..."
4 if [ -z "${CLANG_FORMAT}" ]; then
5 CLANG_FORMAT=clang-format
7 echo "LINT: Using binary $CLANG_FORMAT"
8 CLANG_FORMAT_WHITELIST="util/ci/clang-format-whitelist.txt"
10 files_to_lint="$(find src/ -name '*.cpp' -or -name '*.h')"
14 for f in ${files_to_lint}; do
15 d=$(diff -u "$f" <(${CLANG_FORMAT} "$f") || true)
17 if ! [ -z "$d" ]; then
18 whitelisted=$(awk '$1 == "'$f'" { print 1 }' "$CLANG_FORMAT_WHITELIST")
20 # If file is not whitelisted, mark a failure
21 if [ -z "${whitelisted}" ]; then
22 errorcount=$((errorcount+1))
24 printf "The file %s is not compliant with the coding style" "$f"
25 if [ ${errorcount} -gt 50 ]; then
26 printf "\nToo many errors encountered previously, this diff is hidden.\n"
36 if [ "$fail" = 1 ]; then
37 echo "LINT reports failure."