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