render method
The report as spec_checks coverage prints it: the counts table, the
id-less count and the class table, one line per row plus a total.
Implementation
String render() {
final b = StringBuffer();
String l(String s, int w) => s.padRight(w);
String r(Object n, int w) => '$n'.padLeft(w);
b.writeln(
'${l('row', 9)} ${r('model', 5)} ${r('filledNow', 9)} ${r('blockNow', 8)} '
'${r('oldPresent', 10)} ${r('oldFilled', 9)} ${r('refExp', 6)} ${r('variant', 7)}',
);
for (final g in rows) {
b.writeln(
'${l(g, 9)} ${r(model[g] ?? 0, 5)} ${r(filled[g] ?? 0, 9)} ${r(block[g] ?? 0, 8)} '
'${r(oldPresent[g] ?? 0, 10)} ${r(oldFilled[g] ?? 0, 9)} '
'${r(referenceExpansions[g] ?? 0, 6)} ${r(variants[g] ?? 0, 7)}',
);
}
b.writeln(
'${l('TOTAL', 9)} ${r(total(model), 5)} ${r(total(filled), 9)} ${r(total(block), 8)} '
'${r(total(oldPresent), 10)} ${r(total(oldFilled), 9)} '
'${r(total(referenceExpansions), 6)} ${r(total(variants), 7)}',
);
b.writeln(
'id-less sample sub-sections (not counted, T-4): $idlessSampleSections',
);
b.writeln();
b.writeln(
'${l('row', 9)} ${classOrder.map((c) => r(c, 3)).join(' ')} eligible filled%elig',
);
for (final g in rows) {
final el = eligible(g);
final pct = el == 0 ? 0.0 : 100 * (filled[g] ?? 0) / el;
b.writeln(
'${l(g, 9)} ${classOrder.map((c) => r(classes[g]?[c] ?? 0, 3)).join(' ')}'
' ${r(el, 8)} ${r(pct.toStringAsFixed(1), 5)}',
);
}
final tot = <String, int>{};
for (final g in rows) {
classes[g]?.forEach((c, n) => tot[c] = (tot[c] ?? 0) + n);
}
b.writeln(
'${l('TOTAL', 9)} ${classOrder.map((c) => r(tot[c] ?? 0, 3)).join(' ')}',
);
return b.toString();
}