Spaces:
Paused
Paused
| ; | |
| Object.defineProperty(exports, "__esModule", { value: true }); | |
| exports.LocalConsoleReporter = void 0; | |
| const SEVERITY_COLORS = { | |
| critical: '\x1b[31m', | |
| major: '\x1b[33m', | |
| minor: '\x1b[36m', | |
| info: '\x1b[90m' | |
| }; | |
| const SEVERITY_EMOJI = { | |
| critical: '🚨', | |
| major: '🔴', | |
| minor: '🟠', | |
| info: 'ℹ️' | |
| }; | |
| const TYPE_COLORS = { | |
| security: '\x1b[35m', | |
| bug: '\x1b[31m', | |
| performance: '\x1b[33m', | |
| style: '\x1b[90m', | |
| general: '\x1b[0m' | |
| }; | |
| const RESET = '\x1b[0m'; | |
| class LocalConsoleReporter { | |
| printFindings(findings, options) { | |
| if (options.output === 'json') { | |
| this.printJson(findings); | |
| return; | |
| } | |
| this.printConsole(findings); | |
| } | |
| printConsole(findings) { | |
| if (findings.length === 0) { | |
| return; | |
| } | |
| const sortedFindings = [...findings].sort((a, b) => { | |
| const severityOrder = { critical: 0, major: 1, minor: 2, info: 3 }; | |
| const severityDiff = severityOrder[a.severity] - severityOrder[b.severity]; | |
| if (severityDiff !== 0) | |
| return severityDiff; | |
| return b.confidence - a.confidence; | |
| }); | |
| const groupedByFile = new Map(); | |
| for (const finding of sortedFindings) { | |
| if (!groupedByFile.has(finding.filename)) { | |
| groupedByFile.set(finding.filename, []); | |
| } | |
| groupedByFile.get(finding.filename).push(finding); | |
| } | |
| for (const [filename, fileFindings] of groupedByFile) { | |
| console.log(`\n${'='.repeat(80)}`); | |
| console.log(`${SEVERITY_COLORS.info}📄 ${filename}${RESET}`); | |
| console.log('='.repeat(80)); | |
| for (const finding of fileFindings) { | |
| this.printFinding(finding); | |
| } | |
| } | |
| } | |
| printFinding(finding) { | |
| const severityColor = SEVERITY_COLORS[finding.severity] || ''; | |
| const typeColor = TYPE_COLORS[finding.type] || ''; | |
| const emoji = SEVERITY_EMOJI[finding.severity] || '•'; | |
| console.log(`\n${severityColor}${emoji} [${finding.severity.toUpperCase()}]${RESET} ${typeColor}${finding.type}${RESET} (${finding.confidence}% confidence)`); | |
| console.log(`${' '.repeat(4)}📍 Line ${finding.line}${finding.endLine !== finding.line ? `-${finding.endLine}` : ''}`); | |
| const messageLines = finding.message.split('\n').filter(l => l.trim()); | |
| for (const line of messageLines) { | |
| console.log(`${' '.repeat(4)}${line}`); | |
| } | |
| if (finding.suggestion) { | |
| console.log(`${' '.repeat(4)}💡 Suggested fix:`); | |
| const suggestionLines = finding.suggestion.split('\n'); | |
| for (const line of suggestionLines.slice(0, 10)) { | |
| console.log(`${' '.repeat(8)}${line}`); | |
| } | |
| if (suggestionLines.length > 10) { | |
| console.log(`${' '.repeat(8)}... (${suggestionLines.length - 10} more lines)`); | |
| } | |
| } | |
| } | |
| printJson(findings) { | |
| const output = { | |
| version: '1.0', | |
| timestamp: new Date().toISOString(), | |
| summary: { | |
| total: findings.length, | |
| critical: findings.filter(f => f.severity === 'critical').length, | |
| major: findings.filter(f => f.severity === 'major').length, | |
| minor: findings.filter(f => f.severity === 'minor').length, | |
| info: findings.filter(f => f.severity === 'info').length | |
| }, | |
| findings: findings.map(f => ({ | |
| filename: f.filename, | |
| line: f.line, | |
| endLine: f.endLine, | |
| severity: f.severity, | |
| type: f.type, | |
| message: f.message, | |
| confidence: f.confidence, | |
| suggestion: f.suggestion, | |
| patternType: f.patternType | |
| })) | |
| }; | |
| console.log(JSON.stringify(output, null, 2)); | |
| } | |
| printSummary(findings) { | |
| const critical = findings.filter(f => f.severity === 'critical').length; | |
| const major = findings.filter(f => f.severity === 'major').length; | |
| const minor = findings.filter(f => f.severity === 'minor').length; | |
| const info = findings.filter(f => f.severity === 'info').length; | |
| console.log(`\n${'='.repeat(80)}`); | |
| console.log('📊 REVIEW SUMMARY'); | |
| console.log('='.repeat(80)); | |
| console.log(` 🚨 Critical: ${critical}`); | |
| console.log(` 🔴 Major: ${major}`); | |
| console.log(` 🟠 Minor: ${minor}`); | |
| console.log(` ℹ️ Info: ${info}`); | |
| console.log('='.repeat(80)); | |
| } | |
| } | |
| exports.LocalConsoleReporter = LocalConsoleReporter; | |
| //# sourceMappingURL=console-reporter.js.map |