Skip to content

Commit 9ab907c

Browse files
committed
Merge pull request #76 from loadsys/f/add-phpmetrics
F/add phpmetrics
2 parents a6b3c6e + 29f5d65 commit 9ab907c

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"phpdocumentor/phpdocumentor": "~2.0",
1414
"psy/psysh": "@stable",
1515
"loadsys/loadsys_codesniffer": "~3.0",
16-
"nikic/php-parser": "~0.9"
16+
"nikic/php-parser": "~0.9",
17+
"phpmetrics/phpmetrics": "^1.10"
1718
},
1819
"config": {
1920
"bin-dir": "bin"
@@ -39,6 +40,7 @@
3940
"git-localchanges",
4041
"git-remotechanges",
4142
"logs-clear",
43+
"metrics-generate",
4244
"migrations",
4345
"nfsexports-setsudoaccess",
4446
"owner-set",

metrics-generate

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env bash
2+
3+
#---------------------------------------------------------------------
4+
usage ()
5+
{
6+
cat <<EOT
7+
8+
${0##*/}
9+
Wraps up the call to the PHPMetrics library for standard Cake
10+
project folder layouts. Writes reports into the tmp/metrics/
11+
folder.
12+
13+
Should be run from the project root folder.
14+
15+
Usage:
16+
bin/${0##*/}
17+
18+
19+
EOT
20+
21+
exit ${1:-0} # Exit with code 0 unless an arg is passed to the method.
22+
}
23+
if [ "$1" = '-h' ]; then
24+
usage
25+
fi
26+
27+
28+
# Set up local variables.
29+
umask a+rw
30+
31+
DIR="$( cd -P "$( dirname "$0" )"/.. >/dev/null 2>&1 && pwd )"
32+
TMP_DIR="tmp"
33+
REPORT_DIR="${TMP_DIR}/metrics"
34+
REPORT_FILE="${REPORT_DIR}/index.html"
35+
TARGET_FOLDERS=("./src")
36+
37+
if [ $# -gt 0 ]; then
38+
TARGET_FOLDERS=("$@")
39+
fi
40+
41+
42+
echo "## Generating metrics report.";
43+
bin/phpmetrics \
44+
--report-html="$REPORT_FILE" \
45+
${TARGET_FOLDERS[@]}

0 commit comments

Comments
 (0)