-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathseverityEngine.ts
More file actions
40 lines (33 loc) · 1.13 KB
/
severityEngine.ts
File metadata and controls
40 lines (33 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import type { IssueType, IssueLevel } from '../core/types.ts';
export class SeverityEngine {
static determineLevel(type: IssueType, status?: number): IssueLevel {
switch (type) {
case 'runtime_crash':
case 'white_screen':
case 'retry_storm':
case 'cors_failure':
case 'security_risk':
return 'critical';
case 'network_failure':
if (status && status >= 500) return 'critical';
return 'high';
case 'console_error':
case 'resource_failure':
return 'high';
case 'slow_api':
return 'medium';
case 'console_log':
return 'low';
default:
return 'low';
}
}
static enrichLevel(level: IssueLevel, occurrences: number, threshold: number = 10): IssueLevel {
if (occurrences >= threshold) {
if (level === 'low') return 'medium';
if (level === 'medium') return 'high';
if (level === 'high') return 'critical';
}
return level;
}
}