Skip to content

Commit 84f9f09

Browse files
committed
Merge pull request #7 from devdrops/phpmd-improvements
Merged #7.
2 parents 4023ba1 + 2761b56 commit 84f9f09

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

config.dist

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,9 @@ PHPMD_OUTPUT_MODE=text
2828

2929
# PHP Mess Detector patterns (defaults: cleancode).
3030
PHPMD_PATTERNS=cleancode,codesize,controversial,design,naming,unusedcode
31+
32+
# PHP Mess Detector file suffixes
33+
PHPMD_SUFFIXES=php
34+
35+
# PHP Mess Detector list of files/folders to exclude
36+
PHPMD_EXCLUDE=

pre-commit

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,17 @@ else
111111
PHPMD_PATTERNS_LIST="cleancode"
112112
fi
113113

114+
if [ "$PHPMD_SUFFIXES" != "" ]; then
115+
PHPMD_SUFFIXES_LIST="--suffixes $PHPMD_SUFFIXES"
116+
else
117+
PHPMD_SUFFIXES_LIST=""
118+
fi
119+
120+
if [ "$PHPMD_EXCLUDE" != "" ]; then
121+
PHPMD_EXCLUDE_LIST="--exclude $PHPMD_EXCLUDE"
122+
else
123+
PHPMD_EXCLUDE_LIST=""
124+
fi
114125

115126
# Copy contents of staged version of files to temporary staging area
116127
# because we only want the staged version that will be commited and not
@@ -146,7 +157,7 @@ fi
146157

147158
echo ""
148159
tput setaf 7; echo " :: PHP Mess Detector inspection :: "
149-
PHPMD_OUTPUT=$($PHPMD_BIN $STAGED_FILES $PHPMD_OUTPUT $PHPMD_PATTERNS_LIST)
160+
PHPMD_OUTPUT=$($PHPMD_BIN $STAGED_FILES $PHPMD_OUTPUT $PHPMD_PATTERNS_LIST $PHPMD_SUFFIXES_LIST $PHPMD_EXCLUDE_LIST)
150161
PHPMD_RETVAL=$?
151162

152163
if [ $PHPMD_RETVAL -ne 0 ]; then

0 commit comments

Comments
 (0)