From aed16ec65641c374e7d2ef003b6d9d44906842ec Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 27 Apr 2024 12:03:33 +0200 Subject: [PATCH 01/16] Add `lint-go-gopls` --- Makefile | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 0cd6abb81e6d..5e9b06513760 100644 --- a/Makefile +++ b/Makefile @@ -213,6 +213,7 @@ help: @echo " - lint-go lint go files" @echo " - lint-go-fix lint go files and fix issues" @echo " - lint-go-vet lint go files with vet" + @echo " - lint-go-gopls lint go files with gopls" @echo " - lint-js lint js files" @echo " - lint-js-fix lint js files and fix issues" @echo " - lint-css lint css files" @@ -366,7 +367,7 @@ lint-frontend: lint-js lint-css lint-frontend-fix: lint-js-fix lint-css-fix .PHONY: lint-backend -lint-backend: lint-go lint-go-vet lint-editorconfig +lint-backend: lint-go lint-go-vet lint-go-gopls lint-editorconfig .PHONY: lint-backend-fix lint-backend-fix: lint-go-fix lint-go-vet lint-editorconfig @@ -424,7 +425,11 @@ lint-go-vet: @GOOS= GOARCH= $(GO) build code.gitea.io/gitea-vet @$(GO) vet -vettool=gitea-vet ./... -.PHONY: lint-editorconfig +.PHONY: lint-go-gopls +lint-go-gopls: + @echo "Running gopls..." + @gopls check $(GO_SOURCES_NO_BINDATA) + lint-editorconfig: @$(GO) run $(EDITORCONFIG_CHECKER_PACKAGE) $(EDITORCONFIG_FILES) From e86f46ba829b60e6884d33da35fd1ba17bbe5bcf Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 27 Apr 2024 12:19:02 +0200 Subject: [PATCH 02/16] use go run --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 5e9b06513760..6e067ad640c9 100644 --- a/Makefile +++ b/Makefile @@ -36,6 +36,7 @@ XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest GO_LICENSES_PACKAGE ?= github.com/google/go-licenses@v1 GOVULNCHECK_PACKAGE ?= golang.org/x/vuln/cmd/govulncheck@v1 ACTIONLINT_PACKAGE ?= github.com/rhysd/actionlint/cmd/actionlint@v1 +GOPLS_PACKAGE ?= go run golang.org/x/tools/gopls@v0.15 DOCKER_IMAGE ?= gitea/gitea DOCKER_TAG ?= latest @@ -428,7 +429,7 @@ lint-go-vet: .PHONY: lint-go-gopls lint-go-gopls: @echo "Running gopls..." - @gopls check $(GO_SOURCES_NO_BINDATA) + @$(GO) run $(GOPLS_PACKAGE) check $(GO_SOURCES_NO_BINDATA) lint-editorconfig: @$(GO) run $(EDITORCONFIG_CHECKER_PACKAGE) $(EDITORCONFIG_FILES) From 29774f7c849a3773735b48b038d9b2465ff063cb Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 27 Apr 2024 12:19:47 +0200 Subject: [PATCH 03/16] use exact version --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 6e067ad640c9..3f4d1db1346d 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,7 @@ XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest GO_LICENSES_PACKAGE ?= github.com/google/go-licenses@v1 GOVULNCHECK_PACKAGE ?= golang.org/x/vuln/cmd/govulncheck@v1 ACTIONLINT_PACKAGE ?= github.com/rhysd/actionlint/cmd/actionlint@v1 -GOPLS_PACKAGE ?= go run golang.org/x/tools/gopls@v0.15 +GOPLS_PACKAGE ?= go run golang.org/x/tools/gopls@v0.15.3 DOCKER_IMAGE ?= gitea/gitea DOCKER_TAG ?= latest From 2a7bd1a46bafacfaaaf4b0031ad08f19a067b142 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 27 Apr 2024 12:25:51 +0200 Subject: [PATCH 04/16] fix cmd --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3f4d1db1346d..78a1397937ec 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,7 @@ XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest GO_LICENSES_PACKAGE ?= github.com/google/go-licenses@v1 GOVULNCHECK_PACKAGE ?= golang.org/x/vuln/cmd/govulncheck@v1 ACTIONLINT_PACKAGE ?= github.com/rhysd/actionlint/cmd/actionlint@v1 -GOPLS_PACKAGE ?= go run golang.org/x/tools/gopls@v0.15.3 +GOPLS_PACKAGE ?= golang.org/x/tools/gopls@v0.15.3 DOCKER_IMAGE ?= gitea/gitea DOCKER_TAG ?= latest From 57287d7837a12dfa20e2b744c83f2d9d830a3102 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 27 Apr 2024 14:42:01 +0200 Subject: [PATCH 05/16] add to deps-tools --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 78a1397937ec..4e6f3df0bfb3 100644 --- a/Makefile +++ b/Makefile @@ -870,6 +870,7 @@ deps-tools: $(GO) install $(GO_LICENSES_PACKAGE) $(GO) install $(GOVULNCHECK_PACKAGE) $(GO) install $(ACTIONLINT_PACKAGE) + $(GO) install $(GOPLS_PACKAGE) node_modules: package-lock.json npm install --no-save From f7b0d9a975075c88430a6848abe619886bc3a63b Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 27 Apr 2024 18:49:29 +0200 Subject: [PATCH 06/16] run build before lint-backend --- .github/workflows/pull-compliance.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-compliance.yml b/.github/workflows/pull-compliance.yml index f89276fe82a1..b6d63d92725c 100644 --- a/.github/workflows/pull-compliance.yml +++ b/.github/workflows/pull-compliance.yml @@ -21,7 +21,7 @@ jobs: with: go-version-file: go.mod check-latest: true - - run: make deps-backend deps-tools + - run: make deps-backend deps-tools build - run: make lint-backend env: TAGS: bindata sqlite sqlite_unlock_notify From cab07abf55356828fd6b0ba673a4b6fee10525e2 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 27 Apr 2024 19:41:02 +0200 Subject: [PATCH 07/16] Revert "run build before lint-backend" This reverts commit f7b0d9a975075c88430a6848abe619886bc3a63b. --- .github/workflows/pull-compliance.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-compliance.yml b/.github/workflows/pull-compliance.yml index b6d63d92725c..f89276fe82a1 100644 --- a/.github/workflows/pull-compliance.yml +++ b/.github/workflows/pull-compliance.yml @@ -21,7 +21,7 @@ jobs: with: go-version-file: go.mod check-latest: true - - run: make deps-backend deps-tools build + - run: make deps-backend deps-tools - run: make lint-backend env: TAGS: bindata sqlite sqlite_unlock_notify From 922fa2c95494e2c8dcbf957cce861f20151985db Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 27 Apr 2024 21:06:52 +0200 Subject: [PATCH 08/16] add lint script --- Makefile | 4 ++-- tools/lint-go-gopls.sh | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100755 tools/lint-go-gopls.sh diff --git a/Makefile b/Makefile index 4e6f3df0bfb3..22fde833a4b8 100644 --- a/Makefile +++ b/Makefile @@ -428,8 +428,8 @@ lint-go-vet: .PHONY: lint-go-gopls lint-go-gopls: - @echo "Running gopls..." - @$(GO) run $(GOPLS_PACKAGE) check $(GO_SOURCES_NO_BINDATA) + @echo "Running gopls check..." + @GO=$(GO) GOPLS_PACKAGE=$(GOPLS_PACKAGE) tools/lint-go-gopls.sh $(GO_SOURCES_NO_BINDATA) lint-editorconfig: @$(GO) run $(EDITORCONFIG_CHECKER_PACKAGE) $(EDITORCONFIG_FILES) diff --git a/tools/lint-go-gopls.sh b/tools/lint-go-gopls.sh new file mode 100755 index 000000000000..9b17a52721f0 --- /dev/null +++ b/tools/lint-go-gopls.sh @@ -0,0 +1,17 @@ +#!/bin/bash +set -euo pipefail + +# lint all go files with 'gopls check' and look for lines starting with the +# current absolute path, indicating a error was found. This is neccessary +# because the tool does not set non-zero exit code when errors are found. +# ref: https://github.com/golang/go/issues/67078 +ERROR_LINES=$("$GO" run "$GOPLS_PACKAGE" check $@ | grep -P "^$PWD"); +NUM_ERRORS=$(echo "$ERROR_LINES" | wc -l) + +if [ "$NUM_ERRORS" -eq "0" ]; then + exit 0; +else + echo "$ERROR_LINES" + echo "Found $NUM_ERRORS 'gopls check' errors" + exit 1; +fi From 7e54674daf5fd635354742a96c360c9c76535ebd Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 27 Apr 2024 21:09:39 +0200 Subject: [PATCH 09/16] Update tools/lint-go-gopls.sh --- tools/lint-go-gopls.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/lint-go-gopls.sh b/tools/lint-go-gopls.sh index 9b17a52721f0..972870717277 100755 --- a/tools/lint-go-gopls.sh +++ b/tools/lint-go-gopls.sh @@ -5,7 +5,7 @@ set -euo pipefail # current absolute path, indicating a error was found. This is neccessary # because the tool does not set non-zero exit code when errors are found. # ref: https://github.com/golang/go/issues/67078 -ERROR_LINES=$("$GO" run "$GOPLS_PACKAGE" check $@ | grep -P "^$PWD"); +ERROR_LINES=$("$GO" run "$GOPLS_PACKAGE" check $@ | grep -E "^$PWD"); NUM_ERRORS=$(echo "$ERROR_LINES" | wc -l) if [ "$NUM_ERRORS" -eq "0" ]; then From 399be95ce5a81ac38b72aa16549c11217d89a953 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 27 Apr 2024 21:10:37 +0200 Subject: [PATCH 10/16] always run script in repo root --- tools/lint-go-gopls.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/lint-go-gopls.sh b/tools/lint-go-gopls.sh index 972870717277..f282ab2fbc24 100755 --- a/tools/lint-go-gopls.sh +++ b/tools/lint-go-gopls.sh @@ -1,6 +1,8 @@ #!/bin/bash set -euo pipefail +cd "$(dirname -- "${BASH_SOURCE[0]}")" && cd .. + # lint all go files with 'gopls check' and look for lines starting with the # current absolute path, indicating a error was found. This is neccessary # because the tool does not set non-zero exit code when errors are found. From 3c48b39b8c6db980f2586c463373dc0e8f0f53a6 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 27 Apr 2024 22:03:17 +0200 Subject: [PATCH 11/16] hide stderr --- tools/lint-go-gopls.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/lint-go-gopls.sh b/tools/lint-go-gopls.sh index f282ab2fbc24..d80b3b27f6f6 100755 --- a/tools/lint-go-gopls.sh +++ b/tools/lint-go-gopls.sh @@ -7,7 +7,7 @@ cd "$(dirname -- "${BASH_SOURCE[0]}")" && cd .. # current absolute path, indicating a error was found. This is neccessary # because the tool does not set non-zero exit code when errors are found. # ref: https://github.com/golang/go/issues/67078 -ERROR_LINES=$("$GO" run "$GOPLS_PACKAGE" check $@ | grep -E "^$PWD"); +ERROR_LINES=$("$GO" run "$GOPLS_PACKAGE" check $@ 2>/dev/null | grep -E "^$PWD"); NUM_ERRORS=$(echo "$ERROR_LINES" | wc -l) if [ "$NUM_ERRORS" -eq "0" ]; then From 03dd059c20ba470990844c65de117a5cd1c87c11 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 27 Apr 2024 22:30:08 +0200 Subject: [PATCH 12/16] add || true --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 22fde833a4b8..ec7972b299f7 100644 --- a/Makefile +++ b/Makefile @@ -429,7 +429,8 @@ lint-go-vet: .PHONY: lint-go-gopls lint-go-gopls: @echo "Running gopls check..." - @GO=$(GO) GOPLS_PACKAGE=$(GOPLS_PACKAGE) tools/lint-go-gopls.sh $(GO_SOURCES_NO_BINDATA) +# TODO: Fix all errors and remove '|| true' + @GO=$(GO) GOPLS_PACKAGE=$(GOPLS_PACKAGE) tools/lint-go-gopls.sh $(GO_SOURCES_NO_BINDATA) || true lint-editorconfig: @$(GO) run $(EDITORCONFIG_CHECKER_PACKAGE) $(EDITORCONFIG_FILES) From 29625cdcbceb457fde70939475b2220e640c60aa Mon Sep 17 00:00:00 2001 From: silverwind Date: Mon, 29 Apr 2024 19:41:44 +0200 Subject: [PATCH 13/16] add IGNORE_PATTERNS --- tools/lint-go-gopls.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/lint-go-gopls.sh b/tools/lint-go-gopls.sh index d80b3b27f6f6..e0bcd8fc2acf 100755 --- a/tools/lint-go-gopls.sh +++ b/tools/lint-go-gopls.sh @@ -3,11 +3,15 @@ set -euo pipefail cd "$(dirname -- "${BASH_SOURCE[0]}")" && cd .. +IGNORE_PATTERNS=( + "svc.IsAnInteractiveSession is deprecated" +) + # lint all go files with 'gopls check' and look for lines starting with the # current absolute path, indicating a error was found. This is neccessary # because the tool does not set non-zero exit code when errors are found. # ref: https://github.com/golang/go/issues/67078 -ERROR_LINES=$("$GO" run "$GOPLS_PACKAGE" check $@ 2>/dev/null | grep -E "^$PWD"); +ERROR_LINES=$("$GO" run "$GOPLS_PACKAGE" check $@ 2>/dev/null | grep -E "^$PWD" | grep -vFf <(printf '%s\n' "${IGNORE_PATTERNS[@]}")); NUM_ERRORS=$(echo "$ERROR_LINES" | wc -l) if [ "$NUM_ERRORS" -eq "0" ]; then From e278a0de6cc0fa9bba39a860ffb069cfe72c0f1d Mon Sep 17 00:00:00 2001 From: silverwind Date: Mon, 29 Apr 2024 19:57:55 +0200 Subject: [PATCH 14/16] ignore all deprecations --- tools/lint-go-gopls.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/lint-go-gopls.sh b/tools/lint-go-gopls.sh index e0bcd8fc2acf..aac57be602b8 100755 --- a/tools/lint-go-gopls.sh +++ b/tools/lint-go-gopls.sh @@ -4,7 +4,7 @@ set -euo pipefail cd "$(dirname -- "${BASH_SOURCE[0]}")" && cd .. IGNORE_PATTERNS=( - "svc.IsAnInteractiveSession is deprecated" + "is deprecated" ) # lint all go files with 'gopls check' and look for lines starting with the From 54a2ad6cf92b5a8cdd2794972f10d77c0658390d Mon Sep 17 00:00:00 2001 From: silverwind Date: Tue, 4 Jun 2024 20:51:46 +0200 Subject: [PATCH 15/16] fix remaining issues and sh --- Makefile | 4 ++-- services/migrations/migrate.go | 2 +- services/repository/transfer.go | 4 ++-- tests/integration/api_repo_tags_test.go | 4 ++-- tests/integration/dump_restore_test.go | 2 +- tests/integration/gpg_git_test.go | 6 +++--- tools/lint-go-gopls.sh | 8 ++++---- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 500dedddb913..d97360c9f49e 100644 --- a/Makefile +++ b/Makefile @@ -429,9 +429,9 @@ lint-go-vet: .PHONY: lint-go-gopls lint-go-gopls: @echo "Running gopls check..." -# TODO: Fix all errors and remove '|| true' - @GO=$(GO) GOPLS_PACKAGE=$(GOPLS_PACKAGE) tools/lint-go-gopls.sh $(GO_SOURCES_NO_BINDATA) || true + @GO=$(GO) GOPLS_PACKAGE=$(GOPLS_PACKAGE) tools/lint-go-gopls.sh $(GO_SOURCES_NO_BINDATA) +.PHONY: lint-editorconfig lint-editorconfig: @$(GO) run $(EDITORCONFIG_CHECKER_PACKAGE) $(EDITORCONFIG_FILES) diff --git a/services/migrations/migrate.go b/services/migrations/migrate.go index 5bb305616129..21bdc68e7320 100644 --- a/services/migrations/migrate.go +++ b/services/migrations/migrate.go @@ -176,7 +176,7 @@ func newDownloader(ctx context.Context, ownerName string, opts base.MigrateOptio // migrateRepository will download information and then upload it to Uploader, this is a simple // process for small repository. For a big repository, save all the data to disk // before upload is better -func migrateRepository(ctx context.Context, doer *user_model.User, downloader base.Downloader, uploader base.Uploader, opts base.MigrateOptions, messenger base.Messenger) error { +func migrateRepository(_ context.Context, doer *user_model.User, downloader base.Downloader, uploader base.Uploader, opts base.MigrateOptions, messenger base.Messenger) error { if messenger == nil { messenger = base.NilMessenger } diff --git a/services/repository/transfer.go b/services/repository/transfer.go index 3d0bce18d01d..9e0ff7ae1405 100644 --- a/services/repository/transfer.go +++ b/services/repository/transfer.go @@ -285,7 +285,7 @@ func transferOwnership(ctx context.Context, doer *user_model.User, newOwnerName } // changeRepositoryName changes all corresponding setting from old repository name to new one. -func changeRepositoryName(ctx context.Context, doer *user_model.User, repo *repo_model.Repository, newRepoName string) (err error) { +func changeRepositoryName(ctx context.Context, repo *repo_model.Repository, newRepoName string) (err error) { oldRepoName := repo.Name newRepoName = strings.ToLower(newRepoName) if err = repo_model.IsUsableRepoName(newRepoName); err != nil { @@ -347,7 +347,7 @@ func ChangeRepositoryName(ctx context.Context, doer *user_model.User, repo *repo // local copy's origin accordingly. repoWorkingPool.CheckIn(fmt.Sprint(repo.ID)) - if err := changeRepositoryName(ctx, doer, repo, newRepoName); err != nil { + if err := changeRepositoryName(ctx, repo, newRepoName); err != nil { repoWorkingPool.CheckOut(fmt.Sprint(repo.ID)) return err } diff --git a/tests/integration/api_repo_tags_test.go b/tests/integration/api_repo_tags_test.go index c6eeb404c02c..a7f021ca4fbf 100644 --- a/tests/integration/api_repo_tags_test.go +++ b/tests/integration/api_repo_tags_test.go @@ -42,7 +42,7 @@ func TestAPIRepoTags(t *testing.T) { assert.Equal(t, setting.AppURL+"user2/repo1/archive/v1.1.zip", tags[0].ZipballURL) assert.Equal(t, setting.AppURL+"user2/repo1/archive/v1.1.tar.gz", tags[0].TarballURL) - newTag := createNewTagUsingAPI(t, session, token, user.Name, repoName, "gitea/22", "", "nice!\nand some text") + newTag := createNewTagUsingAPI(t, token, user.Name, repoName, "gitea/22", "", "nice!\nand some text") resp = MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &tags) assert.Len(t, tags, 2) @@ -72,7 +72,7 @@ func TestAPIRepoTags(t *testing.T) { MakeRequest(t, req, http.StatusNotFound) } -func createNewTagUsingAPI(t *testing.T, session *TestSession, token, ownerName, repoName, name, target, msg string) *api.Tag { +func createNewTagUsingAPI(t *testing.T, token, ownerName, repoName, name, target, msg string) *api.Tag { urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/tags", ownerName, repoName) req := NewRequestWithJSON(t, "POST", urlStr, &api.CreateTagOption{ TagName: name, diff --git a/tests/integration/dump_restore_test.go b/tests/integration/dump_restore_test.go index bed245305447..47bb6f76e979 100644 --- a/tests/integration/dump_restore_test.go +++ b/tests/integration/dump_restore_test.go @@ -237,7 +237,7 @@ func (c *compareDump) assertLoadFiles(beforeFilename, afterFilename string, t re // // Given []Something{} create afterPtr, beforePtr []*Something{} // - sliceType := reflect.SliceOf(reflect.PtrTo(t.Elem())) + sliceType := reflect.SliceOf(reflect.PointerTo(t.Elem())) beforeSlice := reflect.MakeSlice(sliceType, 0, 10) beforePtr = reflect.New(beforeSlice.Type()) beforePtr.Elem().Set(beforeSlice) diff --git a/tests/integration/gpg_git_test.go b/tests/integration/gpg_git_test.go index 3ba4a5882cf9..047c049c7f45 100644 --- a/tests/integration/gpg_git_test.go +++ b/tests/integration/gpg_git_test.go @@ -35,7 +35,7 @@ func TestGPGGit(t *testing.T) { defer os.Setenv("GNUPGHOME", oldGNUPGHome) // Need to create a root key - rootKeyPair, err := importTestingKey(tmpDir, "gitea", "gitea@fake.local") + rootKeyPair, err := importTestingKey() if !assert.NoError(t, err, "importTestingKey") { return } @@ -262,7 +262,7 @@ func TestGPGGit(t *testing.T) { }) } -func crudActionCreateFile(t *testing.T, ctx APITestContext, user *user_model.User, from, to, path string, callback ...func(*testing.T, api.FileResponse)) func(*testing.T) { +func crudActionCreateFile(_ *testing.T, ctx APITestContext, user *user_model.User, from, to, path string, callback ...func(*testing.T, api.FileResponse)) func(*testing.T) { return doAPICreateFile(ctx, path, &api.CreateFileOptions{ FileOptions: api.FileOptions{ BranchName: from, @@ -281,7 +281,7 @@ func crudActionCreateFile(t *testing.T, ctx APITestContext, user *user_model.Use }, callback...) } -func importTestingKey(tmpDir, name, email string) (*openpgp.Entity, error) { +func importTestingKey() (*openpgp.Entity, error) { if _, _, err := process.GetManager().Exec("gpg --import tests/integration/private-testing.key", "gpg", "--import", "tests/integration/private-testing.key"); err != nil { return nil, err } diff --git a/tools/lint-go-gopls.sh b/tools/lint-go-gopls.sh index aac57be602b8..d9b7799be54f 100755 --- a/tools/lint-go-gopls.sh +++ b/tools/lint-go-gopls.sh @@ -1,18 +1,18 @@ #!/bin/bash -set -euo pipefail +set -uo pipefail cd "$(dirname -- "${BASH_SOURCE[0]}")" && cd .. IGNORE_PATTERNS=( - "is deprecated" + "is deprecated" # no alternatives for the matching cases ) # lint all go files with 'gopls check' and look for lines starting with the # current absolute path, indicating a error was found. This is neccessary # because the tool does not set non-zero exit code when errors are found. # ref: https://github.com/golang/go/issues/67078 -ERROR_LINES=$("$GO" run "$GOPLS_PACKAGE" check $@ 2>/dev/null | grep -E "^$PWD" | grep -vFf <(printf '%s\n' "${IGNORE_PATTERNS[@]}")); -NUM_ERRORS=$(echo "$ERROR_LINES" | wc -l) +ERROR_LINES=$("$GO" run "$GOPLS_PACKAGE" check "$@" 2>/dev/null | grep -E "^$PWD" | grep -vFf <(printf '%s\n' "${IGNORE_PATTERNS[@]}")); +NUM_ERRORS=$(echo -n "$ERROR_LINES" | wc -l) if [ "$NUM_ERRORS" -eq "0" ]; then exit 0; From 3c33cd6b385ddefbc950e24435b1c142aa8a386c Mon Sep 17 00:00:00 2001 From: silverwind Date: Tue, 4 Jun 2024 20:55:56 +0200 Subject: [PATCH 16/16] comment --- tools/lint-go-gopls.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/lint-go-gopls.sh b/tools/lint-go-gopls.sh index d9b7799be54f..4bb69f4c16c1 100755 --- a/tools/lint-go-gopls.sh +++ b/tools/lint-go-gopls.sh @@ -4,7 +4,7 @@ set -uo pipefail cd "$(dirname -- "${BASH_SOURCE[0]}")" && cd .. IGNORE_PATTERNS=( - "is deprecated" # no alternatives for the matching cases + "is deprecated" # TODO: fix these ) # lint all go files with 'gopls check' and look for lines starting with the