calculateScore computes the optimization score (0-100). Each suggestion reduces the score based on its severity.
(suggestions []Suggestion)
| 290 | // calculateScore computes the optimization score (0-100). |
| 291 | // Each suggestion reduces the score based on its severity. |
| 292 | func calculateScore(suggestions []Suggestion) int { |
| 293 | score := 100 |
| 294 | |
| 295 | for _, s := range suggestions { |
| 296 | switch s.Severity { |
| 297 | case SeverityError: |
| 298 | score -= 20 |
| 299 | case SeverityWarning: |
| 300 | score -= 10 |
| 301 | case SeverityInfo: |
| 302 | score -= 5 |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | if score < 0 { |
| 307 | score = 0 |
| 308 | } |
| 309 | |
| 310 | return score |
| 311 | } |
| 312 | |
| 313 | // FormatResult produces a human-readable text report from an OptimizationResult. |
| 314 | func FormatResult(result *OptimizationResult) string { |
no outgoing calls