(
paths: readonly string[],
importRows: readonly WireImportRow[],
unresolved: ReadonlyArray<{ name: string; line: number }> = []
)
| 89 | * and on a hub like `src/types.ts` they would otherwise be most of the rail. |
| 90 | */ |
| 91 | export function buildFileRail( |
| 92 | paths: readonly string[], |
| 93 | importRows: readonly WireImportRow[], |
| 94 | unresolved: ReadonlyArray<{ name: string; line: number }> = [] |
| 95 | ): FileRailModel { |
| 96 | const detail = new Map(importRows.map((row) => [row.file, row])); |
| 97 | |
| 98 | const rows: FileRailRow[] = [...new Set(paths)].map((path) => { |
| 99 | const row = detail.get(path); |
| 100 | const symbols = namedSymbols(row); |
| 101 | return { |
| 102 | path, |
| 103 | test: row?.test ?? looksLikeTest(path), |
| 104 | imported: row !== undefined, |
| 105 | symbols, |
| 106 | symbolCount: symbols.length, |
| 107 | }; |
| 108 | }); |
| 109 | |
| 110 | rows.sort( |
| 111 | (a, b) => Number(a.test) - Number(b.test) || a.path.localeCompare(b.path) |
| 112 | ); |
| 113 | |
| 114 | const byName = new Map<string, number[]>(); |
| 115 | for (const item of unresolved) { |
| 116 | const lines = byName.get(item.name); |
| 117 | if (lines) lines.push(item.line); |
| 118 | else byName.set(item.name, [item.line]); |
| 119 | } |
| 120 | |
| 121 | return { |
| 122 | rows, |
| 123 | total: rows.length, |
| 124 | testCount: rows.filter((row) => row.test).length, |
| 125 | outside: [...byName.entries()] |
| 126 | .map(([name, lines]) => ({ name, lines: [...lines].sort((a, b) => a - b) })) |
| 127 | .sort((a, b) => a.name.localeCompare(b.name)), |
| 128 | }; |
| 129 | } |
| 130 | |
| 131 | /** |
| 132 | * Whether a path looks like test code, for the rows no import edge described. |
no test coverage detected