chore: update golangci-lint to v2.13.0

Migrate the deprecated gofumpt `extra-rules` to `extra.group-params`, as
the alias now also enables the new `clothe-returns` and `balance-calls`
rules. Disable SA4023, which hangs on go 1.27, see
https://github.com/golangci/golangci-lint/issues/6732.

Apply the resulting modernize fixes, mostly flattening embedded struct
literals and switching errors.As to errors.AsType.

Assisted-by: Claude:Opus 5
This commit is contained in:
silverwind
2026-08-20 06:21:34 +02:00
parent b227ad8a5f
commit bef127f188
173 changed files with 1161 additions and 1659 deletions
+5 -7
View File
@@ -69,10 +69,8 @@ func testGetBadgeUsers(t *testing.T) {
// Test getting users with pagination
opts := &user_model.GetBadgeUsersOptions{
BadgeSlug: badge.Slug,
ListOptions: db.ListOptions{
Page: 1,
PageSize: 1,
},
Page: 1,
PageSize: 1,
}
users, count, err := user_model.GetBadgeUsers(t.Context(), opts)
@@ -140,9 +138,9 @@ func testSearchBadgesOrderingAndKeyword(t *testing.T) {
}
opts := &user_model.SearchBadgeOptions{
ListOptions: db.ListOptions{ListAll: true},
Keyword: "badge-sort-",
OrderBy: db.SearchOrderBy("`badge`.id ASC"),
ListAll: true,
Keyword: "badge-sort-",
OrderBy: db.SearchOrderBy("`badge`.id ASC"),
}
oldestFirst, count, err := user_model.SearchBadges(t.Context(), opts)
+3 -8
View File
@@ -7,7 +7,6 @@ import (
"slices"
"testing"
"gitea.dev/models/db"
"gitea.dev/models/unittest"
user_model "gitea.dev/models/user"
"gitea.dev/modules/optional"
@@ -92,9 +91,7 @@ func TestListEmails(t *testing.T) {
// Must find all users and their emails
opts := &user_model.SearchEmailOptions{
ListOptions: db.ListOptions{
PageSize: 10000,
},
PageSize: 10000,
}
emails, count, err := user_model.SearchEmails(t.Context(), opts)
assert.NoError(t, err)
@@ -138,10 +135,8 @@ func TestListEmails(t *testing.T) {
// Must find more than one page, but retrieve only one
opts = &user_model.SearchEmailOptions{
ListOptions: db.ListOptions{
PageSize: 5,
Page: 1,
},
PageSize: 5,
Page: 1,
}
emails, count, err = user_model.SearchEmails(t.Context(), opts)
assert.NoError(t, err)
+15 -15
View File
@@ -157,22 +157,22 @@ func TestSearchUsers(t *testing.T) {
testSuccess(opts, expectedOrgIDs)
}
testOrgSuccess(user_model.SearchUserOptions{OrderBy: "id ASC", ListOptions: db.ListOptions{Page: 1, PageSize: 2}},
testOrgSuccess(user_model.SearchUserOptions{OrderBy: "id ASC", Page: 1, PageSize: 2},
[]int64{3, 6})
testOrgSuccess(user_model.SearchUserOptions{OrderBy: "id ASC", ListOptions: db.ListOptions{Page: 2, PageSize: 2}},
testOrgSuccess(user_model.SearchUserOptions{OrderBy: "id ASC", Page: 2, PageSize: 2},
[]int64{7, 17})
testOrgSuccess(user_model.SearchUserOptions{OrderBy: "id ASC", ListOptions: db.ListOptions{Page: 3, PageSize: 2}},
testOrgSuccess(user_model.SearchUserOptions{OrderBy: "id ASC", Page: 3, PageSize: 2},
[]int64{19, 25})
testOrgSuccess(user_model.SearchUserOptions{OrderBy: "id ASC", ListOptions: db.ListOptions{Page: 4, PageSize: 2}},
testOrgSuccess(user_model.SearchUserOptions{OrderBy: "id ASC", Page: 4, PageSize: 2},
[]int64{26, 41})
testOrgSuccess(user_model.SearchUserOptions{OrderBy: "id ASC", ListOptions: db.ListOptions{Page: 5, PageSize: 2}},
testOrgSuccess(user_model.SearchUserOptions{OrderBy: "id ASC", Page: 5, PageSize: 2},
[]int64{42})
testOrgSuccess(user_model.SearchUserOptions{ListOptions: db.ListOptions{Page: 6, PageSize: 2}},
testOrgSuccess(user_model.SearchUserOptions{Page: 6, PageSize: 2},
[]int64{})
// test users
@@ -181,32 +181,32 @@ func TestSearchUsers(t *testing.T) {
testSuccess(opts, expectedUserIDs)
}
testUserSuccess(user_model.SearchUserOptions{OrderBy: "id ASC", ListOptions: db.ListOptions{Page: 1}},
testUserSuccess(user_model.SearchUserOptions{OrderBy: "id ASC", Page: 1},
[]int64{1, 2, 4, 5, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 20, 21, 24, 27, 28, 29, 30, 32, 34, 37, 38, 39, 40})
testUserSuccess(user_model.SearchUserOptions{ListOptions: db.ListOptions{Page: 1}, IsActive: optional.Some(false)},
testUserSuccess(user_model.SearchUserOptions{Page: 1, IsActive: optional.Some(false)},
[]int64{9})
testUserSuccess(user_model.SearchUserOptions{OrderBy: "id ASC", ListOptions: db.ListOptions{Page: 1}, IsActive: optional.Some(true)},
testUserSuccess(user_model.SearchUserOptions{OrderBy: "id ASC", Page: 1, IsActive: optional.Some(true)},
[]int64{1, 2, 4, 5, 8, 10, 11, 12, 13, 14, 15, 16, 18, 20, 21, 24, 27, 28, 29, 30, 32, 34, 37, 38, 39, 40})
testUserSuccess(user_model.SearchUserOptions{Keyword: "user1", OrderBy: "id ASC", ListOptions: db.ListOptions{Page: 1}, IsActive: optional.Some(true)},
testUserSuccess(user_model.SearchUserOptions{Keyword: "user1", OrderBy: "id ASC", Page: 1, IsActive: optional.Some(true)},
[]int64{1, 10, 11, 12, 13, 14, 15, 16, 18})
// order by name asc default
testUserSuccess(user_model.SearchUserOptions{Keyword: "user1", ListOptions: db.ListOptions{Page: 1}, IsActive: optional.Some(true)},
testUserSuccess(user_model.SearchUserOptions{Keyword: "user1", Page: 1, IsActive: optional.Some(true)},
[]int64{1, 10, 11, 12, 13, 14, 15, 16, 18})
testUserSuccess(user_model.SearchUserOptions{ListOptions: db.ListOptions{Page: 1}, IsAdmin: optional.Some(true)},
testUserSuccess(user_model.SearchUserOptions{Page: 1, IsAdmin: optional.Some(true)},
[]int64{1})
testUserSuccess(user_model.SearchUserOptions{ListOptions: db.ListOptions{Page: 1}, IsRestricted: optional.Some(true)},
testUserSuccess(user_model.SearchUserOptions{Page: 1, IsRestricted: optional.Some(true)},
[]int64{29})
testUserSuccess(user_model.SearchUserOptions{ListOptions: db.ListOptions{Page: 1}, IsProhibitLogin: optional.Some(true)},
testUserSuccess(user_model.SearchUserOptions{Page: 1, IsProhibitLogin: optional.Some(true)},
[]int64{37})
testUserSuccess(user_model.SearchUserOptions{ListOptions: db.ListOptions{Page: 1}, IsTwoFactorEnabled: optional.Some(true)},
testUserSuccess(user_model.SearchUserOptions{Page: 1, IsTwoFactorEnabled: optional.Some(true)},
[]int64{24})
}