problems property

List<String> get problems

Every way the inventory answers the rows wrong, one line each: an unknown row id, a row answered twice, a row not answered, an entry with neither a specimen nor a reason (or both), and a reason that is a to-do ("not built yet").

Implementation

List<String> get problems {
  final out = <String>[];
  final seen = <String>{};
  for (final entry in entries) {
    final row = DesignInventoryRow.byId(entry.row);
    if (row == null) {
      out.add('unknown row id "${entry.row}"');
      continue;
    }
    if (!seen.add(entry.row)) {
      out.add('${entry.row}: answered more than once');
    }
    final reason = entry.absentReason?.trim();
    if (entry.builder == null && (reason == null || reason.isEmpty)) {
      out.add(
        '${entry.row}: neither a live specimen nor a reason it is absent',
      );
    } else if (entry.builder != null && entry.absentReason != null) {
      out.add('${entry.row}: both a live specimen and a reason it is absent');
    } else if (reason != null && _placeholder.hasMatch(reason)) {
      out.add(
        '${entry.row}: "$reason" is a to-do, not a reason the look leaves '
        'it out',
      );
    }
  }
  for (final row in DesignInventoryRow.all) {
    if (!seen.contains(row.id)) {
      out.add('${row.id}: missing (${row.name})');
    }
  }
  return out;
}