diff --git a/scripts/technical-debt-metrics.sh b/scripts/technical-debt-metrics.sh index b3f3df14ec9aa..efe28e4c7e85d 100755 --- a/scripts/technical-debt-metrics.sh +++ b/scripts/technical-debt-metrics.sh @@ -159,12 +159,14 @@ then then printf '
No changes to technical debt.\n' else - printf '%s\n' "${rep}" | + printf '%s\n' "${rep}" | # outputs lines containing `|Current number|Change|Type|`, so + # `$2` refers to `Current number` and `$3` to `Change`. awk -F '|' -v rep="${rep}" ' - BEGIN{total=0; weight=0} + BEGIN{total=0; weight=0; absWeight=0} + {absWeight+=$3+0} (($3+0 == $3) && (!($2+0 == 0))) {total+=1 / $2; weight+=$3 / $2} END{ - average=weight/total + if (total == 0) {average=absWeight} else {average=weight/total} if(average < 0) {change= "Decrease"; average=-average; weight=-weight} else {change= "Increase"} printf("
%s in tech debt: (relative, absolute) = (%4.2f, %4.2f)\n\n%s\n", change, average, weight, rep) }' fi