mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-21 12:13:38 +09:00
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:
@@ -326,7 +326,7 @@ func GiteaHooksEditPost(ctx *context.Context) {
|
||||
}
|
||||
|
||||
func giteaHookParams(ctx *context.Context) webhookParams {
|
||||
form := web.GetForm(ctx).(*forms.NewWebhookForm)
|
||||
form := web.GetForm[*forms.NewWebhookForm](ctx)
|
||||
|
||||
contentType := webhook.ContentTypeJSON
|
||||
if webhook.HookContentType(form.ContentType) == webhook.ContentTypeForm {
|
||||
@@ -353,7 +353,7 @@ func GogsHooksEditPost(ctx *context.Context) {
|
||||
}
|
||||
|
||||
func gogsHookParams(ctx *context.Context) webhookParams {
|
||||
form := web.GetForm(ctx).(*forms.NewGogshookForm)
|
||||
form := web.GetForm[*forms.NewGogshookForm](ctx)
|
||||
|
||||
contentType := webhook.ContentTypeJSON
|
||||
if webhook.HookContentType(form.ContentType) == webhook.ContentTypeForm {
|
||||
@@ -379,7 +379,7 @@ func DiscordHooksEditPost(ctx *context.Context) {
|
||||
}
|
||||
|
||||
func discordHookParams(ctx *context.Context) webhookParams {
|
||||
form := web.GetForm(ctx).(*forms.NewDiscordHookForm)
|
||||
form := web.GetForm[*forms.NewDiscordHookForm](ctx)
|
||||
|
||||
return webhookParams{
|
||||
Type: webhook_module.DISCORD,
|
||||
@@ -404,7 +404,7 @@ func DingtalkHooksEditPost(ctx *context.Context) {
|
||||
}
|
||||
|
||||
func dingtalkHookParams(ctx *context.Context) webhookParams {
|
||||
form := web.GetForm(ctx).(*forms.NewDingtalkHookForm)
|
||||
form := web.GetForm[*forms.NewDingtalkHookForm](ctx)
|
||||
|
||||
return webhookParams{
|
||||
Type: webhook_module.DINGTALK,
|
||||
@@ -425,7 +425,7 @@ func TelegramHooksEditPost(ctx *context.Context) {
|
||||
}
|
||||
|
||||
func telegramHookParams(ctx *context.Context) webhookParams {
|
||||
form := web.GetForm(ctx).(*forms.NewTelegramHookForm)
|
||||
form := web.GetForm[*forms.NewTelegramHookForm](ctx)
|
||||
|
||||
return webhookParams{
|
||||
Type: webhook_module.TELEGRAM,
|
||||
@@ -459,7 +459,7 @@ func matrixRoomIDEncode(roomID string) string {
|
||||
}
|
||||
|
||||
func matrixHookParams(ctx *context.Context) webhookParams {
|
||||
form := web.GetForm(ctx).(*forms.NewMatrixHookForm)
|
||||
form := web.GetForm[*forms.NewMatrixHookForm](ctx)
|
||||
|
||||
// TODO: need to migrate to the latest (v3) API: https://spec.matrix.org/v1.18/client-server-api/
|
||||
return webhookParams{
|
||||
@@ -487,7 +487,7 @@ func MSTeamsHooksEditPost(ctx *context.Context) {
|
||||
}
|
||||
|
||||
func mSTeamsHookParams(ctx *context.Context) webhookParams {
|
||||
form := web.GetForm(ctx).(*forms.NewMSTeamsHookForm)
|
||||
form := web.GetForm[*forms.NewMSTeamsHookForm](ctx)
|
||||
|
||||
return webhookParams{
|
||||
Type: webhook_module.MSTEAMS,
|
||||
@@ -508,7 +508,7 @@ func SlackHooksEditPost(ctx *context.Context) {
|
||||
}
|
||||
|
||||
func slackHookParams(ctx *context.Context) webhookParams {
|
||||
form := web.GetForm(ctx).(*forms.NewSlackHookForm)
|
||||
form := web.GetForm[*forms.NewSlackHookForm](ctx)
|
||||
|
||||
return webhookParams{
|
||||
Type: webhook_module.SLACK,
|
||||
@@ -535,7 +535,7 @@ func FeishuHooksEditPost(ctx *context.Context) {
|
||||
}
|
||||
|
||||
func feishuHookParams(ctx *context.Context) webhookParams {
|
||||
form := web.GetForm(ctx).(*forms.NewFeishuHookForm)
|
||||
form := web.GetForm[*forms.NewFeishuHookForm](ctx)
|
||||
|
||||
return webhookParams{
|
||||
Type: webhook_module.FEISHU,
|
||||
@@ -556,7 +556,7 @@ func WechatworkHooksEditPost(ctx *context.Context) {
|
||||
}
|
||||
|
||||
func wechatworkHookParams(ctx *context.Context) webhookParams {
|
||||
form := web.GetForm(ctx).(*forms.NewWechatWorkHookForm)
|
||||
form := web.GetForm[*forms.NewWechatWorkHookForm](ctx)
|
||||
|
||||
return webhookParams{
|
||||
Type: webhook_module.WECHATWORK,
|
||||
@@ -577,7 +577,7 @@ func PackagistHooksEditPost(ctx *context.Context) {
|
||||
}
|
||||
|
||||
func packagistHookParams(ctx *context.Context) webhookParams {
|
||||
form := web.GetForm(ctx).(*forms.NewPackagistHookForm)
|
||||
form := web.GetForm[*forms.NewPackagistHookForm](ctx)
|
||||
|
||||
return webhookParams{
|
||||
Type: webhook_module.PACKAGIST,
|
||||
|
||||
Reference in New Issue
Block a user