From 9d906f416ad419308f21f80efba87971cde03319 Mon Sep 17 00:00:00 2001 From: Joseph Kato Date: Wed, 9 Oct 2024 14:35:23 -0700 Subject: [PATCH] chore: update Go and golangci --- .github/workflows/golangci-lint.yml | 11 +++++++---- .github/workflows/main.yml | 2 +- .golangci.yml | 3 +-- cmd/vale/color.go | 2 +- cmd/vale/funcs.go | 2 +- cmd/vale/native.go | 6 +++--- go.mod | 2 +- internal/check/existence_test.go | 4 ++-- internal/core/config_test.go | 4 ++-- internal/core/error.go | 6 +++--- internal/glob/glob_test.go | 2 +- internal/lint/dita.go | 2 +- internal/lint/lint.go | 4 ++-- 13 files changed, 26 insertions(+), 24 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 266f3952..8b9d2e01 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -15,17 +15,20 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + - uses: actions/setup-go@v4 with: - go-version: "1.21" + go-version: "1.22" cache: false + - name: golangci-lint uses: golangci/golangci-lint-action@v3 with: + skip-go-installation: true # 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 @@ -44,10 +47,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" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3ba3bebf..b265a06f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,7 +14,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: "1.21" + go-version: "1.22" - name: Setup release environment run: |- diff --git a/.golangci.yml b/.golangci.yml index c3187b4f..c3b763f2 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,6 +1,6 @@ run: timeout: 3m - go: "1.20" + go: "1.22" # 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 @@ -79,7 +79,6 @@ linters: - errname - errorlint - exhaustive - - exportloopref - gocritic - goimports - gomoddirectives diff --git a/cmd/vale/color.go b/cmd/vale/color.go index 4e972b3e..2818fb7a 100755 --- a/cmd/vale/color.go +++ b/cmd/vale/color.go @@ -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": diff --git a/cmd/vale/funcs.go b/cmd/vale/funcs.go index 0199a4dd..ad9900d7 100644 --- a/cmd/vale/funcs.go +++ b/cmd/vale/funcs.go @@ -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) diff --git a/cmd/vale/native.go b/cmd/vale/native.go index 690c4d65..025bf3be 100644 --- a/cmd/vale/native.go +++ b/cmd/vale/native.go @@ -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 } @@ -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 } diff --git a/go.mod b/go.mod index b8152d60..eabaf108 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/internal/check/existence_test.go b/internal/check/existence_test.go index 243e1a33..340018b5 100644 --- a/internal/check/existence_test.go +++ b/internal/check/existence_test.go @@ -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}) }) } @@ -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) }) } diff --git a/internal/core/config_test.go b/internal/core/config_test.go index 9a86cc37..905f00f4 100644 --- a/internal/core/config_test.go +++ b/internal/core/config_test.go @@ -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) } @@ -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) } diff --git a/internal/core/error.go b/internal/core/error.go index 2f0b3eda..fd357354 100644 --- a/internal/core/error.go +++ b/internal/core/error.go @@ -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.")), @@ -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) }) } @@ -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 }) } diff --git a/internal/glob/glob_test.go b/internal/glob/glob_test.go index 65761540..b3b20973 100644 --- a/internal/glob/glob_test.go +++ b/internal/glob/glob_test.go @@ -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) } } } diff --git a/internal/lint/dita.go b/internal/lint/dita.go index 67f6f17e..2c6ef5fb 100644 --- a/internal/lint/dita.go +++ b/internal/lint/dita.go @@ -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. diff --git a/internal/lint/lint.go b/internal/lint/lint.go index 66c9a5b6..7c56da22 100755 --- a/internal/lint/lint.go +++ b/internal/lint/lint.go @@ -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() @@ -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