Skip to content

Commit

Permalink
chore: update Go and golangci
Browse files Browse the repository at this point in the history
  • Loading branch information
jdkato committed Oct 9, 2024
1 parent 7064a62 commit 40d7e72
Show file tree
Hide file tree
Showing 16 changed files with 28 additions and 27 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-go@v4
with:
go-version: "1.21"
go-version: "1.23"
cache: false

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Require: The version of golangci-lint to use.
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
version: v1.54
version: v1.61

# Optional: working directory, useful for monorepos
# working-directory: somedir
Expand All @@ -44,10 +46,10 @@ jobs:
# skip-cache: true

# Optional: if set to true, then the action won't cache or restore ~/go/pkg.
# skip-pkg-cache: true
skip-pkg-cache: true

# Optional: if set to true, then the action won't cache or restore ~/.cache/go-build.
# skip-build-cache: true
skip-build-cache: true

# Optional: The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
# install-mode: "goinstall"
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: "1.21"
go-version: "1.23"

- name: Setup release environment
run: |-
Expand Down
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
image: golang:1.21
image: golang:1.23

stages:
- test
Expand Down
3 changes: 1 addition & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
run:
timeout: 3m
go: "1.20"
go: "1.23"

# This file contains only configs which differ from defaults.
# All possible options can be found here https://github.com/golangci/golangci-lint/blob/master/.golangci.reference.yml
Expand Down Expand Up @@ -79,7 +79,6 @@ linters:
- errname
- errorlint
- exhaustive
- exportloopref
- gocritic
- goimports
- gomoddirectives
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ clone_folder: c:\GOPATH\src\github.com\errata-ai\vale
environment:
GOPATH: c:\GOPATH
GOROOT: C:\go
GOVERSION: 1.21.0
GOVERSION: 1.23.0
# tree-sitter
CGO_ENABLED: 1
CC: C:\msys64\mingw64\bin\gcc.exe
Expand Down
2 changes: 1 addition & 1 deletion cmd/vale/color.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func printVerboseAlert(f *core.File, wrap bool) (int, int, int) {
table.SetRowSeparator("")
table.SetAutoWrapText(!wrap)

fmt.Printf("\n %s", pterm.Underscore.Sprintf(f.Path))
fmt.Printf("\n %s", pterm.Underscore.Sprint(f.Path))
for _, a := range alerts {
switch a.Severity {
case "suggestion":
Expand Down
2 changes: 1 addition & 1 deletion cmd/vale/funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func init() {
return pterm.Yellow(s)
}
funcs["underline"] = func(s string) string {
return pterm.Underscore.Sprintf(s)
return pterm.Underscore.Sprint(s)
}
funcs["newTable"] = func(wrap bool) *tablewriter.Table {
table := tablewriter.NewWriter(os.Stdout)
Expand Down
6 changes: 3 additions & 3 deletions cmd/vale/native.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,11 @@ func writeNativeConfig() (string, error) {
return "", err
}

return cfgFile, os.WriteFile(cfgFile, jsonCfg, os.ModePerm)
return cfgFile, os.WriteFile(cfgFile, jsonCfg, 0600)
}

func installNativeHostUnix(manifestData []byte, manifestFile string) error {
err := os.WriteFile(manifestFile, manifestData, os.ModePerm)
err := os.WriteFile(manifestFile, manifestData, 0600)
if err != nil {
return err
}
Expand All @@ -195,7 +195,7 @@ func installNativeHostWindows(manifestData []byte, manifestFile, browser string)
}
subdir := filepath.Join(manifestDir, manifestFile)

err = os.WriteFile(subdir, manifestData, os.ModePerm)
err = os.WriteFile(subdir, manifestData, 0600)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/errata-ai/vale/v3

go 1.21.6
go 1.23.2

require (
github.com/Masterminds/sprig/v3 v3.2.3
Expand Down
4 changes: 2 additions & 2 deletions internal/check/existence_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestExistence(t *testing.T) {

func FuzzExistenceInit(f *testing.F) {
f.Add("hello")
f.Fuzz(func(t *testing.T, s string) {
f.Fuzz(func(_ *testing.T, s string) {
_, _ = makeExistence([]string{s})
})
}
Expand All @@ -69,7 +69,7 @@ func FuzzExistence(f *testing.F) {
}

f.Add("hello")
f.Fuzz(func(t *testing.T, s string) {
f.Fuzz(func(_ *testing.T, s string) {
_, _ = rule.Run(nlp.NewBlock("", s, ""), file, cfg)
})
}
4 changes: 2 additions & 2 deletions internal/core/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func TestFindAssetDefault(t *testing.T) {
}
target := filepath.Join(expected, "tmp.tmpl")

err = os.WriteFile(target, []byte{}, os.ModePerm)
err = os.WriteFile(target, []byte{}, 0600)
if err != nil {
t.Fatal("Failed to create file", err)
}
Expand Down Expand Up @@ -105,7 +105,7 @@ func TestFallbackToDefault(t *testing.T) {
}
target := filepath.Join(expected, "tmp.tmpl")

err = os.WriteFile(target, []byte{}, os.ModePerm)
err = os.WriteFile(target, []byte{}, 0600)
if err != nil {
t.Fatal("Failed to create file", err)
}
Expand Down
6 changes: 3 additions & 3 deletions internal/core/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func annotate(file []byte, target string, finder errorCondition) (lineError, err
func NewError(code, title, msg string) error {
return fmt.Errorf(
"%s %s\n\n%s\n\n%s",
pterm.BgRed.Sprintf(code),
pterm.BgRed.Sprint(code),
title,
msg,
pterm.Fuzzy.Sprint(pterm.Italic.Sprintf("Execution stopped with code 1.")),
Expand Down Expand Up @@ -125,7 +125,7 @@ func NewE201FromTarget(msg, value, file string) error {
msg,
value,
file,
func(position int, line, target string) bool {
func(_ int, line, target string) bool {
return strings.Contains(line, target)
})
}
Expand All @@ -136,7 +136,7 @@ func NewE201FromPosition(msg, file string, goal int) error {
msg,
"",
file,
func(position int, line, target string) bool {
func(position int, _, _ string) bool {
return position == goal
})
}
2 changes: 1 addition & 1 deletion internal/glob/glob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestGlob(t *testing.T) {
for _, tc := range tt.tests {
test := fmt.Sprintf("%s -> %s", tt.pattern, tc.query)
if tc.match != g.Match(tc.query) {
t.Errorf(test)
t.Error(test)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/lint/code/comments_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestComments(t *testing.T) {
markup := toJSON(comments)
if markup != string(b2) {
bin := filepath.Join(binDir, fmt.Sprintf("%d.json", i))
_ = os.WriteFile(bin, []byte(markup), os.ModePerm)
_ = os.WriteFile(bin, []byte(markup), 0600)
t.Errorf("%s", markup)
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/lint/dita.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (l Linter) lintDITA(file *core.File) error {
}

targetFileName := strings.TrimSuffix(filepath.Base(file.Path), filepath.Ext(file.Path)) + ".html"
_ = filepath.WalkDir(tempDir, func(fp string, de os.DirEntry, err error) error {
_ = filepath.WalkDir(tempDir, func(fp string, de os.DirEntry, _ error) error {
// Find .html file, also looking in subdirectories in case an
// "outer" file was referenced in the DITA file, which is allowed
// because of the outer.control option of the dita command.
Expand Down
4 changes: 2 additions & 2 deletions internal/lint/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ func (l *Linter) lintBlock(f *core.File, blk nlp.Block, lines, pad int, lookup b
}

func (l *Linter) shouldRun(name string, f *core.File, chk check.Rule, blk nlp.Block) bool {
min := l.Manager.Config.MinAlertLevel
minLevel := l.Manager.Config.MinAlertLevel
run := false

details := chk.Fields()
Expand All @@ -303,7 +303,7 @@ func (l *Linter) shouldRun(name string, f *core.File, chk check.Rule, blk nlp.Bl
if f.QueryComments(name) { //nolint:gocritic
// It has been disabled via an in-text comment.
return false
} else if core.LevelToInt[details.Level] < min {
} else if core.LevelToInt[details.Level] < minLevel {
return false
} else if !chkScope.Matches(blk) {
return false
Expand Down

0 comments on commit 40d7e72

Please sign in to comment.