Skip to content

Commit

Permalink
chore: update Go, linter, and clean
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Feb 19, 2024
1 parent 8aceb42 commit 2cc38ac
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
env:
GO_VERSION: stable
GOLANGCI_LINT_VERSION: v1.55.2
GOLANGCI_LINT_VERSION: v1.56.2
CGO_ENABLED: 0

steps:
Expand All @@ -26,7 +26,7 @@ jobs:

# https://github.com/marketplace/actions/setup-go-environment
- name: Set up Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/go-cross.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:

# https://github.com/marketplace/actions/setup-go-environment
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:

# https://github.com/marketplace/actions/setup-go-environment
- name: Set up Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.19-alpine
FROM golang:1.22-alpine

# cache buster
RUN echo 4
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module github.com/golangci/misspell

go 1.19
go 1.21

require github.com/gobwas/glob v0.2.3
12 changes: 6 additions & 6 deletions mime.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"net/http"
"os"
"path/filepath"
"slices"
"strings"
)

Expand Down Expand Up @@ -77,13 +78,12 @@ func isSCMPath(s string) bool {
if strings.Contains(filepath.Base(s), "EDITMSG") {
return false
}

parts := strings.Split(filepath.Clean(s), string(filepath.Separator))
for _, dir := range parts {
if scm[dir] {
return true
}
}
return false

return slices.ContainsFunc(parts, func(dir string) bool {
return scm[dir]
})
}

var magicHeaders = [][]byte{
Expand Down
12 changes: 5 additions & 7 deletions replace.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"bytes"
"io"
"regexp"
"slices"
"strings"
"text/scanner"
)
Expand All @@ -17,12 +18,9 @@ func max(x, y int) int {
}

func inArray(haystack []string, needle string) bool {
for _, word := range haystack {
if strings.EqualFold(needle, word) {
return true
}
}
return false
return slices.ContainsFunc(haystack, func(word string) bool {
return strings.EqualFold(needle, word)
})
}

var wordRegexp = regexp.MustCompile(`[a-zA-Z0-9']+`)
Expand Down Expand Up @@ -192,7 +190,7 @@ Loop:
return buf.String(), diffs
}

// Replace is corrects misspellings in input, returning corrected version along with a list of diffs.
// Replace is correcting misspellings in input, returning corrected version along with a list of diffs.
func (r *Replacer) Replace(input string) (string, []Diff) {
output := r.engine.Replace(input)
if input == output {
Expand Down
4 changes: 3 additions & 1 deletion words_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ func (a sortByLen) Less(i, j int) bool {
return len(a[i]) > len(a[j])
}

func TestWordSort(t *testing.T) {
func Test_wordSort(t *testing.T) {
if len(DictMain)%2 == 1 {
t.Errorf("Dictionary is a not a multiple of 2")
}

words := make([]string, 0, len(DictMain)/2)
for i := 0; i < len(DictMain); i += 2 {
words = append(words, DictMain[i])
}

if !sort.IsSorted(sortByLen(words)) {
t.Errorf("Words not sorted by len, by alpha!")
t.Errorf("Words.go is autogenerated -- do not edit.")
Expand Down

0 comments on commit 2cc38ac

Please sign in to comment.