-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_metrics.sh
47 lines (33 loc) · 1.36 KB
/
generate_metrics.sh
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
# genrate_metrics.sh
# Desxription: A shell script to make it easy to generate static code reports using phpmetrics by Jean-François Lépine (see http://phpmetrics.org)
#
# Author: Ted Nugent [email protected]
# Gihub: https://github.com/frontalnugity/phpmetrics-generator
# get current commit head
REPORT_DIR='_metrics'
# get GIT commit name for report
GEN_DATE="$(date +'%Y-%m-%d [%H-%M-%S]')";
#generate output path'
OUTPUT_DIR=$REPORT_DIR'/'$GEN_DATE
PHPMETRICS_EXCLUDED='vendor,node_modules,storage'
PHPMETRICS_EXTENSIONS='php,sh,sql,vue,js,css,scss,json'
# auto-create metrics folder (if it doesn't exist)
if [ -d $REPORT_DIR ]; then
echo "REPORT DIRECTOR exists"
else
mkdir $REPORT_DIR
fi
# auto-create rport output folder (if it doesn't exist)
if [ -d $REPORT_DIR/$GEN_DATE ]; then
echo "METRICS DIRECTOR exists"
else
mkdir $REPORT_DIR/$GEN_DATE
fi
# generate metrics repprt
phpmetrics --exclude=$PHPMETRICS_EXCLUDED,$REPORT_DIR --extensions=$PHPMETRICS_EXTENSIONS --report-html=$OUTPUT_DIR --report-violations=$OUTPUT_DIR/violations.xml .
# generate index
(echo "<a href='./$GEN_DATE/index.html'>$GEN_DATE</A><br>\n"; cat $REPORT_DIR/index.html;) > $REPORT_DIR/$GEN_DATE.tmp
rm $REPORT_DIR/index.html
mv $REPORT_DIR/$GEN_DATE.tmp $REPORT_DIR/index.html
# open index of reports in your browser
open $REPORT_DIR/index.html