From 82d40296b08ecc906f311d1f611d8375848a92d2 Mon Sep 17 00:00:00 2001 From: silverwind Date: Fri, 8 May 2026 06:49:34 +0200 Subject: [PATCH] chore(deps): bump tool deps and pin, update `golangci-lint` (#37574) 1. Pin all makefile go deps to exact version, renovate will bump them in the future 2. Bump all deps and golangci-lint and fix all new issues, most are from modernize Signed-off-by: silverwind Co-authored-by: Claude (Opus 4.7) --- Makefile | 14 +++++++------- models/auth/source.go | 2 +- models/unittest/reflection.go | 2 +- modules/packages/rubygems/marshal.go | 2 +- modules/web/handler.go | 5 +++-- modules/web/middleware/binding.go | 4 ++-- services/cron/tasks.go | 2 +- services/gitdiff/highlightdiff.go | 4 ++-- services/issue/commit.go | 5 ++--- services/pull/pull.go | 4 ++-- services/repository/gitgraph/parser.go | 4 ++-- 11 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index 6f4a88f6d7..1087dc8410 100644 --- a/Makefile +++ b/Makefile @@ -11,15 +11,15 @@ COMMA := , XGO_VERSION := go-1.26.x -AIR_PACKAGE ?= github.com/air-verse/air@v1 # renovate: datasource=go -EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/v3/cmd/editorconfig-checker@v3 # renovate: datasource=go -GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.11.4 # renovate: datasource=go +AIR_PACKAGE ?= github.com/air-verse/air@v1.65.1 # renovate: datasource=go +EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/v3/cmd/editorconfig-checker@v3.6.1 # renovate: datasource=go +GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.12.2 # renovate: datasource=go GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.15 # renovate: datasource=go MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/misspell@v0.8.0 # renovate: datasource=go -SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@v0.33.1 # renovate: datasource=go -XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest -GOVULNCHECK_PACKAGE ?= golang.org/x/vuln/cmd/govulncheck@v1 # renovate: datasource=go -ACTIONLINT_PACKAGE ?= github.com/rhysd/actionlint/cmd/actionlint@v1.7.11 # renovate: datasource=go +SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@v0.33.2 # renovate: datasource=go +XGO_PACKAGE ?= src.techknowlogick.com/xgo@v1.9.0 # renovate: datasource=go +GOVULNCHECK_PACKAGE ?= golang.org/x/vuln/cmd/govulncheck@v1.3.0 # renovate: datasource=go +ACTIONLINT_PACKAGE ?= github.com/rhysd/actionlint/cmd/actionlint@v1.7.12 # renovate: datasource=go HAS_GO := $(shell hash $(GO) > /dev/null 2>&1 && echo yes) ifeq ($(HAS_GO), yes) diff --git a/models/auth/source.go b/models/auth/source.go index 7a008f08a8..16f36eb0c2 100644 --- a/models/auth/source.go +++ b/models/auth/source.go @@ -100,7 +100,7 @@ var registeredConfigs = map[Type]func() Config{} // RegisterTypeConfig register a config for a provided type func RegisterTypeConfig(typ Type, exemplar Config) { - if reflect.TypeOf(exemplar).Kind() == reflect.Ptr { + if reflect.TypeOf(exemplar).Kind() == reflect.Pointer { // Pointer: registeredConfigs[typ] = func() Config { return reflect.New(reflect.ValueOf(exemplar).Elem().Type()).Interface().(Config) diff --git a/models/unittest/reflection.go b/models/unittest/reflection.go index bc96a05973..47145d6c03 100644 --- a/models/unittest/reflection.go +++ b/models/unittest/reflection.go @@ -9,7 +9,7 @@ import ( ) func fieldByName(v reflect.Value, field string) reflect.Value { - if v.Kind() == reflect.Ptr { + if v.Kind() == reflect.Pointer { v = v.Elem() } f := v.FieldByName(field) diff --git a/modules/packages/rubygems/marshal.go b/modules/packages/rubygems/marshal.go index 1505221acc..bf7b7e2c53 100644 --- a/modules/packages/rubygems/marshal.go +++ b/modules/packages/rubygems/marshal.go @@ -91,7 +91,7 @@ func (e *MarshalEncoder) marshal(v any) error { val := reflect.ValueOf(v) typ := reflect.TypeOf(v) - if typ.Kind() == reflect.Ptr { + if typ.Kind() == reflect.Pointer { val = val.Elem() typ = typ.Elem() } diff --git a/modules/web/handler.go b/modules/web/handler.go index 46865d0f40..ce3b49eaef 100644 --- a/modules/web/handler.go +++ b/modules/web/handler.go @@ -9,6 +9,7 @@ import ( "net" "net/http" "reflect" + "slices" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/web/routing" @@ -131,8 +132,8 @@ type middlewareProvider = func(next http.Handler) http.Handler func executeMiddlewaresHandler(w http.ResponseWriter, r *http.Request, middlewares []middlewareProvider, endpoint http.HandlerFunc) { handler := endpoint - for i := len(middlewares) - 1; i >= 0; i-- { - handler = middlewares[i](handler).ServeHTTP + for _, middleware := range slices.Backward(middlewares) { + handler = middleware(handler).ServeHTTP } handler(w, r) } diff --git a/modules/web/middleware/binding.go b/modules/web/middleware/binding.go index 988beb47c5..85d8541081 100644 --- a/modules/web/middleware/binding.go +++ b/modules/web/middleware/binding.go @@ -29,7 +29,7 @@ func AssignForm(form any, data map[string]any) { typ := reflect.TypeOf(form) val := reflect.ValueOf(form) - for typ.Kind() == reflect.Ptr { + for typ.Kind() == reflect.Pointer { typ = typ.Elem() val = val.Elem() } @@ -104,7 +104,7 @@ func Validate(errs binding.Errors, data map[string]any, f Form, l translation.Lo data["ErrorMsg"] = l.TrString("form.unknown_error") typ := reflect.TypeOf(f) - if typ.Kind() == reflect.Ptr { + if typ.Kind() == reflect.Pointer { typ = typ.Elem() } diff --git a/services/cron/tasks.go b/services/cron/tasks.go index 4b0660d9e9..f64c44f46b 100644 --- a/services/cron/tasks.go +++ b/services/cron/tasks.go @@ -57,7 +57,7 @@ func (t *Task) IsEnabled() bool { // GetConfig will return a copy of the task's config func (t *Task) GetConfig() Config { - if reflect.TypeOf(t.config).Kind() == reflect.Ptr { + if reflect.TypeOf(t.config).Kind() == reflect.Pointer { // Pointer: return reflect.New(reflect.ValueOf(t.config).Elem().Type()).Interface().(Config) } diff --git a/services/gitdiff/highlightdiff.go b/services/gitdiff/highlightdiff.go index 1de3963788..0fb4e6a92b 100644 --- a/services/gitdiff/highlightdiff.go +++ b/services/gitdiff/highlightdiff.go @@ -6,6 +6,7 @@ package gitdiff import ( "bytes" "html/template" + "slices" "strings" "unicode/utf8" @@ -385,8 +386,7 @@ func (hcd *highlightCodeDiff) recoverOneDiff(str string) template.HTML { } // close all opening tags - for i := len(tagStack) - 1; i >= 0; i-- { - tagToClose := tagStack[i] + for _, tagToClose := range slices.Backward(tagStack) { // get the closing tag "" from "" or "" pos := strings.IndexAny(tagToClose, " >") // pos must be positive, because the tags were pushed by us diff --git a/services/issue/commit.go b/services/issue/commit.go index 68ccc906b6..93bfa78ae6 100644 --- a/services/issue/commit.go +++ b/services/issue/commit.go @@ -10,6 +10,7 @@ import ( "html" "net/url" "regexp" + "slices" "strconv" "strings" "time" @@ -123,9 +124,7 @@ func getIssueFromRef(ctx context.Context, repo *repo_model.Repository, index int // UpdateIssuesCommit checks if issues are manipulated by commit message. func UpdateIssuesCommit(ctx context.Context, doer *user_model.User, repo *repo_model.Repository, commits []*repository.PushCommit, branchName string) error { // Commits are appended in the reverse order. - for i := len(commits) - 1; i >= 0; i-- { - c := commits[i] - + for _, c := range slices.Backward(commits) { type markKey struct { ID int64 Action references.XRefAction diff --git a/services/pull/pull.go b/services/pull/pull.go index 3524b4d9bf..4f76df31da 100644 --- a/services/pull/pull.go +++ b/services/pull/pull.go @@ -9,6 +9,7 @@ import ( "fmt" "io" "regexp" + "slices" "strings" "time" "unicode/utf8" @@ -845,8 +846,7 @@ func GetSquashMergeCommitMessages(ctx context.Context, pr *issues_model.PullRequ // use PR's commit messages as squash commit message // commits list is in reverse chronological order maxMsgSize := setting.Repository.PullRequest.DefaultMergeMessageSize - for i := len(commits) - 1; i >= 0; i-- { - commit := commits[i] + for _, commit := range slices.Backward(commits) { msg := strings.TrimSpace(commit.MessageUTF8()) if msg == "" { continue diff --git a/services/repository/gitgraph/parser.go b/services/repository/gitgraph/parser.go index 859deff113..ca555218d4 100644 --- a/services/repository/gitgraph/parser.go +++ b/services/repository/gitgraph/parser.go @@ -6,6 +6,7 @@ package gitgraph import ( "bytes" "fmt" + "slices" ) // Parser represents a git graph parser. It is stateful containing the previous @@ -163,8 +164,7 @@ func (parser *Parser) ParseGlyphs(glyphs []byte) { // release unused colors parser.releaseUnusedColors() - for i := len(glyphs) - 1; i >= 0; i-- { - glyph := glyphs[i] + for i, glyph := range slices.Backward(glyphs) { switch glyph { case '|': fallthrough