linter: run clang-format and fail on diffs

This commit is contained in:
Pierre Bourdon 2016-06-24 13:23:10 +02:00
parent e1c65406dc
commit 3af8f71472
1 changed files with 16 additions and 15 deletions

View File

@ -1,22 +1,23 @@
#! /bin/sh #! /bin/bash
# #
# Linter script that checks for common style issues in Dolphin's codebase. # Linter script that checks for common style issues in Dolphin's codebase.
REPO_BASE=$(realpath $(dirname $0)/..)
fail=0 fail=0
# Step 1: check for trailing whitespaces. # Check for clang-format issues.
echo "[.] Checking for trailing whitespaces." git status --porcelain | awk '{print $2}' | while read f; do
res=$( if ! echo "${f}" | egrep -q "[.](cpp|h|mm)$"; then
find ${REPO_BASE}/Source/Core -name "*.cpp" -o -name "*.h" \ continue
| xargs egrep -n "\s+$" fi
) if ! echo "${f}" | egrep -q "^Source/Core"; then
if [ -n "$res" ]; then continue
echo "FAIL: ${res}" fi
fail=1 d=$(diff -u "${f}" <(clang-format ${f}))
else if ! [ -z "${d}" ]; then
echo "OK" echo "!!! ${f} not compliant to coding style, here is the fix:"
fi echo "${d}"
fail=1
fi
done
exit ${fail} exit ${fail}