ShtukbaseStandard
archivo del paquete→ .shtukbase/packages/risks/checks/r02_risk_accepted.ts

checks/r02_risk_accepted.ts

19 líneas, 1.1 KB.

El archivo tal como está en el paquete: el código y sus comentarios no se traducen.

  1. // RSK-R02. A risk in «accepted» says why: a reason in `acceptedBecause` or a decision in `decision`. The decision,
  2. // when the project has the decisions collection, is checked for existence by SCH-R01 (package collections).
  3. import type { Project, Result } from '../../collections/checks/lib/speclib.ts';
  4. import { main } from '../../collections/checks/lib/runner.ts';
  5. import { addr, has, state } from '../../quality/checks/lib/qlib.ts';
  6. export const RULE = { id: 'rsk-r02', title: 'An accepted risk is accepted with a reason or a decision', scope: 'risks in the state "Accepted"' };
  7. export function check(p: Project, res: Result): void {
  8. if (!res.part('risks', p.need('RISK'))) return;
  9. const recs = p.records('RISK').filter((r) => state(r) === 'accepted');
  10. res.scope = recs.map((r) => addr(r.id));
  11. for (const r of recs)
  12. if (!has(r, 'acceptedBecause') && !has(r, 'decision'))
  13. res.hole(addr(r.id), `${p.label(r, 'RISK')}: the risk is accepted, but why is not said`,
  14. 'write the reason in acceptedBecause or refer to a decision (decision), or return the risk to "Open"', 'no-reason');
  15. }
  16. if (import.meta.main) main({ RULE, check });