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

View File

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