source:
utils/developer/branch_stats.sh
@
14449
Last change on this file since 14449 was 14182, checked in by nicolasmartin, 4 years ago | |
---|---|
|
|
File size: 2.0 KB |
Rev | Line | |
---|---|---|
[14182] | 1 | #!/bin/bash |
[10864] | 2 | |
[14182] | 3 | #set -ex |
[10864] | 4 | |
[14182] | 5 | ## Rough statistics on routines (code / notes / blank) |
[10864] | 6 | |
[14182] | 7 | [ -z "$*" ] && { echo 'No branch path(s) given => QUIT'; exit 2; } |
[10864] | 8 | |
[14182] | 9 | branches=$* |
[10864] | 10 | |
[14182] | 11 | export LC_NUMERIC='en_GB.UTF-8' ## Decimal separator |
12 | fmt='%-50s %7d(%4.1f%%) %7d(%4.1f%%) %7d(%4.1f%%) %7d\n' | |
[10864] | 13 | |
[14182] | 14 | for branch in $branches; do |
[10864] | 15 | |
[14182] | 16 | cod_sum=0; not_sum=0; blk_sum=0; lin_sum=0 |
17 | paths="$branch/NEMOGCM/NEMO $branch/src" | |
18 | ||
19 | [ -z "$( ls $paths 2> /dev/null )" ] && continue | |
20 | ||
21 | printf "%-50s %7s(ratio) %7s(ratio) %7s(ratio) %7s\n" \ | |
22 | '' code notes blank all | |
23 | ||
24 | for dir in $( find $paths -type d -mindepth 1 -maxdepth 1 2> /dev/null ); do | |
25 | ||
26 | files=$( find $dir -name "*.[fFh]90" 2> /dev/null ) | |
27 | ||
28 | cod_nb=$( grep -h '^ *[^! ]' $files | wc -l ); not_nb=$( grep -h '^ *!' $files | wc -l ) | |
29 | blk_nb=$( grep -h '^ *$' $files | wc -l ) | |
30 | lin_nb=$(( cod_nb + not_nb + blk_nb )) | |
31 | ||
32 | cod_ratio=$( echo "scale = 3; ( ${cod_nb} / ${lin_nb} ) * 100" | bc ) | |
33 | not_ratio=$( echo "scale = 3; ( ${not_nb} / ${lin_nb} ) * 100" | bc ) | |
34 | blk_ratio=$( echo "scale = 3; ( ${blk_nb} / ${lin_nb} ) * 100" | bc ) | |
35 | ||
36 | dir=$( echo $dir | awk -F/ '{printf "%s/%s/%s", $(NF-2), $(NF-1), $(NF)}' ) | |
37 | ||
38 | printf "$fmt" $dir \ | |
39 | ${cod_nb} ${cod_ratio} ${not_nb} ${not_ratio} ${blk_nb} ${blk_ratio} \ | |
40 | $lin_nb | |
41 | ||
42 | cod_sum=$(( cod_sum + cod_nb )); not_sum=$(( not_sum + not_nb )) | |
43 | blk_sum=$(( blk_sum + blk_nb )); lin_sum=$(( lin_sum + lin_nb )) | |
44 | ||
45 | done | |
46 | ||
47 | cod_ratio=$( echo "scale = 3; ( ${cod_sum} / ${lin_sum} ) * 100" | bc ) | |
48 | not_ratio=$( echo "scale = 3; ( ${not_sum} / ${lin_sum} ) * 100" | bc ) | |
49 | blk_ratio=$( echo "scale = 3; ( ${blk_sum} / ${lin_sum} ) * 100" | bc ) | |
50 | ||
51 | branch=$( echo $branch | awk -F/ '{print $NF}' ) | |
52 | ||
53 | printf "$fmt" $branch \ | |
54 | ${cod_sum} ${cod_ratio} ${not_sum} ${not_ratio} ${blk_sum} ${blk_ratio} \ | |
55 | ${lin_sum} | |
56 | ||
57 | echo | |
58 | ||
[10864] | 59 | done |
60 | ||
61 | exit 0 |
Note: See TracBrowser
for help on using the repository browser.