From 674689af4a843813f03ae270a6158f3b60d3e5b5 Mon Sep 17 00:00:00 2001
From: Renovate Bot <forgejo-renovate-action@forgejo.org>
Date: Wed, 14 Aug 2024 02:03:02 +0000
Subject: [PATCH 1/2] Update module
 github.com/golangci/golangci-lint/cmd/golangci-lint to v1.60.1

---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 291f828956..9aefc6edea 100644
--- a/Makefile
+++ b/Makefile
@@ -29,7 +29,7 @@ XGO_VERSION := go-1.21.x
 AIR_PACKAGE ?= github.com/air-verse/air@v1 # renovate: datasource=go
 EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/v3/cmd/editorconfig-checker@v3.0.3 # renovate: datasource=go
 GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.7.0 # renovate: datasource=go
-GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.1 # renovate: datasource=go
+GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.60.1 # renovate: datasource=go
 GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.11 # renovate: datasource=go
 MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/misspell@v0.6.0 # renovate: datasource=go
 SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@v0.31.0 # renovate: datasource=go

From fe18428806bc33c3717f1fd124acba5ac311dcb1 Mon Sep 17 00:00:00 2001
From: Gusted <postmaster@gusted.xyz>
Date: Wed, 14 Aug 2024 11:43:42 +0200
Subject: [PATCH 2/2] Fix linting issues

---
 cmd/hook.go                                   |  4 ++--
 cmd/hook_test.go                              |  2 +-
 models/activities/user_heatmap_test.go        |  3 +--
 models/asymkey/gpg_key_common.go              |  4 ++--
 models/auth/oauth2_test.go                    |  2 +-
 models/git/protected_branch_test.go           | 11 +----------
 models/migrations/v1_16/v189.go               |  2 +-
 models/migrations/v1_16/v193_test.go          |  8 ++++----
 models/repo/repo_list.go                      |  2 +-
 models/user/user_test.go                      |  2 +-
 modules/cache/context.go                      |  4 +++-
 modules/git/log_name_status.go                |  2 +-
 modules/issue/template/template.go            |  2 +-
 modules/packages/arch/metadata.go             | 16 ++++++++--------
 modules/queue/base_channel.go                 |  2 +-
 modules/queue/workerqueue_test.go             |  4 ++--
 routers/api/v1/repo/pull.go                   |  2 +-
 routers/web/repo/pull.go                      |  2 +-
 routers/web/repo/view.go                      |  5 +++--
 routers/web/user/home.go                      |  2 +-
 routers/web/user/profile.go                   |  2 +-
 services/actions/notifier_helper.go           |  4 +++-
 services/automerge/automerge.go               |  2 +-
 services/gitdiff/gitdiff_test.go              |  5 ++---
 services/release/release_test.go              |  2 +-
 tests/integration/api_issue_stopwatch_test.go |  2 +-
 tests/integration/api_push_mirror_test.go     | 13 +++++++------
 tests/integration/api_releases_test.go        |  6 +++---
 tests/integration/api_repo_teams_test.go      |  2 +-
 tests/integration/html_helper.go              |  6 +++---
 tests/integration/migrate_test.go             |  2 +-
 tests/integration/repo_fork_test.go           |  2 +-
 tests/integration/repo_test.go                |  2 +-
 tests/integration/user_test.go                |  2 +-
 34 files changed, 64 insertions(+), 69 deletions(-)

diff --git a/cmd/hook.go b/cmd/hook.go
index eec93aece7..edab611972 100644
--- a/cmd/hook.go
+++ b/cmd/hook.go
@@ -535,14 +535,14 @@ Forgejo or set your environment appropriately.`, "")
 
 	index := bytes.IndexByte(rs.Data, byte(0))
 	if index >= len(rs.Data) {
-		return fail(ctx, "Protocol: format error", "pkt-line: format error "+fmt.Sprint(rs.Data))
+		return fail(ctx, "Protocol: format error", "pkt-line: format error %s", rs.Data)
 	}
 
 	if index < 0 {
 		if len(rs.Data) == 10 && rs.Data[9] == '\n' {
 			index = 9
 		} else {
-			return fail(ctx, "Protocol: format error", "pkt-line: format error "+fmt.Sprint(rs.Data))
+			return fail(ctx, "Protocol: format error", "pkt-line: format error %s", rs.Data)
 		}
 	}
 
diff --git a/cmd/hook_test.go b/cmd/hook_test.go
index 890b236c7d..514eb917e1 100644
--- a/cmd/hook_test.go
+++ b/cmd/hook_test.go
@@ -117,7 +117,7 @@ func TestDelayWriter(t *testing.T) {
 	defer test.MockVariableValue(&setting.InternalToken, "Random")()
 	defer test.MockVariableValue(&setting.InstallLock, true)()
 	defer test.MockVariableValue(&setting.Git.VerbosePush, true)()
-	require.NoError(t, os.Setenv("SSH_ORIGINAL_COMMAND", "true"))
+	t.Setenv("SSH_ORIGINAL_COMMAND", "true")
 
 	// Setup the Stdin.
 	f, err := os.OpenFile(t.TempDir()+"/stdin", os.O_RDWR|os.O_CREATE|os.O_EXCL, 0o666)
diff --git a/models/activities/user_heatmap_test.go b/models/activities/user_heatmap_test.go
index 7063da8bd1..316ea7d76e 100644
--- a/models/activities/user_heatmap_test.go
+++ b/models/activities/user_heatmap_test.go
@@ -4,7 +4,6 @@
 package activities_test
 
 import (
-	"fmt"
 	"testing"
 	"time"
 
@@ -92,7 +91,7 @@ func TestGetUserHeatmapDataByUser(t *testing.T) {
 		require.NoError(t, err)
 		assert.Len(t, actions, contributions, "invalid action count: did the test data became too old?")
 		assert.Equal(t, count, int64(contributions))
-		assert.Equal(t, tc.CountResult, contributions, fmt.Sprintf("testcase '%s'", tc.desc))
+		assert.Equal(t, tc.CountResult, contributions, tc.desc)
 
 		// Test JSON rendering
 		jsonData, err := json.Marshal(heatmap)
diff --git a/models/asymkey/gpg_key_common.go b/models/asymkey/gpg_key_common.go
index b1b4f1eb57..db1912c316 100644
--- a/models/asymkey/gpg_key_common.go
+++ b/models/asymkey/gpg_key_common.go
@@ -114,7 +114,7 @@ func readArmoredSign(r io.Reader) (body io.Reader, err error) {
 		return nil, err
 	}
 	if block.Type != openpgp.SignatureType {
-		return nil, fmt.Errorf("expected '" + openpgp.SignatureType + "', got: " + block.Type)
+		return nil, fmt.Errorf("expected %q, got: %s", openpgp.SignatureType, block.Type)
 	}
 	return block.Body, nil
 }
@@ -139,7 +139,7 @@ func tryGetKeyIDFromSignature(sig *packet.Signature) string {
 	if sig.IssuerKeyId != nil && (*sig.IssuerKeyId) != 0 {
 		return fmt.Sprintf("%016X", *sig.IssuerKeyId)
 	}
-	if sig.IssuerFingerprint != nil && len(sig.IssuerFingerprint) > 0 {
+	if len(sig.IssuerFingerprint) > 0 {
 		return fmt.Sprintf("%016X", sig.IssuerFingerprint[12:20])
 	}
 	return ""
diff --git a/models/auth/oauth2_test.go b/models/auth/oauth2_test.go
index c43d9d36c2..94b506ed48 100644
--- a/models/auth/oauth2_test.go
+++ b/models/auth/oauth2_test.go
@@ -22,7 +22,7 @@ func TestOAuth2Application_GenerateClientSecret(t *testing.T) {
 	app := unittest.AssertExistsAndLoadBean(t, &auth_model.OAuth2Application{ID: 1})
 	secret, err := app.GenerateClientSecret(db.DefaultContext)
 	require.NoError(t, err)
-	assert.Positive(t, len(secret))
+	assert.NotEmpty(t, secret)
 	unittest.AssertExistsAndLoadBean(t, &auth_model.OAuth2Application{ID: 1, ClientSecret: app.ClientSecret})
 }
 
diff --git a/models/git/protected_branch_test.go b/models/git/protected_branch_test.go
index 1962859a8c..278fa9fee4 100644
--- a/models/git/protected_branch_test.go
+++ b/models/git/protected_branch_test.go
@@ -4,7 +4,6 @@
 package git
 
 import (
-	"fmt"
 	"testing"
 
 	"github.com/stretchr/testify/assert"
@@ -65,14 +64,6 @@ func TestBranchRuleMatch(t *testing.T) {
 
 	for _, kase := range kases {
 		pb := ProtectedBranch{RuleName: kase.Rule}
-		var should, infact string
-		if !kase.ExpectedMatch {
-			should = " not"
-		} else {
-			infact = " not"
-		}
-		assert.EqualValues(t, kase.ExpectedMatch, pb.Match(kase.BranchName),
-			fmt.Sprintf("%s should%s match %s but it is%s", kase.BranchName, should, kase.Rule, infact),
-		)
+		assert.EqualValues(t, kase.ExpectedMatch, pb.Match(kase.BranchName), "%s - %s", kase.BranchName, kase.Rule)
 	}
 }
diff --git a/models/migrations/v1_16/v189.go b/models/migrations/v1_16/v189.go
index afd93b0eac..5649645051 100644
--- a/models/migrations/v1_16/v189.go
+++ b/models/migrations/v1_16/v189.go
@@ -83,7 +83,7 @@ func UnwrapLDAPSourceCfg(x *xorm.Engine) error {
 			if err != nil {
 				return fmt.Errorf("failed to unmarshal %s: %w", source.Cfg, err)
 			}
-			if wrapped.Source != nil && len(wrapped.Source) > 0 {
+			if len(wrapped.Source) > 0 {
 				bs, err := json.Marshal(wrapped.Source)
 				if err != nil {
 					return err
diff --git a/models/migrations/v1_16/v193_test.go b/models/migrations/v1_16/v193_test.go
index 1ead74f968..0da670888b 100644
--- a/models/migrations/v1_16/v193_test.go
+++ b/models/migrations/v1_16/v193_test.go
@@ -57,8 +57,8 @@ func Test_AddRepoIDForAttachment(t *testing.T) {
 	err := x.Table("attachment").Where("issue_id > 0").Find(&issueAttachments)
 	require.NoError(t, err)
 	for _, attach := range issueAttachments {
-		assert.Greater(t, attach.RepoID, int64(0))
-		assert.Greater(t, attach.IssueID, int64(0))
+		assert.Positive(t, attach.RepoID)
+		assert.Positive(t, attach.IssueID)
 		var issue Issue
 		has, err := x.ID(attach.IssueID).Get(&issue)
 		require.NoError(t, err)
@@ -70,8 +70,8 @@ func Test_AddRepoIDForAttachment(t *testing.T) {
 	err = x.Table("attachment").Where("release_id > 0").Find(&releaseAttachments)
 	require.NoError(t, err)
 	for _, attach := range releaseAttachments {
-		assert.Greater(t, attach.RepoID, int64(0))
-		assert.Greater(t, attach.ReleaseID, int64(0))
+		assert.Positive(t, attach.RepoID)
+		assert.Positive(t, attach.ReleaseID)
 		var release Release
 		has, err := x.ID(attach.ReleaseID).Get(&release)
 		require.NoError(t, err)
diff --git a/models/repo/repo_list.go b/models/repo/repo_list.go
index 6cce2d33a3..162f933fbe 100644
--- a/models/repo/repo_list.go
+++ b/models/repo/repo_list.go
@@ -743,7 +743,7 @@ func GetUserRepositories(ctx context.Context, opts *SearchRepoOptions) (Reposito
 		cond = cond.And(builder.Eq{"is_private": false})
 	}
 
-	if opts.LowerNames != nil && len(opts.LowerNames) > 0 {
+	if len(opts.LowerNames) > 0 {
 		cond = cond.And(builder.In("lower_name", opts.LowerNames))
 	}
 
diff --git a/models/user/user_test.go b/models/user/user_test.go
index ba29cbc3af..8f4350f776 100644
--- a/models/user/user_test.go
+++ b/models/user/user_test.go
@@ -598,7 +598,7 @@ func Test_ValidateUser(t *testing.T) {
 		{ID: 2, Visibility: structs.VisibleTypePrivate}: true,
 	}
 	for kase, expected := range kases {
-		assert.EqualValues(t, expected, nil == user_model.ValidateUser(kase), fmt.Sprintf("case: %+v", kase))
+		assert.EqualValues(t, expected, nil == user_model.ValidateUser(kase))
 	}
 }
 
diff --git a/modules/cache/context.go b/modules/cache/context.go
index 62bbf5dcba..5f0ca81e8d 100644
--- a/modules/cache/context.go
+++ b/modules/cache/context.go
@@ -73,7 +73,9 @@ func (cc *cacheContext) Expired() bool {
 	return timeNow().Sub(cc.created) > cacheContextLifetime
 }
 
-var cacheContextKey = struct{}{}
+type cacheContextType = struct{ useless struct{} }
+
+var cacheContextKey = cacheContextType{useless: struct{}{}}
 
 /*
 Since there are both WithCacheContext and WithNoCacheContext,
diff --git a/modules/git/log_name_status.go b/modules/git/log_name_status.go
index 9e345f3ee0..1fd58abfcd 100644
--- a/modules/git/log_name_status.go
+++ b/modules/git/log_name_status.go
@@ -114,7 +114,7 @@ type LogNameStatusCommitData struct {
 // Next returns the next LogStatusCommitData
 func (g *LogNameStatusRepoParser) Next(treepath string, paths2ids map[string]int, changed []bool, maxpathlen int) (*LogNameStatusCommitData, error) {
 	var err error
-	if g.next == nil || len(g.next) == 0 {
+	if len(g.next) == 0 {
 		g.buffull = false
 		g.next, err = g.rd.ReadSlice('\x00')
 		if err != nil {
diff --git a/modules/issue/template/template.go b/modules/issue/template/template.go
index 0a105c723c..967bed0261 100644
--- a/modules/issue/template/template.go
+++ b/modules/issue/template/template.go
@@ -401,7 +401,7 @@ func (f *valuedField) Render() string {
 }
 
 func (f *valuedField) Value() string {
-	return strings.TrimSpace(f.Get(fmt.Sprintf("form-field-" + f.ID)))
+	return strings.TrimSpace(f.Get("form-field-" + f.ID))
 }
 
 func (f *valuedField) Options() []*valuedOption {
diff --git a/modules/packages/arch/metadata.go b/modules/packages/arch/metadata.go
index 9b443899bb..8fba53e58b 100644
--- a/modules/packages/arch/metadata.go
+++ b/modules/packages/arch/metadata.go
@@ -258,42 +258,42 @@ func ValidatePackageSpec(p *Package) error {
 	}
 	for _, cd := range p.VersionMetadata.CheckDepends {
 		if !rePkgVer.MatchString(cd) {
-			return util.NewInvalidArgumentErrorf("invalid check dependency: " + cd)
+			return util.NewInvalidArgumentErrorf("invalid check dependency: %s", cd)
 		}
 	}
 	for _, d := range p.VersionMetadata.Depends {
 		if !rePkgVer.MatchString(d) {
-			return util.NewInvalidArgumentErrorf("invalid dependency: " + d)
+			return util.NewInvalidArgumentErrorf("invalid dependency: %s", d)
 		}
 	}
 	for _, md := range p.VersionMetadata.MakeDepends {
 		if !rePkgVer.MatchString(md) {
-			return util.NewInvalidArgumentErrorf("invalid make dependency: " + md)
+			return util.NewInvalidArgumentErrorf("invalid make dependency: %s", md)
 		}
 	}
 	for _, p := range p.VersionMetadata.Provides {
 		if !rePkgVer.MatchString(p) {
-			return util.NewInvalidArgumentErrorf("invalid provides: " + p)
+			return util.NewInvalidArgumentErrorf("invalid provides: %s", p)
 		}
 	}
 	for _, p := range p.VersionMetadata.Conflicts {
 		if !rePkgVer.MatchString(p) {
-			return util.NewInvalidArgumentErrorf("invalid conflicts: " + p)
+			return util.NewInvalidArgumentErrorf("invalid conflicts: %s", p)
 		}
 	}
 	for _, p := range p.VersionMetadata.Replaces {
 		if !rePkgVer.MatchString(p) {
-			return util.NewInvalidArgumentErrorf("invalid replaces: " + p)
+			return util.NewInvalidArgumentErrorf("invalid replaces: %s", p)
 		}
 	}
 	for _, p := range p.VersionMetadata.Replaces {
 		if !rePkgVer.MatchString(p) {
-			return util.NewInvalidArgumentErrorf("invalid xdata: " + p)
+			return util.NewInvalidArgumentErrorf("invalid xdata: %s", p)
 		}
 	}
 	for _, od := range p.VersionMetadata.OptDepends {
 		if !reOptDep.MatchString(od) {
-			return util.NewInvalidArgumentErrorf("invalid optional dependency: " + od)
+			return util.NewInvalidArgumentErrorf("invalid optional dependency: %s", od)
 		}
 	}
 	for _, bf := range p.VersionMetadata.Backup {
diff --git a/modules/queue/base_channel.go b/modules/queue/base_channel.go
index d03c72bdae..dd8ccb15f4 100644
--- a/modules/queue/base_channel.go
+++ b/modules/queue/base_channel.go
@@ -120,7 +120,7 @@ func (q *baseChannel) RemoveAll(ctx context.Context) error {
 	q.mu.Lock()
 	defer q.mu.Unlock()
 
-	for q.c != nil && len(q.c) > 0 {
+	for len(q.c) > 0 {
 		<-q.c
 	}
 
diff --git a/modules/queue/workerqueue_test.go b/modules/queue/workerqueue_test.go
index 112a16c8e3..4cfe8ede97 100644
--- a/modules/queue/workerqueue_test.go
+++ b/modules/queue/workerqueue_test.go
@@ -173,8 +173,8 @@ func testWorkerPoolQueuePersistence(t *testing.T, queueSetting setting.QueueSett
 
 	q2() // restart the queue to continue to execute the tasks in it
 
-	assert.NotZero(t, len(tasksQ1))
-	assert.NotZero(t, len(tasksQ2))
+	assert.NotEmpty(t, tasksQ1)
+	assert.NotEmpty(t, tasksQ2)
 	assert.EqualValues(t, testCount, len(tasksQ1)+len(tasksQ2))
 }
 
diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go
index 4ae4d08814..97937fa937 100644
--- a/routers/api/v1/repo/pull.go
+++ b/routers/api/v1/repo/pull.go
@@ -752,7 +752,7 @@ func EditPullRequest(ctx *context.APIContext) {
 	// update allow edits
 	if form.AllowMaintainerEdit != nil {
 		if err := pull_service.SetAllowEdits(ctx, ctx.Doer, pr, *form.AllowMaintainerEdit); err != nil {
-			if errors.Is(pull_service.ErrUserHasNoPermissionForAction, err) {
+			if errors.Is(err, pull_service.ErrUserHasNoPermissionForAction) {
 				ctx.Error(http.StatusForbidden, "SetAllowEdits", fmt.Sprintf("SetAllowEdits: %s", err))
 				return
 			}
diff --git a/routers/web/repo/pull.go b/routers/web/repo/pull.go
index 56a46f7f06..d2b0f5b0fb 100644
--- a/routers/web/repo/pull.go
+++ b/routers/web/repo/pull.go
@@ -1821,7 +1821,7 @@ func SetAllowEdits(ctx *context.Context) {
 	}
 
 	if err := pull_service.SetAllowEdits(ctx, ctx.Doer, pr, form.AllowMaintainerEdit); err != nil {
-		if errors.Is(pull_service.ErrUserHasNoPermissionForAction, err) {
+		if errors.Is(err, pull_service.ErrUserHasNoPermissionForAction) {
 			ctx.Error(http.StatusForbidden)
 			return
 		}
diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go
index bc4376756d..e966917640 100644
--- a/routers/web/repo/view.go
+++ b/routers/web/repo/view.go
@@ -8,6 +8,7 @@ import (
 	"bytes"
 	gocontext "context"
 	"encoding/base64"
+	"errors"
 	"fmt"
 	"html/template"
 	"image"
@@ -753,12 +754,12 @@ func checkHomeCodeViewable(ctx *context.Context) {
 		}
 
 		if firstUnit != nil {
-			ctx.Redirect(fmt.Sprintf("%s%s", ctx.Repo.Repository.Link(), firstUnit.URI))
+			ctx.Redirect(ctx.Repo.Repository.Link() + firstUnit.URI)
 			return
 		}
 	}
 
-	ctx.NotFound("Home", fmt.Errorf(ctx.Locale.TrString("units.error.no_unit_allowed_repo")))
+	ctx.NotFound("Home", errors.New(ctx.Locale.TrString("units.error.no_unit_allowed_repo")))
 }
 
 func checkCitationFile(ctx *context.Context, entry *git.TreeEntry) {
diff --git a/routers/web/user/home.go b/routers/web/user/home.go
index 0a1b08c57b..55d579eb2d 100644
--- a/routers/web/user/home.go
+++ b/routers/web/user/home.go
@@ -761,7 +761,7 @@ func UsernameSubRoute(ctx *context.Context) {
 		}
 		// check view permissions
 		if !user_model.IsUserVisibleToViewer(ctx, ctx.ContextUser, ctx.Doer) {
-			ctx.NotFound("user", fmt.Errorf(ctx.ContextUser.Name))
+			ctx.NotFound("User not visible", nil)
 			return false
 		}
 		return true
diff --git a/routers/web/user/profile.go b/routers/web/user/profile.go
index 24b0db2f1d..78069318fe 100644
--- a/routers/web/user/profile.go
+++ b/routers/web/user/profile.go
@@ -56,7 +56,7 @@ func OwnerProfile(ctx *context.Context) {
 func userProfile(ctx *context.Context) {
 	// check view permissions
 	if !user_model.IsUserVisibleToViewer(ctx, ctx.ContextUser, ctx.Doer) {
-		ctx.NotFound("user", fmt.Errorf(ctx.ContextUser.Name))
+		ctx.NotFound("User not visible", nil)
 		return
 	}
 
diff --git a/services/actions/notifier_helper.go b/services/actions/notifier_helper.go
index 4196cf7686..86897d5cba 100644
--- a/services/actions/notifier_helper.go
+++ b/services/actions/notifier_helper.go
@@ -34,7 +34,9 @@ import (
 	"github.com/nektos/act/pkg/model"
 )
 
-var methodCtxKey struct{}
+type methodCtx struct{}
+
+var methodCtxKey = methodCtx{}
 
 // withMethod sets the notification method that this context currently executes.
 // Used for debugging/ troubleshooting purposes.
diff --git a/services/automerge/automerge.go b/services/automerge/automerge.go
index 10f3c28d56..9729616033 100644
--- a/services/automerge/automerge.go
+++ b/services/automerge/automerge.go
@@ -276,7 +276,7 @@ func handlePullRequestAutoMerge(pullID int64, sha string) {
 	}
 
 	if err := pull_service.CheckPullMergeable(ctx, doer, &perm, pr, pull_service.MergeCheckTypeGeneral, false); err != nil {
-		if errors.Is(pull_service.ErrUserNotAllowedToMerge, err) {
+		if errors.Is(err, pull_service.ErrUserNotAllowedToMerge) {
 			log.Info("%-v was scheduled to automerge by an unauthorized user", pr)
 			return
 		}
diff --git a/services/gitdiff/gitdiff_test.go b/services/gitdiff/gitdiff_test.go
index 40285f8119..f2c099d554 100644
--- a/services/gitdiff/gitdiff_test.go
+++ b/services/gitdiff/gitdiff_test.go
@@ -5,7 +5,6 @@
 package gitdiff
 
 import (
-	"fmt"
 	"strconv"
 	"strings"
 	"testing"
@@ -645,9 +644,9 @@ func TestGetDiffRangeWithWhitespaceBehavior(t *testing.T) {
 				MaxFiles:           setting.Git.MaxGitDiffFiles,
 				WhitespaceBehavior: behavior,
 			})
-		require.NoError(t, err, fmt.Sprintf("Error when diff with %s", behavior))
+		require.NoError(t, err, "Error when diff with %s", behavior)
 		for _, f := range diffs.Files {
-			assert.Positive(t, len(f.Sections), fmt.Sprintf("%s should have sections", f.Name))
+			assert.NotEmpty(t, f.Sections, "%s should have sections", f.Name)
 		}
 	}
 }
diff --git a/services/release/release_test.go b/services/release/release_test.go
index 0cd655b317..026bba8258 100644
--- a/services/release/release_test.go
+++ b/services/release/release_test.go
@@ -289,7 +289,7 @@ func TestRelease_Update(t *testing.T) {
 		IsTag:        false,
 	}
 	require.NoError(t, CreateRelease(gitRepo, release, "", []*AttachmentChange{}))
-	assert.Greater(t, release.ID, int64(0))
+	assert.Positive(t, release.ID)
 
 	release.IsDraft = false
 	tagName := release.TagName
diff --git a/tests/integration/api_issue_stopwatch_test.go b/tests/integration/api_issue_stopwatch_test.go
index 2306678217..4765787e6f 100644
--- a/tests/integration/api_issue_stopwatch_test.go
+++ b/tests/integration/api_issue_stopwatch_test.go
@@ -40,7 +40,7 @@ func TestAPIListStopWatches(t *testing.T) {
 		assert.EqualValues(t, issue.Title, apiWatches[0].IssueTitle)
 		assert.EqualValues(t, repo.Name, apiWatches[0].RepoName)
 		assert.EqualValues(t, repo.OwnerName, apiWatches[0].RepoOwnerName)
-		assert.Greater(t, apiWatches[0].Seconds, int64(0))
+		assert.Positive(t, apiWatches[0].Seconds)
 	}
 }
 
diff --git a/tests/integration/api_push_mirror_test.go b/tests/integration/api_push_mirror_test.go
index f0ef670757..24d5330517 100644
--- a/tests/integration/api_push_mirror_test.go
+++ b/tests/integration/api_push_mirror_test.go
@@ -5,6 +5,7 @@ package integration
 
 import (
 	"context"
+	"errors"
 	"fmt"
 	"net/http"
 	"net/url"
@@ -52,15 +53,15 @@ func testAPIPushMirror(t *testing.T, u *url.URL) {
 	remoteAddress := fmt.Sprintf("%s%s/%s", u.String(), url.PathEscape(user.Name), url.PathEscape(mirrorRepo.Name))
 
 	deletePushMirrors := repo_model.DeletePushMirrors
-	deletePushMirrorsError := "deletePushMirrorsError"
+	deletePushMirrorsError := errors.New("deletePushMirrorsError")
 	deletePushMirrorsFail := func(ctx context.Context, opts repo_model.PushMirrorOptions) error {
-		return fmt.Errorf(deletePushMirrorsError)
+		return deletePushMirrorsError
 	}
 
 	addPushMirrorRemote := mirror_service.AddPushMirrorRemote
-	addPushMirrorRemoteError := "addPushMirrorRemoteError"
+	addPushMirrorRemoteError := errors.New("addPushMirrorRemoteError")
 	addPushMirrorRemoteFail := func(ctx context.Context, m *repo_model.PushMirror, addr string) error {
-		return fmt.Errorf(addPushMirrorRemoteError)
+		return addPushMirrorRemoteError
 	}
 
 	for _, testCase := range []struct {
@@ -81,7 +82,7 @@ func testAPIPushMirror(t *testing.T, u *url.URL) {
 		},
 		{
 			name:        "fail to add and delete",
-			message:     deletePushMirrorsError,
+			message:     deletePushMirrorsError.Error(),
 			status:      http.StatusInternalServerError,
 			mirrorCount: 1,
 			setup: func() {
@@ -91,7 +92,7 @@ func testAPIPushMirror(t *testing.T, u *url.URL) {
 		},
 		{
 			name:        "fail to add",
-			message:     addPushMirrorRemoteError,
+			message:     addPushMirrorRemoteError.Error(),
 			status:      http.StatusInternalServerError,
 			mirrorCount: 0,
 			setup: func() {
diff --git a/tests/integration/api_releases_test.go b/tests/integration/api_releases_test.go
index 92b4845602..ad29343b7b 100644
--- a/tests/integration/api_releases_test.go
+++ b/tests/integration/api_releases_test.go
@@ -266,17 +266,17 @@ func TestAPIDeleteReleaseByTagName(t *testing.T) {
 	createNewReleaseUsingAPI(t, token, owner, repo, "release-tag", "", "Release Tag", "test")
 
 	// delete release
-	req := NewRequestf(t, http.MethodDelete, fmt.Sprintf("/api/v1/repos/%s/%s/releases/tags/release-tag", owner.Name, repo.Name)).
+	req := NewRequestf(t, http.MethodDelete, "/api/v1/repos/%s/%s/releases/tags/release-tag", owner.Name, repo.Name).
 		AddTokenAuth(token)
 	_ = MakeRequest(t, req, http.StatusNoContent)
 
 	// make sure release is deleted
-	req = NewRequestf(t, http.MethodDelete, fmt.Sprintf("/api/v1/repos/%s/%s/releases/tags/release-tag", owner.Name, repo.Name)).
+	req = NewRequestf(t, http.MethodDelete, "/api/v1/repos/%s/%s/releases/tags/release-tag", owner.Name, repo.Name).
 		AddTokenAuth(token)
 	_ = MakeRequest(t, req, http.StatusNotFound)
 
 	// delete release tag too
-	req = NewRequestf(t, http.MethodDelete, fmt.Sprintf("/api/v1/repos/%s/%s/tags/release-tag", owner.Name, repo.Name)).
+	req = NewRequestf(t, http.MethodDelete, "/api/v1/repos/%s/%s/tags/release-tag", owner.Name, repo.Name).
 		AddTokenAuth(token)
 	_ = MakeRequest(t, req, http.StatusNoContent)
 }
diff --git a/tests/integration/api_repo_teams_test.go b/tests/integration/api_repo_teams_test.go
index 558bac8150..91bfd66b3a 100644
--- a/tests/integration/api_repo_teams_test.go
+++ b/tests/integration/api_repo_teams_test.go
@@ -39,7 +39,7 @@ func TestAPIRepoTeams(t *testing.T) {
 	if assert.Len(t, teams, 2) {
 		assert.EqualValues(t, "Owners", teams[0].Name)
 		assert.True(t, teams[0].CanCreateOrgRepo)
-		assert.True(t, util.SliceSortedEqual(unit.AllUnitKeyNames(), teams[0].Units), fmt.Sprintf("%v == %v", unit.AllUnitKeyNames(), teams[0].Units))
+		assert.True(t, util.SliceSortedEqual(unit.AllUnitKeyNames(), teams[0].Units))
 		assert.EqualValues(t, "owner", teams[0].Permission)
 
 		assert.EqualValues(t, "test_team", teams[1].Name)
diff --git a/tests/integration/html_helper.go b/tests/integration/html_helper.go
index f6768714a6..802dcb05a4 100644
--- a/tests/integration/html_helper.go
+++ b/tests/integration/html_helper.go
@@ -42,7 +42,7 @@ func (doc *HTMLDoc) AssertDropdown(t testing.TB, name string) *goquery.Selection
 	t.Helper()
 
 	dropdownGroup := doc.Find(fmt.Sprintf(".dropdown:has(input[name='%s'])", name))
-	assert.Equal(t, 1, dropdownGroup.Length(), fmt.Sprintf("%s dropdown does not exist", name))
+	assert.Equal(t, 1, dropdownGroup.Length(), "%s dropdown does not exist", name)
 	return dropdownGroup
 }
 
@@ -60,13 +60,13 @@ func (doc *HTMLDoc) AssertDropdownHasSelectedOption(t testing.TB, dropdownName,
 	dropdownGroup := doc.AssertDropdown(t, dropdownName)
 
 	selectedValue, _ := dropdownGroup.Find(fmt.Sprintf("input[name='%s']", dropdownName)).Attr("value")
-	assert.Equal(t, expectedValue, selectedValue, fmt.Sprintf("%s dropdown doesn't have expected value selected", dropdownName))
+	assert.Equal(t, expectedValue, selectedValue, "%s dropdown doesn't have expected value selected", dropdownName)
 
 	dropdownValues := dropdownGroup.Find(".menu [data-value]").Map(func(i int, s *goquery.Selection) string {
 		value, _ := s.Attr("data-value")
 		return value
 	})
-	assert.Contains(t, dropdownValues, expectedValue, fmt.Sprintf("%s dropdown doesn't have an option with expected value", dropdownName))
+	assert.Contains(t, dropdownValues, expectedValue, "%s dropdown doesn't have an option with expected value", dropdownName)
 }
 
 // Find gets the descendants of each element in the current set of
diff --git a/tests/integration/migrate_test.go b/tests/integration/migrate_test.go
index 123f975ca9..43cfc4f37d 100644
--- a/tests/integration/migrate_test.go
+++ b/tests/integration/migrate_test.go
@@ -83,7 +83,7 @@ func TestMigrate(t *testing.T) {
 			{svc: structs.ForgejoService},
 		} {
 			// Step 0: verify the repo is available
-			req := NewRequestf(t, "GET", fmt.Sprintf("/%s/%s", ownerName, repoName))
+			req := NewRequestf(t, "GET", "/%s/%s", ownerName, repoName)
 			_ = session.MakeRequest(t, req, http.StatusOK)
 			// Step 1: get the Gitea migration form
 			req = NewRequestf(t, "GET", "/repo/migrate/?service_type=%d", s.svc)
diff --git a/tests/integration/repo_fork_test.go b/tests/integration/repo_fork_test.go
index 38cbc3af28..2627749836 100644
--- a/tests/integration/repo_fork_test.go
+++ b/tests/integration/repo_fork_test.go
@@ -45,7 +45,7 @@ func testRepoFork(t *testing.T, session *TestSession, ownerName, repoName, forkO
 	link, exists := htmlDoc.doc.Find(fmt.Sprintf("form.ui.form[action=\"%s\"]", forkURL)).Attr("action")
 	assert.True(t, exists, "The template has changed")
 	_, exists = htmlDoc.doc.Find(fmt.Sprintf(".owner.dropdown .item[data-value=\"%d\"]", forkOwner.ID)).Attr("data-value")
-	assert.True(t, exists, fmt.Sprintf("Fork owner '%s' is not present in select box", forkOwnerName))
+	assert.True(t, exists, "Fork owner %q is not present in select box", forkOwnerName)
 	req = NewRequestWithValues(t, "POST", link, map[string]string{
 		"_csrf":     htmlDoc.GetCSRF(),
 		"uid":       fmt.Sprintf("%d", forkOwner.ID),
diff --git a/tests/integration/repo_test.go b/tests/integration/repo_test.go
index 367d131638..bf8a7eb694 100644
--- a/tests/integration/repo_test.go
+++ b/tests/integration/repo_test.go
@@ -444,7 +444,7 @@ func TestViewRepoDirectory(t *testing.T) {
 	repoSummary := htmlDoc.doc.Find(".repository-summary")
 
 	repoFilesTable := htmlDoc.doc.Find("#repo-files-table")
-	assert.NotZero(t, len(repoFilesTable.Nodes))
+	assert.NotEmpty(t, repoFilesTable.Nodes)
 
 	assert.Zero(t, description.Length())
 	assert.Zero(t, repoTopics.Length())
diff --git a/tests/integration/user_test.go b/tests/integration/user_test.go
index e5e819dfe9..e53f7f1e8d 100644
--- a/tests/integration/user_test.go
+++ b/tests/integration/user_test.go
@@ -291,7 +291,7 @@ func TestListStopWatches(t *testing.T) {
 		assert.EqualValues(t, issue.Title, apiWatches[0].IssueTitle)
 		assert.EqualValues(t, repo.Name, apiWatches[0].RepoName)
 		assert.EqualValues(t, repo.OwnerName, apiWatches[0].RepoOwnerName)
-		assert.Greater(t, apiWatches[0].Seconds, int64(0))
+		assert.Positive(t, apiWatches[0].Seconds)
 	}
 }