Skip to content

Commit a99d530

Browse files
Copilotpethers
andcommitted
fix: tighten quality score threshold parsing and critical count consistency
Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
1 parent 80e45d3 commit a99d530

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

scripts/validate-quality-scores.cjs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
const fs = require('fs');
44

55
const filePath = process.argv[2];
6-
const thresholdRaw = process.env.MULTIDIM_THRESHOLD;
7-
const thresholdParsed = parseInt(thresholdRaw, 10);
8-
const threshold = Number.isInteger(thresholdParsed) && thresholdParsed >= 1 ? thresholdParsed : 60;
6+
const thresholdRaw = String(process.env.MULTIDIM_THRESHOLD ?? '').trim();
7+
const threshold = /^[1-9]\d*$/.test(thresholdRaw) ? Number(thresholdRaw) : 60;
98

109
try {
1110
const scores = JSON.parse(fs.readFileSync(filePath, 'utf-8'));
@@ -15,17 +14,18 @@ try {
1514
process.exit(0);
1615
}
1716

18-
const overallScores = entries
19-
.filter(e => e.multidimensional && typeof e.multidimensional.overallScore === 'number')
20-
.map(e => e.multidimensional.overallScore);
17+
const multidimensionalEntries = entries.filter(
18+
e => e.multidimensional && typeof e.multidimensional.overallScore === 'number',
19+
);
20+
const overallScores = multidimensionalEntries.map(e => e.multidimensional.overallScore);
2121
if (overallScores.length === 0) {
2222
console.log('NO_MULTIDIM');
2323
process.exit(0);
2424
}
2525

2626
const avg = Math.round(overallScores.reduce((a, b) => a + b, 0) / overallScores.length);
2727
const passed = overallScores.filter(s => s >= threshold).length;
28-
const critical = entries.filter(e => e.multidimensional && !e.multidimensional.passesThreshold).length;
28+
const critical = multidimensionalEntries.filter(e => e.multidimensional.overallScore < threshold).length;
2929
console.log(`${avg}|${passed}|${overallScores.length}|${critical}`);
3030
} catch (e) {
3131
console.log(`ERROR:${e.message}`);

0 commit comments

Comments
 (0)