fix: #149 join stops at a labeled or located paragraph and after the fields (GST-987)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
garrytanandcapy-ai[bot] committed 2026-11-02 16:36:45 +00:00
1 parent 8b591faf9c
commit ecd12e43ff
2 files changed
+7 -1

No files matched your search

+1 -1
View File
@@ -164,7 +164,7 @@ export function parseFindings(reader: string, output: string, fixableRaises = tr
}
const detail = listItem && /^[-*+]\s/.test(t) && !locus && !label && !section && !!current && !current.list && !current.fields.size;
if (detail && !blocks) { current!.raw += ` | ${t}`; continue; }
if (afterGap && current?.heading && !LIST_ITEM.test(t) && !HEADING.test(t) && !NUMBERED_HEAD.test(t)) {
if (afterGap && current?.heading && !current.fields.size && !LIST_ITEM.test(t) && !HEADING.test(t) && !NUMBERED_HEAD.test(t) && !LEAD_LABEL.test(t) && !LOCUS.test(t)) {
current.raw += ` | ${t}`;
if (blocks) current.label = 'CRITICAL';
else if (label) current.label = stronger(current.label, label);
+6
View File
@@ -49,6 +49,12 @@ describe('native FIXABLE by review class (GST-987)', () => {
expect(parseFindings('adversarial-native', output, false).map(f => f.label)).toEqual(['Medium', 'Low']);
expect(parseFindings('adversarial-native', output, true).map(f => f.label)).toEqual(['CRITICAL', 'CRITICAL']);
});
test('a labeled or located paragraph after a numbered heading stays its own finding (#149 joins only plain body text)', () => {
for (const raises of [true, false]) {
expect(parseFindings('outside-voice', '### 1. P2 race in a.ts:3\n\nP0: also data loss in b.ts:9\n\nSeverity: Medium', raises).map(f => f.label)).toEqual(['P2', 'P0']);
expect(parseFindings('outside-voice', '### 1. P2 race in a.ts:3\n\nBody.\n\nP1: second issue in b.ts:9', raises).map(f => f.label)).toEqual(['P2', 'P1']);
}
});
test('collect reads the class from --manifest and defaults to the gate class without one', () => {
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'gst987-'));
const out = path.join(dir, 'native.txt');