Skip to content

Commit 62a5a43

Browse files
committed
fix: Resolve lint errors from golangci-lint v2.11.4 upgrade
Replace sort.Slice/sort.SliceStable/sort.Strings with slices equivalents and disable package-naming rule for the types package.
1 parent f28b69b commit 62a5a43

File tree

4 files changed

+18
-14
lines changed

4 files changed

+18
-14
lines changed

.golangci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ linters:
8888
disabled: true
8989
- name: use-waitgroup-go
9090
disabled: true
91+
- name: package-naming
92+
disabled: true
9193
exclusions:
9294
generated: lax
9395
presets:

docs/generator.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package docs
22

33
import (
4+
"cmp"
45
"embed"
56
"fmt"
67
"os"
78
"regexp"
8-
"sort"
9+
"slices"
910

1011
"github.com/cloudquery/plugin-sdk/v4/caser"
1112
"github.com/cloudquery/plugin-sdk/v4/schema"
@@ -87,8 +88,8 @@ func DefaultTitleTransformer(table *schema.Table) string {
8788
}
8889

8990
func sortTables(tables schema.Tables) {
90-
sort.SliceStable(tables, func(i, j int) bool {
91-
return tables[i].Name < tables[j].Name
91+
slices.SortStableFunc(tables, func(a, b *schema.Table) int {
92+
return cmp.Compare(a.Name, b.Name)
9293
})
9394

9495
for _, table := range tables {

plugin/sort.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
package plugin
22

33
import (
4-
"sort"
4+
"cmp"
5+
"slices"
56

67
"github.com/apache/arrow-go/v18/arrow"
78
"github.com/apache/arrow-go/v18/arrow/array"
@@ -18,16 +19,16 @@ func sortRecords(table *schema.Table, records []arrow.RecordBatch, columnName st
1819
panic("table has no '" + columnName + "' column to sort on")
1920
}
2021
colIndex := sch.FieldIndices(columnName)[0]
21-
sort.Slice(records, func(i, j int) bool {
22-
switch records[i].Column(colIndex).DataType().(type) {
22+
slices.SortFunc(records, func(a, b arrow.RecordBatch) int {
23+
switch a.Column(colIndex).DataType().(type) {
2324
case *arrow.Int64Type:
24-
v1 := records[i].Column(colIndex).(*array.Int64).Value(0)
25-
v2 := records[j].Column(colIndex).(*array.Int64).Value(0)
26-
return v1 < v2
25+
v1 := a.Column(colIndex).(*array.Int64).Value(0)
26+
v2 := b.Column(colIndex).(*array.Int64).Value(0)
27+
return cmp.Compare(v1, v2)
2728
case *arrow.StringType:
28-
v1 := records[i].Column(colIndex).(*array.String).Value(0)
29-
v2 := records[j].Column(colIndex).(*array.String).Value(0)
30-
return v1 < v2
29+
v1 := a.Column(colIndex).(*array.String).Value(0)
30+
v2 := b.Column(colIndex).(*array.String).Value(0)
31+
return cmp.Compare(v1, v2)
3132
default:
3233
panic("unsupported type for sorting")
3334
}

writers/writers_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"context"
55
"math/rand"
66
"runtime"
7-
"sort"
7+
"slices"
88
"strconv"
99
"testing"
1010

@@ -144,7 +144,7 @@ func writerMatrix[T writers.Writer, C any, O ~func(T)](prefix string, constructo
144144
bCases := make([]bCase, 0, len(optsMatrix))
145145

146146
k := maps.Keys(optsMatrix)
147-
sort.Strings(k)
147+
slices.Sort(k)
148148

149149
for _, name := range k {
150150
opts := optsMatrix[name]

0 commit comments

Comments
 (0)