mirror of
https://github.com/go-gitea/gitea
synced 2025-08-07 10:08:20 +00:00
Run gopls modernize
on codebase (#34751)
Recent modernize fixes: https://github.com/golang/tools/commits/master/gopls/internal/analysis/modernize
This commit is contained in:
@@ -5,6 +5,7 @@ package user
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"slices"
|
||||
|
||||
"code.gitea.io/gitea/models/db"
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
@@ -87,11 +88,8 @@ func CodeSearch(ctx *context.Context) {
|
||||
loadRepoIDs := make([]int64, 0, len(searchResults))
|
||||
for _, result := range searchResults {
|
||||
var find bool
|
||||
for _, id := range loadRepoIDs {
|
||||
if id == result.RepoID {
|
||||
find = true
|
||||
break
|
||||
}
|
||||
if slices.Contains(loadRepoIDs, result.RepoID) {
|
||||
find = true
|
||||
}
|
||||
if !find {
|
||||
loadRepoIDs = append(loadRepoIDs, result.RepoID)
|
||||
|
@@ -197,7 +197,7 @@ func Milestones(ctx *context.Context) {
|
||||
reposQuery = reposQuery[1 : len(reposQuery)-1]
|
||||
// for each ID (delimiter ",") add to int to repoIDs
|
||||
|
||||
for _, rID := range strings.Split(reposQuery, ",") {
|
||||
for rID := range strings.SplitSeq(reposQuery, ",") {
|
||||
// Ensure nonempty string entries
|
||||
if rID != "" && rID != "0" {
|
||||
rIDint64, err := strconv.ParseInt(rID, 10, 64)
|
||||
@@ -520,10 +520,7 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
|
||||
opts.IsClosed = optional.Some(isShowClosed)
|
||||
|
||||
// Make sure page number is at least 1. Will be posted to ctx.Data.
|
||||
page := ctx.FormInt("page")
|
||||
if page <= 1 {
|
||||
page = 1
|
||||
}
|
||||
page := max(ctx.FormInt("page"), 1)
|
||||
opts.Paginator = &db.ListOptions{
|
||||
Page: page,
|
||||
PageSize: setting.UI.IssuePagingNum,
|
||||
|
@@ -203,10 +203,7 @@ func NotificationPurgePost(ctx *context.Context) {
|
||||
|
||||
// NotificationSubscriptions returns the list of subscribed issues
|
||||
func NotificationSubscriptions(ctx *context.Context) {
|
||||
page := ctx.FormInt("page")
|
||||
if page < 1 {
|
||||
page = 1
|
||||
}
|
||||
page := max(ctx.FormInt("page"), 1)
|
||||
|
||||
sortType := ctx.FormString("sort")
|
||||
ctx.Data["SortType"] = sortType
|
||||
@@ -331,10 +328,7 @@ func NotificationSubscriptions(ctx *context.Context) {
|
||||
|
||||
// NotificationWatching returns the list of watching repos
|
||||
func NotificationWatching(ctx *context.Context) {
|
||||
page := ctx.FormInt("page")
|
||||
if page < 1 {
|
||||
page = 1
|
||||
}
|
||||
page := max(ctx.FormInt("page"), 1)
|
||||
|
||||
keyword := ctx.FormTrim("q")
|
||||
ctx.Data["Keyword"] = keyword
|
||||
|
@@ -46,10 +46,7 @@ func ListPackages(ctx *context.Context) {
|
||||
ctx.ServerError("RenderUserOrgHeader", err)
|
||||
return
|
||||
}
|
||||
page := ctx.FormInt("page")
|
||||
if page <= 1 {
|
||||
page = 1
|
||||
}
|
||||
page := max(ctx.FormInt("page"), 1)
|
||||
query := ctx.FormTrim("q")
|
||||
packageType := ctx.FormTrim("type")
|
||||
|
||||
@@ -320,10 +317,7 @@ func ListPackageVersions(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
page := ctx.FormInt("page")
|
||||
if page <= 1 {
|
||||
page = 1
|
||||
}
|
||||
page := max(ctx.FormInt("page"), 1)
|
||||
pagination := &db.ListOptions{
|
||||
PageSize: setting.UI.PackagesPagingNum,
|
||||
Page: page,
|
||||
|
Reference in New Issue
Block a user