From ef4b3673ddb3d9ac2900f1a9e05c4ca51f1f40a5 Mon Sep 17 00:00:00 2001 From: Jason Song Date: Sat, 26 Nov 2022 22:12:52 +0800 Subject: [PATCH] chore: golang lint --- models/bots/run_job_list.go | 4 ++-- models/bots/task_list.go | 4 ++-- models/dbfs/dbfs_test.go | 3 ++- models/migrations/migrations.go | 1 - modules/bots/log.go | 2 +- modules/notification/bots/bots.go | 4 ++-- routers/common/runners.go | 8 ++++---- routers/web/web.go | 1 - templates/repo/bots/build_list.tmpl | 2 +- templates/repo/header.tmpl | 2 +- 10 files changed, 15 insertions(+), 16 deletions(-) diff --git a/models/bots/run_job_list.go b/models/bots/run_job_list.go index 89234657e1..6f65f4cf94 100644 --- a/models/bots/run_job_list.go +++ b/models/bots/run_job_list.go @@ -16,14 +16,14 @@ import ( type RunJobList []*RunJob func (jobs RunJobList) GetRunIDs() []int64 { - var runIDsMap = make(map[int64]struct{}) + runIDsMap := make(map[int64]struct{}) for _, j := range jobs { if j.RunID == 0 { continue } runIDsMap[j.RunID] = struct{}{} } - var runIDs = make([]int64, 0, len(runIDsMap)) + runIDs := make([]int64, 0, len(runIDsMap)) for runID := range runIDsMap { runIDs = append(runIDs, runID) } diff --git a/models/bots/task_list.go b/models/bots/task_list.go index 3b274eea43..19d338a9b8 100644 --- a/models/bots/task_list.go +++ b/models/bots/task_list.go @@ -16,14 +16,14 @@ import ( type TaskList []*Task func (tasks TaskList) GetJobIDs() []int64 { - var jobIDsMap = make(map[int64]struct{}) + jobIDsMap := make(map[int64]struct{}) for _, t := range tasks { if t.JobID == 0 { continue } jobIDsMap[t.JobID] = struct{}{} } - var jobIDs = make([]int64, 0, len(jobIDsMap)) + jobIDs := make([]int64, 0, len(jobIDsMap)) for jobID := range jobIDsMap { jobIDs = append(jobIDs, jobID) } diff --git a/models/dbfs/dbfs_test.go b/models/dbfs/dbfs_test.go index 9ebe23a1c5..45aedb1f90 100644 --- a/models/dbfs/dbfs_test.go +++ b/models/dbfs/dbfs_test.go @@ -13,8 +13,9 @@ import ( "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/unittest" - _ "github.com/mattn/go-sqlite3" "github.com/stretchr/testify/assert" + + _ "github.com/mattn/go-sqlite3" ) func changeDefaultFileBlockSize(n int64) (restore func()) { diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index 605303bbe2..dc05501e84 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -444,7 +444,6 @@ var migrations = []Migration{ // v235 -> v236 NewMigration("Add index for access_token", v1_19.AddIndexForAccessToken), - // in dev NewMigration("Add bots tables", addBotTables), } diff --git a/modules/bots/log.go b/modules/bots/log.go index d2cb0b00d8..fd08637b98 100644 --- a/modules/bots/log.go +++ b/modules/bots/log.go @@ -57,7 +57,7 @@ func WriteLogs(ctx context.Context, filename string, offset int64, rows []*runne return ns, nil } -func ReadLogs(ctx context.Context, inStorage bool, filename string, offset int64, limit int64) ([]*runnerv1.LogRow, error) { +func ReadLogs(ctx context.Context, inStorage bool, filename string, offset, limit int64) ([]*runnerv1.LogRow, error) { f, err := openLogs(ctx, inStorage, filename) if err != nil { return nil, err diff --git a/modules/notification/bots/bots.go b/modules/notification/bots/bots.go index 5264b6b686..0dac5fbc85 100644 --- a/modules/notification/bots/bots.go +++ b/modules/notification/bots/bots.go @@ -180,7 +180,7 @@ func (a *botsNotifier) NotifyIssueChangeStatus(ctx context.Context, doer *user_m } func (a *botsNotifier) NotifyIssueChangeLabels(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, - addedLabels []*issues_model.Label, removedLabels []*issues_model.Label, + _, _ []*issues_model.Label, ) { var err error if err = issue.LoadRepo(ctx); err != nil { @@ -288,7 +288,7 @@ func (a *botsNotifier) NotifyRenameRepository(ctx context.Context, doer *user_mo func (a *botsNotifier) NotifyTransferRepository(ctx context.Context, doer *user_model.User, repo *repo_model.Repository, oldOwnerName string) { } -func (a *botsNotifier) NotifyCreateRepository(ctx context.Context, doer *user_model.User, u *user_model.User, repo *repo_model.Repository) { +func (a *botsNotifier) NotifyCreateRepository(ctx context.Context, doer, u *user_model.User, repo *repo_model.Repository) { if err := notify(repo, doer, repo.DefaultBranch, webhook.HookEventRepository, &api.RepositoryPayload{ diff --git a/routers/common/runners.go b/routers/common/runners.go index a19a4e9590..d0cf15b30c 100644 --- a/routers/common/runners.go +++ b/routers/common/runners.go @@ -20,7 +20,6 @@ import ( // RunnersList render common runners list page func RunnersList(ctx *context.Context, tplName base.TplName, opts bots_model.FindRunnerOptions) { - count, err := bots_model.CountRunners(opts) if err != nil { ctx.ServerError("AdminRunners", err) @@ -65,7 +64,7 @@ func RunnersList(ctx *context.Context, tplName base.TplName, opts bots_model.Fin } // RunnerDetails render runner details page -func RunnerDetails(ctx *context.Context, tplName base.TplName, page int, runnerID int64, ownerID int64, repoID int64) { +func RunnerDetails(ctx *context.Context, tplName base.TplName, page int, runnerID, ownerID, repoID int64) { runner, err := bots_model.GetRunnerByID(runnerID) if err != nil { ctx.ServerError("GetRunnerByID", err) @@ -117,7 +116,7 @@ func RunnerDetails(ctx *context.Context, tplName base.TplName, page int, runnerI } // RunnerDetailsEditPost response for edit runner details -func RunnerDetailsEditPost(ctx *context.Context, runnerID int64, ownerID int64, repoID int64, redirectTo string) { +func RunnerDetailsEditPost(ctx *context.Context, runnerID, ownerID, repoID int64, redirectTo string) { runner, err := bots_model.GetRunnerByID(runnerID) if err != nil { log.Warn("RunnerDetailsEditPost.GetRunnerByID failed: %v, url: %s", err, ctx.Req.URL) @@ -162,7 +161,8 @@ func RunnerResetRegistrationToken(ctx *context.Context, ownerID, repoID int64, r // RunnerDeletePost response for deleting a runner func RunnerDeletePost(ctx *context.Context, runnerID int64, - successRedirectTo, failedRedirectTo string) { + successRedirectTo, failedRedirectTo string, +) { runner, err := bots_model.GetRunnerByID(runnerID) if err != nil { log.Warn("DeleteRunnerPost.GetRunnerByID failed: %v, url: %s", err, ctx.Req.URL) diff --git a/routers/web/web.go b/routers/web/web.go index b16aa86c74..618f5acd22 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -967,7 +967,6 @@ func RegisterRoutes(m *web.Route) { m.Post("/{runnerid}/delete", repo.RunnerDeletePost) m.Get("/reset_registration_token", repo.ResetRunnerRegistrationToken) }) - }, func(ctx *context.Context) { ctx.Data["PageIsSettings"] = true ctx.Data["LFSStartServer"] = setting.LFS.StartServer diff --git a/templates/repo/bots/build_list.tmpl b/templates/repo/bots/build_list.tmpl index 596603acf1..e84816e62d 100644 --- a/templates/repo/bots/build_list.tmpl +++ b/templates/repo/bots/build_list.tmpl @@ -16,7 +16,7 @@
-
{{ TimeSinceUnix .Updated $.locale }}
+
{{TimeSinceUnix .Updated $.locale}}
{{.TakeTime}}
diff --git a/templates/repo/header.tmpl b/templates/repo/header.tmpl index 52a5ead893..f5bce7d735 100644 --- a/templates/repo/header.tmpl +++ b/templates/repo/header.tmpl @@ -183,7 +183,7 @@ {{end}} - {{ if and (not .UnitBotsGlobalDisabled) (.Permission.CanRead $.UnitTypeBots)}} + {{if and (not .UnitBotsGlobalDisabled) (.Permission.CanRead $.UnitTypeBots)}} {{svg "octicon-play"}} {{.locale.Tr "repo.bots"}} {{if .Repository.NumOpenRuns}}