(input: {
status?: IndexStatusCoverage | undefined;
scopes?: readonly CoverageScope[] | undefined;
})
| 762 | * Graphen UND in `parse_partial` steht, ist partiell, nicht vollstaendig. |
| 763 | */ |
| 764 | export function buildCoverageIndex(input: { |
| 765 | status?: IndexStatusCoverage | undefined; |
| 766 | scopes?: readonly CoverageScope[] | undefined; |
| 767 | }): CoverageIndex { |
| 768 | const records = new Map<string, CoverageRecord>(); |
| 769 | const truncations: string[] = []; |
| 770 | const counts = { partial: 0, skipped: 0, notIndexedDirs: 0, notIndexedFiles: 0, scopeEntries: 0 }; |
| 771 | const scopeReadings = new Map<string, { last: CoverageScope; total: number; consistent: boolean; rows: Map<string, CoverageRow> }>(); |
| 772 | for (const scope of input.scopes ?? []) { |
| 773 | const key = scope.scope || '.'; |
| 774 | const reading = scopeReadings.get(key) ?? { last: scope, total: scope.total, consistent: true, rows: new Map<string, CoverageRow>() }; |
| 775 | reading.consistent &&= scope.total === reading.total |
| 776 | && ['known_gaps', 'no_recorded_issue', 'complete'].includes(scope.status); |
| 777 | reading.last = scope; |
| 778 | for (const row of scope.entries) reading.rows.set(`${row.path}\0${row.kind}`, row); |
| 779 | scopeReadings.set(key, reading); |
| 780 | } |
| 781 | const complete = (reading: NonNullable<ReturnType<typeof scopeReadings.get>>) => |
| 782 | reading.consistent && !reading.last.hasMore && reading.rows.size === reading.total; |
| 783 | const rootReading = scopeReadings.get('.'); |
| 784 | const listingComplete = rootReading !== undefined && complete(rootReading); |
| 785 | const rootRows = listingComplete ? [...rootReading!.rows.values()] : []; |
| 786 | const listedKind = (kind: string) => rootRows.filter((row) => row.kind === kind).length; |
| 787 | |
| 788 | const status = input.status; |
| 789 | if (status !== undefined) { |
| 790 | for (const entry of status.parsePartial) { |
| 791 | putRecord(records, { |
| 792 | path: entry.path, |
| 793 | kind: 'file', |
| 794 | state: 'partial', |
| 795 | reason: entry.errorRanges, |
| 796 | source: 'index_status.parse_partial', |
| 797 | }); |
| 798 | } |
| 799 | for (const entry of status.skipped) { |
| 800 | putRecord(records, { |
| 801 | path: entry.path, |
| 802 | kind: 'file', |
| 803 | state: 'skipped', |
| 804 | reason: [entry.reason, entry.phase].filter((part) => part.length > 0).join(' / '), |
| 805 | source: 'index_status.skipped', |
| 806 | }); |
| 807 | } |
| 808 | for (const path of status.notIndexedDirs) { |
| 809 | putRecord(records, { |
| 810 | path, |
| 811 | kind: 'dir', |
| 812 | state: 'not-indexed', |
| 813 | reason: '', |
| 814 | source: 'index_status.not_indexed.dirs', |
| 815 | }); |
| 816 | } |
| 817 | for (const entry of status.notIndexedFiles) { |
| 818 | putRecord(records, { |
| 819 | path: entry.path, |
| 820 | kind: 'file', |
| 821 | state: 'not-indexed', |
no test coverage detected