Skip to content

Commit ba0730f

Browse files
committed
CS Fixer and Mess Detector
1 parent 2d98690 commit ba0730f

File tree

3 files changed

+41
-7
lines changed

3 files changed

+41
-7
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Create your own config file ;)
2+
config

config renamed to config.dist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# path to phpcs "binary"
22
PHPCS_BIN=/usr/local/bin/phpcs
3+
PHPCSFIXER_BIN=/Users/davimarcondes/.composer/vendor/bin/php-cs-fixer
4+
PHPMD_BIN=/usr/local/bin/phpmd
35

46
# the coding standard, you can also specify a path to your own standard here
57
# e. g. /path/to/my/standard/dir/

pre-commit

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,44 @@ do
113113
STAGED_FILES="$STAGED_FILES $TMP_STAGING/$FILE"
114114
done
115115

116-
OUTPUT=$($PHPCS_BIN -s $IGNORE_WARNINGS --standard=$PHPCS_CODING_STANDARD $ENCODING $IGNORE $SNIFFS $STAGED_FILES)
117-
RETVAL=$?
116+
echo ""
117+
echo " :: PHP CodeSniffer inspection :: "
118+
echo ""
119+
PHPCS_OUTPUT=$($PHPCS_BIN -s $IGNORE_WARNINGS --standard=$PHPCS_CODING_STANDARD $ENCODING $IGNORE $SNIFFS $STAGED_FILES)
120+
PHPCS_RETVAL=$?
121+
122+
if [ $PHPCS_RETVAL -ne 0 ]; then
123+
echo "$PHPCS_OUTPUT" | less
124+
else
125+
echo " :: Inspection is OK! :: "
126+
fi
118127

119-
# delete temporary copy of staging area
120-
rm -rf $TMP_STAGING
128+
echo ""
129+
echo " :: PHP CS Fixer inspection :: "
130+
echo ""
131+
PHPCSFIXER_OUTPUT=$($PHPCSFIXER_BIN fix $STAGED_FILES --level=psr2 --dry-run --diff)
132+
PHPCSFIXER_RETVAL=$?
121133

122-
if [ $RETVAL -ne 0 ]; then
123-
echo "$OUTPUT" | less
134+
if [ $PHPCSFIXER_RETVAL -ne 0 ]; then
135+
echo "$PHPCSFIXER_OUTPUT" | less
136+
else
137+
echo " :: Inspection is OK! :: "
124138
fi
125139

126-
exit $RETVAL
140+
echo ""
141+
echo " :: PHP Mess Detector inspection :: "
142+
echo ""
143+
PHPMD_OUTPUT=$($PHPMD_BIN $STAGED_FILES text cleancode,codesize,controversial,design,naming,unusedcode)
144+
PHPMD_RETVAL=$?
145+
146+
if [ $PHPMD_RETVAL -ne 0 ]; then
147+
echo "$PHPMD_OUTPUT" | less
148+
else
149+
echo " :: Inspection is OK! :: "
150+
fi
151+
152+
153+
# delete temporary copy of staging area
154+
rm -rf $TMP_STAGING
155+
156+
exit $PHPCS_RETVAL

0 commit comments

Comments
 (0)