Skip to content
This repository has been archived by the owner on Mar 6, 2021. It is now read-only.

Commit

Permalink
add sniff option to disable sniffs from the coding standard
Browse files Browse the repository at this point in the history
  • Loading branch information
ASA1-ET-JENKINS committed Jun 21, 2013
1 parent b3d047d commit 0ac0229
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 5 additions & 1 deletion phpcs-pre-commit/config
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ 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)$"

# ignore warnings
PHPCS_IGNORE_WARNINGS=1

# encoding
PHPCS_ENCODING=utf-8
PHPCS_ENCODING=utf-8
10 changes: 8 additions & 2 deletions phpcs-pre-commit/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -107,4 +113,4 @@ if [ $RETVAL -ne 0 ]; then
echo "$OUTPUT" | less
fi

exit $RETVAL
exit $RETVAL

0 comments on commit 0ac0229

Please sign in to comment.