( report: CheckReport, result: CheckedModule, file: string, cwd: string )
| 290 | |
| 291 | // a module's diagnostics and sites as lines in source order, tallied into the report |
| 292 | const reportModule = ( |
| 293 | report: CheckReport, |
| 294 | result: CheckedModule, |
| 295 | file: string, |
| 296 | cwd: string |
| 297 | ): void => { |
| 298 | const path = printablePathOf(cwd, file) |
| 299 | const sortedDiagnostics = [...result.diagnostics].sort( |
| 300 | (l, r) => l.start - r.start |
| 301 | ) |
| 302 | for (const diagnostic of sortedDiagnostics) { |
| 303 | report.diagnostics.push({ |
| 304 | severity: diagnostic.severity, |
| 305 | rule: diagnostic.rule, |
| 306 | file: printablePathOf(cwd, diagnostic.file), |
| 307 | line: diagnostic.line, |
| 308 | column: diagnostic.column, |
| 309 | start: diagnostic.start, |
| 310 | end: diagnostic.end, |
| 311 | message: diagnostic.message, |
| 312 | reasons: diagnostic.reasons, |
| 313 | ...(diagnostic.hint !== undefined && { hint: diagnostic.hint }) |
| 314 | }) |
| 315 | } |
| 316 | const entries: [number, string][] = result.diagnostics.map(diagnostic => [ |
| 317 | diagnostic.start, |
| 318 | renderDiagnostic({ |
| 319 | ...diagnostic, |
| 320 | file: printablePathOf(cwd, diagnostic.file) |
| 321 | }) |
| 322 | ]) |
| 323 | const errors = result.diagnostics.filter( |
| 324 | diagnostic => diagnostic.severity === "error" |
| 325 | ) |
| 326 | const isAt = (error: Diagnostic, site: CheckedModule["sites"][number]) => |
| 327 | error.file === file && error.start === site.start && error.end === site.end |
| 328 | // an accepted site can fail too, like one that throws a ParseError |
| 329 | const failed = result.sites.filter( |
| 330 | site => |
| 331 | site.status === "rejected" || errors.some(error => isAt(error, site)) |
| 332 | ) |
| 333 | report.errors += errors.length |
| 334 | report.errorsOutsideSites += errors.filter( |
| 335 | error => !failed.some(site => isAt(error, site)) |
| 336 | ).length |
| 337 | for (const site of result.sites) { |
| 338 | report.sites++ |
| 339 | if (failed.includes(site)) continue |
| 340 | if (site.status === "island") report.islands++ |
| 341 | else report.accepted++ |
| 342 | entries.push([ |
| 343 | site.start, |
| 344 | `${path}:${site.line}:${site.column} ${site.status}${site.strategy === undefined ? "" : ` ${site.strategy}`}` |
| 345 | ]) |
| 346 | } |
| 347 | entries.sort((l, r) => l[0] - r[0]) |
| 348 | for (const [, line] of entries) report.lines.push(line) |
| 349 | } |
no test coverage detected