git repos / blockattack-game

commit 037887fa

Poul Sander · 2016-11-24 21:24
037887fa6c716cbc0cb4ad3fcdb628f554352133 patch · browse files
parent c6c637ccd95ac3ebfbd57666b8b88bc91e25b86d

Added check for indentation. This is supposed to fail on Travis

Changed files

A source/misc/lint/runLint.sh
M travis_build.script before
diff --git a/source/misc/lint/runLint.sh b/source/misc/lint/runLint.sh new file mode 100644 index 0000000..5e49ccf --- /dev/null +++ b/source/misc/lint/runLint.sh
@@ -0,0 +1,20 @@
+#! /bin/bash
+set -euo pipefail
+
+TMPFILE=$(mktemp /tmp/sago-lint.XXXXXX)
+
+find ./source/code/ -name "*.cpp" -not -path "./source/code/Libs/*" | xargs --no-run-if-empty grep --with-filename --line-number "^ " >> ${TMPFILE} || true
+find ./source/code/ -name "*.h*" -not -path "./source/code/Libs/*" | xargs --no-run-if-empty grep --with-filename --line-number "^ " >> ${TMPFILE} || true
+
+if [ -s "$TMPFILE" ]
+then
+echo "In the following places the lines are indended with spaces. This project uses tabs for indentation."
+echo "The rule applies to comments too although the check can be bypassed by using either C++ style comments or \" *\" to start a line (Doxygen comments)"
+cat "$TMPFILE"
+echo ""
+echo "Validation failed"
+rm "$TMPFILE"
+exit 1
+fi
+
+rm "$TMPFILE"
diff --git a/travis_build.script b/travis_build.script index bab9ebe..37d83d4 100755 --- a/travis_build.script +++ b/travis_build.script
@@ -1,5 +1,9 @@
#! /bin/bash
set -e
+
+# First check for formatting errors
+bash source/misc/lint/runLint.sh
+
# Travis runs Ubuntu 12.04 and misses libutfcpp-dev.
cp source/misc/travis_help/utf8_v2_3_4/source/utf8.h source/code/
cp -r source/misc/travis_help/utf8_v2_3_4/source/utf8 source/code/