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 12:25:06 +02:00
committed by GitHub
parent fac8bf2eca
commit 76a81b24f9
248 changed files with 1110 additions and 995 deletions
+1 -1
View File
@@ -251,7 +251,7 @@ func RunnersEditPost(ctx *context.Context) {
return
}
form := web.GetForm(ctx).(*forms.EditRunnerForm)
form := web.GetForm[*forms.EditRunnerForm](ctx)
runner.Description = form.Description
err = actions_model.UpdateRunner(ctx, runner, "description")
+2 -2
View File
@@ -122,7 +122,7 @@ func VariableCreate(ctx *context.Context) {
return
}
form := web.GetForm(ctx).(*forms.EditVariableForm)
form := web.GetForm[*forms.EditVariableForm](ctx)
v, err := actions_service.CreateVariable(ctx, vCtx.OwnerID, vCtx.RepoID, form.Name, form.Data, form.Description)
if err != nil {
@@ -154,7 +154,7 @@ func VariableUpdate(ctx *context.Context) {
return
}
form := web.GetForm(ctx).(*forms.EditVariableForm)
form := web.GetForm[*forms.EditVariableForm](ctx)
variable.Name = form.Name
variable.Data = form.Data
variable.Description = form.Description
+1 -1
View File
@@ -11,7 +11,7 @@ import (
)
func GetLabelEditForm(ctx *context.Context) *forms.CreateLabelForm {
form := web.GetForm(ctx).(*forms.CreateLabelForm)
form := web.GetForm[*forms.CreateLabelForm](ctx)
if ctx.HasError() {
ctx.JSONError(ctx.GetErrMsg())
return nil
+2 -2
View File
@@ -63,7 +63,7 @@ func PerformRuleEditPost(ctx *context.Context, owner *user_model.User, redirectU
return
}
form := web.GetForm(ctx).(*forms.PackageCleanupRuleForm)
form := web.GetForm[*forms.PackageCleanupRuleForm](ctx)
if form.Action == "remove" {
if err := packages_model.DeleteCleanupRuleByID(ctx, pcr.ID); err != nil {
@@ -85,7 +85,7 @@ func performRuleEditPost(ctx *context.Context, owner *user_model.User, pcr *pack
pcr = &packages_model.PackageCleanupRule{}
}
form := web.GetForm(ctx).(*forms.PackageCleanupRuleForm)
form := web.GetForm[*forms.PackageCleanupRuleForm](ctx)
pcr.Enabled = form.Enabled
pcr.OwnerID = owner.ID
+2 -2
View File
@@ -78,7 +78,7 @@ func MoveColumns(ctx *context.Context) {
}
func AddColumnToProjectPost(ctx *context.Context) {
form := web.GetForm(ctx).(*forms.EditProjectColumnForm)
form := web.GetForm[*forms.EditProjectColumnForm](ctx)
project := findProject(ctx)
if ctx.Written() {
return
@@ -98,7 +98,7 @@ func AddColumnToProjectPost(ctx *context.Context) {
}
func EditProjectColumn(ctx *context.Context) {
form := web.GetForm(ctx).(*forms.EditProjectColumnForm)
form := web.GetForm[*forms.EditProjectColumnForm](ctx)
_, column := findColumn(ctx)
if ctx.Written() {
return
+1 -1
View File
@@ -27,7 +27,7 @@ func SetSecretsContext(ctx *context.Context, ownerID, repoID int64) {
}
func PerformSecretsPost(ctx *context.Context, ownerID, repoID int64, redirectURL string) {
form := web.GetForm(ctx).(*forms.AddSecretForm)
form := web.GetForm[*forms.AddSecretForm](ctx)
s, _, err := secret_service.CreateOrUpdateSecret(ctx, ownerID, repoID, form.Name, util.NormalizeStringEOL(form.Data), form.Description)
if err != nil {
+1 -1
View File
@@ -66,7 +66,7 @@ func BlockedUsersPost(ctx *context.Context, blocker *user_model.User, redirect s
return
}
form := web.GetForm(ctx).(*forms.BlockUserForm)
form := web.GetForm[*forms.BlockUserForm](ctx)
err := blockedUsersPost(ctx, form, blocker)
if err == nil {
ctx.JSONRedirect(redirect)