File tree 8 files changed +20
-20
lines changed
8 files changed +20
-20
lines changed Original file line number Diff line number Diff line change 13
13
runs-on : ubuntu-latest
14
14
env :
15
15
GO_VERSION : stable
16
- GOLANGCI_LINT_VERSION : v1.55 .2
16
+ GOLANGCI_LINT_VERSION : v1.56 .2
17
17
CGO_ENABLED : 0
18
18
19
19
steps :
26
26
27
27
# https://github.com/marketplace/actions/setup-go-environment
28
28
- name : Set up Go ${{ env.GO_VERSION }}
29
- uses : actions/setup-go@v4
29
+ uses : actions/setup-go@v5
30
30
with :
31
31
go-version : ${{ env.GO_VERSION }}
32
32
Original file line number Diff line number Diff line change 26
26
27
27
# https://github.com/marketplace/actions/setup-go-environment
28
28
- name : Set up Go ${{ matrix.go-version }}
29
- uses : actions/setup-go@v4
29
+ uses : actions/setup-go@v5
30
30
with :
31
31
go-version : ${{ matrix.go-version }}
32
32
Original file line number Diff line number Diff line change 22
22
23
23
# https://github.com/marketplace/actions/setup-go-environment
24
24
- name : Set up Go ${{ env.GO_VERSION }}
25
- uses : actions/setup-go@v4
25
+ uses : actions/setup-go@v5
26
26
with :
27
27
go-version : ${{ env.GO_VERSION }}
28
28
Original file line number Diff line number Diff line change 1
- FROM golang:1.19 -alpine
1
+ FROM golang:1.22 -alpine
2
2
3
3
# cache buster
4
4
RUN echo 4
Original file line number Diff line number Diff line change 1
1
module github.com/golangci/misspell
2
2
3
- go 1.19
3
+ go 1.21
4
4
5
5
require github.com/gobwas/glob v0.2.3
Original file line number Diff line number Diff line change 7
7
"net/http"
8
8
"os"
9
9
"path/filepath"
10
+ "slices"
10
11
"strings"
11
12
)
12
13
@@ -77,13 +78,12 @@ func isSCMPath(s string) bool {
77
78
if strings .Contains (filepath .Base (s ), "EDITMSG" ) {
78
79
return false
79
80
}
81
+
80
82
parts := strings .Split (filepath .Clean (s ), string (filepath .Separator ))
81
- for _ , dir := range parts {
82
- if scm [dir ] {
83
- return true
84
- }
85
- }
86
- return false
83
+
84
+ return slices .ContainsFunc (parts , func (dir string ) bool {
85
+ return scm [dir ]
86
+ })
87
87
}
88
88
89
89
var magicHeaders = [][]byte {
Original file line number Diff line number Diff line change 5
5
"bytes"
6
6
"io"
7
7
"regexp"
8
+ "slices"
8
9
"strings"
9
10
"text/scanner"
10
11
)
@@ -17,12 +18,9 @@ func max(x, y int) int {
17
18
}
18
19
19
20
func inArray (haystack []string , needle string ) bool {
20
- for _ , word := range haystack {
21
- if strings .EqualFold (needle , word ) {
22
- return true
23
- }
24
- }
25
- return false
21
+ return slices .ContainsFunc (haystack , func (word string ) bool {
22
+ return strings .EqualFold (needle , word )
23
+ })
26
24
}
27
25
28
26
var wordRegexp = regexp .MustCompile (`[a-zA-Z0-9']+` )
@@ -192,7 +190,7 @@ Loop:
192
190
return buf .String (), diffs
193
191
}
194
192
195
- // Replace is corrects misspellings in input, returning corrected version along with a list of diffs.
193
+ // Replace is correcting misspellings in input, returning corrected version along with a list of diffs.
196
194
func (r * Replacer ) Replace (input string ) (string , []Diff ) {
197
195
output := r .engine .Replace (input )
198
196
if input == output {
Original file line number Diff line number Diff line change @@ -19,14 +19,16 @@ func (a sortByLen) Less(i, j int) bool {
19
19
return len (a [i ]) > len (a [j ])
20
20
}
21
21
22
- func TestWordSort (t * testing.T ) {
22
+ func Test_wordSort (t * testing.T ) {
23
23
if len (DictMain )% 2 == 1 {
24
24
t .Errorf ("Dictionary is a not a multiple of 2" )
25
25
}
26
+
26
27
words := make ([]string , 0 , len (DictMain )/ 2 )
27
28
for i := 0 ; i < len (DictMain ); i += 2 {
28
29
words = append (words , DictMain [i ])
29
30
}
31
+
30
32
if ! sort .IsSorted (sortByLen (words )) {
31
33
t .Errorf ("Words not sorted by len, by alpha!" )
32
34
t .Errorf ("Words.go is autogenerated -- do not edit." )
You can’t perform that action at this time.
0 commit comments