1
0
Fork 0
mirror of https://github.com/Yetangitu/ampache synced 2025-10-03 09:49:30 +02:00
ampache/scripts/tests/codestyle.sh
2013-11-17 19:32:43 +01:00

46 lines
1.2 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 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"
# Optionnal fix & false positive
#FIXERS2="visibility"
EXIT=0
echo -e "\e[1;34mChecking mandatory formatting/coding standards\e[00m"
$PHPCSFIXER $PHPCSFIXERARGS$FIXERS1 --dry-run .
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