mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-08 22:13:26 +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:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user