fix: resolve simple-vulnerability-scanner goconst failures

Migrate .golangci.yml from v1 issues.exclude-rules to v2
linters.exclusions.rules — the v1 key was silently ignored by golangci-lint
v2, so test-file goconst exclusions weren't applied. With the config fixed,
all test-file violations disappear. Extract severity constants in output.go
to fix the 4 remaining non-test goconst violations (CRITICAL/HIGH/MODERATE/
LOW each appear 3x in severityRank, severityBreakdown, and severityColorFn).
This commit is contained in:
CarterPerez-dev 2026-05-08 06:21:26 -04:00
parent 5863be7dac
commit 25671b4f9d
2 changed files with 36 additions and 25 deletions

View File

@ -25,6 +25,19 @@ linters:
- testifylint
- fatcontext
exclusions:
rules:
- path: _test\.go
linters:
- funlen
- dupl
- goconst
- gosec
paths:
- vendor
- testdata
max-same-issues: 50
settings:
errcheck:
check-type-assertions: true
@ -78,24 +91,11 @@ linters:
kv-only: true
context: all
issues:
max-same-issues: 50
exclude-dirs:
- vendor
- testdata
exclude-rules:
- path: _test\.go
linters:
- funlen
- dupl
- goconst
formatters:
enable:
- gci # Groups imports
- gofumpt # Whitespace
- golines # Vertical wrap
- gci
- gofumpt
- golines
settings:
golines:
max-len: 80

View File

@ -35,6 +35,13 @@ import (
"github.com/CarterPerez-dev/angela/pkg/types"
)
const (
severityCritical = "CRITICAL"
severityHigh = "HIGH"
severityModerate = "MODERATE"
severityLow = "LOW"
)
func printDivider() {
fmt.Printf("\n %s\n", ui.HiBlack(ui.HRule(44)))
}
@ -314,13 +321,13 @@ func sortVulnsBySeverity(
func severityRank(sev string) int {
switch strings.ToUpper(sev) {
case "CRITICAL":
case severityCritical:
return 0
case "HIGH":
case severityHigh:
return 1
case "MODERATE":
case severityModerate:
return 2
case "LOW":
case severityLow:
return 3
default:
return 4
@ -336,7 +343,11 @@ func severityBreakdown(
}
order := []string{
"CRITICAL", "HIGH", "MODERATE", "LOW", "UNKNOWN",
severityCritical,
severityHigh,
severityModerate,
severityLow,
"UNKNOWN",
}
var parts []string
@ -520,13 +531,13 @@ func severityColorFn(
sev string,
) func(a ...any) string {
switch strings.ToUpper(sev) {
case "CRITICAL":
case severityCritical:
return ui.Red
case "HIGH":
case severityHigh:
return ui.RedBold
case "MODERATE":
case severityModerate:
return ui.HiYellow
case "LOW":
case severityLow:
return ui.Cyan
default:
return ui.HiBlack