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

Add sniff option to disable sniffs from coding standard #5

Merged
merged 1 commit into from
Jul 9, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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