1
0
Fork 0
mirror of https://github.com/Yetangitu/ampache synced 2025-10-04 18:29:40 +02:00
ampache/scripts/tests/codestyle.sh
Phyks (Lucas Verney) 2890aa89bf Fix Travis-CI build
* Fix php-cs according to https://github.com/ampache/ampache/issues/1251
to fix travis build. Use composer to force the 1.* version to be used.

* Add `encoding` fixer.

* Use the same set of fixers in Git commit hook and test script.

* Update hooks and scripts.

* Fix a braces issue detected by php-cs.

Closes issue #1251.
2016-06-13 15:32:48 +02:00

46 lines
1.3 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 --fixers="
# Mandatory fix
FIXERS1="indentation,linefeed,trailing_spaces,short_tag,braces,controls_spaces,eof_ending,visibility,align_equals,concat_with_spaces,elseif,line_after_namespace,lowercase_constants,encoding"
# Optionnal fix & false positive
#FIXERS2="visibility"
EXIT=0
echo -e "\e[1;34mChecking mandatory formatting/coding standards\e[00m"
$PHPCSFIXER $PHPCSFIXERARGS$FIXERS1 --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