From 0ac02296bdaf65055348a9f4b14e5673c5162bb7 Mon Sep 17 00:00:00 2001 From: Gordon Franke Date: Fri, 21 Jun 2013 09:35:34 +0200 Subject: [PATCH] add sniff option to disable sniffs from the coding standard --- phpcs-pre-commit/config | 6 +++++- phpcs-pre-commit/pre-commit | 10 ++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/phpcs-pre-commit/config b/phpcs-pre-commit/config index e790a1a..0658888 100644 --- a/phpcs-pre-commit/config +++ b/phpcs-pre-commit/config @@ -8,6 +8,10 @@ PHPCS_CODING_STANDARD=PEAR # comma-separated list of file patterns being ignored PHPCS_IGNORE= +# comma-seperated list of sniffs from the standard that should be used +# use `phpcs --standard=PSR1 -e` to list sniffs for your standard +PHPCS_SNIFFS=Generic.Files.ByteOrderMark,Generic.PHP.DisallowShortOpenTag + # egrep compatible pattern of files to be checked PHPCS_FILE_PATTERN="\.(php|phtml)$" @@ -15,4 +19,4 @@ PHPCS_FILE_PATTERN="\.(php|phtml)$" PHPCS_IGNORE_WARNINGS=1 # encoding -PHPCS_ENCODING=utf-8 \ No newline at end of file +PHPCS_ENCODING=utf-8 diff --git a/phpcs-pre-commit/pre-commit b/phpcs-pre-commit/pre-commit index 821a907..4d0b78e 100755 --- a/phpcs-pre-commit/pre-commit +++ b/phpcs-pre-commit/pre-commit @@ -70,6 +70,12 @@ else IGNORE="" fi +if [ "$PHPCS_SNIFFS" != "" ]; then + SNIFFS="--sniffs=$PHPCS_SNIFFS" +else + SNIFFS="" +fi + if [ "$PHPCS_ENCODING" != "" ]; then ENCODING="--encoding=$PHPCS_ENCODING" else @@ -97,7 +103,7 @@ do STAGED_FILES="$STAGED_FILES $TMP_STAGING/$FILE" done -OUTPUT=$($PHPCS_BIN -s $IGNORE_WARNINGS --standard=$PHPCS_CODING_STANDARD $ENCODING $IGNORE $STAGED_FILES) +OUTPUT=$($PHPCS_BIN -s $IGNORE_WARNINGS --standard=$PHPCS_CODING_STANDARD $ENCODING $IGNORE $SNIFFS $STAGED_FILES) RETVAL=$? # delete temporary copy of staging area @@ -107,4 +113,4 @@ if [ $RETVAL -ne 0 ]; then echo "$OUTPUT" | less fi -exit $RETVAL \ No newline at end of file +exit $RETVAL