From 2459f480f3be74946bdc484632f368361e4afa4a Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Mon, 29 Jan 2018 15:00:25 +0100 Subject: [PATCH 1/2] Update syntax.sh --- Hooks/syntax.sh | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/Hooks/syntax.sh b/Hooks/syntax.sh index 2446e8d..5739d77 100644 --- a/Hooks/syntax.sh +++ b/Hooks/syntax.sh @@ -1,12 +1,29 @@ git diff --cached --name-only | while read FILE; do + if [[ "$FILE" =~ ^.+(php|inc|module|install|test)$ ]]; then - # Courtesy of swytsh from the comments below. if [[ -f $FILE ]]; then + + # php lint php -l "$FILE" 1> /dev/null if [ $? -ne 0 ]; then - echo -e "\e[1;31m\tAborting commit due to files with syntax errors.\e[0m" >&2 + echo -e "\e[1;31m\tPhp linting error.\e[0m" >&2 + exit 1 + fi + + # phpcs + ./vendor/bin/phpcs --standard="./Build/Config/phpcs.xml" --encoding=utf-8 -n -p $FILE + if [ $? -ne 0 ]; then + echo -e "\e[1;31m\tCode Sniffer error.\e[0m" >&2 + exit 1 + fi + + # phpmd + ./vendor/bin/phpmd --standard="./Build/Config/phpmd.xml" --encoding=utf-8 -n -p $FILE + if [ $? -ne 0 ]; then + echo -e "\e[1;31m\tMess Detector error.\e[0m" >&2 exit 1 fi fi fi + done || exit $? From f1cc4bcc0baa06ae7886f6574e31ff58a492fb87 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Wed, 31 Jan 2018 19:11:59 +0100 Subject: [PATCH 2/2] Update syntax.sh --- Hooks/syntax.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Hooks/syntax.sh b/Hooks/syntax.sh index 5739d77..9c7dd79 100644 --- a/Hooks/syntax.sh +++ b/Hooks/syntax.sh @@ -18,7 +18,7 @@ if [[ "$FILE" =~ ^.+(php|inc|module|install|test)$ ]]; then fi # phpmd - ./vendor/bin/phpmd --standard="./Build/Config/phpmd.xml" --encoding=utf-8 -n -p $FILE + ./vendor/bin/phpmd $FILE ./Build/Config/phpmd.xml --exclude *tests* --minimumpriority 1 if [ $? -ne 0 ]; then echo -e "\e[1;31m\tMess Detector error.\e[0m" >&2 exit 1