Reject empty collection coverage

AI assistance: Codex validated and addressed the Greptile empty-collection review finding with focused regression coverage.
This commit is contained in:
Paul Bakaus
2026-07-30 09:43:58 -07:00
parent de9d543825
commit f274ca2c01
2 changed files with 42 additions and 1 deletions
+4 -1
View File
@@ -122,7 +122,10 @@ function hasCoverageValue(value) {
if (value && typeof value === 'object') {
return Object.values(value).some(hasCoverageValue);
}
if (typeof value === 'string') return value.trim().length > 0;
if (typeof value === 'string') {
const trimmed = value.trim();
return trimmed.length > 0 && !/^(?:\[\s*\]|\{\s*\})$/.test(trimmed);
}
return false;
}
+38
View File
@@ -239,6 +239,44 @@ describe('checkDesignCoverage', () => {
}
});
it('does not count empty frontmatter collection literals as section coverage', () => {
for (const colors of ['[]', '{}']) {
const design = [
'---',
'name: X',
`colors: ${colors}`,
'typography:',
' body:',
' fontFamily: Inter',
'components:',
' button:',
' backgroundColor: "#111111"',
'---',
'',
'# Design System: X',
'',
].join('\n');
const findings = checkDesignCoverage({ design, designPath: 'DESIGN.md', parseDesignMd });
assert.deepEqual(ids(findings), ['design-md-coverage']);
assert.match(findings[0].summary, /no colors section/);
}
});
it('counts populated frontmatter array literals as section coverage', () => {
const design = [
'---',
'name: X',
'colors: ["#111111"]',
'typography: [Inter]',
'components: [button]',
'---',
'',
'# Design System: X',
'',
].join('\n');
assert.deepEqual(checkDesignCoverage({ design, designPath: 'DESIGN.md', parseDesignMd }), []);
});
it('reports nothing without a DESIGN.md', () => {
assert.deepEqual(checkDesignCoverage({ design: null, parseDesignMd }), []);
});