feat: normalize exclusions format
This commit is contained in:
@@ -41,6 +41,25 @@ describe('findings exclusions', () => {
|
||||
assert.equal(exclusions[0].title, 'fetch_package_versions jq overhead');
|
||||
});
|
||||
|
||||
it('repairs exclusions wrapper format to a top-level array', () => {
|
||||
const fullPath = path.join(workspace, EXCLUSIONS_PATH);
|
||||
fs.mkdirSync(path.dirname(fullPath), { recursive: true });
|
||||
fs.writeFileSync(fullPath, JSON.stringify({
|
||||
exclusions: [
|
||||
{ location: 'README.md:12', suggestion: 'keep' },
|
||||
],
|
||||
}, null, 2));
|
||||
|
||||
const exclusions = loadExclusions(workspace);
|
||||
const repaired = JSON.parse(fs.readFileSync(fullPath, 'utf8'));
|
||||
|
||||
assert.equal(exclusions.length, 1);
|
||||
assert.ok(Array.isArray(repaired));
|
||||
assert.equal(repaired[0].location, 'README.md:12');
|
||||
assert.equal(repaired[0].suggestion, 'keep');
|
||||
assert.ok(logs.some(line => line.includes('排除問題格式已修正為頂層陣列: source=exclusions -> array')));
|
||||
});
|
||||
|
||||
it('applies exclusions loaded from wrapper format', () => {
|
||||
const findings = [
|
||||
{ location: 'entrypoint.sh:180', role: 'Maya', suggestion: 'keep' },
|
||||
|
||||
Reference in New Issue
Block a user