chore: enable forcetypeassert linter, fix issues (#38804)

Enable [`forcetypeassert`](https://github.com/gostaticanalysis/forcetypeassert)
linter to prevent unchecked type assertions. ~650 issues fixed, most
fixes were clean, some use `setting.PanicInDevOrTesting`.

The only behaviour changes are where code would previously send a 500 error
or panic, a 4xx error is now emitted.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
silverwind
2026-08-09 10:25:06 +00:00
committed by GitHub
co-authored by wxiaoguang
parent fac8bf2eca
commit 76a81b24f9
248 changed files with 1110 additions and 995 deletions
+10 -3
View File
@@ -10,6 +10,7 @@ import (
api "gitea.dev/modules/structs"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestWithScheduleInEventPayload(t *testing.T) {
@@ -49,9 +50,15 @@ func TestWithScheduleInEventPayload(t *testing.T) {
event := map[string]any{}
assert.NoError(t, json.Unmarshal([]byte(updated), &event))
assert.Equal(t, "@weekly", event["schedule"])
assert.Equal(t, "test-repo", event["repository"].(map[string]any)["name"])
assert.Equal(t, "test-user", event["sender"].(map[string]any)["login"])
assert.Equal(t, "test-org", event["organization"].(map[string]any)["name"])
repository, ok := event["repository"].(map[string]any)
require.True(t, ok)
assert.Equal(t, "test-repo", repository["name"])
sender, ok := event["sender"].(map[string]any)
require.True(t, ok)
assert.Equal(t, "test-user", sender["login"])
organization, ok := event["organization"].(map[string]any)
require.True(t, ok)
assert.Equal(t, "test-org", organization["name"])
})
t.Run("keeps payload when schedule empty", func(t *testing.T) {