From ef49d1bda53659d4e6693b3b60df8cea50539865 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sun, 5 Feb 2023 18:06:11 +0800 Subject: [PATCH 1/2] upgrade golangcilint to v1.51.0 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 20510bbec6ddb..ea7bc55c5d5ad 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ AIR_PACKAGE ?= github.com/cosmtrek/air@v1.40.4 EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/cmd/editorconfig-checker@2.5.0 ERRCHECK_PACKAGE ?= github.com/kisielk/errcheck@v1.6.1 GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.3.1 -GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.47.0 +GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.0 GXZ_PAGAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.10 MISSPELL_PACKAGE ?= github.com/client9/misspell/cmd/misspell@v0.3.4 SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@v0.30.0 From 8b4472c0093c165bfedef90ac51a7d9edba9bf6a Mon Sep 17 00:00:00 2001 From: techknowlogick Date: Tue, 7 Feb 2023 12:30:45 -0500 Subject: [PATCH 2/2] placate lint --- .golangci.yml | 3 +++ Makefile | 2 +- go.mod | 1 + go.sum | 3 ++- models/db/context.go | 6 ++++-- modules/log/groutinelabel.go | 2 +- modules/setting/setting.go | 2 +- routers/api/packages/pypi/pypi.go | 6 ++++-- 8 files changed, 17 insertions(+), 8 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 99133badd9b86..d252b20235906 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -173,3 +173,6 @@ issues: linters: - revive text: "exported: type name will be used as user.UserBadge by other packages, and that stutters; consider calling this Badge" + - path: models/db/sql_postgres_with_schema.go + linters: + - nolintlint diff --git a/Makefile b/Makefile index ea7bc55c5d5ad..a900eb1ac8cce 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ XGO_VERSION := go-1.19.x AIR_PACKAGE ?= github.com/cosmtrek/air@v1.40.4 EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/cmd/editorconfig-checker@2.5.0 ERRCHECK_PACKAGE ?= github.com/kisielk/errcheck@v1.6.1 -GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.3.1 +GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.4.0 GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.0 GXZ_PAGAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.10 MISSPELL_PACKAGE ?= github.com/client9/misspell/cmd/misspell@v0.3.4 diff --git a/go.mod b/go.mod index fa78018b55fe9..689444205e7cb 100644 --- a/go.mod +++ b/go.mod @@ -285,6 +285,7 @@ require ( go.uber.org/multierr v1.8.0 // indirect go.uber.org/zap v1.23.0 // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect + golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde // indirect golang.org/x/time v0.0.0-20220922220347-f3bd1da661af // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto v0.0.0-20220616135557-88e70c0c3a90 // indirect diff --git a/go.sum b/go.sum index 09a1a13fd7ec5..89c0997739724 100644 --- a/go.sum +++ b/go.sum @@ -1759,7 +1759,8 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw= +golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde h1:ejfdSekXMDxDLbRrJMwUk6KnSLZ2McaUCVcIKM+N6jc= +golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= diff --git a/models/db/context.go b/models/db/context.go index 4fd35200cf71c..0d8d0a5bc40d3 100644 --- a/models/db/context.go +++ b/models/db/context.go @@ -24,8 +24,10 @@ type contextKey struct { } // enginedContextKey is a context key. It is used with context.Value() to get the current Engined for the context -var enginedContextKey = &contextKey{"engined"} -var _ Engined = &Context{} +var ( + enginedContextKey = &contextKey{"engined"} + _ Engined = &Context{} +) // Context represents a db context type Context struct { diff --git a/modules/log/groutinelabel.go b/modules/log/groutinelabel.go index 0d3739fd98d7f..c83880f4de2f7 100644 --- a/modules/log/groutinelabel.go +++ b/modules/log/groutinelabel.go @@ -7,7 +7,7 @@ package log import "unsafe" //go:linkname runtime_getProfLabel runtime/pprof.runtime_getProfLabel -func runtime_getProfLabel() unsafe.Pointer // nolint +func runtime_getProfLabel() unsafe.Pointer //nolint type labelMap map[string]string diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 1eefa188c2e70..26a55c913b392 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -944,7 +944,7 @@ func loadFromConf(allowEmpty bool, extraConfig string) { if SecretKey == "" { // FIXME: https://github.com/go-gitea/gitea/issues/16832 // Until it supports rotating an existing secret key, we shouldn't move users off of the widely used default value - SecretKey = "!#@FDEWREWR&*(" // nolint:gosec + SecretKey = "!#@FDEWREWR&*(" //nolint:gosec } CookieRememberName = sec.Key("COOKIE_REMEMBER_NAME").MustString("gitea_incredible") diff --git a/routers/api/packages/pypi/pypi.go b/routers/api/packages/pypi/pypi.go index 2063fc37ce108..e6cc21799a70b 100644 --- a/routers/api/packages/pypi/pypi.go +++ b/routers/api/packages/pypi/pypi.go @@ -22,8 +22,10 @@ import ( ) // https://peps.python.org/pep-0426/#name -var normalizer = strings.NewReplacer(".", "-", "_", "-") -var nameMatcher = regexp.MustCompile(`\A(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\.\-_]*[a-zA-Z0-9])\z`) +var ( + normalizer = strings.NewReplacer(".", "-", "_", "-") + nameMatcher = regexp.MustCompile(`\A(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\.\-_]*[a-zA-Z0-9])\z`) +) // https://peps.python.org/pep-0440/#appendix-b-parsing-version-strings-with-regular-expressions var versionMatcher = regexp.MustCompile(`\Av?` +