jenkins-bot has submitted this change and it was merged.
Change subject: Tools: Run PHP code sniffer in the make phplint command
......................................................................
Tools: Run PHP code sniffer in the make phplint command
Standardise on a set of PHP code conventions
Provide instructions for setup.
Change-Id: I364b2c2899598f455a548b48725919ad56de09f6
---
M Makefile
M scripts/phpcheck.sh
2 files changed, 21 insertions(+), 1 deletion(-)
Approvals:
MaxSem: Looks good to me, approved
jenkins-bot: Verified
diff --git a/Makefile b/Makefile
index 29ed639..3405bc8 100644
--- a/Makefile
+++ b/Makefile
@@ -44,6 +44,9 @@
checkless:
@php ../../maintenance/checkLess.php
+dependencies: nodecheck remotes
+ pear install PHP_CodeSniffer
+
phplint:
@scripts/phpcheck.sh
diff --git a/scripts/phpcheck.sh b/scripts/phpcheck.sh
index 593058e..a73479f 100755
--- a/scripts/phpcheck.sh
+++ b/scripts/phpcheck.sh
@@ -1,7 +1,16 @@
#!/bin/sh
# PHP Lint stuff before commiting
-for file in `find . -name \*.php`
+command -v phpcs >/dev/null 2>&1 || { echo >&2 "I require phpcs but it's not
installed. Aborting. Run `make dependencies`"; exit 1; }
+if [ -z ${MEDIAWIKI_CODESNIFFER_CONFIG_DIR+x} ]
+ then
+ echo "@MEDIAWIKI_CODESNIFFER_CONFIG_DIR is unset"
+ echo "Please setup mediawiki/tools/codesniffer"
+ echo "Then add `export
@MEDIAWIKI_CODESNIFFER_CONFIG_DIR=/path/`"
+ exit 1
+fi
+
+for file in `find . -name \*.php -not -path './node_modules/*'`
do
RESULTS=`php -l $file`
if [ "$RESULTS" != "No syntax errors detected in $file" ]
@@ -9,4 +18,12 @@
echo $RESULTS
exit 1
fi
+ RESULTS=`phpcs $file --standard=$MEDIAWIKI_CODESNIFFER_CONFIG_DIR`
+ if [ "$RESULTS" != "" ]
+ then
+ echo "Problem with $file:"
+ echo $RESULTS
+ exit 1
+ fi
done
+
--
To view, visit https://gerrit.wikimedia.org/r/119512
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I364b2c2899598f455a548b48725919ad56de09f6
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
Gerrit-Reviewer: Awjrichards <[email protected]>
Gerrit-Reviewer: Hashar <[email protected]>
Gerrit-Reviewer: JGonera <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: Kaldari <[email protected]>
Gerrit-Reviewer: MaxSem <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits