loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Update go tool dependencies, restructure lint targets (#24239)

- Update all tool dependencies to latest tag
- Remove unused errcheck, it is part of golangci-lint
- Include main.go in air
- Enable wastedassign again now that it's
[generics-compatible](https://github.com/golangci/golangci-lint/pull/3689)
- Restructured lint targets to new `lint-*` namespace

authored by

silverwind and committed by
GitHub
8dc6eabb 88201914

+88 -58
+2 -1
.air.toml
··· 5 5 cmd = "make backend" 6 6 bin = "gitea" 7 7 include_ext = ["go", "tmpl"] 8 + include_file = ["main.go"] 9 + include_dir = ["cmd", "models", "modules", "options", "routers", "services"] 8 10 exclude_dir = ["modules/git/tests", "services/gitdiff/testdata", "modules/avatar/testdata", "models/fixtures", "models/migrations/fixtures", "modules/migration/file_format_testdata", "modules/avatar/identicon/testdata"] 9 - include_dir = ["cmd", "models", "modules", "options", "routers", "services"] 10 11 exclude_regex = ["_test.go$", "_gen.go$"]
+1 -1
.drone.yml
··· 59 59 - name: lint-backend-windows 60 60 image: gitea/test_env:linux-1.20-amd64 # https://gitea.com/gitea/test-env 61 61 commands: 62 - - make golangci-lint-windows vet 62 + - make lint-go-windows lint-go-vet 63 63 environment: 64 64 GOPROXY: https://goproxy.io # proxy.golang.org is blocked in China, this proxy is not 65 65 GOSUMDB: sum.golang.org
+1 -1
.golangci.yml
··· 22 22 - unconvert 23 23 - unused 24 24 # - varcheck # deprecated - https://github.com/golangci/golangci-lint/issues/1841 25 - # - wastedassign # disabled - https://github.com/golangci/golangci-lint/issues/2649 25 + - wastedassign 26 26 enable-all: false 27 27 disable-all: true 28 28 fast: false
+71 -39
Makefile
··· 25 25 26 26 XGO_VERSION := go-1.20.x 27 27 28 - AIR_PACKAGE ?= github.com/cosmtrek/air@v1.40.4 29 - EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/cmd/editorconfig-checker@2.6.0 30 - ERRCHECK_PACKAGE ?= github.com/kisielk/errcheck@v1.6.2 31 - GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.4.0 32 - GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.2 33 - GXZ_PAGAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.10 28 + AIR_PACKAGE ?= github.com/cosmtrek/air@v1.43.0 29 + EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/cmd/editorconfig-checker@2.7.0 30 + GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.5.0 31 + GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.52.2 32 + GXZ_PAGAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.11 34 33 MISSPELL_PACKAGE ?= github.com/client9/misspell/cmd/misspell@v0.3.4 35 34 SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@v0.30.4 36 35 XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest 37 - GO_LICENSES_PACKAGE ?= github.com/google/go-licenses@v1.5.0 36 + GO_LICENSES_PACKAGE ?= github.com/google/go-licenses@v1.6.0 38 37 GOVULNCHECK_PACKAGE ?= golang.org/x/vuln/cmd/govulncheck@latest 39 38 40 39 DOCKER_IMAGE ?= gitea/gitea ··· 194 193 @echo " - deps-backend install backend dependencies" 195 194 @echo " - deps-tools install tool dependencies" 196 195 @echo " - lint lint everything" 196 + @echo " - lint-fix lint everything and fix issues" 197 197 @echo " - lint-frontend lint frontend files" 198 + @echo " - lint-frontend-fix lint frontend files and fix issues" 198 199 @echo " - lint-backend lint backend files" 200 + @echo " - lint-backend-fix lint backend files and fix issues" 201 + @echo " - lint-go lint go files" 202 + @echo " - lint-go-fix lint go files and fix issues" 203 + @echo " - lint-go-vet lint go files with vet" 204 + @echo " - lint-js lint js files" 205 + @echo " - lint-js-fix lint js files and fix issues" 206 + @echo " - lint-css lint css files" 207 + @echo " - lint-css-fix lint css files and fix issues" 199 208 @echo " - lint-md lint markdown files" 209 + @echo " - lint-swagger lint swagger files" 200 210 @echo " - checks run various consistency checks" 201 211 @echo " - checks-frontend check frontend files" 202 212 @echo " - checks-backend check backend files" ··· 214 224 @echo " - generate-manpage generate manpage" 215 225 @echo " - generate-swagger generate the swagger spec from code comments" 216 226 @echo " - swagger-validate check if the swagger spec is valid" 217 - @echo " - golangci-lint run golangci-lint linter" 218 227 @echo " - go-licenses regenerate go licenses" 219 - @echo " - vet examines Go source code and reports suspicious constructs" 220 228 @echo " - tidy run go mod tidy" 221 229 @echo " - test[\#TestSpecificName] run unit test" 222 230 @echo " - test-sqlite[\#TestSpecificName] run integration test for sqlite" ··· 286 294 misspell-check: 287 295 go run $(MISSPELL_PACKAGE) -error $(GO_DIRS) $(WEB_DIRS) 288 296 289 - .PHONY: vet 290 - vet: 291 - @echo "Running go vet..." 292 - @GOOS= GOARCH= $(GO) build code.gitea.io/gitea-vet 293 - @$(GO) vet -vettool=gitea-vet $(GO_PACKAGES) 294 - 295 297 .PHONY: $(TAGS_EVIDENCE) 296 298 $(TAGS_EVIDENCE): 297 299 @mkdir -p $(MAKE_EVIDENCE_DIR) ··· 324 326 $(GO) run $(SWAGGER_PACKAGE) validate './$(SWAGGER_SPEC)' 325 327 $(SED_INPLACE) '$(SWAGGER_SPEC_S_TMPL)' './$(SWAGGER_SPEC)' 326 328 327 - .PHONY: errcheck 328 - errcheck: 329 - @echo "Running errcheck..." 330 - $(GO) run $(ERRCHECK_PACKAGE) $(GO_PACKAGES) 331 - 332 329 .PHONY: checks 333 330 checks: checks-frontend checks-backend 334 331 ··· 341 338 .PHONY: lint 342 339 lint: lint-frontend lint-backend 343 340 341 + .PHONY: lint-fix 342 + lint-fix: lint-frontend-fix lint-backend-fix 343 + 344 344 .PHONY: lint-frontend 345 - lint-frontend: node_modules lint-md 345 + lint-frontend: lint-js lint-css lint-md lint-swagger 346 + 347 + .PHONY: lint-frontend-fix 348 + lint-frontend-fix: lint-js-fix lint-css-fix lint-md lint-swagger 349 + 350 + .PHONY: lint-backend 351 + lint-backend: lint-go lint-go-vet lint-editorconfig 352 + 353 + .PHONY: lint-backend-fix 354 + lint-backend-fix: lint-go-fix lint-go-vet lint-editorconfig 355 + 356 + .PHONY: lint-js 357 + lint-js: node_modules 346 358 npx eslint --color --max-warnings=0 --ext js,vue web_src/js build *.config.js docs/assets/js tests/e2e 359 + 360 + .PHONY: lint-js-fix 361 + lint-js-fix: node_modules 362 + npx eslint --color --max-warnings=0 --ext js,vue web_src/js build *.config.js docs/assets/js tests/e2e --fix 363 + 364 + .PHONY: lint-css 365 + lint-css: node_modules 347 366 npx stylelint --color --max-warnings=0 web_src/css 367 + 368 + .PHONY: lint-css-fix 369 + lint-css-fix: node_modules 370 + npx stylelint --color --max-warnings=0 web_src/css --fix 371 + 372 + .PHONY: lint-swagger 373 + lint-swagger: node_modules 348 374 npx spectral lint -q -F hint $(SWAGGER_SPEC) 349 375 350 376 .PHONY: lint-md 351 377 lint-md: node_modules 352 378 npx markdownlint docs *.md 353 379 354 - .PHONY: lint-backend 355 - lint-backend: golangci-lint vet editorconfig-checker 380 + .PHONY: lint-go 381 + lint-go: 382 + $(GO) run $(GOLANGCI_LINT_PACKAGE) run 383 + 384 + .PHONY: lint-go-fix 385 + lint-go-fix: 386 + $(GO) run $(GOLANGCI_LINT_PACKAGE) run --fix 387 + 388 + # workaround step for the lint-backend-windows CI task because 'go run' can not 389 + # have distinct GOOS/GOARCH for its build and run steps 390 + .PHONY: lint-go-windows 391 + lint-go-windows: 392 + @GOOS= GOARCH= $(GO) install $(GOLANGCI_LINT_PACKAGE) 393 + golangci-lint run 394 + 395 + .PHONY: lint-go-vet 396 + lint-go-vet: 397 + @echo "Running go vet..." 398 + @GOOS= GOARCH= $(GO) build code.gitea.io/gitea-vet 399 + @$(GO) vet -vettool=gitea-vet $(GO_PACKAGES) 400 + 401 + .PHONY: lint-editorconfig 402 + lint-editorconfig: 403 + $(GO) run $(EDITORCONFIG_CHECKER_PACKAGE) templates 356 404 357 405 .PHONY: watch 358 406 watch: ··· 843 891 deps-tools: 844 892 $(GO) install $(AIR_PACKAGE) 845 893 $(GO) install $(EDITORCONFIG_CHECKER_PACKAGE) 846 - $(GO) install $(ERRCHECK_PACKAGE) 847 894 $(GO) install $(GOFUMPT_PACKAGE) 848 895 $(GO) install $(GOLANGCI_LINT_PACKAGE) 849 896 $(GO) install $(GXZ_PAGAGE) ··· 941 988 @./gitea docs --man > man/man1/gitea.1 942 989 @gzip -9 man/man1/gitea.1 && echo man/man1/gitea.1.gz created 943 990 @#TODO A small script that formats config-cheat-sheet.en-us.md nicely for use as a config man page 944 - 945 - .PHONY: golangci-lint 946 - golangci-lint: 947 - $(GO) run $(GOLANGCI_LINT_PACKAGE) run 948 - 949 - # workaround step for the lint-backend-windows CI task because 'go run' can not 950 - # have distinct GOOS/GOARCH for its build and run steps 951 - .PHONY: golangci-lint-windows 952 - golangci-lint-windows: 953 - @GOOS= GOARCH= $(GO) install $(GOLANGCI_LINT_PACKAGE) 954 - golangci-lint run 955 - 956 - .PHONY: editorconfig-checker 957 - editorconfig-checker: 958 - $(GO) run $(EDITORCONFIG_CHECKER_PACKAGE) templates 959 991 960 992 .PHONY: docker 961 993 docker:
+3 -1
modules/charset/escape_stream.go
··· 47 47 // Text tells the next streamer there is a text 48 48 func (e *escapeStreamer) Text(data string) error { 49 49 sb := &strings.Builder{} 50 - pos, until, next := 0, 0, 0 50 + var until int 51 + var next int 52 + pos := 0 51 53 if len(data) > len(UTF8BOM) && data[:len(UTF8BOM)] == string(UTF8BOM) { 52 54 _, _ = sb.WriteString(data[:len(UTF8BOM)]) 53 55 pos = len(UTF8BOM)
+1 -1
modules/templates/util_dict.go
··· 108 108 return "<pre>dumpVar: only available in dev mode</pre>" 109 109 } 110 110 m, ok := dumpVarMarshalable(v, map[uintptr]bool{}) 111 - dumpStr := "" 111 + var dumpStr string 112 112 jsonBytes, err := json.MarshalIndent(m, "", " ") 113 113 if err != nil { 114 114 dumpStr = fmt.Sprintf("dumpVar: unable to marshal %T: %v", v, err)
+1 -1
modules/timeutil/since.go
··· 23 23 ) 24 24 25 25 func computeTimeDiffFloor(diff int64, lang translation.Locale) (int64, string) { 26 - diffStr := "" 26 + var diffStr string 27 27 switch { 28 28 case diff <= 0: 29 29 diff = 0
-1
modules/translation/i18n/localestore.go
··· 72 72 l.idxToMsgMap[idx] = key.Value() 73 73 } 74 74 } 75 - iniFile = nil 76 75 77 76 return nil 78 77 }
+1 -1
routers/common/markup.go
··· 20 20 21 21 // RenderMarkup renders markup text for the /markup and /markdown endpoints 22 22 func RenderMarkup(ctx *context.Context, mode, text, urlPrefix, filePath string, wiki bool) { 23 - markupType := "" 23 + var markupType string 24 24 relativePath := "" 25 25 26 26 if len(text) == 0 {
+4 -7
services/gitdiff/gitdiff_test.go
··· 520 520 Docker Pulls 521 521 + cut off 522 522 + cut off` 523 - result, err = ParsePatch(setting.Git.MaxGitDiffLines, setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles, strings.NewReader(diff), "") 523 + _, err = ParsePatch(setting.Git.MaxGitDiffLines, setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles, strings.NewReader(diff), "") 524 524 if err != nil { 525 525 t.Errorf("ParsePatch failed: %s", err) 526 526 } ··· 536 536 Docker Pulls 537 537 + cut off 538 538 + cut off` 539 - result, err = ParsePatch(setting.Git.MaxGitDiffLines, setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles, strings.NewReader(diff2), "") 539 + _, err = ParsePatch(setting.Git.MaxGitDiffLines, setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles, strings.NewReader(diff2), "") 540 540 if err != nil { 541 541 t.Errorf("ParsePatch failed: %s", err) 542 542 } 543 - println(result) 544 543 545 544 diff2a := `diff --git "a/A \\ B" b/A/B 546 545 --- "a/A \\ B" ··· 553 552 Docker Pulls 554 553 + cut off 555 554 + cut off` 556 - result, err = ParsePatch(setting.Git.MaxGitDiffLines, setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles, strings.NewReader(diff2a), "") 555 + _, err = ParsePatch(setting.Git.MaxGitDiffLines, setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles, strings.NewReader(diff2a), "") 557 556 if err != nil { 558 557 t.Errorf("ParsePatch failed: %s", err) 559 558 } 560 - println(result) 561 559 562 560 diff3 := `diff --git a/README.md b/README.md 563 561 --- a/README.md ··· 570 568 Docker Pulls 571 569 + cut off 572 570 + cut off` 573 - result, err = ParsePatch(setting.Git.MaxGitDiffLines, setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles, strings.NewReader(diff3), "") 571 + _, err = ParsePatch(setting.Git.MaxGitDiffLines, setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles, strings.NewReader(diff3), "") 574 572 if err != nil { 575 573 t.Errorf("ParsePatch failed: %s", err) 576 574 } 577 - println(result) 578 575 } 579 576 580 577 func setupDefaultDiff() *Diff {
+1 -1
tests/integration/api_packages_pub_test.go
··· 120 120 assert.NoError(t, err) 121 121 assert.Equal(t, int64(len(content)), pb.Size) 122 122 123 - resp = uploadFile(t, result.URL, content, http.StatusBadRequest) 123 + _ = uploadFile(t, result.URL, content, http.StatusBadRequest) 124 124 }) 125 125 126 126 t.Run("Download", func(t *testing.T) {
+2 -3
tests/integration/api_repo_test.go
··· 183 183 for _, testCase := range testCases { 184 184 t.Run(testCase.name, func(t *testing.T) { 185 185 for userToLogin, expected := range testCase.expectedResults { 186 - var session *TestSession 187 186 var testName string 188 187 var userID int64 189 188 var token string 190 189 if userToLogin != nil && userToLogin.ID > 0 { 191 190 testName = fmt.Sprintf("LoggedUser%d", userToLogin.ID) 192 - session = loginUser(t, userToLogin.Name) 191 + session := loginUser(t, userToLogin.Name) 193 192 token = getTokenForLoggedInUser(t, session) 194 193 userID = userToLogin.ID 195 194 } else { 196 195 testName = "AnonymousUser" 197 - session = emptyTestSession(t) 196 + _ = emptyTestSession(t) 198 197 } 199 198 200 199 t.Run(testName, func(t *testing.T) {