2016-06-24 11:23:10 +00:00
|
|
|
#! /bin/bash
|
2015-10-30 21:12:31 +00:00
|
|
|
#
|
|
|
|
# Linter script that checks for common style issues in Dolphin's codebase.
|
|
|
|
|
|
|
|
fail=0
|
|
|
|
|
2017-06-05 00:16:29 +00:00
|
|
|
# Default to staged files, unless a commit was passed.
|
|
|
|
COMMIT=${1:---cached}
|
|
|
|
|
2017-05-08 18:20:42 +00:00
|
|
|
# Loop through each modified file.
|
2017-06-05 00:16:29 +00:00
|
|
|
for f in $(git diff --name-only --diff-filter=ACMRTUXB $COMMIT); do
|
2017-05-08 18:20:42 +00:00
|
|
|
# Filter them.
|
2016-06-24 11:23:10 +00:00
|
|
|
if ! echo "${f}" | egrep -q "[.](cpp|h|mm)$"; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
if ! echo "${f}" | egrep -q "^Source/Core"; then
|
|
|
|
continue
|
|
|
|
fi
|
2017-05-08 18:20:42 +00:00
|
|
|
|
|
|
|
# Check for clang-format issues.
|
2016-06-24 11:23:10 +00:00
|
|
|
d=$(diff -u "${f}" <(clang-format ${f}))
|
|
|
|
if ! [ -z "${d}" ]; then
|
|
|
|
echo "!!! ${f} not compliant to coding style, here is the fix:"
|
|
|
|
echo "${d}"
|
|
|
|
fail=1
|
|
|
|
fi
|
2017-05-08 18:20:42 +00:00
|
|
|
|
|
|
|
# Check for newline at EOF.
|
|
|
|
if [ -n "$(tail -c 1 ${f})" ]; then
|
|
|
|
echo "!!! ${f} not compliant to coding style:"
|
|
|
|
echo "Missing newline at end of file"
|
|
|
|
fail=1
|
|
|
|
fi
|
2016-06-24 11:23:10 +00:00
|
|
|
done
|
2015-10-30 21:12:31 +00:00
|
|
|
|
|
|
|
exit ${fail}
|