Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions bin/scorecard
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ const isBug = record.kind === 'bug';
const round1 = (x) => Math.round(x * 10) / 10;
const fmtMs = (ms) => { const s = Math.max(0, Math.round(ms / 1000)); return `${Math.floor(s / 60)}m${String(s % 60).padStart(2, '0')}s`; };

// ---- (0) malformed gate entries -------------------------------------------------------------------
const wellFormed = (e) => !!e && typeof e === 'object' && ('reason' in e || (('result' in e) && e.result !== null && typeof e.result === 'object'));
const badGates = Object.keys(gates).filter((k) => k !== 'QA' && !wellFormed(gates[k]));
if (badGates.length) emit(NAME, { ok: false, pass: null, code: 'BAD_RECORD', message: "a gate's RESULT object belongs under .result, not flattened onto the gate entry", gates: badGates });

// ---- (1) hard gates -----------------------------------------------------------------------------
const hardFailed = [];
for (const k of W.hard) {
Expand Down
9 changes: 9 additions & 0 deletions test/scorecard.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,12 @@ test('missing record or weights is ok:false with exit 2', () => {
assert.equal(r.status, 2);
assert.match(r.stdout, /BAD_RECORD/);
});

test('a gate entry with neither result nor reason is BAD_RECORD, exit 2, the gates named', () => {
const rec = record();
rec.gates.G2 = { ok: true, pass: false, code: 'MISSED', missed: [{ file: 'src/deposit.mapper.ts' }], tier: 'A' };
const { code, result } = run(rec);
assert.equal(code, 2);
assert.equal(result.code, 'BAD_RECORD');
assert.deepEqual(result.gates, ['G2']);
});
Loading