diff --git a/.golangci.yml b/.golangci.yml index 1be6b63ef3a9..342fe97837bf 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -5,6 +5,7 @@ linters: - depguard - dupl - errcheck + - forbidigo - gocritic # - gocyclo # The cyclomatic complexety of a lot of functions is too high, we should refactor those another time. - gofmt @@ -105,6 +106,9 @@ issues: - errcheck - dupl - gosec + - path: cmd + linters: + - forbidigo - linters: - dupl text: "webhook" diff --git a/Makefile b/Makefile index c94f36d6a92f..9291c4486572 100644 --- a/Makefile +++ b/Makefile @@ -278,8 +278,12 @@ clean: fmt: GOFUMPT_PACKAGE=$(GOFUMPT_PACKAGE) $(GO) run build/code-batch-process.go gitea-fmt -w '{file-list}' $(eval TEMPLATES := $(shell find templates -type f -name '*.tmpl')) - @# strip whitespace after '{{' and before `}}` unless there is only whitespace before it - @$(SED_INPLACE) -e 's/{{[ ]\{1,\}/{{/g' -e '/^[ ]\{1,\}}}/! s/[ ]\{1,\}}}/}}/g' $(TEMPLATES) + @# strip whitespace after '{{' or '(' and before '}}' or ')' unless there is only + @# whitespace before it + @$(SED_INPLACE) \ + -e 's/{{[ ]\{1,\}/{{/g' -e '/^[ ]\{1,\}}}/! s/[ ]\{1,\}}}/}}/g' \ + -e 's/([ ]\{1,\}/(/g' -e '/^[ ]\{1,\})/! s/[ ]\{1,\})/)/g' \ + $(TEMPLATES) .PHONY: fmt-check fmt-check: fmt diff --git a/contrib/backport/backport.go b/contrib/backport/backport.go index aa665ac2e15f..358f4ed3c814 100644 --- a/contrib/backport/backport.go +++ b/contrib/backport/backport.go @@ -1,6 +1,7 @@ // Copyright 2023 The Gitea Authors. All rights reserved. // SPDX-License-Identifier: MIT +//nolint:forbidigo package main import ( diff --git a/contrib/fixtures/fixture_generation.go b/contrib/fixtures/fixture_generation.go index 210e0aae0676..06c0354efa81 100644 --- a/contrib/fixtures/fixture_generation.go +++ b/contrib/fixtures/fixture_generation.go @@ -1,6 +1,7 @@ // Copyright 2020 The Gitea Authors. All rights reserved. // SPDX-License-Identifier: MIT +//nolint:forbidigo package main import ( diff --git a/docs/content/doc/contributing/guidelines-frontend.en-us.md b/docs/content/doc/contributing/guidelines-frontend.en-us.md index 36c88739ecb4..bde7d3151074 100644 --- a/docs/content/doc/contributing/guidelines-frontend.en-us.md +++ b/docs/content/doc/contributing/guidelines-frontend.en-us.md @@ -49,6 +49,7 @@ We recommend [Google HTML/CSS Style Guide](https://google.github.io/styleguide/h 9. Avoid unnecessary `!important` in CSS, add comments to explain why it's necessary if it can't be avoided. 10. Avoid mixing different events in one event listener, prefer to use individual event listeners for every event. 11. Custom event names are recommended to use `ce-` prefix. +12. Gitea's tailwind-style CSS classes use `gt-` prefix (`gt-relative`), while Gitea's own private framework-level CSS classes use `g-` prefix (`g-modal-confirm`). ### Accessibility / ARIA diff --git a/go.mod b/go.mod index 9f0a23f4550f..a71b136cb1f2 100644 --- a/go.mod +++ b/go.mod @@ -291,7 +291,7 @@ replace github.com/shurcooL/vfsgen => github.com/lunny/vfsgen v0.0.0-20220105142 replace github.com/blevesearch/zapx/v15 v15.3.6 => github.com/zeripath/zapx/v15 v15.3.6-alignment-fix -replace github.com/nektos/act => gitea.com/gitea/act v0.243.3-0.20230407083103-5c4a96bcb797 +replace github.com/nektos/act => gitea.com/gitea/act v0.243.4 exclude github.com/gofrs/uuid v3.2.0+incompatible diff --git a/go.sum b/go.sum index e48fa8b45b80..2a3cc5967e54 100644 --- a/go.sum +++ b/go.sum @@ -52,8 +52,8 @@ codeberg.org/gusted/mcaptcha v0.0.0-20220723083913-4f3072e1d570/go.mod h1:IIAjsi dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20220703122237-02e73435a078 h1:cliQ4HHsCo6xi2oWZYKWW4bly/Ory9FuTpFPRxj/mAg= git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20220703122237-02e73435a078/go.mod h1:g/V2Hjas6Z1UHUp4yIx6bATpNzJ7DYtD0FG3+xARWxs= -gitea.com/gitea/act v0.243.3-0.20230407083103-5c4a96bcb797 h1:QdQ+pHxpbIi2qsgZbYVxqYV7trfW3P5M/T4AfpoM7iw= -gitea.com/gitea/act v0.243.3-0.20230407083103-5c4a96bcb797/go.mod h1:mabw6AZAiDgxGlK83orWLrNERSPvgBJzEUS3S7u2bHI= +gitea.com/gitea/act v0.243.4 h1:MuBHBLCJfpa6mzwwvs4xqQynrSP2RRzpHpWfTV16PmI= +gitea.com/gitea/act v0.243.4/go.mod h1:mabw6AZAiDgxGlK83orWLrNERSPvgBJzEUS3S7u2bHI= gitea.com/go-chi/binding v0.0.0-20221013104517-b29891619681 h1:MMSPgnVULVwV9kEBgvyEUhC9v/uviZ55hPJEMjpbNR4= gitea.com/go-chi/binding v0.0.0-20221013104517-b29891619681/go.mod h1:77TZu701zMXWJFvB8gvTbQ92zQ3DQq/H7l5wAEjQRKc= gitea.com/go-chi/cache v0.0.0-20210110083709-82c4c9ce2d5e/go.mod h1:k2V/gPDEtXGjjMGuBJiapffAXTv76H4snSmlJRLUhH0= diff --git a/models/migrations/base/tests.go b/models/migrations/base/tests.go index 2f1b24664831..14f374f1a7c3 100644 --- a/models/migrations/base/tests.go +++ b/models/migrations/base/tests.go @@ -1,6 +1,7 @@ // Copyright 2022 The Gitea Authors. All rights reserved. // SPDX-License-Identifier: MIT +//nolint:forbidigo package base import ( diff --git a/models/migrations/v1_11/v112.go b/models/migrations/v1_11/v112.go index 3478ffe4498a..ff1f972204e7 100644 --- a/models/migrations/v1_11/v112.go +++ b/models/migrations/v1_11/v112.go @@ -31,7 +31,7 @@ func RemoveAttachmentMissedRepo(x *xorm.Engine) error { for i := 0; i < len(attachments); i++ { uuid := attachments[i].UUID if err = util.RemoveAll(filepath.Join(setting.Attachment.Path, uuid[0:1], uuid[1:2], uuid)); err != nil { - fmt.Printf("Error: %v", err) + fmt.Printf("Error: %v", err) //nolint:forbidigo } } diff --git a/models/unittest/fixtures.go b/models/unittest/fixtures.go index f7ee766731c2..c653ce1e38a1 100644 --- a/models/unittest/fixtures.go +++ b/models/unittest/fixtures.go @@ -1,6 +1,7 @@ // Copyright 2021 The Gitea Authors. All rights reserved. // SPDX-License-Identifier: MIT +//nolint:forbidigo package unittest import ( diff --git a/modules/doctor/paths.go b/modules/doctor/paths.go index d7bf2539e760..1558efc25b90 100644 --- a/modules/doctor/paths.go +++ b/modules/doctor/paths.go @@ -106,7 +106,7 @@ func isWritableDir(path string) error { return err } if err := os.Remove(tmpFile.Name()); err != nil { - fmt.Printf("Warning: can't remove temporary file: '%s'\n", tmpFile.Name()) + fmt.Printf("Warning: can't remove temporary file: '%s'\n", tmpFile.Name()) //nolint:forbidigo } tmpFile.Close() return nil diff --git a/modules/log/event.go b/modules/log/event.go index 5729e022bfe4..723c8810bc42 100644 --- a/modules/log/event.go +++ b/modules/log/event.go @@ -345,7 +345,7 @@ func (m *MultiChannelledLog) Start() { for _, logger := range m.loggers { err := logger.LogEvent(event) if err != nil { - fmt.Println(err) + fmt.Println(err) //nolint:forbidigo } } m.rwmutex.RUnlock() @@ -379,7 +379,7 @@ func (m *MultiChannelledLog) emptyQueue() bool { for _, logger := range m.loggers { err := logger.LogEvent(event) if err != nil { - fmt.Println(err) + fmt.Println(err) //nolint:forbidigo } } m.rwmutex.RUnlock() diff --git a/modules/queue/unique_queue_disk_channel_test.go b/modules/queue/unique_queue_disk_channel_test.go index e1a2132dd666..f75c69f78515 100644 --- a/modules/queue/unique_queue_disk_channel_test.go +++ b/modules/queue/unique_queue_disk_channel_test.go @@ -4,7 +4,6 @@ package queue import ( - "fmt" "strconv" "sync" "testing" @@ -17,7 +16,6 @@ import ( func TestPersistableChannelUniqueQueue(t *testing.T) { tmpDir := t.TempDir() - fmt.Printf("TempDir %s\n", tmpDir) _ = log.NewLogger(1000, "console", "console", `{"level":"warn","stacktracelevel":"NONE","stderr":true}`) // Common function to create the Queue diff --git a/modules/web/routing/logger_manager.go b/modules/web/routing/logger_manager.go index aa25ec3a2716..acd8c4b7dc99 100644 --- a/modules/web/routing/logger_manager.go +++ b/modules/web/routing/logger_manager.go @@ -31,7 +31,7 @@ const ( type Printer func(trigger Event, record *requestRecord) type requestRecordsManager struct { - print Printer + print Printer //nolint:forbidigo lock sync.Mutex diff --git a/templates/admin/auth/edit.tmpl b/templates/admin/auth/edit.tmpl index c39725699c40..0aed59ffabbd 100644 --- a/templates/admin/auth/edit.tmpl +++ b/templates/admin/auth/edit.tmpl @@ -436,7 +436,7 @@ -
{{.locale.Tr "repo.editor.commit_empty_file_text"}}
{{.locale.Tr "repo.editor.commit_empty_file_text"}}
{{.locale.Tr "settings.access_token_deletion_desc"}}
{{.locale.Tr "settings.gpg_helper" "https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/about-commit-signature-verification#gpg-commit-signature-verification" | Str2html}}
-{{.locale.Tr "settings.ssh_helper" "https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/connecting-to-github-with-ssh" "https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/troubleshooting-ssh" | Str2html}}
-