MCPcopy Create free account
hub / github.com/arktypeio/arktype / reportModule

Function reportModule

ark/aot/check.ts:292–349  ·  view source on GitHub ↗
(
	report: CheckReport,
	result: CheckedModule,
	file: string,
	cwd: string
)

Source from the content-addressed store, hash-verified

290
291// a module's diagnostics and sites as lines in source order, tallied into the report
292const 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}

Callers 1

checkFunction · 0.85

Calls 7

printablePathOfFunction · 0.90
renderDiagnosticFunction · 0.90
isAtFunction · 0.85
sortMethod · 0.80
filterMethod · 0.80
mapMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected