mirror of
https://github.com/Yetangitu/ampache
synced 2025-10-03 01:39:28 +02:00

Fix coding guidelines incoherences. Code should match PSR1/2 now, and php-cs is set to check it on each commit. Also fixed the Git hook to take into account only added, modified, copied and renamed files (preventing errors when trying to check deleted files). Closes #1260.
42 lines
1 KiB
Bash
42 lines
1 KiB
Bash
#!/bin/bash
|
|
|
|
if [ -e "php-cs-fixer.phar" ]
|
|
then
|
|
PHPCSFIXER="php php-cs-fixer.phar"
|
|
elif hash php-cs-fixer
|
|
then
|
|
PHPCSFIXER="php-cs-fixer"
|
|
else
|
|
echo -e "\e[1;31mPlease install or download latest stable php-cs-fixer\e[00m";
|
|
echo -e "\e[1;31mhttp://cs.sensiolabs.org/\e[00m";
|
|
exit 1
|
|
fi
|
|
|
|
PHPCSFIXERARGS="fix -v --config-file=.php_cs"
|
|
|
|
EXIT=0
|
|
|
|
echo -e "\e[1;34mChecking mandatory formatting/coding standards\e[00m"
|
|
$PHPCSFIXER $PHPCSFIXERARGS --dry-run --diff .
|
|
rc=$?
|
|
if [[ $rc == 0 ]]
|
|
then
|
|
echo -e "\e[1;32mFormatting is OK\e[00m"
|
|
else
|
|
echo -e "\e[1;31mPlease check code Formatting\e[00m"
|
|
echo -e "\e[1;31m$PHPCSFIXER $PHPCSFIXERARGS$FIXERS1 .\e[00m"
|
|
EXIT=1
|
|
fi
|
|
|
|
#echo -e "\e[1;34mChecking optionnal formatting/coding standards\e[00m"
|
|
#$PHPCSFIXER $PHPCSFIXERARGS$FIXERS2 --dry-run .
|
|
#rc=$?
|
|
#if [[ $rc == 0 ]]
|
|
#then
|
|
# echo -e "\e[1;32mOptionnal formatting is OK\e[00m"
|
|
#else
|
|
# echo -e "\e[1;33mThere are errors in the formatting (or false positive)\e[00m"
|
|
# echo -e "\e[1;33m$PHPCSFIXER $PHPCSFIXERARGS$FIXERS2 .\e[00m"
|
|
#fi
|
|
|
|
exit $EXIT
|