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
+6 -6
View File
@@ -252,7 +252,7 @@ func CreatePullReviewCommentReply(ctx *context.APIContext) {
// "422":
// "$ref": "#/responses/validationError"
opts := web.GetForm(ctx).(*api.CreatePullReviewCommentReplyOptions)
opts := web.GetForm[*api.CreatePullReviewCommentReplyOptions](ctx)
parent := getPullReviewCommentToResolve(ctx)
if parent == nil {
@@ -499,7 +499,7 @@ func CreatePullReview(ctx *context.APIContext) {
// "422":
// "$ref": "#/responses/validationError"
opts := web.GetForm(ctx).(*api.CreatePullReviewOptions)
opts := web.GetForm[*api.CreatePullReviewOptions](ctx)
pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("index"))
if err != nil {
ctx.APIErrorAuto(err)
@@ -622,7 +622,7 @@ func SubmitPullReview(ctx *context.APIContext) {
// "422":
// "$ref": "#/responses/validationError"
opts := web.GetForm(ctx).(*api.SubmitPullReviewOptions)
opts := web.GetForm[*api.SubmitPullReviewOptions](ctx)
review, pr, isWrong := prepareSingleReview(ctx)
if isWrong {
return
@@ -792,7 +792,7 @@ func CreateReviewRequests(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
opts := web.GetForm(ctx).(*api.PullReviewRequestOptions)
opts := web.GetForm[*api.PullReviewRequestOptions](ctx)
apiReviewRequest(ctx, *opts, true)
}
@@ -834,7 +834,7 @@ func DeleteReviewRequests(ctx *context.APIContext) {
// "$ref": "#/responses/forbidden"
// "404":
// "$ref": "#/responses/notFound"
opts := web.GetForm(ctx).(*api.PullReviewRequestOptions)
opts := web.GetForm[*api.PullReviewRequestOptions](ctx)
apiReviewRequest(ctx, *opts, false)
}
@@ -1014,7 +1014,7 @@ func DismissPullReview(ctx *context.APIContext) {
// "$ref": "#/responses/notFound"
// "422":
// "$ref": "#/responses/validationError"
opts := web.GetForm(ctx).(*api.DismissPullReviewOptions)
opts := web.GetForm[*api.DismissPullReviewOptions](ctx)
dismissReview(ctx, opts.Message, true, opts.Priors)
}