(file: string, result: ValidationResult)
| 58 | } |
| 59 | |
| 60 | function printReport(file: string, result: ValidationResult): void { |
| 61 | const out = process.stdout; |
| 62 | |
| 63 | if (result.totalErrors === 0 && result.totalWarnings === 0) { |
| 64 | out.write(`✓ ${file}: valid\n`); |
| 65 | return; |
| 66 | } |
| 67 | |
| 68 | out.write( |
| 69 | `${file}: ${result.totalErrors} error${pluralize(result.totalErrors)}, ${result.totalWarnings} warning${pluralize(result.totalWarnings)}\n`, |
| 70 | ); |
| 71 | |
| 72 | for (const canvas of result.canvases) { |
| 73 | if (canvas.diagnostics.length === 0) continue; |
| 74 | out.write(`\n canvas "${canvas.canvasId}":\n`); |
| 75 | for (const d of canvas.diagnostics) printDiagnostic(d, " "); |
| 76 | } |
| 77 | |
| 78 | if (result.channelDiagnostics.length > 0) { |
| 79 | out.write(`\n channels:\n`); |
| 80 | for (const d of result.channelDiagnostics) printDiagnostic(d, " "); |
| 81 | } |
| 82 | |
| 83 | if (result.memoryDiagnostics.length > 0) { |
| 84 | out.write(`\n memory:\n`); |
| 85 | for (const d of result.memoryDiagnostics) printDiagnostic(d, " "); |
| 86 | } |
| 87 | |
| 88 | if (result.modelDiagnostics.length > 0) { |
| 89 | out.write(`\n models:\n`); |
| 90 | for (const d of result.modelDiagnostics) printDiagnostic(d, " "); |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | function printDiagnostic(d: Diagnostic, indent: string): void { |
| 95 | const where: string[] = []; |
no test coverage detected