Skip to content

Commit 53de72c

Browse files
authored
lint: modernize - enable slicessort, stringsseq (#4162)
* modernize: slices.Insert, slices.Sort * modernize: strings.SplitSeq
1 parent 113a6da commit 53de72c

File tree

4 files changed

+4
-7
lines changed

4 files changed

+4
-7
lines changed

.golangci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,7 @@ linters:
267267
- fmtappendf
268268
- forvar
269269
- omitzero
270-
- slicessort
271270
- stringsbuilder
272-
- stringsseq
273271
- waitgroup
274272

275273
nestif:

pkg/cwhub/sync.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ func insertInOrderNoCase(sl []string, value string) []string {
486486
return strings.ToLower(sl[i]) >= strings.ToLower(value)
487487
})
488488

489-
return append(sl[:i], append([]string{value}, sl[i:]...)...)
489+
return slices.Insert(sl, i, value)
490490
}
491491

492492
func removeDuplicates(sl []string) []string {

pkg/exprhelpers/helpers.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"path/filepath"
1616
"reflect"
1717
"regexp"
18+
"slices"
1819
"sort"
1920
"strconv"
2021
"strings"
@@ -707,9 +708,7 @@ func MedianInterval(params ...any) (any, error) {
707708
}
708709

709710
// Sort intervals for median calculation
710-
sort.Slice(intervals, func(i, j int) bool {
711-
return intervals[i] < intervals[j]
712-
})
711+
slices.Sort(intervals)
713712

714713
n := len(intervals)
715714
if n%2 == 1 {

pkg/hubtest/hubtest_item.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ func (*HubTestItem) ImprovedLogDisplay(crowdsecLogFile string) error {
295295
failures := []string{}
296296
general := []string{}
297297

298-
for _, line := range strings.Split(string(crowdsecLog), "\n") {
298+
for line := range strings.SplitSeq(string(crowdsecLog), "\n") {
299299
if strings.Contains(line, `"Evaluating operator: MATCH"`) {
300300
success = append(success, line)
301301
} else if strings.Contains(line, `"Evaluating operator: NO MATCH"`) {

0 commit comments

Comments
 (0)