-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathphp_analyze
More file actions
executable file
·67 lines (59 loc) · 1.55 KB
/
php_analyze
File metadata and controls
executable file
·67 lines (59 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env bash
# php_analyze
#
# AUTORES : Henrique Boaventura Fausto Ribeiro
# DESCRIÇÃO : Script que faz a verificação de sintax em arquivos PHP.
# USO : php_analyze <diretorio> php_analyze <arquivo>
# LICENÇA : GPL v2
#
contador=0;
inContadorTotalArq=0;
inContadorArqAnalisados=0;
nuPercentual=0;
declare -a erros
if [ "$1" == "" ]
then
arquivos=$(find . -name "*.php")
elif [ "${1##*.}" == "php" ]
then
arquivos=$1
else
arquivos=$(find $1 -name "*.php")
fi
# Descobrindo o número total de arquivos que serão analisados.
for file in $arquivos
do
inContadorTotalArq=`expr $inContadorTotalArq + 1`
done
for file in $arquivos
do
analize=`php5 -l $file`
# Calcundo o percentual de arquivos já processados
inContadorArqAnalisados=`expr $inContadorArqAnalisados + 1`
nuPercentual=`expr $inContadorArqAnalisados \* 100`
nuPercentual=`echo "scale=2;$nuPercentual/$inContadorTotalArq" | bc -l`
echo -n "Analizando o arquivo($nuPercentual%): ${file:2} "
if [ "$analize" == "No syntax errors detected in $file" ]
then
echo '... OK'
else
echo -e "... \e[1;31mERRO\e[m"
#echo -e " \e[1;31m"$analize"\e[m "
erros[$contador]=' '${file:2}' - '$analize
contador=`expr $contador + 1`
fi
done
echo
echo Analize concluída com $contador erros:
zebra=0;
for v in "${erros[@]}";
do
echo -e "\e[$zebra;31m"-$v"\e[m"
if [ $zebra == 0 ]
then
zebra=1
else
zebra=0
fi
done
echo Total de arquivos analisados: $inContadorTotalArq