From 8e46f6c2f21c4c4a1a193bfe010059be21373d3e Mon Sep 17 00:00:00 2001 From: spycrab Date: Wed, 17 Jan 2018 12:40:35 +0100 Subject: [PATCH] Add linter --- tools/lint.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 tools/lint.sh diff --git a/tools/lint.sh b/tools/lint.sh new file mode 100755 index 0000000000..ef9362eff5 --- /dev/null +++ b/tools/lint.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# Tool for checking for clang-format compliance +# Heavily inspired by: https://github.com/dolphin-emu/dolphin/blob/master/Tools/lint.sh + +COMMIT=${1:---cached} +FILES=$(git diff --name-only --diff-filter=ACMRTUXB $COMMIT) + +EXIT_CODE=0 + +for f in ${FILES}; do + # Ignore anything that isn't a source file + if ! echo "$f" | egrep -q "^src.*\.(cpp|h)$"; then + continue + fi + # Check if clang-format and the original differ + if ! clang-format "$f" | diff - "$f"; then + echo "$f violates the coding style, fix listed above" + EXIT_CODE=1 + fi +done + +exit $EXIT_CODE