Issue Summary
The custom linter has identified 53 instances of unsafe sort operations that should be replaced with type-safe alternatives from the Go slices package.
Findings
- Count: 53 violations
- Violation types:
sort.Slice → use slices.SortFunc (most common)
sort.SliceStable → use slices.SortStableFunc (~9 instances)
- Primary packages: pkg/workflow, pkg/cli
Affected Files (Sample)
pkg/workflow/dependabot.go (3 instances)
pkg/workflow/error_recovery.go
pkg/workflow/expression_extraction.go (2 instances)
pkg/workflow/metrics.go (2 instances)
pkg/cli/audit_comparison.go, pkg/cli/audit_expanded.go, pkg/cli/compile_stats.go
pkg/cli/forecast.go (3 instances)
pkg/cli/token_usage.go (4 instances)
- (... and 35+ more)
Remediation
- Import
slices package where needed
- Replace
sort.Slice(arr, func(i, j int) bool {...}) with slices.SortFunc(arr, func(a, b elem_type) int {...})
- Replace
sort.SliceStable(arr, func(i, j int) bool {...}) with slices.SortStableFunc(arr, func(a, b elem_type) int {...})
- Update comparison logic (return -1, 0, 1 instead of bool)
Expected Outcome
All 53 instances migrated to type-safe sort functions; make golint-custom passes.
Generated by 🧌 LintMonster · 146.1 AIC · ⌖ 4.33 AIC · ⊞ 20K · ◷
Issue Summary
The custom linter has identified 53 instances of unsafe sort operations that should be replaced with type-safe alternatives from the Go
slicespackage.Findings
sort.Slice→ useslices.SortFunc(most common)sort.SliceStable→ useslices.SortStableFunc(~9 instances)Affected Files (Sample)
pkg/workflow/dependabot.go(3 instances)pkg/workflow/error_recovery.gopkg/workflow/expression_extraction.go(2 instances)pkg/workflow/metrics.go(2 instances)pkg/cli/audit_comparison.go,pkg/cli/audit_expanded.go,pkg/cli/compile_stats.gopkg/cli/forecast.go(3 instances)pkg/cli/token_usage.go(4 instances)Remediation
slicespackage where neededsort.Slice(arr, func(i, j int) bool {...})withslices.SortFunc(arr, func(a, b elem_type) int {...})sort.SliceStable(arr, func(i, j int) bool {...})withslices.SortStableFunc(arr, func(a, b elem_type) int {...})Expected Outcome
All 53 instances migrated to type-safe sort functions;
make golint-custompasses.