From 13406e7aa789acc02960a422fb1a0c3e14166252 Mon Sep 17 00:00:00 2001 From: silverwind Date: Fri, 24 Jul 2026 23:47:23 +0200 Subject: [PATCH] chore: update and relax revive naming rules (#38615) - enable `skip-initialism-name-checks`, so names like `sessionUid` are allowed - replace removed `skip-package-name-checks` option with new `package-naming` with fitting rules for gitea - drop dead exclusion paths --- .golangci.yml | 10 ++++++---- modules/templates/util_json.go | 4 ++-- modules/templates/util_render.go | 2 +- modules/util/string.go | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index ba5090367e..819dead018 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -87,6 +87,11 @@ linters: - name: increment-decrement - name: modifies-value-receiver - name: package-comments + - name: package-naming + arguments: + - convention-name-check-regex: '^[a-z][a-z0-9_]*$' # underscores are used by migration packages + skip-default-bad-name-check: true + skip-collision-with-common-std: true - name: redefines-builtin-id - name: superfluous-else - name: time-naming @@ -96,7 +101,7 @@ linters: arguments: - [] # AllowList - do not remove as args for the rule are positional and won't work without lists first - [] # DenyList - - - skip-package-name-checks: true # supress errors from underscore in migration packages + - - skip-initialism-name-checks: true staticcheck: checks: - all @@ -158,9 +163,6 @@ linters: - .venv - public - web_src - - third_party$ - - builtin$ - - examples$ issues: max-issues-per-linter: 0 max-same-issues: 0 diff --git a/modules/templates/util_json.go b/modules/templates/util_json.go index 928d9c998e..eaa384cf78 100644 --- a/modules/templates/util_json.go +++ b/modules/templates/util_json.go @@ -9,11 +9,11 @@ import ( "gitea.dev/modules/json" ) -type JsonUtils struct{} //nolint:revive // variable naming triggers on Json, wants JSON +type JsonUtils struct{} var jsonUtils = JsonUtils{} -func NewJsonUtils() *JsonUtils { //nolint:revive // variable naming triggers on Json, wants JSON +func NewJsonUtils() *JsonUtils { return &jsonUtils } diff --git a/modules/templates/util_render.go b/modules/templates/util_render.go index 46f90be78a..43833034c2 100644 --- a/modules/templates/util_render.go +++ b/modules/templates/util_render.go @@ -186,7 +186,7 @@ func reactionToEmoji(reaction string) template.HTML { return template.HTML(fmt.Sprintf(`:%s:`, reaction, setting.StaticURLPrefix, url.PathEscape(reaction))) } -func (ut *RenderUtils) MarkdownToHtml(input string) template.HTML { //nolint:revive // variable naming triggers on Html, wants HTML +func (ut *RenderUtils) MarkdownToHtml(input string) template.HTML { output, err := markdown.RenderString(markup.NewRenderContext(ut.ctx).WithMetas(markup.ComposeSimpleDocumentMetas()), input) if err != nil { log.Error("RenderString: %v", err) diff --git a/modules/util/string.go b/modules/util/string.go index b9b59df3ef..a0cc71798a 100644 --- a/modules/util/string.go +++ b/modules/util/string.go @@ -120,7 +120,7 @@ func asciiLower(b byte) byte { // AsciiEqualFold is from Golang https://cs.opensource.google/go/go/+/refs/tags/go1.24.4:src/net/http/internal/ascii/print.go // ASCII only. In most cases for protocols, we should only use this but not [strings.EqualFold] -func AsciiEqualFold(s, t string) bool { //nolint:revive // PascalCase +func AsciiEqualFold(s, t string) bool { if len(s) != len(t) { return false }