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
+1 -1
View File
@@ -170,7 +170,7 @@ func ToBranchProtection(ctx context.Context, bp *git_model.ProtectedBranch, repo
}
return &api.BranchProtection{
BranchName: branchName,
BranchName: branchName, //nolint:staticcheck // deprecated field
RuleName: bp.RuleName,
Priority: bp.Priority,
EnablePush: bp.CanPush,
+9 -15
View File
@@ -20,11 +20,9 @@ import (
// ToCommitUser convert a git.Signature to an api.CommitUser
func ToCommitUser(sig *git.Signature) *api.CommitUser {
return &api.CommitUser{
Identity: api.Identity{
Name: sig.Name,
Email: sig.Email,
},
Date: sig.When.UTC().Format(time.RFC3339),
Name: sig.Name,
Email: sig.Email,
Date: sig.When.UTC().Format(time.RFC3339),
}
}
@@ -157,18 +155,14 @@ func ToCommit(ctx context.Context, repo *repo_model.Repository, gitRepo *git.Rep
RepoCommit: &api.RepoCommit{
URL: repo.APIURL() + "/git/commits/" + url.PathEscape(commit.ID.String()),
Author: &api.CommitUser{
Identity: api.Identity{
Name: commit.Author.Name,
Email: commit.Author.Email,
},
Date: commit.Author.When.Format(time.RFC3339),
Name: commit.Author.Name,
Email: commit.Author.Email,
Date: commit.Author.When.Format(time.RFC3339),
},
Committer: &api.CommitUser{
Identity: api.Identity{
Name: commit.Committer.Name,
Email: commit.Committer.Email,
},
Date: commit.Committer.When.Format(time.RFC3339),
Name: commit.Committer.Name,
Email: commit.Committer.Email,
Date: commit.Committer.When.Format(time.RFC3339),
},
Message: commit.MessageUTF8(),
Tree: &api.CommitMeta{
+6 -6
View File
@@ -21,12 +21,12 @@ func TestToCommitMeta(t *testing.T) {
sha1 := git.Sha1ObjectFormat
signature := &git.Signature{Name: "Test Signature", Email: "test@email.com", When: time.Unix(0, 0)}
tag := &git.Tag{
Name: "Test Tag",
ID: sha1.EmptyObjectID(),
Object: sha1.EmptyObjectID(),
Type: "Test Type",
Tagger: signature,
CommitMessage: git.CommitMessage{MessageRaw: "Test Message"},
Name: "Test Tag",
ID: sha1.EmptyObjectID(),
Object: sha1.EmptyObjectID(),
Type: "Test Type",
Tagger: signature,
MessageRaw: "Test Message",
}
commitMeta := ToCommitMeta(headRepo, tag)
+2 -2
View File
@@ -130,9 +130,9 @@ func toProject(ctx context.Context, p *project_model.Project, doer *user_model.U
Description: p.Description,
OwnerID: p.OwnerID,
RepoID: p.RepoID,
CreatorID: p.CreatorID,
CreatorID: p.CreatorID, //nolint:staticcheck // deprecated field
State: state,
IsClosed: p.IsClosed,
IsClosed: p.IsClosed, //nolint:staticcheck // deprecated field
TemplateType: projectTemplateTypeToString(p.TemplateType),
CardType: projectCardTypeToString(p.CardType),
Type: projectTypeToString(p.Type),
+6 -10
View File
@@ -15,18 +15,14 @@ func ToWikiCommit(commit *git.Commit) *api.WikiCommit {
return &api.WikiCommit{
ID: commit.ID.String(),
Author: &api.CommitUser{
Identity: api.Identity{
Name: commit.Author.Name,
Email: commit.Author.Email,
},
Date: commit.Author.When.UTC().Format(time.RFC3339),
Name: commit.Author.Name,
Email: commit.Author.Email,
Date: commit.Author.When.UTC().Format(time.RFC3339),
},
Committer: &api.CommitUser{
Identity: api.Identity{
Name: commit.Committer.Name,
Email: commit.Committer.Email,
},
Date: commit.Committer.When.UTC().Format(time.RFC3339),
Name: commit.Committer.Name,
Email: commit.Committer.Email,
Date: commit.Committer.When.UTC().Format(time.RFC3339),
},
Message: commit.MessageUTF8(),
}