Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function createBaseline(summary: FileSummary): string {
if (summary.findings.length === 0)
return summary.content;
const findings = summary.findings.slice().sort(Finding.compare);
const lines: string[] = [];
let lineStart = 0;
let findingPosition = 0;
let pendingFindings: Finding[] = [];
for (const line of summary.content.split(/\n/g)) {
lines.push(line);
const nextLineStart = lineStart + line.length + 1;
const lineLength = line.length - (line.endsWith('\r') ? 1 : 0);
const pending: Finding[] = [];
for (const finding of pendingFindings)
lines.push(formatFinding(finding, lineStart, lineLength, nextLineStart, pending));
pendingFindings = pending;
for (; findingPosition < findings.length && findings[findingPosition].start.position < nextLineStart; ++findingPosition)
lines.push(formatFinding(findings[findingPosition], lineStart, lineLength, nextLineStart, pendingFindings));