Skip to content

[lint-monster] Sort Type-Safety: Migrate from sort.Slice to slices.SortFunc #38012

Closed

Description

@github-actions

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

  1. Import slices package where needed
  2. Replace sort.Slice(arr, func(i, j int) bool {...}) with slices.SortFunc(arr, func(a, b elem_type) int {...})
  3. Replace sort.SliceStable(arr, func(i, j int) bool {...}) with slices.SortStableFunc(arr, func(a, b elem_type) int {...})
  4. 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 · ◷

  • expires on Jun 15, 2026, 7:50 PM UTC-08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

automationcookielint

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions