summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.golangci.yml9
-rw-r--r--cmd/hook.go2
-rw-r--r--integrations/api_issue_stopwatch_test.go2
-rw-r--r--integrations/api_packages_container_test.go4
-rw-r--r--integrations/editor_test.go6
-rw-r--r--integrations/git_test.go6
-rw-r--r--integrations/integration_test.go2
-rw-r--r--integrations/nonascii_branches_test.go2
-rw-r--r--integrations/oauth_test.go4
-rw-r--r--integrations/repo_fork_test.go2
-rw-r--r--integrations/repo_generate_test.go2
-rw-r--r--integrations/user_test.go2
-rw-r--r--models/action.go2
-rw-r--r--models/admin/notice.go2
-rw-r--r--models/asymkey/gpg_key_commit_verification.go2
-rw-r--r--models/asymkey/ssh_key_test.go6
-rw-r--r--models/auth/oauth2.go8
-rwxr-xr-xmodels/db/engine.go2
-rw-r--r--models/db/index.go2
-rw-r--r--models/db/list_options.go2
-rw-r--r--models/db/sql_postgres_with_schema.go2
-rw-r--r--models/git/branches.go8
-rw-r--r--models/git/commit_status.go2
-rw-r--r--models/issues/assignees.go4
-rw-r--r--models/issues/comment.go12
-rw-r--r--models/issues/issue.go14
-rw-r--r--models/issues/issue_project.go30
-rw-r--r--models/issues/issue_watch.go2
-rw-r--r--models/issues/issue_xref.go70
-rw-r--r--models/issues/pull.go2
-rw-r--r--models/issues/review.go20
-rw-r--r--models/issues/stopwatch.go4
-rw-r--r--models/issues/tracked_time.go8
-rw-r--r--models/migrations/v143.go2
-rw-r--r--models/migrations/v180.go2
-rw-r--r--models/migrations/v189.go2
-rw-r--r--models/notification.go10
-rw-r--r--models/organization/team.go4
-rw-r--r--models/packages/package_version.go2
-rw-r--r--models/perm/access/repo_permission.go2
-rw-r--r--models/project/issue.go4
-rw-r--r--models/release.go4
-rw-r--r--models/repo.go2
-rw-r--r--models/repo/archiver.go2
-rw-r--r--models/repo/repo.go6
-rw-r--r--models/statistic.go2
-rw-r--r--models/unit/unit.go2
-rw-r--r--models/user/search.go2
-rw-r--r--models/webhook/hooktask.go2
-rw-r--r--modules/activitypub/client.go6
-rw-r--r--modules/activitypub/user_settings.go4
-rw-r--r--modules/base/natural_sort.go2
-rw-r--r--modules/charset/charset_test.go4
-rw-r--r--modules/charset/escape.go6
-rw-r--r--modules/context/api.go2
-rw-r--r--modules/context/private.go2
-rw-r--r--modules/context/repo.go4
-rw-r--r--modules/context/utils.go2
-rw-r--r--modules/convert/convert.go2
-rw-r--r--modules/convert/issue.go2
-rw-r--r--modules/doctor/fix16961.go2
-rw-r--r--modules/eventsource/event.go6
-rw-r--r--modules/git/batch_reader.go10
-rw-r--r--modules/git/blob_nogogit.go2
-rw-r--r--modules/git/commit.go2
-rw-r--r--modules/git/commit_info_nogogit.go2
-rw-r--r--modules/git/diff.go2
-rw-r--r--modules/git/pipeline/lfs_nogogit.go2
-rw-r--r--modules/git/repo_attribute.go2
-rw-r--r--modules/git/repo_base_nogogit.go2
-rw-r--r--modules/git/repo_branch_nogogit.go2
-rw-r--r--modules/git/repo_compare.go6
-rw-r--r--modules/git/repo_compare_test.go4
-rw-r--r--modules/git/repo_index.go2
-rw-r--r--modules/git/repo_tag_nogogit.go2
-rw-r--r--modules/git/sha1_nogogit.go2
-rw-r--r--modules/git/signature_nogogit.go2
-rw-r--r--modules/git/utils.go2
-rw-r--r--modules/gitgraph/graph_test.go2
-rw-r--r--modules/graceful/context.go2
-rw-r--r--modules/highlight/highlight.go8
-rw-r--r--modules/indexer/code/bleve.go2
-rw-r--r--modules/indexer/code/elastic_search.go2
-rw-r--r--modules/markup/common/footnote.go3
-rw-r--r--modules/markup/markdown/markdown.go4
-rw-r--r--modules/markup/orgmode/orgmode.go4
-rw-r--r--modules/markup/sanitizer_test.go2
-rw-r--r--modules/migration/issue.go10
-rw-r--r--modules/nosql/manager.go2
-rw-r--r--modules/nosql/manager_leveldb.go2
-rw-r--r--modules/nosql/manager_redis.go2
-rw-r--r--modules/packages/multi_hasher.go2
-rw-r--r--modules/process/manager.go2
-rw-r--r--modules/process/manager_stacktraces.go2
-rw-r--r--modules/queue/helper.go2
-rw-r--r--modules/queue/queue_bytefifo.go4
-rw-r--r--modules/queue/queue_disk_channel.go2
-rw-r--r--modules/queue/unique_queue_disk_channel.go2
-rw-r--r--modules/references/references.go4
-rw-r--r--modules/repository/hooks.go2
-rw-r--r--modules/setting/database.go4
-rw-r--r--modules/setting/federation.go2
-rw-r--r--modules/setting/i18n.go4
-rw-r--r--modules/setting/log.go2
-rw-r--r--modules/setting/service.go2
-rw-r--r--modules/storage/storage.go12
-rw-r--r--modules/structs/org_type.go2
-rw-r--r--modules/templates/helper.go4
-rw-r--r--modules/templates/helper_test.go4
-rw-r--r--modules/timeutil/since.go4
-rw-r--r--modules/timeutil/timestamp.go2
-rw-r--r--modules/util/io.go2
-rw-r--r--modules/web/wrap_convert.go18
-rw-r--r--routers/api/v1/activitypub/reqsignature.go6
-rw-r--r--routers/api/v1/notify/notifications.go2
-rw-r--r--routers/api/v1/org/org.go2
-rw-r--r--routers/api/v1/repo/file.go2
-rw-r--r--routers/api/v1/repo/issue_label.go2
-rw-r--r--routers/api/v1/repo/status.go2
-rw-r--r--routers/api/v1/utils/hook.go2
-rw-r--r--routers/private/hook_pre_receive.go2
-rw-r--r--routers/private/manager_process.go2
-rw-r--r--routers/private/serv.go2
-rw-r--r--routers/web/admin/repos.go2
-rw-r--r--routers/web/auth/oauth.go2
-rw-r--r--routers/web/feed/convert.go4
-rw-r--r--routers/web/repo/branch.go2
-rw-r--r--routers/web/repo/download.go2
-rw-r--r--routers/web/repo/editor_test.go4
-rw-r--r--routers/web/repo/projects.go2
-rw-r--r--routers/web/repo/view.go2
-rw-r--r--routers/web/user/setting/profile.go2
-rw-r--r--routers/web/web.go4
-rw-r--r--services/agit/agit.go4
-rw-r--r--services/auth/source/ldap/source_search.go186
-rw-r--r--services/auth/sspi_windows.go2
-rw-r--r--services/automerge/automerge.go2
-rw-r--r--services/gitdiff/gitdiff.go7
-rw-r--r--services/issue/assignee.go6
-rw-r--r--services/issue/issue.go2
-rw-r--r--services/mailer/mail.go8
-rw-r--r--services/mailer/mail_test.go2
-rw-r--r--services/migrations/onedev.go2
-rw-r--r--services/pull/merge.go4
-rw-r--r--services/pull/review.go2
-rw-r--r--services/task/migrate.go2
-rw-r--r--services/webhook/webhook.go4
147 files changed, 402 insertions, 397 deletions
diff --git a/.golangci.yml b/.golangci.yml
index 4ad9c9d4cb..11c58454a0 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -19,6 +19,11 @@ linters:
- revive
- gofumpt
- depguard
+ - nakedret
+ - unconvert
+ - wastedassign
+ - nolintlint
+ - stylecheck
enable-all: false
disable-all: true
fast: false
@@ -32,6 +37,10 @@ run:
- web_src
linters-settings:
+ stylecheck:
+ checks: ["all", "-ST1005", "-ST1003"]
+ nakedret:
+ max-func-lines: 0
gocritic:
disabled-checks:
- ifElseChain
diff --git a/cmd/hook.go b/cmd/hook.go
index 73386038b3..ab6d48b545 100644
--- a/cmd/hook.go
+++ b/cmd/hook.go
@@ -792,7 +792,7 @@ func writeDataPktLine(out io.Writer, data []byte) error {
if err != nil {
return fail("Internal Server Error", "Pkt-Line response failed: %v", err)
}
- if 4 != lr {
+ if lr != 4 {
return fail("Internal Server Error", "Pkt-Line response failed: %v", err)
}
diff --git a/integrations/api_issue_stopwatch_test.go b/integrations/api_issue_stopwatch_test.go
index 0d06447181..b4e5f90543 100644
--- a/integrations/api_issue_stopwatch_test.go
+++ b/integrations/api_issue_stopwatch_test.go
@@ -38,7 +38,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, int64(apiWatches[0].Seconds), int64(0))
+ assert.Greater(t, apiWatches[0].Seconds, int64(0))
}
}
diff --git a/integrations/api_packages_container_test.go b/integrations/api_packages_container_test.go
index 2b5be9dd4c..1ed80dfd02 100644
--- a/integrations/api_packages_container_test.go
+++ b/integrations/api_packages_container_test.go
@@ -88,7 +88,7 @@ func TestPackageContainer(t *testing.T) {
req = NewRequest(t, "GET", fmt.Sprintf("%sv2", setting.AppURL))
addTokenAuthHeader(req, anonymousToken)
- resp = MakeRequest(t, req, http.StatusOK)
+ MakeRequest(t, req, http.StatusOK)
})
t.Run("User", func(t *testing.T) {
@@ -112,7 +112,7 @@ func TestPackageContainer(t *testing.T) {
req = NewRequest(t, "GET", fmt.Sprintf("%sv2", setting.AppURL))
addTokenAuthHeader(req, userToken)
- resp = MakeRequest(t, req, http.StatusOK)
+ MakeRequest(t, req, http.StatusOK)
})
})
diff --git a/integrations/editor_test.go b/integrations/editor_test.go
index 3ed0e510c4..c6c5ab2f61 100644
--- a/integrations/editor_test.go
+++ b/integrations/editor_test.go
@@ -82,7 +82,7 @@ func TestCreateFileOnProtectedBranch(t *testing.T) {
"_csrf": csrf,
"protected": "off",
})
- resp = session.MakeRequest(t, req, http.StatusSeeOther)
+ session.MakeRequest(t, req, http.StatusSeeOther)
// Check if master branch has been locked successfully
flashCookie = session.GetCookie("macaron_flash")
assert.NotNil(t, flashCookie)
@@ -109,7 +109,7 @@ func testEditFile(t *testing.T, session *TestSession, user, repo, branch, filePa
"commit_choice": "direct",
},
)
- resp = session.MakeRequest(t, req, http.StatusSeeOther)
+ session.MakeRequest(t, req, http.StatusSeeOther)
// Verify the change
req = NewRequest(t, "GET", path.Join(user, repo, "raw/branch", branch, filePath))
@@ -139,7 +139,7 @@ func testEditFileToNewBranch(t *testing.T, session *TestSession, user, repo, bra
"new_branch_name": targetBranch,
},
)
- resp = session.MakeRequest(t, req, http.StatusSeeOther)
+ session.MakeRequest(t, req, http.StatusSeeOther)
// Verify the change
req = NewRequest(t, "GET", path.Join(user, repo, "raw/branch", targetBranch, filePath))
diff --git a/integrations/git_test.go b/integrations/git_test.go
index a3ba7b7aa9..d6bd673822 100644
--- a/integrations/git_test.go
+++ b/integrations/git_test.go
@@ -150,7 +150,7 @@ func standardCommitAndPushTest(t *testing.T, dstPath string) (little, big string
defer PrintCurrentTest(t)()
little, big = commitAndPushTest(t, dstPath, "data-file-")
})
- return
+ return little, big
}
func lfsCommitAndPushTest(t *testing.T, dstPath string) (littleLFS, bigLFS string) {
@@ -191,7 +191,7 @@ func lfsCommitAndPushTest(t *testing.T, dstPath string) (littleLFS, bigLFS strin
lockTest(t, dstPath)
})
})
- return
+ return littleLFS, bigLFS
}
func commitAndPushTest(t *testing.T, dstPath, prefix string) (little, big string) {
@@ -210,7 +210,7 @@ func commitAndPushTest(t *testing.T, dstPath, prefix string) (little, big string
big = doCommitAndPush(t, bigSize, dstPath, prefix)
})
})
- return
+ return little, big
}
func rawTest(t *testing.T, ctx *APITestContext, little, big, littleLFS, bigLFS string) {
diff --git a/integrations/integration_test.go b/integrations/integration_test.go
index b0004927f7..8a43de7c45 100644
--- a/integrations/integration_test.go
+++ b/integrations/integration_test.go
@@ -438,7 +438,7 @@ func getTokenForLoggedInUser(t testing.TB, session *TestSession) string {
"_csrf": doc.GetCSRF(),
"name": fmt.Sprintf("api-testing-token-%d", tokenCounter),
})
- resp = session.MakeRequest(t, req, http.StatusSeeOther)
+ session.MakeRequest(t, req, http.StatusSeeOther)
req = NewRequest(t, "GET", "/user/settings/applications")
resp = session.MakeRequest(t, req, http.StatusOK)
htmlDoc := NewHTMLParser(t, resp.Body)
diff --git a/integrations/nonascii_branches_test.go b/integrations/nonascii_branches_test.go
index 5ab7b8526a..038ada8ca2 100644
--- a/integrations/nonascii_branches_test.go
+++ b/integrations/nonascii_branches_test.go
@@ -26,7 +26,7 @@ func testSrcRouteRedirect(t *testing.T, session *TestSession, user, repo, route,
// Perform redirect
req = NewRequest(t, "GET", location)
- resp = session.MakeRequest(t, req, expectedStatus)
+ session.MakeRequest(t, req, expectedStatus)
}
func setDefaultBranch(t *testing.T, session *TestSession, user, repo, branch string) {
diff --git a/integrations/oauth_test.go b/integrations/oauth_test.go
index 678dfbae2d..c16bb4e24c 100644
--- a/integrations/oauth_test.go
+++ b/integrations/oauth_test.go
@@ -197,7 +197,7 @@ func TestAccessTokenExchangeWithBasicAuth(t *testing.T) {
"code_verifier": "N1Zo9-8Rfwhkt68r1r29ty8YwIraXR8eh_1Qwxg7yQXsonBt", // test PKCE additionally
})
req.Header.Add("Authorization", "Basic ZGE3ZGEzYmEtOWExMy00MTY3LTg1NmYtMzg5OWRlMGIwMTM4OmJsYWJsYQ==")
- resp = MakeRequest(t, req, http.StatusBadRequest)
+ MakeRequest(t, req, http.StatusBadRequest)
// missing header
req = NewRequestWithValues(t, "POST", "/login/oauth/access_token", map[string]string{
@@ -206,7 +206,7 @@ func TestAccessTokenExchangeWithBasicAuth(t *testing.T) {
"code": "authcode",
"code_verifier": "N1Zo9-8Rfwhkt68r1r29ty8YwIraXR8eh_1Qwxg7yQXsonBt", // test PKCE additionally
})
- resp = MakeRequest(t, req, http.StatusBadRequest)
+ MakeRequest(t, req, http.StatusBadRequest)
}
func TestRefreshTokenInvalidation(t *testing.T) {
diff --git a/integrations/repo_fork_test.go b/integrations/repo_fork_test.go
index d701850f14..5f28e66ac8 100644
--- a/integrations/repo_fork_test.go
+++ b/integrations/repo_fork_test.go
@@ -45,7 +45,7 @@ func testRepoFork(t *testing.T, session *TestSession, ownerName, repoName, forkO
"uid": fmt.Sprintf("%d", forkOwner.ID),
"repo_name": forkRepoName,
})
- resp = session.MakeRequest(t, req, http.StatusSeeOther)
+ session.MakeRequest(t, req, http.StatusSeeOther)
// Step4: check the existence of the forked repo
req = NewRequestf(t, "GET", "/%s/%s", forkOwnerName, forkRepoName)
diff --git a/integrations/repo_generate_test.go b/integrations/repo_generate_test.go
index 4fbbb56c50..0123932a74 100644
--- a/integrations/repo_generate_test.go
+++ b/integrations/repo_generate_test.go
@@ -46,7 +46,7 @@ func testRepoGenerate(t *testing.T, session *TestSession, templateOwnerName, tem
"repo_name": generateRepoName,
"git_content": "true",
})
- resp = session.MakeRequest(t, req, http.StatusSeeOther)
+ session.MakeRequest(t, req, http.StatusSeeOther)
// Step4: check the existence of the generated repo
req = NewRequestf(t, "GET", "/%s/%s", generateOwnerName, generateRepoName)
diff --git a/integrations/user_test.go b/integrations/user_test.go
index 6a3d30472d..41127a4e40 100644
--- a/integrations/user_test.go
+++ b/integrations/user_test.go
@@ -245,6 +245,6 @@ 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, int64(apiWatches[0].Seconds), int64(0))
+ assert.Greater(t, apiWatches[0].Seconds, int64(0))
}
}
diff --git a/models/action.go b/models/action.go
index 78cc93e1a2..791759f7e8 100644
--- a/models/action.go
+++ b/models/action.go
@@ -459,7 +459,7 @@ func DeleteOldActions(olderThan time.Duration) (err error) {
}
_, err = db.GetEngine(db.DefaultContext).Where("created_unix < ?", time.Now().Add(-olderThan).Unix()).Delete(&Action{})
- return
+ return err
}
func notifyWatchers(ctx context.Context, actions ...*Action) error {
diff --git a/models/admin/notice.go b/models/admin/notice.go
index 77277e4b2d..4d385cf951 100644
--- a/models/admin/notice.go
+++ b/models/admin/notice.go
@@ -142,5 +142,5 @@ func DeleteOldSystemNotices(olderThan time.Duration) (err error) {
}
_, err = db.GetEngine(db.DefaultContext).Where("created_unix < ?", time.Now().Add(-olderThan).Unix()).Delete(&Notice{})
- return
+ return err
}
diff --git a/models/asymkey/gpg_key_commit_verification.go b/models/asymkey/gpg_key_commit_verification.go
index 2f66863091..d5b06f83fd 100644
--- a/models/asymkey/gpg_key_commit_verification.go
+++ b/models/asymkey/gpg_key_commit_verification.go
@@ -520,5 +520,5 @@ func CalculateTrustStatus(verification *CommitVerification, repoTrustModel repo_
}
}
- return
+ return err
}
diff --git a/models/asymkey/ssh_key_test.go b/models/asymkey/ssh_key_test.go
index 71c8860f1c..adffedd0b6 100644
--- a/models/asymkey/ssh_key_test.go
+++ b/models/asymkey/ssh_key_test.go
@@ -317,7 +317,7 @@ func TestFromOpenSSH(t *testing.T) {
td := t.TempDir()
data := []byte("hello, ssh world")
- dataPath := write(t, []byte(data), td, "data")
+ dataPath := write(t, data, td, "data")
privPath := write(t, []byte(tt.priv), td, "id")
write(t, []byte(tt.pub), td, "id.pub")
@@ -372,14 +372,14 @@ func TestToOpenSSH(t *testing.T) {
td := t.TempDir()
data := []byte("hello, ssh world")
- write(t, []byte(data), td, "data")
+ write(t, data, td, "data")
armored, err := sshsig.Sign([]byte(tt.priv), bytes.NewReader(data), "file")
if err != nil {
t.Fatal(err)
}
- sigPath := write(t, []byte(armored), td, "oursig")
+ sigPath := write(t, armored, td, "oursig")
// Create an allowed_signers file with two keys to check against.
allowedSigner := "test@rekor.dev " + tt.pub + "\n"
diff --git a/models/auth/oauth2.go b/models/auth/oauth2.go
index c5c6e91120..5a58ec62b7 100644
--- a/models/auth/oauth2.go
+++ b/models/auth/oauth2.go
@@ -123,7 +123,7 @@ func GetOAuth2ApplicationByClientID(ctx context.Context, clientID string) (app *
if !has {
return nil, ErrOAuthClientIDInvalid{ClientID: clientID}
}
- return
+ return app, err
}
// GetOAuth2ApplicationByID returns the oauth2 application with the given id. Returns an error if not found.
@@ -143,7 +143,7 @@ func GetOAuth2ApplicationByID(ctx context.Context, id int64) (app *OAuth2Applica
func GetOAuth2ApplicationsByUserID(ctx context.Context, userID int64) (apps []*OAuth2Application, err error) {
apps = make([]*OAuth2Application, 0)
err = db.GetEngine(ctx).Where("uid = ?", userID).Find(&apps)
- return
+ return apps, err
}
// CreateOAuth2ApplicationOptions holds options to create an oauth2 application
@@ -300,7 +300,7 @@ func (code *OAuth2AuthorizationCode) GenerateRedirectURI(state string) (redirect
}
q.Set("code", code.Code)
redirect.RawQuery = q.Encode()
- return
+ return redirect, err
}
// Invalidate deletes the auth code from the database to invalidate this code
@@ -430,7 +430,7 @@ func GetOAuth2GrantByID(ctx context.Context, id int64) (grant *OAuth2Grant, err
} else if !has {
return nil, nil
}
- return
+ return grant, err
}
// GetOAuth2GrantsByUserID lists all grants of a certain user
diff --git a/models/db/engine.go b/models/db/engine.go
index 8a3b4b206e..93cf5ad8bc 100755
--- a/models/db/engine.go
+++ b/models/db/engine.go
@@ -285,5 +285,5 @@ func DeleteAllRecords(tableName string) error {
// GetMaxID will return max id of the table
func GetMaxID(beanOrTableName interface{}) (maxID int64, err error) {
_, err = x.Select("MAX(id)").Table(beanOrTableName).Get(&maxID)
- return
+ return maxID, err
}
diff --git a/models/db/index.go b/models/db/index.go
index 9b164db1fa..673c382b27 100644
--- a/models/db/index.go
+++ b/models/db/index.go
@@ -44,7 +44,7 @@ func UpsertResourceIndex(ctx context.Context, tableName string, groupID int64) (
default:
return fmt.Errorf("database type not supported")
}
- return
+ return err
}
var (
diff --git a/models/db/list_options.go b/models/db/list_options.go
index d1d52b6667..54f6d945c8 100644
--- a/models/db/list_options.go
+++ b/models/db/list_options.go
@@ -58,7 +58,7 @@ func (opts *ListOptions) GetSkipTake() (skip, take int) {
func (opts *ListOptions) GetStartEnd() (start, end int) {
start, take := opts.GetSkipTake()
end = start + take
- return
+ return start, end
}
// SetDefaultValues sets default values
diff --git a/models/db/sql_postgres_with_schema.go b/models/db/sql_postgres_with_schema.go
index d6b6262927..4bbd12bdeb 100644
--- a/models/db/sql_postgres_with_schema.go
+++ b/models/db/sql_postgres_with_schema.go
@@ -44,7 +44,7 @@ func (d *postgresSchemaDriver) Open(name string) (driver.Conn, error) {
_, err := execer.Exec(`SELECT set_config(
'search_path',
$1 || ',' || current_setting('search_path'),
- false)`, []driver.Value{schemaValue}) //nolint
+ false)`, []driver.Value{schemaValue})
if err != nil {
_ = conn.Close()
return nil, err
diff --git a/models/git/branches.go b/models/git/branches.go
index 0a44c0a68d..7f05a56676 100644
--- a/models/git/branches.go
+++ b/models/git/branches.go
@@ -363,7 +363,7 @@ func updateApprovalWhitelist(ctx context.Context, repo *repo_model.Repository, c
whitelist = append(whitelist, userID)
}
- return
+ return whitelist, err
}
// updateUserWhitelist checks whether the user whitelist changed and returns a whitelist with
@@ -392,7 +392,7 @@ func updateUserWhitelist(ctx context.Context, repo *repo_model.Repository, curre
whitelist = append(whitelist, userID)
}
- return
+ return whitelist, err
}
// updateTeamWhitelist checks whether the team whitelist changed and returns a whitelist with
@@ -415,7 +415,7 @@ func updateTeamWhitelist(ctx context.Context, repo *repo_model.Repository, curre
}
}
- return
+ return whitelist, err
}
// DeleteProtectedBranch removes ProtectedBranch relation between the user and repository.
@@ -539,7 +539,7 @@ func FindRenamedBranch(repoID int64, from string) (branch *RenamedBranch, exist
}
exist, err = db.GetEngine(db.DefaultContext).Get(branch)
- return
+ return branch, exist, err
}
// RenameBranch rename a branch
diff --git a/models/git/commit_status.go b/models/git/commit_status.go
index 54a7b43199..9e24221862 100644
--- a/models/git/commit_status.go
+++ b/models/git/commit_status.go
@@ -74,7 +74,7 @@ func upsertCommitStatusIndex(ctx context.Context, repoID int64, sha string) (err
default:
return fmt.Errorf("database type not supported")
}
- return
+ return err
}
// GetNextCommitStatusIndex retried 3 times to generate a resource index
diff --git a/models/issues/assignees.go b/models/issues/assignees.go
index 5921112fea..7f589f5d7e 100644
--- a/models/issues/assignees.go
+++ b/models/issues/assignees.go
@@ -42,7 +42,7 @@ func (issue *Issue) LoadAssignees(ctx context.Context) (err error) {
if len(issue.Assignees) > 0 {
issue.Assignee = issue.Assignees[0]
}
- return
+ return err
}
// GetAssigneeIDsByIssue returns the IDs of users assigned to an issue
@@ -167,5 +167,5 @@ func MakeIDsFromAPIAssigneesToAdd(oneAssignee string, multipleAssignees []string
// Get the IDs of all assignees
assigneeIDs, err = user_model.GetUserIDsByNames(requestAssignees, false)
- return
+ return assigneeIDs, err
}
diff --git a/models/issues/comment.go b/models/issues/comment.go
index a4e69e7118..a71afda9e0 100644
--- a/models/issues/comment.go
+++ b/models/issues/comment.go
@@ -315,7 +315,7 @@ func (c *Comment) LoadIssueCtx(ctx context.Context) (err error) {
return nil
}
c.Issue, err = GetIssueByID(ctx, c.IssueID)
- return
+ return err
}
// BeforeInsert will be invoked by XORM before inserting a record
@@ -627,7 +627,7 @@ func (c *Comment) LoadResolveDoer() (err error) {
err = nil
}
}
- return
+ return err
}
// IsResolved check if an code comment is resolved
@@ -955,7 +955,7 @@ func createIssueDependencyComment(ctx context.Context, doer *user_model.User, is
DependentIssueID: issue.ID,
}
_, err = CreateCommentCtx(ctx, opts)
- return
+ return err
}
// CreateCommentOptions defines options for creating comment
@@ -1350,7 +1350,7 @@ func CreatePushPullComment(ctx context.Context, pusher *user_model.User, pr *Pul
comment, err = CreateComment(ops)
- return
+ return comment, err
}
// CreateAutoMergeComment is a internal function, only use it for CommentTypePRScheduledToAutoMerge and CommentTypePRUnScheduledToAutoMerge CommentTypes
@@ -1372,7 +1372,7 @@ func CreateAutoMergeComment(ctx context.Context, typ CommentType, pr *PullReques
Repo: pr.BaseRepo,
Issue: pr.Issue,
})
- return
+ return comment, err
}
// getCommitsFromRepo get commit IDs from repo in between oldCommitID and newCommitID
@@ -1434,7 +1434,7 @@ func getCommitIDsFromRepo(ctx context.Context, repo *repo_model.Repository, oldC
}
}
- return
+ return commitIDs, isForcePush, err
}
type commitBranchCheckItem struct {
diff --git a/models/issues/issue.go b/models/issues/issue.go
index 76a0ea7d0c..064f0d22ab 100644
--- a/models/issues/issue.go
+++ b/models/issues/issue.go
@@ -223,7 +223,7 @@ func (issue *Issue) GetPullRequest() (pr *PullRequest, err error) {
return nil, err
}
pr.Issue = issue
- return
+ return pr, err
}
// LoadLabels loads labels
@@ -255,7 +255,7 @@ func (issue *Issue) loadPoster(ctx context.Context) (err error) {
return
}
}
- return
+ return err
}
func (issue *Issue) loadPullRequest(ctx context.Context) (err error) {
@@ -311,7 +311,7 @@ func (issue *Issue) loadReactions(ctx context.Context) (err error) {
return err
}
// Load reaction user data
- if _, err := ReactionList(reactions).LoadUsers(ctx, issue.Repo); err != nil {
+ if _, err := reactions.LoadUsers(ctx, issue.Repo); err != nil {
return err
}
@@ -2110,7 +2110,7 @@ func updateIssueClosedNum(ctx context.Context, issue *Issue) (err error) {
} else {
err = repo_model.StatsCorrectNumClosed(ctx, issue.RepoID, false, "num_closed_issues")
}
- return
+ return err
}
// FindAndUpdateIssueMentions finds users mentioned in the given content string, and saves them in the database.
@@ -2123,7 +2123,7 @@ func FindAndUpdateIssueMentions(ctx context.Context, issue *Issue, doer *user_mo
if err = UpdateIssueMentions(ctx, issue.ID, mentions); err != nil {
return nil, fmt.Errorf("UpdateIssueMentions [%d]: %v", issue.ID, err)
}
- return
+ return mentions, err
}
// ResolveIssueMentionsByVisibility returns the users mentioned in an issue, removing those that
@@ -2257,7 +2257,7 @@ func ResolveIssueMentionsByVisibility(ctx context.Context, issue *Issue, doer *u
users = append(users, user)
}
- return
+ return users, err
}
// UpdateIssuesMigrationsByType updates all migrated repositories' issues from gitServiceType to replace originalAuthorID to posterID
@@ -2380,7 +2380,7 @@ func DeleteIssuesByRepoID(ctx context.Context, repoID int64) (attachmentPaths []
return
}
- return
+ return attachmentPaths, err
}
// RemapExternalUser ExternalUserRemappable interface
diff --git a/models/issues/issue_project.go b/models/issues/issue_project.go
index 5e0a337f7d..b83665c2bb 100644
--- a/models/issues/issue_project.go
+++ b/models/issues/issue_project.go
@@ -14,32 +14,32 @@ import (
)
// LoadProject load the project the issue was assigned to
-func (i *Issue) LoadProject() (err error) {
- return i.loadProject(db.DefaultContext)
+func (issue *Issue) LoadProject() (err error) {
+ return issue.loadProject(db.DefaultContext)
}
-func (i *Issue) loadProject(ctx context.Context) (err error) {
- if i.Project == nil {
+func (issue *Issue) loadProject(ctx context.Context) (err error) {
+ if issue.Project == nil {
var p project_model.Project
if _, err = db.GetEngine(ctx).Table("project").
Join("INNER", "project_issue", "project.id=project_issue.project_id").
- Where("project_issue.issue_id = ?", i.ID).
+ Where("project_issue.issue_id = ?", issue.ID).
Get(&p); err != nil {
return err
}
- i.Project = &p
+ issue.Project = &p
}
- return
+ return err
}
// ProjectID return project id if issue was assigned to one
-func (i *Issue) ProjectID() int64 {
- return i.projectID(db.DefaultContext)
+func (issue *Issue) ProjectID() int64 {
+ return issue.projectID(db.DefaultContext)
}
-func (i *Issue) projectID(ctx context.Context) int64 {
+func (issue *Issue) projectID(ctx context.Context) int64 {
var ip project_model.ProjectIssue
- has, err := db.GetEngine(ctx).Where("issue_id=?", i.ID).Get(&ip)
+ has, err := db.GetEngine(ctx).Where("issue_id=?", issue.ID).Get(&ip)
if err != nil || !has {
return 0
}
@@ -47,13 +47,13 @@ func (i *Issue) projectID(ctx context.Context) int64 {
}
// ProjectBoardID return project board id if issue was assigned to one
-func (i *Issue) ProjectBoardID() int64 {
- return i.projectBoardID(db.DefaultContext)
+func (issue *Issue) ProjectBoardID() int64 {
+ return issue.projectBoardID(db.DefaultContext)
}
-func (i *Issue) projectBoardID(ctx context.Context) int64 {
+func (issue *Issue) projectBoardID(ctx context.Context) int64 {
var ip project_model.ProjectIssue
- has, err := db.GetEngine(ctx).Where("issue_id=?", i.ID).Get(&ip)
+ has, err := db.GetEngine(ctx).Where("issue_id=?", issue.ID).Get(&ip)
if err != nil || !has {
return 0
}
diff --git a/models/issues/issue_watch.go b/models/issues/issue_watch.go
index bf907aa8fd..cb9d7e7125 100644
--- a/models/issues/issue_watch.go
+++ b/models/issues/issue_watch.go
@@ -65,7 +65,7 @@ func GetIssueWatch(ctx context.Context, userID, issueID int64) (iw *IssueWatch,
Where("user_id = ?", userID).
And("issue_id = ?", issueID).
Get(iw)
- return
+ return iw, exists, err
}
// CheckIssueWatch check if an user is watching an issue
diff --git a/models/issues/issue_xref.go b/models/issues/issue_xref.go
index f4380a02ec..6de91058e8 100644
--- a/models/issues/issue_xref.go
+++ b/models/issues/issue_xref.go
@@ -231,46 +231,46 @@ func (issue *Issue) verifyReferencedIssue(stdCtx context.Context, ctx *crossRefe
}
// AddCrossReferences add cross references
-func (comment *Comment) AddCrossReferences(stdCtx context.Context, doer *user_model.User, removeOld bool) error {
- if comment.Type != CommentTypeCode && comment.Type != CommentTypeComment {
+func (c *Comment) AddCrossReferences(stdCtx context.Context, doer *user_model.User, removeOld bool) error {
+ if c.Type != CommentTypeCode && c.Type != CommentTypeComment {
return nil
}
- if err := comment.LoadIssueCtx(stdCtx); err != nil {
+ if err := c.LoadIssueCtx(stdCtx); err != nil {
return err
}
ctx := &crossReferencesContext{
Type: CommentTypeCommentRef,
Doer: doer,
- OrigIssue: comment.Issue,
- OrigComment: comment,
+ OrigIssue: c.Issue,
+ OrigComment: c,
RemoveOld: removeOld,
}
- return comment.Issue.createCrossReferences(stdCtx, ctx, "", comment.Content)
+ return c.Issue.createCrossReferences(stdCtx, ctx, "", c.Content)
}
-func (comment *Comment) neuterCrossReferences(ctx context.Context) error {
- return neuterCrossReferences(ctx, comment.IssueID, comment.ID)
+func (c *Comment) neuterCrossReferences(ctx context.Context) error {
+ return neuterCrossReferences(ctx, c.IssueID, c.ID)
}
// LoadRefComment loads comment that created this reference from database
-func (comment *Comment) LoadRefComment() (err error) {
- if comment.RefComment != nil {
+func (c *Comment) LoadRefComment() (err error) {
+ if c.RefComment != nil {
return nil
}
- comment.RefComment, err = GetCommentByID(db.DefaultContext, comment.RefCommentID)
- return
+ c.RefComment, err = GetCommentByID(db.DefaultContext, c.RefCommentID)
+ return err
}
// LoadRefIssue loads comment that created this reference from database
-func (comment *Comment) LoadRefIssue() (err error) {
- if comment.RefIssue != nil {
+func (c *Comment) LoadRefIssue() (err error) {
+ if c.RefIssue != nil {
return nil
}
- comment.RefIssue, err = GetIssueByID(db.DefaultContext, comment.RefIssueID)
+ c.RefIssue, err = GetIssueByID(db.DefaultContext, c.RefIssueID)
if err == nil {
- err = comment.RefIssue.LoadRepo(db.DefaultContext)
+ err = c.RefIssue.LoadRepo(db.DefaultContext)
}
- return
+ return err
}
// CommentTypeIsRef returns true if CommentType is a reference from another issue
@@ -279,44 +279,44 @@ func CommentTypeIsRef(t CommentType) bool {
}
// RefCommentHTMLURL returns the HTML URL for the comment that created this reference
-func (comment *Comment) RefCommentHTMLURL() string {
+func (c *Comment) RefCommentHTMLURL() string {
// Edge case for when the reference is inside the title or the description of the referring issue
- if comment.RefCommentID == 0 {
- return comment.RefIssueHTMLURL()
+ if c.RefCommentID == 0 {
+ return c.RefIssueHTMLURL()
}
- if err := comment.LoadRefComment(); err != nil { // Silently dropping errors :unamused:
- log.Error("LoadRefComment(%d): %v", comment.RefCommentID, err)
+ if err := c.LoadRefComment(); err != nil { // Silently dropping errors :unamused:
+ log.Error("LoadRefComment(%d): %v", c.RefCommentID, err)
return ""
}
- return comment.RefComment.HTMLURL()
+ return c.RefComment.HTMLURL()
}
// RefIssueHTMLURL returns the HTML URL of the issue where this reference was created
-func (comment *Comment) RefIssueHTMLURL() string {
- if err := comment.LoadRefIssue(); err != nil { // Silently dropping errors :unamused:
- log.Error("LoadRefIssue(%d): %v", comment.RefCommentID, err)
+func (c *Comment) RefIssueHTMLURL() string {
+ if err := c.LoadRefIssue(); err != nil { // Silently dropping errors :unamused:
+ log.Error("LoadRefIssue(%d): %v", c.RefCommentID, err)
return ""
}
- return comment.RefIssue.HTMLURL()
+ return c.RefIssue.HTMLURL()
}
// RefIssueTitle returns the title of the issue where this reference was created
-func (comment *Comment) RefIssueTitle() string {
- if err := comment.LoadRefIssue(); err != nil { // Silently dropping errors :unamused:
- log.Error("LoadRefIssue(%d): %v", comment.RefCommentID, err)
+func (c *Comment) RefIssueTitle() string {
+ if err := c.LoadRefIssue(); err != nil { // Silently dropping errors :unamused:
+ log.Error("LoadRefIssue(%d): %v", c.RefCommentID, err)
return ""
}
- return comment.RefIssue.Title
+ return c.RefIssue.Title
}
// RefIssueIdent returns the user friendly identity (e.g. "#1234") of the issue where this reference was created
-func (comment *Comment) RefIssueIdent() string {
- if err := comment.LoadRefIssue(); err != nil { // Silently dropping errors :unamused:
- log.Error("LoadRefIssue(%d): %v", comment.RefCommentID, err)
+func (c *Comment) RefIssueIdent() string {
+ if err := c.LoadRefIssue(); err != nil { // Silently dropping errors :unamused:
+ log.Error("LoadRefIssue(%d): %v", c.RefCommentID, err)
return ""
}
// FIXME: check this name for cross-repository references (#7901 if it gets merged)
- return fmt.Sprintf("#%d", comment.RefIssue.Index)
+ return fmt.Sprintf("#%d", c.RefIssue.Index)
}
// __________ .__ .__ __________ __
diff --git a/models/issues/pull.go b/models/issues/pull.go
index f2ca19b03e..52b9596889 100644
--- a/models/issues/pull.go
+++ b/models/issues/pull.go
@@ -323,7 +323,7 @@ func (pr *PullRequest) LoadProtectedBranchCtx(ctx context.Context) (err error) {
}
pr.ProtectedBranch, err = git_model.GetProtectedBranchBy(ctx, pr.BaseRepo.ID, pr.BaseBranch)
}
- return
+ return err
}
// ReviewCount represents a count of Reviews
diff --git a/models/issues/review.go b/models/issues/review.go
index ee65bec3f8..1cb99dc337 100644
--- a/models/issues/review.go
+++ b/models/issues/review.go
@@ -134,7 +134,7 @@ func (r *Review) LoadCodeComments(ctx context.Context) (err error) {
return
}
r.CodeComments, err = fetchCodeCommentsByReview(ctx, r.Issue, nil, r)
- return
+ return err
}
func (r *Review) loadIssue(ctx context.Context) (err error) {
@@ -142,7 +142,7 @@ func (r *Review) loadIssue(ctx context.Context) (err error) {
return
}
r.Issue, err = GetIssueByID(ctx, r.IssueID)
- return
+ return err
}
func (r *Review) loadReviewer(ctx context.Context) (err error) {
@@ -150,7 +150,7 @@ func (r *Review) loadReviewer(ctx context.Context) (err error) {
return
}
r.Reviewer, err = user_model.GetUserByIDCtx(ctx, r.ReviewerID)
- return
+ return err
}
func (r *Review) loadReviewerTeam(ctx context.Context) (err error) {
@@ -159,7 +159,7 @@ func (r *Review) loadReviewerTeam(ctx context.Context) (err error) {
}
r.ReviewerTeam, err = organization.GetTeamByID(ctx, r.ReviewerTeamID)
- return
+ return err
}
// LoadReviewer loads reviewer
@@ -186,7 +186,7 @@ func (r *Review) LoadAttributes(ctx context.Context) (err error) {
if err = r.loadReviewerTeam(ctx); err != nil {
return
}
- return
+ return err
}
// GetReviewByID returns the review by the given ID
@@ -537,7 +537,7 @@ func GetReviewByIssueIDAndUserID(ctx context.Context, issueID, userID int64) (*R
func GetTeamReviewerByIssueIDAndTeamID(ctx context.Context, issueID, teamID int64) (review *Review, err error) {
review = new(Review)
- has := false
+ var has bool
if has, err = db.GetEngine(ctx).SQL("SELECT * FROM review WHERE id IN (SELECT max(id) as id FROM review WHERE issue_id = ? AND reviewer_team_id = ?)",
issueID, teamID).
Get(review); err != nil {
@@ -548,21 +548,21 @@ func GetTeamReviewerByIssueIDAndTeamID(ctx context.Context, issueID, teamID int6
return nil, ErrReviewNotExist{0}
}
- return
+ return review, err
}
// MarkReviewsAsStale marks existing reviews as stale
func MarkReviewsAsStale(issueID int64) (err error) {
_, err = db.GetEngine(db.DefaultContext).Exec("UPDATE `review` SET stale=? WHERE issue_id=?", true, issueID)
- return
+ return err
}
// MarkReviewsAsNotStale marks existing reviews as not stale for a giving commit SHA
func MarkReviewsAsNotStale(issueID int64, commitID string) (err error) {
_, err = db.GetEngine(db.DefaultContext).Exec("UPDATE `review` SET stale=? WHERE issue_id=? AND commit_id=?", false, issueID, commitID)
- return
+ return err
}
// DismissReview change the dismiss status of a review
@@ -579,7 +579,7 @@ func DismissReview(review *Review, isDismiss bool) (err error) {
_, err = db.GetEngine(db.DefaultContext).ID(review.ID).Cols("dismissed").Update(review)
- return
+ return err
}
// InsertReviews inserts review and review comments
diff --git a/models/issues/stopwatch.go b/models/issues/stopwatch.go
index e7ac1314e9..0a7ad41f9c 100644
--- a/models/issues/stopwatch.go
+++ b/models/issues/stopwatch.go
@@ -63,7 +63,7 @@ func getStopwatch(ctx context.Context, userID, issueID int64) (sw *Stopwatch, ex
Where("user_id = ?", userID).
And("issue_id = ?", issueID).
Get(sw)
- return
+ return sw, exists, err
}
// UserIDCount is a simple coalition of UserID and Count
@@ -130,7 +130,7 @@ func HasUserStopwatch(ctx context.Context, userID int64) (exists bool, sw *Stopw
exists, err = db.GetEngine(ctx).
Where("user_id = ?", userID).
Get(sw)
- return
+ return exists, sw, err
}
// FinishIssueStopwatchIfPossible if stopwatch exist then finish it otherwise ignore
diff --git a/models/issues/tracked_time.go b/models/issues/tracked_time.go
index 54179bd3ab..9f8767362f 100644
--- a/models/issues/tracked_time.go
+++ b/models/issues/tracked_time.go
@@ -63,7 +63,7 @@ func (t *TrackedTime) loadAttributes(ctx context.Context) (err error) {
return
}
}
- return
+ return err
}
// LoadAttributes load Issue, User
@@ -73,7 +73,7 @@ func (tl TrackedTimeList) LoadAttributes() (err error) {
return err
}
}
- return
+ return err
}
// FindTrackedTimesOptions represent the filters for tracked times. If an ID is 0 it will be ignored.
@@ -130,7 +130,7 @@ func (opts *FindTrackedTimesOptions) toSession(e db.Engine) db.Engine {
// GetTrackedTimes returns all tracked times that fit to the given options.
func GetTrackedTimes(ctx context.Context, options *FindTrackedTimesOptions) (trackedTimes TrackedTimeList, err error) {
err = options.toSession(db.GetEngine(ctx)).Find(&trackedTimes)
- return
+ return trackedTimes, err
}
// CountTrackedTimes returns count of tracked times that fit to the given options.
@@ -291,7 +291,7 @@ func deleteTimes(ctx context.Context, opts FindTrackedTimesOptions) (removedTime
}
_, err = opts.toSession(db.GetEngine(ctx)).Table("tracked_time").Cols("deleted").Update(&TrackedTime{Deleted: true})
- return
+ return removedTime, err
}
func deleteTime(ctx context.Context, t *TrackedTime) error {
diff --git a/models/migrations/v143.go b/models/migrations/v143.go
index 93237ebfcd..17f3af4497 100644
--- a/models/migrations/v143.go
+++ b/models/migrations/v143.go
@@ -48,5 +48,5 @@ func recalculateStars(x *xorm.Engine) (err error) {
log.Debug("recalculate Stars number for all user finished")
- return
+ return err
}
diff --git a/models/migrations/v180.go b/models/migrations/v180.go
index 492c91f1b9..4468a71078 100644
--- a/models/migrations/v180.go
+++ b/models/migrations/v180.go
@@ -66,7 +66,7 @@ func deleteMigrationCredentials(x *xorm.Engine) (err error) {
return
}
}
- return
+ return err
}
func removeCredentials(payload string) (string, error) {
diff --git a/models/migrations/v189.go b/models/migrations/v189.go
index f136a89b4e..823e27e2ea 100644
--- a/models/migrations/v189.go
+++ b/models/migrations/v189.go
@@ -81,7 +81,7 @@ func unwrapLDAPSourceCfg(x *xorm.Engine) error {
}
err := jsonUnmarshalHandleDoubleEncode([]byte(source.Cfg), &wrapped)
if err != nil {
- return fmt.Errorf("failed to unmarshal %s: %w", string(source.Cfg), err)
+ return fmt.Errorf("failed to unmarshal %s: %w", source.Cfg, err)
}
if wrapped.Source != nil && len(wrapped.Source) > 0 {
bs, err := json.Marshal(wrapped.Source)
diff --git a/models/notification.go b/models/notification.go
index 3f0e374b83..fdc4ffad13 100644
--- a/models/notification.go
+++ b/models/notification.go
@@ -131,7 +131,7 @@ func (opts *FindNotificationOptions) ToSession(ctx context.Context) *xorm.Sessio
// GetNotifications returns all notifications that fit to the given options.
func GetNotifications(ctx context.Context, options *FindNotificationOptions) (nl NotificationList, err error) {
err = options.ToSession(ctx).OrderBy("notification.updated_unix DESC").Find(&nl)
- return
+ return nl, err
}
// CountNotifications count all notifications that fit to the given options and ignore pagination.
@@ -291,7 +291,7 @@ func getNotificationsByIssueID(ctx context.Context, issueID int64) (notification
err = db.GetEngine(ctx).
Where("issue_id = ?", issueID).
Find(&notifications)
- return
+ return notifications, err
}
func notificationExists(notifications []*Notification, issueID, userID int64) bool {
@@ -370,7 +370,7 @@ func NotificationsForUser(ctx context.Context, user *user_model.User, statuses [
}
err = sess.Find(&notifications)
- return
+ return notifications, err
}
// CountUnread count unread notifications for a user
@@ -401,7 +401,7 @@ func (n *Notification) loadAttributes(ctx context.Context) (err error) {
if err = n.loadComment(ctx); err != nil {
return
}
- return
+ return err
}
func (n *Notification) loadRepo(ctx context.Context) (err error) {
@@ -730,7 +730,7 @@ func GetNotificationCount(ctx context.Context, user *user_model.User, status Not
Where("user_id = ?", user.ID).
And("status = ?", status).
Count(&Notification{})
- return
+ return count, err
}
// UserIDCount is a simple coalition of UserID and Count
diff --git a/models/organization/team.go b/models/organization/team.go
index b32ffa6ca7..0b53c84d67 100644
--- a/models/organization/team.go
+++ b/models/organization/team.go
@@ -185,7 +185,7 @@ func (t *Team) GetUnitNames() (res []string) {
for _, u := range t.Units {
res = append(res, unit.Units[u.Type].NameKey)
}
- return
+ return res
}
// GetUnitsMap returns the team units permissions
@@ -226,7 +226,7 @@ func (t *Team) GetRepositoriesCtx(ctx context.Context) (err error) {
t.Repos, err = GetTeamRepositories(ctx, &SearchTeamRepoOptions{
TeamID: t.ID,
})
- return
+ return err
}
// GetMembersCtx returns paginated members in team of organization.
diff --git a/models/packages/package_version.go b/models/packages/package_version.go
index 78e76c5054..583f832e5e 100644
--- a/models/packages/package_version.go
+++ b/models/packages/package_version.go
@@ -235,7 +235,7 @@ func (opts *PackageSearchOptions) toConds() builder.Cond {
}
if !opts.HasFiles.IsNone() {
- var filesCond builder.Cond = builder.Exists(builder.Select("package_file.id").From("package_file").Where(builder.Expr("package_file.version_id = package_version.id")))
+ filesCond := builder.Exists(builder.Select("package_file.id").From("package_file").Where(builder.Expr("package_file.version_id = package_version.id")))
if opts.HasFiles.IsFalse() {
filesCond = builder.Not{filesCond}
diff --git a/models/perm/access/repo_permission.go b/models/perm/access/repo_permission.go
index 6bc1c82703..99919c70bf 100644
--- a/models/perm/access/repo_permission.go
+++ b/models/perm/access/repo_permission.go
@@ -273,7 +273,7 @@ func GetUserRepoPermission(ctx context.Context, repo *repo_model.Repository, use
}
}
- return
+ return perm, err
}
// IsUserRealRepoAdmin check if this user is real repo admin
diff --git a/models/project/issue.go b/models/project/issue.go
index 6e6a8c5746..59af7063a5 100644
--- a/models/project/issue.go
+++ b/models/project/issue.go
@@ -103,7 +103,7 @@ func MoveIssuesOnProjectBoard(board *Board, sortedIssueIDs map[int64]int64) erro
})
}
-func (pb *Board) removeIssues(ctx context.Context) error {
- _, err := db.GetEngine(ctx).Exec("UPDATE `project_issue` SET project_board_id = 0 WHERE project_board_id = ? ", pb.ID)
+func (b *Board) removeIssues(ctx context.Context) error {
+ _, err := db.GetEngine(ctx).Exec("UPDATE `project_issue` SET project_board_id = 0 WHERE project_board_id = ? ", b.ID)
return err
}
diff --git a/models/release.go b/models/release.go
index 94e803c716..b169920f2f 100644
--- a/models/release.go
+++ b/models/release.go
@@ -132,7 +132,7 @@ func AddReleaseAttachments(ctx context.Context, releaseID int64, attachmentUUIDs
}
}
- return
+ return err
}
// GetRelease returns release by given ID.
@@ -305,7 +305,7 @@ func GetReleaseAttachments(ctx context.Context, rels ...*Release) (err error) {
sortedRels.Rel[currentIndex].Attachments = append(sortedRels.Rel[currentIndex].Attachments, attachment)
}
- return
+ return err
}
type releaseSorter struct {
diff --git a/models/repo.go b/models/repo.go
index e9d83f5f32..ca83b03e42 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -756,7 +756,7 @@ func DoctorUserStarNum() (err error) {
log.Debug("recalculate Stars number for all user finished")
- return
+ return err
}
// DeleteDeployKey delete deploy keys
diff --git a/models/repo/archiver.go b/models/repo/archiver.go
index dc64cce49b..fd07d8554d 100644
--- a/models/repo/archiver.go
+++ b/models/repo/archiver.go
@@ -112,5 +112,5 @@ func FindRepoArchives(opts FindRepoArchiversOption) ([]*RepoArchiver, error) {
func SetArchiveRepoState(repo *Repository, isArchived bool) (err error) {
repo.IsArchived = isArchived
_, err = db.GetEngine(db.DefaultContext).Where("id = ?", repo.ID).Cols("is_archived").NoAutoTime().Update(repo)
- return
+ return err
}
diff --git a/models/repo/repo.go b/models/repo/repo.go
index f6097d2d6a..8ef405a665 100644
--- a/models/repo/repo.go
+++ b/models/repo/repo.go
@@ -280,7 +280,7 @@ func (repo *Repository) CommitLink(commitID string) (result string) {
} else {
result = repo.HTMLURL() + "/commit/" + url.PathEscape(commitID)
}
- return
+ return result
}
// APIURL returns the repository API URL
@@ -325,7 +325,7 @@ func (repo *Repository) UnitEnabled(tp unit.Type) (result bool) {
}); err != nil {
log.Error("repo.UnitEnabled: %v", err)
}
- return
+ return result
}
// UnitEnabled if this repository has the given unit enabled
@@ -546,7 +546,7 @@ func (repo *Repository) DescriptionHTML(ctx context.Context) template.HTML {
log.Error("Failed to render description for %s (ID: %d): %v", repo.Name, repo.ID, err)
return template.HTML(markup.Sanitize(repo.Description))
}
- return template.HTML(markup.Sanitize(string(desc)))
+ return template.HTML(markup.Sanitize(desc))
}
// CloneLink represents different types of clone URLs of repository.
diff --git a/models/statistic.go b/models/statistic.go
index 55ace626c8..ec094b5f5b 100644
--- a/models/statistic.go
+++ b/models/statistic.go
@@ -111,5 +111,5 @@ func GetStatistic() (stats Statistic) {
stats.Counter.Attachment, _ = e.Count(new(repo_model.Attachment))
stats.Counter.Project, _ = e.Count(new(project_model.Project))
stats.Counter.ProjectBoard, _ = e.Count(new(project_model.Board))
- return
+ return stats
}
diff --git a/models/unit/unit.go b/models/unit/unit.go
index e94775413e..b83bd61831 100644
--- a/models/unit/unit.go
+++ b/models/unit/unit.go
@@ -318,7 +318,7 @@ func FindUnitTypes(nameKeys ...string) (res []Type) {
res = append(res, TypeInvalid)
}
}
- return
+ return res
}
// TypeFromKey give the unit key name and return unit
diff --git a/models/user/search.go b/models/user/search.go
index a81cee1c22..1b65dcb12d 100644
--- a/models/user/search.go
+++ b/models/user/search.go
@@ -59,7 +59,7 @@ func (opts *SearchUserOptions) toSearchQueryBase() *xorm.Session {
}
if opts.Actor != nil {
- var exprCond builder.Cond = builder.Expr("org_user.org_id = `user`.id")
+ exprCond := builder.Expr("org_user.org_id = `user`.id")
// If Admin - they see all users!
if !opts.Actor.IsAdmin {
diff --git a/models/webhook/hooktask.go b/models/webhook/hooktask.go
index aff94fb38c..4415518cf0 100644
--- a/models/webhook/hooktask.go
+++ b/models/webhook/hooktask.go
@@ -286,7 +286,7 @@ func deleteDeliveredHookTasksByWebhook(hookID int64, numberDeliveriesToKeep int)
Cols("hook_task.delivered").
Join("INNER", "webhook", "hook_task.hook_id = webhook.id").
OrderBy("hook_task.delivered desc").
- Limit(1, int(numberDeliveriesToKeep)).
+ Limit(1, numberDeliveriesToKeep).
Find(&deliveryDates)
if err != nil {
return err
diff --git a/modules/activitypub/client.go b/modules/activitypub/client.go
index 738b1e4737..9bcef69de1 100644
--- a/modules/activitypub/client.go
+++ b/modules/activitypub/client.go
@@ -92,7 +92,7 @@ func NewClient(user *user_model.User, pubID string) (c *Client, err error) {
priv: privParsed,
pubID: pubID,
}
- return
+ return c, err
}
// NewRequest function
@@ -110,7 +110,7 @@ func (c *Client) NewRequest(b []byte, to string) (req *http.Request, err error)
return
}
err = signer.SignRequest(c.priv, c.pubID, req, b)
- return
+ return req, err
}
// Post function
@@ -120,5 +120,5 @@ func (c *Client) Post(b []byte, to string) (resp *http.Response, err error) {
return
}
resp, err = c.client.Do(req)
- return
+ return resp, err
}
diff --git a/modules/activitypub/user_settings.go b/modules/activitypub/user_settings.go
index 2144e7b47f..fc9775b0f0 100644
--- a/modules/activitypub/user_settings.go
+++ b/modules/activitypub/user_settings.go
@@ -35,11 +35,11 @@ func GetKeyPair(user *user_model.User) (pub, priv string, err error) {
// GetPublicKey function returns a user's public key
func GetPublicKey(user *user_model.User) (pub string, err error) {
pub, _, err = GetKeyPair(user)
- return
+ return pub, err
}
// GetPrivateKey function returns a user's private key
func GetPrivateKey(user *user_model.User) (priv string, err error) {
_, priv, err = GetKeyPair(user)
- return
+ return priv, err
}
diff --git a/modules/base/natural_sort.go b/modules/base/natural_sort.go
index 60db363df0..46cdd52932 100644
--- a/modules/base/natural_sort.go
+++ b/modules/base/natural_sort.go
@@ -55,7 +55,7 @@ func isDecimal(r rune) bool {
}
func compareByNumbers(str1 string, pos1 int, str2 string, pos2 int) (i1, i2 int, less, equal bool) {
- var d1, d2 bool = true, true
+ d1, d2 := true, true
var dec1, dec2 string
for d1 || d2 {
if d1 {
diff --git a/modules/charset/charset_test.go b/modules/charset/charset_test.go
index cfd5fb5696..6dd13c039d 100644
--- a/modules/charset/charset_test.go
+++ b/modules/charset/charset_test.go
@@ -296,11 +296,11 @@ func TestDetectEncoding(t *testing.T) {
}
func stringMustStartWith(t *testing.T, expected, value string) {
- assert.Equal(t, expected, string(value[:len(expected)]))
+ assert.Equal(t, expected, value[:len(expected)])
}
func stringMustEndWith(t *testing.T, expected, value string) {
- assert.Equal(t, expected, string(value[len(value)-len(expected):]))
+ assert.Equal(t, expected, value[len(value)-len(expected):])
}
func bytesMustStartWith(t *testing.T, expected, value []byte) {
diff --git a/modules/charset/escape.go b/modules/charset/escape.go
index 20a4bb2a10..9c1baafba3 100644
--- a/modules/charset/escape.go
+++ b/modules/charset/escape.go
@@ -222,15 +222,15 @@ readingloop:
return
}
escaped.HasError = true
- return
+ return escaped, err
}
func writeBroken(output io.Writer, bs []byte) (err error) {
_, err = fmt.Fprintf(output, `<span class="broken-code-point">&lt;%X&gt;</span>`, bs)
- return
+ return err
}
func writeEscaped(output io.Writer, r rune) (err error) {
_, err = fmt.Fprintf(output, `<span class="escaped-code-point" data-escaped="[U+%04X]"><span class="char">%c</span></span>`, r, r)
- return
+ return err
}
diff --git a/modules/context/api.go b/modules/context/api.go
index 33534dbf6b..558a9f51ee 100644
--- a/modules/context/api.go
+++ b/modules/context/api.go
@@ -340,7 +340,7 @@ func ReferencesGitRepo(allowEmpty ...bool) func(ctx *APIContext) (cancel context
}
}
- return
+ return cancel
}
}
diff --git a/modules/context/private.go b/modules/context/private.go
index fdc7751227..9e7977b5d5 100644
--- a/modules/context/private.go
+++ b/modules/context/private.go
@@ -82,5 +82,5 @@ func PrivateContexter() func(http.Handler) http.Handler {
func OverrideContext(ctx *PrivateContext) (cancel context.CancelFunc) {
// We now need to override the request context as the base for our work because even if the request is cancelled we have to continue this work
ctx.Override, _, cancel = process.GetManager().AddTypedContext(graceful.GetManager().HammerContext(), fmt.Sprintf("PrivateContext: %s", ctx.Req.RequestURI), process.RequestProcessType, true)
- return
+ return cancel
}
diff --git a/modules/context/repo.go b/modules/context/repo.go
index 217cbd3dfc..1836373918 100644
--- a/modules/context/repo.go
+++ b/modules/context/repo.go
@@ -734,7 +734,7 @@ func RepoAssignment(ctx *Context) (cancel context.CancelFunc) {
ctx.Data["GoDocDirectory"] = prefix + "{/dir}"
ctx.Data["GoDocFile"] = prefix + "{/dir}/{file}#L{line}"
}
- return
+ return cancel
}
// RepoRefType type of repo reference
@@ -1001,7 +1001,7 @@ func RepoRefByType(refType RepoRefType, ignoreNotExistErr ...bool) func(*Context
return
}
ctx.Data["CommitsCount"] = ctx.Repo.CommitsCount
- return
+ return cancel
}
}
diff --git a/modules/context/utils.go b/modules/context/utils.go
index aea51cc5d6..a72c8b47e6 100644
--- a/modules/context/utils.go
+++ b/modules/context/utils.go
@@ -52,5 +52,5 @@ func parseTime(value string) (int64, error) {
func prepareQueryArg(ctx *Context, name string) (value string, err error) {
value, err = url.PathUnescape(ctx.FormString(name))
value = strings.TrimSpace(value)
- return
+ return value, err
}
diff --git a/modules/convert/convert.go b/modules/convert/convert.go
index c8cb23261e..c62b4303ed 100644
--- a/modules/convert/convert.go
+++ b/modules/convert/convert.go
@@ -257,7 +257,7 @@ func ToHook(repoLink string, w *webhook.Webhook) *api.Hook {
return &api.Hook{
ID: w.ID,
- Type: string(w.Type),
+ Type: w.Type,
URL: fmt.Sprintf("%s/settings/hooks/%d", repoLink, w.ID),
Active: w.IsActive,
Config: config,
diff --git a/modules/convert/issue.go b/modules/convert/issue.go
index 35eff05229..5364367a80 100644
--- a/modules/convert/issue.go
+++ b/modules/convert/issue.go
@@ -123,7 +123,7 @@ func ToTrackedTime(t *issues_model.TrackedTime) (apiT *api.TrackedTime) {
if t.User != nil {
apiT.UserName = t.User.Name
}
- return
+ return apiT
}
// ToStopWatches convert Stopwatch list to api.StopWatches
diff --git a/modules/doctor/fix16961.go b/modules/doctor/fix16961.go
index 92c4418505..307cfcd9ff 100644
--- a/modules/doctor/fix16961.go
+++ b/modules/doctor/fix16961.go
@@ -216,7 +216,7 @@ func fixBrokenRepoUnit16961(repoUnit *repo_model.RepoUnit, bs []byte) (fixed boo
return false, nil
}
- switch unit.Type(repoUnit.Type) {
+ switch repoUnit.Type {
case unit.TypeCode, unit.TypeReleases, unit.TypeWiki, unit.TypeProjects:
cfg := &repo_model.UnitConfig{}
repoUnit.Config = cfg
diff --git a/modules/eventsource/event.go b/modules/eventsource/event.go
index 9fe20715e3..281a1bb135 100644
--- a/modules/eventsource/event.go
+++ b/modules/eventsource/event.go
@@ -18,7 +18,7 @@ func wrapNewlines(w io.Writer, prefix, value []byte) (sum int64, err error) {
if len(value) == 0 {
return
}
- n := 0
+ var n int
last := 0
for j := bytes.IndexByte(value, '\n'); j > -1; j = bytes.IndexByte(value[last:], '\n') {
n, err = w.Write(prefix)
@@ -45,7 +45,7 @@ func wrapNewlines(w io.Writer, prefix, value []byte) (sum int64, err error) {
}
n, err = w.Write([]byte("\n"))
sum += int64(n)
- return
+ return sum, err
}
// Event is an eventsource event, not all fields need to be set
@@ -64,7 +64,7 @@ type Event struct {
// The return value n is the number of bytes written. Any error encountered during the write is also returned.
func (e *Event) WriteTo(w io.Writer) (int64, error) {
sum := int64(0)
- nint := 0
+ var nint int
n, err := wrapNewlines(w, []byte("event: "), []byte(e.Name))
sum += n
if err != nil {
diff --git a/modules/git/batch_reader.go b/modules/git/batch_reader.go
index 902fa89718..feb0dd31be 100644
--- a/modules/git/batch_reader.go
+++ b/modules/git/batch_reader.go
@@ -176,12 +176,12 @@ func ReadBatchLine(rd *bufio.Reader) (sha []byte, typ string, size int64, err er
typ = typ[:idx]
size, err = strconv.ParseInt(sizeStr, 10, 64)
- return
+ return sha, typ, size, err
}
// ReadTagObjectID reads a tag object ID hash from a cat-file --batch stream, throwing away the rest of the stream.
func ReadTagObjectID(rd *bufio.Reader, size int64) (string, error) {
- id := ""
+ var id string
var n int64
headerLoop:
for {
@@ -216,7 +216,7 @@ headerLoop:
// ReadTreeID reads a tree ID from a cat-file --batch stream, throwing away the rest of the stream.
func ReadTreeID(rd *bufio.Reader, size int64) (string, error) {
- id := ""
+ var id string
var n int64
headerLoop:
for {
@@ -328,7 +328,7 @@ func ParseTreeLine(rd *bufio.Reader, modeBuf, fnameBuf, shaBuf []byte) (mode, fn
// Deal with the 20-byte SHA
idx = 0
for idx < 20 {
- read := 0
+ var read int
read, err = rd.Read(shaBuf[idx:20])
n += read
if err != nil {
@@ -337,7 +337,7 @@ func ParseTreeLine(rd *bufio.Reader, modeBuf, fnameBuf, shaBuf []byte) (mode, fn
idx += read
}
sha = shaBuf
- return
+ return mode, fname, sha, n, err
}
var callerPrefix string
diff --git a/modules/git/blob_nogogit.go b/modules/git/blob_nogogit.go
index 211c188559..89bb98162f 100644
--- a/modules/git/blob_nogogit.go
+++ b/modules/git/blob_nogogit.go
@@ -99,7 +99,7 @@ func (b *blobReader) Read(p []byte) (n int, err error) {
}
n, err = b.rd.Read(p)
b.n -= int64(n)
- return
+ return n, err
}
// Close implements io.Closer
diff --git a/modules/git/commit.go b/modules/git/commit.go
index 82b5e0b25d..82712dd1ef 100644
--- a/modules/git/commit.go
+++ b/modules/git/commit.go
@@ -418,7 +418,7 @@ func (c *Commit) LoadBranchName() (err error) {
}
c.Branch, err = c.GetBranchName()
- return
+ return err
}
// GetTagName gets the current tag name for given commit
diff --git a/modules/git/commit_info_nogogit.go b/modules/git/commit_info_nogogit.go
index f430c672f8..ceab11adbb 100644
--- a/modules/git/commit_info_nogogit.go
+++ b/modules/git/commit_info_nogogit.go
@@ -157,7 +157,7 @@ func GetLastCommitForPaths(ctx context.Context, cache *LastCommitCache, commit *
if typ != "commit" {
return nil, fmt.Errorf("unexpected type: %s for commit id: %s", typ, commitID)
}
- c, err = CommitFromReader(commit.repo, MustIDFromString(string(commitID)), io.LimitReader(batchReader, int64(size)))
+ c, err = CommitFromReader(commit.repo, MustIDFromString(commitID), io.LimitReader(batchReader, size))
if err != nil {
return nil, err
}
diff --git a/modules/git/diff.go b/modules/git/diff.go
index c9d68bb130..f75ebd4fd2 100644
--- a/modules/git/diff.go
+++ b/modules/git/diff.go
@@ -115,7 +115,7 @@ func ParseDiffHunkString(diffhunk string) (leftLine, leftHunk, rightLine, righHu
rightLine = leftLine
righHunk = leftHunk
}
- return
+ return leftLine, leftHunk, rightLine, righHunk
}
// Example: @@ -1,8 +1,9 @@ => [..., 1, 8, 1, 9]
diff --git a/modules/git/pipeline/lfs_nogogit.go b/modules/git/pipeline/lfs_nogogit.go
index a2b5dd0c96..061da8ca50 100644
--- a/modules/git/pipeline/lfs_nogogit.go
+++ b/modules/git/pipeline/lfs_nogogit.go
@@ -116,7 +116,7 @@ func FindLFSFile(repo *git.Repository, hash git.SHA1) ([]*LFSResult, error) {
continue
case "commit":
// Read in the commit to get its tree and in case this is one of the last used commits
- curCommit, err = git.CommitFromReader(repo, git.MustIDFromString(string(commitID)), io.LimitReader(batchReader, int64(size)))
+ curCommit, err = git.CommitFromReader(repo, git.MustIDFromString(string(commitID)), io.LimitReader(batchReader, size))
if err != nil {
return nil, err
}
diff --git a/modules/git/repo_attribute.go b/modules/git/repo_attribute.go
index 596a91e803..1305e6f224 100644
--- a/modules/git/repo_attribute.go
+++ b/modules/git/repo_attribute.go
@@ -334,7 +334,7 @@ func (wr *lineSeparatedAttributeWriter) Write(p []byte) (n int, err error) {
wr.tmp = []byte(remaining[3:])
break
}
- return l, fmt.Errorf("unexpected tail %s", string(remaining))
+ return l, fmt.Errorf("unexpected tail %s", remaining)
}
_, _ = sb.WriteRune(rn)
remaining = tail
diff --git a/modules/git/repo_base_nogogit.go b/modules/git/repo_base_nogogit.go
index df24d952a8..63c278c261 100644
--- a/modules/git/repo_base_nogogit.go
+++ b/modules/git/repo_base_nogogit.go
@@ -101,5 +101,5 @@ func (repo *Repository) Close() (err error) {
repo.checkReader = nil
repo.checkWriter = nil
}
- return
+ return err
}
diff --git a/modules/git/repo_branch_nogogit.go b/modules/git/repo_branch_nogogit.go
index bc58991085..2983a35ca5 100644
--- a/modules/git/repo_branch_nogogit.go
+++ b/modules/git/repo_branch_nogogit.go
@@ -95,7 +95,7 @@ func callShowRef(ctx context.Context, repoPath, prefix, arg string, skip, limit
return nil
})
- return
+ return branchNames, countAll, err
}
func walkShowRef(ctx context.Context, repoPath, arg string, skip, limit int, walkfn func(sha1, refname string) error) (countAll int, err error) {
diff --git a/modules/git/repo_compare.go b/modules/git/repo_compare.go
index 3c7af73000..577c9f475e 100644
--- a/modules/git/repo_compare.go
+++ b/modules/git/repo_compare.go
@@ -132,7 +132,7 @@ type lineCountWriter struct {
func (l *lineCountWriter) Write(p []byte) (n int, err error) {
n = len(p)
l.numLines += bytes.Count(p, []byte{'\000'})
- return
+ return n, err
}
// GetDiffNumChangedFiles counts the number of changed files
@@ -177,7 +177,7 @@ func (repo *Repository) GetDiffShortStat(base, head string) (numFiles, totalAddi
if err != nil && strings.Contains(err.Error(), "no merge base") {
return GetDiffShortStat(repo.Ctx, repo.Path, base, head)
}
- return
+ return numFiles, totalAdditions, totalDeletions, err
}
// GetDiffShortStat counts number of changed files, number of additions and deletions
@@ -231,7 +231,7 @@ func parseDiffStat(stdout string) (numFiles, totalAdditions, totalDeletions int,
return 0, 0, 0, fmt.Errorf("unable to parse shortstat: %s. Error parsing NumDeletions %v", stdout, err)
}
}
- return
+ return numFiles, totalAdditions, totalDeletions, err
}
// GetDiffOrPatch generates either diff or formatted patch data between given revisions
diff --git a/modules/git/repo_compare_test.go b/modules/git/repo_compare_test.go
index e163a3090b..245920c2bd 100644
--- a/modules/git/repo_compare_test.go
+++ b/modules/git/repo_compare_test.go
@@ -117,8 +117,8 @@ func TestReadWritePullHead(t *testing.T) {
return
}
- assert.Len(t, string(headContents), 40)
- assert.True(t, string(headContents) == newCommit)
+ assert.Len(t, headContents, 40)
+ assert.True(t, headContents == newCommit)
// Remove file after the test
err = repo.RemoveReference(PullPrefix + "1/head")
diff --git a/modules/git/repo_index.go b/modules/git/repo_index.go
index ae68dcaa87..50d82c77d7 100644
--- a/modules/git/repo_index.go
+++ b/modules/git/repo_index.go
@@ -64,7 +64,7 @@ func (repo *Repository) ReadTreeToTemporaryIndex(treeish string) (filename, tmpD
defer cancel()
return "", "", func() {}, err
}
- return
+ return filename, tmpDir, cancel, err
}
// EmptyIndex empties the index
diff --git a/modules/git/repo_tag_nogogit.go b/modules/git/repo_tag_nogogit.go
index 8d44db0a2e..9a574666f8 100644
--- a/modules/git/repo_tag_nogogit.go
+++ b/modules/git/repo_tag_nogogit.go
@@ -27,7 +27,7 @@ func (repo *Repository) IsTagExist(name string) bool {
// returning at most limit tags, or all if limit is 0.
func (repo *Repository) GetTags(skip, limit int) (tags []string, err error) {
tags, _, err = callShowRef(repo.Ctx, repo.Path, TagPrefix, "--tags", skip, limit)
- return
+ return tags, err
}
// GetTagType gets the type of the tag, either commit (simple) or tag (annotated)
diff --git a/modules/git/sha1_nogogit.go b/modules/git/sha1_nogogit.go
index 1835c68f5a..a2620cba69 100644
--- a/modules/git/sha1_nogogit.go
+++ b/modules/git/sha1_nogogit.go
@@ -58,5 +58,5 @@ func NewHasher(t ObjectType, size int64) Hasher {
// Sum generates a SHA1 for the provided hash
func (h Hasher) Sum() (sha1 SHA1) {
copy(sha1[:], h.Hash.Sum(nil))
- return
+ return sha1
}
diff --git a/modules/git/signature_nogogit.go b/modules/git/signature_nogogit.go
index 81da739a5b..2fc8dde04d 100644
--- a/modules/git/signature_nogogit.go
+++ b/modules/git/signature_nogogit.go
@@ -91,5 +91,5 @@ func newSignatureFromCommitline(line []byte) (sig *Signature, err error) {
return
}
}
- return
+ return sig, err
}
diff --git a/modules/git/utils.go b/modules/git/utils.go
index 53c124ac8a..d6bf9f4413 100644
--- a/modules/git/utils.go
+++ b/modules/git/utils.go
@@ -163,7 +163,7 @@ func (l *LimitedReaderCloser) Read(p []byte) (n int, err error) {
}
n, err = l.R.Read(p)
l.N -= int64(n)
- return
+ return n, err
}
// Close implements io.Closer
diff --git a/modules/gitgraph/graph_test.go b/modules/gitgraph/graph_test.go
index ea6553529a..2cfbe4b2fa 100644
--- a/modules/gitgraph/graph_test.go
+++ b/modules/gitgraph/graph_test.go
@@ -53,7 +53,7 @@ func BenchmarkParseGlyphs(b *testing.B) {
parser := &Parser{}
parser.Reset()
tgBytes := []byte(testglyphs)
- tg := tgBytes
+ var tg []byte
for i := 0; i < b.N; i++ {
parser.Reset()
tg = tgBytes
diff --git a/modules/graceful/context.go b/modules/graceful/context.go
index 9d955329a4..b9d975a1d5 100644
--- a/modules/graceful/context.go
+++ b/modules/graceful/context.go
@@ -26,7 +26,7 @@ func NewChannelContext(done <-chan struct{}, err error) *ChannelContext {
// Deadline returns the time when work done on behalf of this context
// should be canceled. There is no Deadline for a ChannelContext
func (ctx *ChannelContext) Deadline() (deadline time.Time, ok bool) {
- return
+ return deadline, ok
}
// Done returns the channel provided at the creation of this context.
diff --git a/modules/highlight/highlight.go b/modules/highlight/highlight.go
index a72f26d5f0..acd3bebb9f 100644
--- a/modules/highlight/highlight.go
+++ b/modules/highlight/highlight.go
@@ -114,7 +114,7 @@ func CodeFromLexer(lexer chroma.Lexer, code string) string {
htmlbuf := bytes.Buffer{}
htmlw := bufio.NewWriter(&htmlbuf)
- iterator, err := lexer.Tokenise(nil, string(code))
+ iterator, err := lexer.Tokenise(nil, code)
if err != nil {
log.Error("Can't tokenize code: %v", err)
return code
@@ -197,7 +197,7 @@ func File(numLines int, fileName, language string, code []byte) []string {
m := make([]string, 0, numLines)
for _, v := range strings.SplitN(htmlbuf.String(), "\n", numLines) {
- content := string(v)
+ content := v
// need to keep lines that are only \n so copy/paste works properly in browser
if content == "" {
content = "\n"
@@ -220,8 +220,8 @@ func File(numLines int, fileName, language string, code []byte) []string {
// return unhiglighted map
func plainText(code string, numLines int) []string {
m := make([]string, 0, numLines)
- for _, v := range strings.SplitN(string(code), "\n", numLines) {
- content := string(v)
+ for _, v := range strings.SplitN(code, "\n", numLines) {
+ content := v
// need to keep lines that are only \n so copy/paste works properly in browser
if content == "" {
content = "\n"
diff --git a/modules/indexer/code/bleve.go b/modules/indexer/code/bleve.go
index 1abb3c0219..0b31f7119c 100644
--- a/modules/indexer/code/bleve.go
+++ b/modules/indexer/code/bleve.go
@@ -392,7 +392,7 @@ func (b *BleveIndexer) Search(ctx context.Context, repoIDs []int64, language, ke
searchResults := make([]*SearchResult, len(result.Hits))
for i, hit := range result.Hits {
- var startIndex, endIndex int = -1, -1
+ startIndex, endIndex := -1, -1
for _, locations := range hit.Locations["Content"] {
location := locations[0]
locationStart := int(location.Start)
diff --git a/modules/indexer/code/elastic_search.go b/modules/indexer/code/elastic_search.go
index 7263f27657..a669c66bb4 100644
--- a/modules/indexer/code/elastic_search.go
+++ b/modules/indexer/code/elastic_search.go
@@ -348,7 +348,7 @@ func convertResult(searchResult *elastic.SearchResult, kw string, pageSize int)
// FIXME: There is no way to get the position the keyword on the content currently on the same request.
// So we get it from content, this may made the query slower. See
// https://discuss.elastic.co/t/fetching-position-of-keyword-in-matched-document/94291
- var startIndex, endIndex int = -1, -1
+ var startIndex, endIndex int
c, ok := hit.Highlight["content"]
if ok && len(c) > 0 {
// FIXME: Since the highlighting content will include <em> and </em> for the keywords,
diff --git a/modules/markup/common/footnote.go b/modules/markup/common/footnote.go
index 821b3e6387..d07f5e6090 100644
--- a/modules/markup/common/footnote.go
+++ b/modules/markup/common/footnote.go
@@ -203,9 +203,8 @@ func (b *footnoteBlockParser) Open(parent ast.Node, reader text.Reader, pc parse
return nil, parser.NoChildren
}
open := pos + 1
- closes := 0
closure := util.FindClosure(line[pos+1:], '[', ']', false, false) //nolint
- closes = pos + 1 + closure
+ closes := pos + 1 + closure
next := closes + 1
if closure > -1 {
if next >= len(line) || line[next] != ':' {
diff --git a/modules/markup/markdown/markdown.go b/modules/markup/markdown/markdown.go
index 37e11e606f..4ce85dfc31 100644
--- a/modules/markup/markdown/markdown.go
+++ b/modules/markup/markdown/markdown.go
@@ -156,7 +156,7 @@ func actualRender(ctx *markup.RenderContext, input io.Reader, output io.Writer)
log.Warn("Unable to render markdown due to panic in goldmark: %v", err)
if log.IsDebug() {
- log.Debug("Panic in markdown: %v\n%s", err, string(log.Stack(2)))
+ log.Debug("Panic in markdown: %v\n%s", err, log.Stack(2))
}
}()
@@ -185,7 +185,7 @@ func render(ctx *markup.RenderContext, input io.Reader, output io.Writer) error
log.Warn("Unable to render markdown due to panic in goldmark - will return raw bytes")
if log.IsDebug() {
- log.Debug("Panic in markdown: %v\n%s", err, string(log.Stack(2)))
+ log.Debug("Panic in markdown: %v\n%s", err, log.Stack(2))
}
_, err = io.Copy(output, input)
if err != nil {
diff --git a/modules/markup/orgmode/orgmode.go b/modules/markup/orgmode/orgmode.go
index 8c9f3b3da7..a78531720d 100644
--- a/modules/markup/orgmode/orgmode.go
+++ b/modules/markup/orgmode/orgmode.go
@@ -75,7 +75,7 @@ func Render(ctx *markup.RenderContext, input io.Reader, output io.Writer) error
if lexer == nil {
// include language-x class as part of commonmark spec
- if _, err := w.WriteString(`<code class="chroma language-` + string(lang) + `">`); err != nil {
+ if _, err := w.WriteString(`<code class="chroma language-` + lang + `">`); err != nil {
return ""
}
if _, err := w.WriteString(html.EscapeString(source)); err != nil {
@@ -83,7 +83,7 @@ func Render(ctx *markup.RenderContext, input io.Reader, output io.Writer) error
}
} else {
// include language-x class as part of commonmark spec
- if _, err := w.WriteString(`<code class="chroma language-` + string(lang) + `">`); err != nil {
+ if _, err := w.WriteString(`<code class="chroma language-` + lang + `">`); err != nil {
return ""
}
lexer = chroma.Coalesce(lexer)
diff --git a/modules/markup/sanitizer_test.go b/modules/markup/sanitizer_test.go
index a0753c4a56..7dfca7a468 100644
--- a/modules/markup/sanitizer_test.go
+++ b/modules/markup/sanitizer_test.go
@@ -55,7 +55,7 @@ func Test_Sanitizer(t *testing.T) {
func TestSanitizeNonEscape(t *testing.T) {
descStr := "<scrÄ°pt>&lt;script&gt;alert(document.domain)&lt;/script&gt;</scrÄ°pt>"
- output := template.HTML(Sanitize(string(descStr)))
+ output := template.HTML(Sanitize(descStr))
if strings.Contains(string(output), "<script>") {
t.Errorf("un-escaped <script> in output: %q", output)
}
diff --git a/modules/migration/issue.go b/modules/migration/issue.go
index 78f648dd2d..cc13570afb 100644
--- a/modules/migration/issue.go
+++ b/modules/migration/issue.go
@@ -30,11 +30,11 @@ type Issue struct {
}
// GetExternalName ExternalUserMigrated interface
-func (i *Issue) GetExternalName() string { return i.PosterName }
+func (issue *Issue) GetExternalName() string { return issue.PosterName }
// GetExternalID ExternalUserMigrated interface
-func (i *Issue) GetExternalID() int64 { return i.PosterID }
+func (issue *Issue) GetExternalID() int64 { return issue.PosterID }
-func (i *Issue) GetLocalIndex() int64 { return i.Number }
-func (i *Issue) GetForeignIndex() int64 { return i.ForeignIndex }
-func (i *Issue) GetContext() DownloaderContext { return i.Context }
+func (issue *Issue) GetLocalIndex() int64 { return issue.Number }
+func (issue *Issue) GetForeignIndex() int64 { return issue.ForeignIndex }
+func (issue *Issue) GetContext() DownloaderContext { return issue.Context }
diff --git a/modules/nosql/manager.go b/modules/nosql/manager.go
index 93338fdc3f..6092a67827 100644
--- a/modules/nosql/manager.go
+++ b/modules/nosql/manager.go
@@ -75,5 +75,5 @@ func valToTimeDuration(vs []string) (result time.Duration) {
return
}
}
- return
+ return result
}
diff --git a/modules/nosql/manager_leveldb.go b/modules/nosql/manager_leveldb.go
index d69ae88800..d356a79bf8 100644
--- a/modules/nosql/manager_leveldb.go
+++ b/modules/nosql/manager_leveldb.go
@@ -72,7 +72,7 @@ func (m *Manager) GetLevelDB(connection string) (db *leveldb.DB, err error) {
if recovered != nil {
panic(recovered)
}
- return
+ return db, err
}
func (m *Manager) getLevelDB(connection string) (*leveldb.DB, error) {
diff --git a/modules/nosql/manager_redis.go b/modules/nosql/manager_redis.go
index b82f899db0..3b2ad75b41 100644
--- a/modules/nosql/manager_redis.go
+++ b/modules/nosql/manager_redis.go
@@ -65,7 +65,7 @@ func (m *Manager) GetRedisClient(connection string) (client redis.UniversalClien
if recovered != nil {
panic(recovered)
}
- return
+ return client
}
func (m *Manager) getRedisClient(connection string) redis.UniversalClient {
diff --git a/modules/packages/multi_hasher.go b/modules/packages/multi_hasher.go
index 0659a18d2a..4d17441d8c 100644
--- a/modules/packages/multi_hasher.go
+++ b/modules/packages/multi_hasher.go
@@ -119,5 +119,5 @@ func (h *MultiHasher) Sums() (hashMD5, hashSHA1, hashSHA256, hashSHA512 []byte)
hashSHA1 = h.sha1.Sum(nil)
hashSHA256 = h.sha256.Sum(nil)
hashSHA512 = h.sha512.Sum(nil)
- return
+ return hashMD5, hashSHA1, hashSHA256, hashSHA512
}
diff --git a/modules/process/manager.go b/modules/process/manager.go
index 5d7aee760f..7f14287de5 100644
--- a/modules/process/manager.go
+++ b/modules/process/manager.go
@@ -183,7 +183,7 @@ func (pm *Manager) nextPID() (start time.Time, pid IDType) {
return
}
pid = IDType(string(pid) + "-" + strconv.FormatInt(pm.next, 10))
- return
+ return start, pid
}
// Remove a process from the ProcessManager.
diff --git a/modules/process/manager_stacktraces.go b/modules/process/manager_stacktraces.go
index fbe3374b87..628d9cebcd 100644
--- a/modules/process/manager_stacktraces.go
+++ b/modules/process/manager_stacktraces.go
@@ -120,7 +120,7 @@ func (pm *Manager) ProcessStacktraces(flat, noSystem bool) ([]*Process, int, int
// We cannot use the pm.ProcessMap here because we will release the mutex ...
processMap := map[IDType]*Process{}
- processCount := 0
+ var processCount int
// Lock the manager
pm.mutex.Lock()
diff --git a/modules/queue/helper.go b/modules/queue/helper.go
index f1aba411a8..9ad95badeb 100644
--- a/modules/queue/helper.go
+++ b/modules/queue/helper.go
@@ -74,7 +74,7 @@ func unmarshalAs(bs []byte, exemplar interface{}) (data Data, err error) {
} else {
err = json.Unmarshal(bs, &data)
}
- return
+ return data, err
}
// assignableTo will check if provided data is assignable to the same type as the exemplar
diff --git a/modules/queue/queue_bytefifo.go b/modules/queue/queue_bytefifo.go
index 99c6428abc..79f69f07ce 100644
--- a/modules/queue/queue_bytefifo.go
+++ b/modules/queue/queue_bytefifo.go
@@ -73,7 +73,7 @@ func NewByteFIFOQueue(typ Type, byteFIFO ByteFIFO, handle HandlerFunc, cfg, exem
failed = append(failed, fail)
}
}
- return
+ return failed
}, config.WorkerPoolConfiguration)
return q, nil
@@ -401,7 +401,7 @@ func NewByteFIFOUniqueQueue(typ Type, byteFIFO UniqueByteFIFO, handle HandlerFun
failed = append(failed, fail)
}
}
- return
+ return failed
}, config.WorkerPoolConfiguration)
return q, nil
diff --git a/modules/queue/queue_disk_channel.go b/modules/queue/queue_disk_channel.go
index 014d93f5b5..c00f620276 100644
--- a/modules/queue/queue_disk_channel.go
+++ b/modules/queue/queue_disk_channel.go
@@ -62,7 +62,7 @@ func NewPersistableChannelQueue(handle HandlerFunc, cfg, exemplar interface{}) (
failed = append(failed, fail)
}
}
- return
+ return failed
}
channelQueue, err := NewChannelQueue(wrappedHandle, ChannelQueueConfiguration{
diff --git a/modules/queue/unique_queue_disk_channel.go b/modules/queue/unique_queue_disk_channel.go
index 6ab03094ba..8e0322bb90 100644
--- a/modules/queue/unique_queue_disk_channel.go
+++ b/modules/queue/unique_queue_disk_channel.go
@@ -62,7 +62,7 @@ func NewPersistableChannelUniqueQueue(handle HandlerFunc, cfg, exemplar interfac
failed = append(failed, fail)
}
}
- return
+ return failed
}
channelUniqueQueue, err := NewChannelUniqueQueue(wrappedHandle, ChannelUniqueQueueConfiguration{
diff --git a/modules/references/references.go b/modules/references/references.go
index 7f5086d093..8fd0c8f055 100644
--- a/modules/references/references.go
+++ b/modules/references/references.go
@@ -379,7 +379,7 @@ func FindRenderizableReferenceAlphanumeric(content string) (bool, *RenderizableR
action, location := findActionKeywords([]byte(content), match[2])
return true, &RenderizableReference{
- Issue: string(content[match[2]:match[3]]),
+ Issue: content[match[2]:match[3]],
RefLocation: &RefSpan{Start: match[2], End: match[3]},
Action: action,
ActionLocation: location,
@@ -506,7 +506,7 @@ func getCrossReference(content []byte, start, end int, fromLink, prOnly bool) *r
}
repo := string(content[start : start+sep])
issue := string(content[start+sep+1 : end])
- index, err := strconv.ParseInt(string(issue), 10, 64)
+ index, err := strconv.ParseInt(issue, 10, 64)
if err != nil {
return nil
}
diff --git a/modules/repository/hooks.go b/modules/repository/hooks.go
index debaa0ecc4..c2eb3a7c75 100644
--- a/modules/repository/hooks.go
+++ b/modules/repository/hooks.go
@@ -104,7 +104,7 @@ done
giteaHookTpls = append(giteaHookTpls, "")
}
- return
+ return hookNames, hookTpls, giteaHookTpls
}
// CreateDelegateHooks creates all the hooks scripts for the repo
diff --git a/modules/setting/database.go b/modules/setting/database.go
index a90ace5b4b..87d56fbc93 100644
--- a/modules/setting/database.go
+++ b/modules/setting/database.go
@@ -107,7 +107,7 @@ func InitDBConfig() {
// DBConnStr returns database connection string
func DBConnStr() (string, error) {
- connStr := ""
+ var connStr string
Param := "?"
if strings.Contains(Database.Name, Param) {
Param = "&"
@@ -168,7 +168,7 @@ func getPostgreSQLConnectionString(dbHost, dbUser, dbPasswd, dbName, dbParam, db
connStr = fmt.Sprintf("postgres://%s:%s@%s:%s/%s%ssslmode=%s",
url.PathEscape(dbUser), url.PathEscape(dbPasswd), host, port, dbName, dbParam, dbsslMode)
}
- return
+ return connStr
}
// ParseMSSQLHostPort splits the host into host and port
diff --git a/modules/setting/federation.go b/modules/setting/federation.go
index 2a8ecadaf9..583d9a6e2b 100644
--- a/modules/setting/federation.go
+++ b/modules/setting/federation.go
@@ -31,7 +31,7 @@ var (
}
)
-// Constant slice of httpsig algorithm objects
+// HttpsigAlgs is a constant slice of httpsig algorithm objects
var HttpsigAlgs []httpsig.Algorithm
func newFederationService() {
diff --git a/modules/setting/i18n.go b/modules/setting/i18n.go
index a9a57dc948..321e144ef3 100644
--- a/modules/setting/i18n.go
+++ b/modules/setting/i18n.go
@@ -40,12 +40,12 @@ func defaultI18nLangs() (res []string) {
for i := 0; i < len(defaultI18nLangNames); i += 2 {
res = append(res, defaultI18nLangNames[i])
}
- return
+ return res
}
func defaultI18nNames() (res []string) {
for i := 0; i < len(defaultI18nLangNames); i += 2 {
res = append(res, defaultI18nLangNames[i+1])
}
- return
+ return res
}
diff --git a/modules/setting/log.go b/modules/setting/log.go
index d69b5c6888..1d9535360a 100644
--- a/modules/setting/log.go
+++ b/modules/setting/log.go
@@ -211,7 +211,7 @@ func generateLogConfig(sec *ini.Section, name string, defaults defaultLogOptions
return
}
jsonConfig = string(byteConfig)
- return
+ return mode, jsonConfig, levelName
}
func generateNamedLogger(key string, options defaultLogOptions) *LogDescription {
diff --git a/modules/setting/service.go b/modules/setting/service.go
index a391926382..bd97e10b0f 100644
--- a/modules/setting/service.go
+++ b/modules/setting/service.go
@@ -96,7 +96,7 @@ func (a AllowedVisibility) ToVisibleTypeSlice() (result []structs.VisibleType) {
result = append(result, structs.VisibleType(i))
}
}
- return
+ return result
}
func newService() {
diff --git a/modules/storage/storage.go b/modules/storage/storage.go
index ef7f6029a5..1b83e3271f 100644
--- a/modules/storage/storage.go
+++ b/modules/storage/storage.go
@@ -169,35 +169,35 @@ func NewStorage(typStr string, cfg interface{}) (ObjectStorage, error) {
func initAvatars() (err error) {
log.Info("Initialising Avatar storage with type: %s", setting.Avatar.Storage.Type)
Avatars, err = NewStorage(setting.Avatar.Storage.Type, &setting.Avatar.Storage)
- return
+ return err
}
func initAttachments() (err error) {
log.Info("Initialising Attachment storage with type: %s", setting.Attachment.Storage.Type)
Attachments, err = NewStorage(setting.Attachment.Storage.Type, &setting.Attachment.Storage)
- return
+ return err
}
func initLFS() (err error) {
log.Info("Initialising LFS storage with type: %s", setting.LFS.Storage.Type)
LFS, err = NewStorage(setting.LFS.Storage.Type, &setting.LFS.Storage)
- return
+ return err
}
func initRepoAvatars() (err error) {
log.Info("Initialising Repository Avatar storage with type: %s", setting.RepoAvatar.Storage.Type)
RepoAvatars, err = NewStorage(setting.RepoAvatar.Storage.Type, &setting.RepoAvatar.Storage)
- return
+ return err
}
func initRepoArchives() (err error) {
log.Info("Initialising Repository Archive storage with type: %s", setting.RepoArchive.Storage.Type)
RepoArchives, err = NewStorage(setting.RepoArchive.Storage.Type, &setting.RepoArchive.Storage)
- return
+ return err
}
func initPackages() (err error) {
log.Info("Initialising Packages storage with type: %s", setting.Packages.Storage.Type)
Packages, err = NewStorage(setting.Packages.Storage.Type, &setting.Packages.Storage)
- return
+ return err
}
diff --git a/modules/structs/org_type.go b/modules/structs/org_type.go
index 4fb9b6fc0f..4401a2801c 100644
--- a/modules/structs/org_type.go
+++ b/modules/structs/org_type.go
@@ -55,5 +55,5 @@ func ExtractKeysFromMapString(in map[string]VisibleType) (keys []string) {
for k := range in {
keys = append(keys, k)
}
- return
+ return keys
}
diff --git a/modules/templates/helper.go b/modules/templates/helper.go
index 99b1979964..93463ce0c2 100644
--- a/modules/templates/helper.go
+++ b/modules/templates/helper.go
@@ -733,7 +733,7 @@ func RenderCommitMessageLink(ctx context.Context, msg, urlPrefix, urlDefault str
log.Error("RenderCommitMessage: %v", err)
return ""
}
- msgLines := strings.Split(strings.TrimSpace(string(fullMessage)), "\n")
+ msgLines := strings.Split(strings.TrimSpace(fullMessage), "\n")
if len(msgLines) == 0 {
return template.HTML("")
}
@@ -843,7 +843,7 @@ func RenderNote(ctx context.Context, msg, urlPrefix string, metas map[string]str
log.Error("RenderNote: %v", err)
return ""
}
- return template.HTML(string(fullMessage))
+ return template.HTML(fullMessage)
}
// IsMultilineCommitMessage checks to see if a commit message contains multiple lines.
diff --git a/modules/templates/helper_test.go b/modules/templates/helper_test.go
index e2997cb853..5ebae7afef 100644
--- a/modules/templates/helper_test.go
+++ b/modules/templates/helper_test.go
@@ -17,8 +17,8 @@ func TestSubjectBodySeparator(t *testing.T) {
assert.Empty(t, subject, "no subject found, but one expected")
assert.Equal(t, body, input)
} else {
- assert.Equal(t, subject, string(input[0:loc[0]]))
- assert.Equal(t, body, string(input[loc[1]:]))
+ assert.Equal(t, subject, input[0:loc[0]])
+ assert.Equal(t, body, input[loc[1]:])
}
}
diff --git a/modules/timeutil/since.go b/modules/timeutil/since.go
index 38b12829ad..b22fe59ba2 100644
--- a/modules/timeutil/since.go
+++ b/modules/timeutil/since.go
@@ -30,7 +30,7 @@ func round(s float64) int64 {
}
func computeTimeDiffFloor(diff int64, lang string) (int64, string) {
- diffStr := ""
+ var diffStr string
switch {
case diff <= 0:
diff = 0
@@ -88,7 +88,7 @@ func computeTimeDiffFloor(diff int64, lang string) (int64, string) {
}
func computeTimeDiff(diff int64, lang string) (int64, string) {
- diffStr := ""
+ var diffStr string
switch {
case diff <= 0:
diff = 0
diff --git a/modules/timeutil/timestamp.go b/modules/timeutil/timestamp.go
index 1fe8d4fcb1..88008d1fad 100644
--- a/modules/timeutil/timestamp.go
+++ b/modules/timeutil/timestamp.go
@@ -57,7 +57,7 @@ func (ts TimeStamp) AsTime() (tm time.Time) {
// AsTimeInLocation convert timestamp as time.Time in Local locale
func (ts TimeStamp) AsTimeInLocation(loc *time.Location) (tm time.Time) {
tm = time.Unix(int64(ts), 0).In(loc)
- return
+ return tm
}
// AsTimePtr convert timestamp as *time.Time in Local locale
diff --git a/modules/util/io.go b/modules/util/io.go
index 0c677c359f..d765e27733 100644
--- a/modules/util/io.go
+++ b/modules/util/io.go
@@ -16,5 +16,5 @@ func ReadAtMost(r io.Reader, buf []byte) (n int, err error) {
if err == io.EOF || err == io.ErrUnexpectedEOF {
err = nil
}
- return
+ return n, err
}
diff --git a/modules/web/wrap_convert.go b/modules/web/wrap_convert.go
index b7bcbc6439..9084cfa074 100644
--- a/modules/web/wrap_convert.go
+++ b/modules/web/wrap_convert.go
@@ -28,7 +28,7 @@ func convertHandler(handler interface{}) wrappedHandlerFunc {
if r, ok := resp.(context.ResponseWriter); ok && r.Status() > 0 {
done = true
}
- return
+ return done, deferrable
}
case func(http.ResponseWriter, *http.Request):
return func(resp http.ResponseWriter, req *http.Request, others ...wrappedHandlerFunc) (done bool, deferrable func()) {
@@ -37,7 +37,7 @@ func convertHandler(handler interface{}) wrappedHandlerFunc {
if r, ok := resp.(context.ResponseWriter); ok && r.Status() > 0 {
done = true
}
- return
+ return done, deferrable
}
case func(ctx *context.Context):
@@ -46,7 +46,7 @@ func convertHandler(handler interface{}) wrappedHandlerFunc {
ctx := context.GetContext(req)
t(ctx)
done = ctx.Written()
- return
+ return done, deferrable
}
case func(ctx *context.Context) goctx.CancelFunc:
return func(resp http.ResponseWriter, req *http.Request, others ...wrappedHandlerFunc) (done bool, deferrable func()) {
@@ -54,7 +54,7 @@ func convertHandler(handler interface{}) wrappedHandlerFunc {
ctx := context.GetContext(req)
deferrable = t(ctx)
done = ctx.Written()
- return
+ return done, deferrable
}
case func(*context.APIContext):
return func(resp http.ResponseWriter, req *http.Request, others ...wrappedHandlerFunc) (done bool, deferrable func()) {
@@ -62,7 +62,7 @@ func convertHandler(handler interface{}) wrappedHandlerFunc {
ctx := context.GetAPIContext(req)
t(ctx)
done = ctx.Written()
- return
+ return done, deferrable
}
case func(*context.APIContext) goctx.CancelFunc:
return func(resp http.ResponseWriter, req *http.Request, others ...wrappedHandlerFunc) (done bool, deferrable func()) {
@@ -70,7 +70,7 @@ func convertHandler(handler interface{}) wrappedHandlerFunc {
ctx := context.GetAPIContext(req)
deferrable = t(ctx)
done = ctx.Written()
- return
+ return done, deferrable
}
case func(*context.PrivateContext):
return func(resp http.ResponseWriter, req *http.Request, others ...wrappedHandlerFunc) (done bool, deferrable func()) {
@@ -78,7 +78,7 @@ func convertHandler(handler interface{}) wrappedHandlerFunc {
ctx := context.GetPrivateContext(req)
t(ctx)
done = ctx.Written()
- return
+ return done, deferrable
}
case func(*context.PrivateContext) goctx.CancelFunc:
return func(resp http.ResponseWriter, req *http.Request, others ...wrappedHandlerFunc) (done bool, deferrable func()) {
@@ -86,7 +86,7 @@ func convertHandler(handler interface{}) wrappedHandlerFunc {
ctx := context.GetPrivateContext(req)
deferrable = t(ctx)
done = ctx.Written()
- return
+ return done, deferrable
}
case func(http.Handler) http.Handler:
return func(resp http.ResponseWriter, req *http.Request, others ...wrappedHandlerFunc) (done bool, deferrable func()) {
@@ -102,7 +102,7 @@ func convertHandler(handler interface{}) wrappedHandlerFunc {
if r, ok := resp.(context.ResponseWriter); ok && r.Status() > 0 {
done = true
}
- return
+ return done, deferrable
}
default:
panic(fmt.Sprintf("Unsupported handler type: %#v", t))
diff --git a/routers/api/v1/activitypub/reqsignature.go b/routers/api/v1/activitypub/reqsignature.go
index b870d1c0f9..5c0776602b 100644
--- a/routers/api/v1/activitypub/reqsignature.go
+++ b/routers/api/v1/activitypub/reqsignature.go
@@ -41,7 +41,7 @@ func getPublicKeyFromResponse(b []byte, keyID *url.URL) (p crypto.PublicKey, err
return
}
p, err = x509.ParsePKIXPublicKey(block.Bytes)
- return
+ return p, err
}
func fetch(iri *url.URL) (b []byte, err error) {
@@ -59,7 +59,7 @@ func fetch(iri *url.URL) (b []byte, err error) {
return
}
b, err = io.ReadAll(io.LimitReader(resp.Body, setting.Federation.MaxSize))
- return
+ return b, err
}
func verifyHTTPSignatures(ctx *gitea_context.APIContext) (authenticated bool, err error) {
@@ -87,7 +87,7 @@ func verifyHTTPSignatures(ctx *gitea_context.APIContext) (authenticated bool, er
// 3. Verify the other actor's key
algo := httpsig.Algorithm(setting.Federation.Algorithms[0])
authenticated = v.Verify(pubKey, algo) == nil
- return
+ return authenticated, err
}
// ReqHTTPSignature function
diff --git a/routers/api/v1/notify/notifications.go b/routers/api/v1/notify/notifications.go
index 0a3684fbe6..44cb4ae769 100644
--- a/routers/api/v1/notify/notifications.go
+++ b/routers/api/v1/notify/notifications.go
@@ -63,5 +63,5 @@ func subjectToSource(value []string) (result []models.NotificationSource) {
result = append(result, models.NotificationSourceRepository)
}
}
- return
+ return result
}
diff --git a/routers/api/v1/org/org.go b/routers/api/v1/org/org.go
index d55a4a4514..5a8b253a20 100644
--- a/routers/api/v1/org/org.go
+++ b/routers/api/v1/org/org.go
@@ -47,7 +47,7 @@ func listUserOrgs(ctx *context.APIContext, u *user_model.User) {
}
ctx.SetLinkHeader(int(maxResults), listOptions.PageSize)
- ctx.SetTotalCountHeader(int64(maxResults))
+ ctx.SetTotalCountHeader(maxResults)
ctx.JSON(http.StatusOK, &apiOrgs)
}
diff --git a/routers/api/v1/repo/file.go b/routers/api/v1/repo/file.go
index 2190094bac..1ac1088839 100644
--- a/routers/api/v1/repo/file.go
+++ b/routers/api/v1/repo/file.go
@@ -251,7 +251,7 @@ func getBlobForEntry(ctx *context.APIContext) (blob *git.Blob, lastModified time
}
blob = entry.Blob()
- return
+ return blob, lastModified
}
// GetArchive get archive of a repository
diff --git a/routers/api/v1/repo/issue_label.go b/routers/api/v1/repo/issue_label.go
index 50c09e02fa..091f1ce27c 100644
--- a/routers/api/v1/repo/issue_label.go
+++ b/routers/api/v1/repo/issue_label.go
@@ -321,5 +321,5 @@ func prepareForReplaceOrAdd(ctx *context.APIContext, form api.IssueLabelsOption)
return
}
- return
+ return issue, labels, err
}
diff --git a/routers/api/v1/repo/status.go b/routers/api/v1/repo/status.go
index f7bc2c5c88..10e78f2a9b 100644
--- a/routers/api/v1/repo/status.go
+++ b/routers/api/v1/repo/status.go
@@ -57,7 +57,7 @@ func NewCommitStatus(ctx *context.APIContext) {
return
}
status := &git_model.CommitStatus{
- State: api.CommitStatusState(form.State),
+ State: form.State,
TargetURL: form.TargetURL,
Description: form.Description,
Context: form.Context,
diff --git a/routers/api/v1/utils/hook.go b/routers/api/v1/utils/hook.go
index 4c3753231d..f0dc595ad5 100644
--- a/routers/api/v1/utils/hook.go
+++ b/routers/api/v1/utils/hook.go
@@ -133,7 +133,7 @@ func addHook(ctx *context.APIContext, form *api.CreateHookOption, orgID, repoID
BranchFilter: form.BranchFilter,
},
IsActive: form.Active,
- Type: webhook.HookType(form.Type),
+ Type: form.Type,
}
if w.Type == webhook.SLACK {
channel, ok := form.Config["channel"]
diff --git a/routers/private/hook_pre_receive.go b/routers/private/hook_pre_receive.go
index cadfea782c..fb4c039d49 100644
--- a/routers/private/hook_pre_receive.go
+++ b/routers/private/hook_pre_receive.go
@@ -248,7 +248,7 @@ func preReceiveBranch(ctx *preReceiveContext, oldCommitID, newCommitID, refFullN
}
// 5. Check if the doer is allowed to push
- canPush := false
+ var canPush bool
if ctx.opts.DeployKeyID != 0 {
canPush = !changedProtectedfiles && protectBranch.CanPush && (!protectBranch.EnableWhitelist || protectBranch.WhitelistDeployKeys)
} else {
diff --git a/routers/private/manager_process.go b/routers/private/manager_process.go
index f8932d61fa..e12bbee18b 100644
--- a/routers/private/manager_process.go
+++ b/routers/private/manager_process.go
@@ -34,7 +34,7 @@ func Processes(ctx *context.PrivateContext) {
var processes []*process_module.Process
goroutineCount := int64(0)
- processCount := 0
+ var processCount int
var err error
if stacktraces {
processes, processCount, goroutineCount, err = process_module.GetManager().ProcessStacktraces(flat, noSystem)
diff --git a/routers/private/serv.go b/routers/private/serv.go
index 803d51e9d9..ddb2e6aa8b 100644
--- a/routers/private/serv.go
+++ b/routers/private/serv.go
@@ -142,7 +142,7 @@ func ServCommand(ctx *context.PrivateContext) {
if repo_model.IsErrRepoNotExist(err) {
repoExist = false
for _, verb := range ctx.FormStrings("verb") {
- if "git-upload-pack" == verb {
+ if verb == "git-upload-pack" {
// User is fetching/cloning a non-existent repository
log.Warn("Failed authentication attempt (cannot find repository: %s/%s) from %s", results.OwnerName, results.RepoName, ctx.RemoteAddr())
ctx.JSON(http.StatusNotFound, private.ErrServCommand{
diff --git a/routers/web/admin/repos.go b/routers/web/admin/repos.go
index 809d1de74b..8ce981ec20 100644
--- a/routers/web/admin/repos.go
+++ b/routers/web/admin/repos.go
@@ -101,7 +101,7 @@ func UnadoptedRepos(ctx *context.Context) {
ctx.ServerError("ListUnadoptedRepositories", err)
}
ctx.Data["Dirs"] = repoNames
- pager := context.NewPagination(int(count), opts.PageSize, opts.Page, 5)
+ pager := context.NewPagination(count, opts.PageSize, opts.Page, 5)
pager.SetDefaultParams(ctx)
pager.AddParam(ctx, "search", "search")
ctx.Data["Page"] = pager
diff --git a/routers/web/auth/oauth.go b/routers/web/auth/oauth.go
index d868b05a44..f70d69509c 100644
--- a/routers/web/auth/oauth.go
+++ b/routers/web/auth/oauth.go
@@ -168,7 +168,7 @@ func newAccessTokenResponse(ctx stdContext.Context, grant *auth.OAuth2Grant, ser
GrantID: grant.ID,
Counter: grant.Counter,
Type: oauth2.TypeRefreshToken,
- RegisteredClaims: jwt.RegisteredClaims{ // nolint
+ RegisteredClaims: jwt.RegisteredClaims{
ExpiresAt: jwt.NewNumericDate(refreshExpirationDate),
},
}
diff --git a/routers/web/feed/convert.go b/routers/web/feed/convert.go
index 64801a6078..978469d125 100644
--- a/routers/web/feed/convert.go
+++ b/routers/web/feed/convert.go
@@ -71,7 +71,7 @@ func feedActionsToFeedItems(ctx *context.Context, actions models.ActionList) (it
for _, act := range actions {
act.LoadActUser()
- content, desc, title := "", "", ""
+ var content, desc, title string
link := &feeds.Link{Href: act.GetCommentLink()}
@@ -246,7 +246,7 @@ func feedActionsToFeedItems(ctx *context.Context, actions models.ActionList) (it
Content: content,
})
}
- return
+ return items, err
}
// GetFeedType return if it is a feed request and altered name and feed type.
diff --git a/routers/web/repo/branch.go b/routers/web/repo/branch.go
index 84970a96a1..d14ba6cbe9 100644
--- a/routers/web/repo/branch.go
+++ b/routers/web/repo/branch.go
@@ -80,7 +80,7 @@ func Branches(ctx *context.Context) {
}
ctx.Data["Branches"] = branches
ctx.Data["DefaultBranchBranch"] = defaultBranchBranch
- pager := context.NewPagination(int(branchesCount), setting.Git.BranchesRangeSize, page, 5)
+ pager := context.NewPagination(branchesCount, setting.Git.BranchesRangeSize, page, 5)
pager.SetDefaultParams(ctx)
ctx.Data["Page"] = pager
diff --git a/routers/web/repo/download.go b/routers/web/repo/download.go
index 2a83bafa85..6755cda874 100644
--- a/routers/web/repo/download.go
+++ b/routers/web/repo/download.go
@@ -116,7 +116,7 @@ func getBlobForEntry(ctx *context.Context) (blob *git.Blob, lastModified time.Ti
}
blob = entry.Blob()
- return
+ return blob, lastModified
}
// SingleDownload download a file by repos path
diff --git a/routers/web/repo/editor_test.go b/routers/web/repo/editor_test.go
index 2bebb6fd52..ac0c385897 100644
--- a/routers/web/repo/editor_test.go
+++ b/routers/web/repo/editor_test.go
@@ -70,9 +70,7 @@ func TestGetClosestParentWithFiles(t *testing.T) {
gitRepo, _ := git.OpenRepository(git.DefaultContext, repo.RepoPath())
defer gitRepo.Close()
commit, _ := gitRepo.GetBranchCommit(branch)
- expectedTreePath := ""
-
- expectedTreePath = "" // Should return the root dir, empty string, since there are no subdirs in this repo
+ var expectedTreePath string // Should return the root dir, empty string, since there are no subdirs in this repo
for _, deletedFile := range []string{
"dir1/dir2/dir3/file.txt",
"file.txt",
diff --git a/routers/web/repo/projects.go b/routers/web/repo/projects.go
index 51c891dbf0..0aa9b5effc 100644
--- a/routers/web/repo/projects.go
+++ b/routers/web/repo/projects.go
@@ -105,7 +105,7 @@ func Projects(ctx *context.Context) {
numPages := 0
if count > 0 {
- numPages = int((int(count) - 1) / setting.UI.IssuePagingNum)
+ numPages = (int(count) - 1/setting.UI.IssuePagingNum)
}
pager := context.NewPagination(total, setting.UI.IssuePagingNum, page, numPages)
diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go
index c327f959f6..17169699df 100644
--- a/routers/web/repo/view.go
+++ b/routers/web/repo/view.go
@@ -353,7 +353,7 @@ func renderReadmeFile(ctx *context.Context, readmeFile *namedBlob, readmeTreelin
if markupType := markup.Type(readmeFile.name); markupType != "" {
ctx.Data["IsMarkup"] = true
- ctx.Data["MarkupType"] = string(markupType)
+ ctx.Data["MarkupType"] = markupType
var result strings.Builder
err := markup.Render(&markup.RenderContext{
Ctx: ctx,
diff --git a/routers/web/user/setting/profile.go b/routers/web/user/setting/profile.go
index 972271269f..46399338fa 100644
--- a/routers/web/user/setting/profile.go
+++ b/routers/web/user/setting/profile.go
@@ -347,7 +347,7 @@ func Repos(ctx *context.Context) {
ctx.Data["Repos"] = repos
}
ctx.Data["Owner"] = ctxUser
- pager := context.NewPagination(int(count), opts.PageSize, opts.Page, 5)
+ pager := context.NewPagination(count, opts.PageSize, opts.Page, 5)
pager.SetDefaultParams(ctx)
ctx.Data["Page"] = pager
ctx.HTML(http.StatusOK, tplSettingsRepositories)
diff --git a/routers/web/web.go b/routers/web/web.go
index 374bafbc8d..d19bc5015d 100644
--- a/routers/web/web.go
+++ b/routers/web/web.go
@@ -138,7 +138,7 @@ func Routes() *web.Route {
// redirect default favicon to the path of the custom favicon with a default as a fallback
routes.Get("/favicon.ico", func(w http.ResponseWriter, req *http.Request) {
- http.Redirect(w, req, path.Join(setting.StaticURLPrefix, "/assets/img/favicon.png"), 301)
+ http.Redirect(w, req, path.Join(setting.StaticURLPrefix, "/assets/img/favicon.png"), http.StatusMovedPermanently)
})
common := []interface{}{}
@@ -1121,7 +1121,7 @@ func RegisterRoutes(m *web.Route) {
}
repo.MustBeNotEmpty(ctx)
- return
+ return cancel
})
m.Group("/pulls/{index}", func() {
diff --git a/services/agit/agit.go b/services/agit/agit.go
index 4359557a1e..9f0ce75123 100644
--- a/services/agit/agit.go
+++ b/services/agit/agit.go
@@ -80,7 +80,7 @@ func ProcReceive(ctx context.Context, repo *repo_model.Repository, gitRepo *git.
continue
}
- headBranch := ""
+ var headBranch string
userName := strings.ToLower(opts.UserName)
if len(curentTopicBranch) == 0 {
@@ -104,7 +104,7 @@ func ProcReceive(ctx context.Context, repo *repo_model.Repository, gitRepo *git.
// create a new pull request
if len(title) == 0 {
- has := false
+ var has bool
title, has = opts.GitPushOptions["title"]
if !has || len(title) == 0 {
commit, err := gitRepo.GetCommit(opts.NewCommitIDs[i])
diff --git a/services/auth/source/ldap/source_search.go b/services/auth/source/ldap/source_search.go
index d01fd14c8b..988d56005e 100644
--- a/services/auth/source/ldap/source_search.go
+++ b/services/auth/source/ldap/source_search.go
@@ -34,7 +34,7 @@ type SearchResult struct {
LdapTeamRemove map[string][]string // organizations teams to remove
}
-func (ls *Source) sanitizedUserQuery(username string) (string, bool) {
+func (source *Source) sanitizedUserQuery(username string) (string, bool) {
// See http://tools.ietf.org/search/rfc4515
badCharacters := "\x00()*\\"
if strings.ContainsAny(username, badCharacters) {
@@ -42,10 +42,10 @@ func (ls *Source) sanitizedUserQuery(username string) (string, bool) {
return "", false
}
- return fmt.Sprintf(ls.Filter, username), true
+ return fmt.Sprintf(source.Filter, username), true
}
-func (ls *Source) sanitizedUserDN(username string) (string, bool) {
+func (source *Source) sanitizedUserDN(username string) (string, bool) {
// See http://tools.ietf.org/search/rfc4514: "special characters"
badCharacters := "\x00()*\\,='\"#+;<>"
if strings.ContainsAny(username, badCharacters) {
@@ -53,10 +53,10 @@ func (ls *Source) sanitizedUserDN(username string) (string, bool) {
return "", false
}
- return fmt.Sprintf(ls.UserDN, username), true
+ return fmt.Sprintf(source.UserDN, username), true
}
-func (ls *Source) sanitizedGroupFilter(group string) (string, bool) {
+func (source *Source) sanitizedGroupFilter(group string) (string, bool) {
// See http://tools.ietf.org/search/rfc4515
badCharacters := "\x00*\\"
if strings.ContainsAny(group, badCharacters) {
@@ -67,7 +67,7 @@ func (ls *Source) sanitizedGroupFilter(group string) (string, bool) {
return group, true
}
-func (ls *Source) sanitizedGroupDN(groupDn string) (string, bool) {
+func (source *Source) sanitizedGroupDN(groupDn string) (string, bool) {
// See http://tools.ietf.org/search/rfc4514: "special characters"
badCharacters := "\x00()*\\'\"#+;<>"
if strings.ContainsAny(groupDn, badCharacters) || strings.HasPrefix(groupDn, " ") || strings.HasSuffix(groupDn, " ") {
@@ -78,18 +78,18 @@ func (ls *Source) sanitizedGroupDN(groupDn string) (string, bool) {
return groupDn, true
}
-func (ls *Source) findUserDN(l *ldap.Conn, name string) (string, bool) {
+func (source *Source) findUserDN(l *ldap.Conn, name string) (string, bool) {
log.Trace("Search for LDAP user: %s", name)
// A search for the user.
- userFilter, ok := ls.sanitizedUserQuery(name)
+ userFilter, ok := source.sanitizedUserQuery(name)
if !ok {
return "", false
}
- log.Trace("Searching for DN using filter %s and base %s", userFilter, ls.UserBase)
+ log.Trace("Searching for DN using filter %s and base %s", userFilter, source.UserBase)
search := ldap.NewSearchRequest(
- ls.UserBase, ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0,
+ source.UserBase, ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0,
false, userFilter, []string{}, nil)
// Ensure we found a user
@@ -197,11 +197,11 @@ func checkRestricted(l *ldap.Conn, ls *Source, userDN string) bool {
}
// List all group memberships of a user
-func (ls *Source) listLdapGroupMemberships(l *ldap.Conn, uid string) []string {
+func (source *Source) listLdapGroupMemberships(l *ldap.Conn, uid string) []string {
var ldapGroups []string
- groupFilter := fmt.Sprintf("(%s=%s)", ls.GroupMemberUID, uid)
+ groupFilter := fmt.Sprintf("(%s=%s)", source.GroupMemberUID, uid)
result, err := l.Search(ldap.NewSearchRequest(
- ls.GroupDN,
+ source.GroupDN,
ldap.ScopeWholeSubtree,
ldap.NeverDerefAliases,
0,
@@ -228,9 +228,9 @@ func (ls *Source) listLdapGroupMemberships(l *ldap.Conn, uid string) []string {
}
// parse LDAP groups and return map of ldap groups to organizations teams
-func (ls *Source) mapLdapGroupsToTeams() map[string]map[string][]string {
+func (source *Source) mapLdapGroupsToTeams() map[string]map[string][]string {
ldapGroupsToTeams := make(map[string]map[string][]string)
- err := json.Unmarshal([]byte(ls.GroupTeamMap), &ldapGroupsToTeams)
+ err := json.Unmarshal([]byte(source.GroupTeamMap), &ldapGroupsToTeams)
if err != nil {
log.Error("Failed to unmarshall LDAP teams map: %v", err)
return ldapGroupsToTeams
@@ -239,11 +239,11 @@ func (ls *Source) mapLdapGroupsToTeams() map[string]map[string][]string {
}
// getMappedMemberships : returns the organizations and teams to modify the users membership
-func (ls *Source) getMappedMemberships(l *ldap.Conn, uid string) (map[string][]string, map[string][]string) {
+func (source *Source) getMappedMemberships(l *ldap.Conn, uid string) (map[string][]string, map[string][]string) {
// get all LDAP group memberships for user
- usersLdapGroups := ls.listLdapGroupMemberships(l, uid)
+ usersLdapGroups := source.listLdapGroupMemberships(l, uid)
// unmarshall LDAP group team map from configs
- ldapGroupsToTeams := ls.mapLdapGroupsToTeams()
+ ldapGroupsToTeams := source.mapLdapGroupsToTeams()
membershipsToAdd := map[string][]string{}
membershipsToRemove := map[string][]string{}
for group, memberships := range ldapGroupsToTeams {
@@ -262,26 +262,26 @@ func (ls *Source) getMappedMemberships(l *ldap.Conn, uid string) (map[string][]s
}
// SearchEntry : search an LDAP source if an entry (name, passwd) is valid and in the specific filter
-func (ls *Source) SearchEntry(name, passwd string, directBind bool) *SearchResult {
+func (source *Source) SearchEntry(name, passwd string, directBind bool) *SearchResult {
// See https://tools.ietf.org/search/rfc4513#section-5.1.2
if len(passwd) == 0 {
log.Debug("Auth. failed for %s, password cannot be empty", name)
return nil
}
- l, err := dial(ls)
+ l, err := dial(source)
if err != nil {
- log.Error("LDAP Connect error, %s:%v", ls.Host, err)
- ls.Enabled = false
+ log.Error("LDAP Connect error, %s:%v", source.Host, err)
+ source.Enabled = false
return nil
}
defer l.Close()
var userDN string
if directBind {
- log.Trace("LDAP will bind directly via UserDN template: %s", ls.UserDN)
+ log.Trace("LDAP will bind directly via UserDN template: %s", source.UserDN)
var ok bool
- userDN, ok = ls.sanitizedUserDN(name)
+ userDN, ok = source.sanitizedUserDN(name)
if !ok {
return nil
@@ -292,11 +292,11 @@ func (ls *Source) SearchEntry(name, passwd string, directBind bool) *SearchResul
return nil
}
- if ls.UserBase != "" {
+ if source.UserBase != "" {
// not everyone has a CN compatible with input name so we need to find
// the real userDN in that case
- userDN, ok = ls.findUserDN(l, name)
+ userDN, ok = source.findUserDN(l, name)
if !ok {
return nil
}
@@ -306,24 +306,24 @@ func (ls *Source) SearchEntry(name, passwd string, directBind bool) *SearchResul
var found bool
- if ls.BindDN != "" && ls.BindPassword != "" {
- err := l.Bind(ls.BindDN, ls.BindPassword)
+ if source.BindDN != "" && source.BindPassword != "" {
+ err := l.Bind(source.BindDN, source.BindPassword)
if err != nil {
- log.Debug("Failed to bind as BindDN[%s]: %v", ls.BindDN, err)
+ log.Debug("Failed to bind as BindDN[%s]: %v", source.BindDN, err)
return nil
}
- log.Trace("Bound as BindDN %s", ls.BindDN)
+ log.Trace("Bound as BindDN %s", source.BindDN)
} else {
log.Trace("Proceeding with anonymous LDAP search.")
}
- userDN, found = ls.findUserDN(l, name)
+ userDN, found = source.findUserDN(l, name)
if !found {
return nil
}
}
- if !ls.AttributesInBind {
+ if !source.AttributesInBind {
// binds user (checking password) before looking-up attributes in user context
err = bindUser(l, userDN, passwd)
if err != nil {
@@ -331,26 +331,26 @@ func (ls *Source) SearchEntry(name, passwd string, directBind bool) *SearchResul
}
}
- userFilter, ok := ls.sanitizedUserQuery(name)
+ userFilter, ok := source.sanitizedUserQuery(name)
if !ok {
return nil
}
- isAttributeSSHPublicKeySet := len(strings.TrimSpace(ls.AttributeSSHPublicKey)) > 0
- isAtributeAvatarSet := len(strings.TrimSpace(ls.AttributeAvatar)) > 0
+ isAttributeSSHPublicKeySet := len(strings.TrimSpace(source.AttributeSSHPublicKey)) > 0
+ isAtributeAvatarSet := len(strings.TrimSpace(source.AttributeAvatar)) > 0
- attribs := []string{ls.AttributeUsername, ls.AttributeName, ls.AttributeSurname, ls.AttributeMail}
- if len(strings.TrimSpace(ls.UserUID)) > 0 {
- attribs = append(attribs, ls.UserUID)
+ attribs := []string{source.AttributeUsername, source.AttributeName, source.AttributeSurname, source.AttributeMail}
+ if len(strings.TrimSpace(source.UserUID)) > 0 {
+ attribs = append(attribs, source.UserUID)
}
if isAttributeSSHPublicKeySet {
- attribs = append(attribs, ls.AttributeSSHPublicKey)
+ attribs = append(attribs, source.AttributeSSHPublicKey)
}
if isAtributeAvatarSet {
- attribs = append(attribs, ls.AttributeAvatar)
+ attribs = append(attribs, source.AttributeAvatar)
}
- log.Trace("Fetching attributes '%v', '%v', '%v', '%v', '%v', '%v', '%v' with filter '%s' and base '%s'", ls.AttributeUsername, ls.AttributeName, ls.AttributeSurname, ls.AttributeMail, ls.AttributeSSHPublicKey, ls.AttributeAvatar, ls.UserUID, userFilter, userDN)
+ log.Trace("Fetching attributes '%v', '%v', '%v', '%v', '%v', '%v', '%v' with filter '%s' and base '%s'", source.AttributeUsername, source.AttributeName, source.AttributeSurname, source.AttributeMail, source.AttributeSSHPublicKey, source.AttributeAvatar, source.UserUID, userFilter, userDN)
search := ldap.NewSearchRequest(
userDN, ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false, userFilter,
attribs, nil)
@@ -372,30 +372,30 @@ func (ls *Source) SearchEntry(name, passwd string, directBind bool) *SearchResul
var sshPublicKey []string
var Avatar []byte
- username := sr.Entries[0].GetAttributeValue(ls.AttributeUsername)
- firstname := sr.Entries[0].GetAttributeValue(ls.AttributeName)
- surname := sr.Entries[0].GetAttributeValue(ls.AttributeSurname)
- mail := sr.Entries[0].GetAttributeValue(ls.AttributeMail)
- uid := sr.Entries[0].GetAttributeValue(ls.UserUID)
- if ls.UserUID == "dn" || ls.UserUID == "DN" {
+ username := sr.Entries[0].GetAttributeValue(source.AttributeUsername)
+ firstname := sr.Entries[0].GetAttributeValue(source.AttributeName)
+ surname := sr.Entries[0].GetAttributeValue(source.AttributeSurname)
+ mail := sr.Entries[0].GetAttributeValue(source.AttributeMail)
+ uid := sr.Entries[0].GetAttributeValue(source.UserUID)
+ if source.UserUID == "dn" || source.UserUID == "DN" {
uid = sr.Entries[0].DN
}
// Check group membership
- if ls.GroupsEnabled && ls.GroupFilter != "" {
- groupFilter, ok := ls.sanitizedGroupFilter(ls.GroupFilter)
+ if source.GroupsEnabled && source.GroupFilter != "" {
+ groupFilter, ok := source.sanitizedGroupFilter(source.GroupFilter)
if !ok {
return nil
}
- groupDN, ok := ls.sanitizedGroupDN(ls.GroupDN)
+ groupDN, ok := source.sanitizedGroupDN(source.GroupDN)
if !ok {
return nil
}
- log.Trace("Fetching groups '%v' with filter '%s' and base '%s'", ls.GroupMemberUID, groupFilter, groupDN)
+ log.Trace("Fetching groups '%v' with filter '%s' and base '%s'", source.GroupMemberUID, groupFilter, groupDN)
groupSearch := ldap.NewSearchRequest(
groupDN, ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false, groupFilter,
- []string{ls.GroupMemberUID},
+ []string{source.GroupMemberUID},
nil)
srg, err := l.Search(groupSearch)
@@ -410,8 +410,8 @@ func (ls *Source) SearchEntry(name, passwd string, directBind bool) *SearchResul
isMember := false
Entries:
for _, group := range srg.Entries {
- for _, member := range group.GetAttributeValues(ls.GroupMemberUID) {
- if (ls.UserUID == "dn" && member == sr.Entries[0].DN) || member == uid {
+ for _, member := range group.GetAttributeValues(source.GroupMemberUID) {
+ if (source.UserUID == "dn" && member == sr.Entries[0].DN) || member == uid {
isMember = true
break Entries
}
@@ -425,25 +425,25 @@ func (ls *Source) SearchEntry(name, passwd string, directBind bool) *SearchResul
}
if isAttributeSSHPublicKeySet {
- sshPublicKey = sr.Entries[0].GetAttributeValues(ls.AttributeSSHPublicKey)
+ sshPublicKey = sr.Entries[0].GetAttributeValues(source.AttributeSSHPublicKey)
}
- isAdmin := checkAdmin(l, ls, userDN)
+ isAdmin := checkAdmin(l, source, userDN)
var isRestricted bool
if !isAdmin {
- isRestricted = checkRestricted(l, ls, userDN)
+ isRestricted = checkRestricted(l, source, userDN)
}
if isAtributeAvatarSet {
- Avatar = sr.Entries[0].GetRawAttributeValue(ls.AttributeAvatar)
+ Avatar = sr.Entries[0].GetRawAttributeValue(source.AttributeAvatar)
}
teamsToAdd := make(map[string][]string)
teamsToRemove := make(map[string][]string)
- if ls.GroupsEnabled && (ls.GroupTeamMap != "" || ls.GroupTeamMapRemoval) {
- teamsToAdd, teamsToRemove = ls.getMappedMemberships(l, uid)
+ if source.GroupsEnabled && (source.GroupTeamMap != "" || source.GroupTeamMapRemoval) {
+ teamsToAdd, teamsToRemove = source.getMappedMemberships(l, uid)
}
- if !directBind && ls.AttributesInBind {
+ if !directBind && source.AttributesInBind {
// binds user (checking password) after looking-up attributes in BindDN context
err = bindUser(l, userDN, passwd)
if err != nil {
@@ -467,52 +467,52 @@ func (ls *Source) SearchEntry(name, passwd string, directBind bool) *SearchResul
}
// UsePagedSearch returns if need to use paged search
-func (ls *Source) UsePagedSearch() bool {
- return ls.SearchPageSize > 0
+func (source *Source) UsePagedSearch() bool {
+ return source.SearchPageSize > 0
}
// SearchEntries : search an LDAP source for all users matching userFilter
-func (ls *Source) SearchEntries() ([]*SearchResult, error) {
- l, err := dial(ls)
+func (source *Source) SearchEntries() ([]*SearchResult, error) {
+ l, err := dial(source)
if err != nil {
- log.Error("LDAP Connect error, %s:%v", ls.Host, err)
- ls.Enabled = false
+ log.Error("LDAP Connect error, %s:%v", source.Host, err)
+ source.Enabled = false
return nil, err
}
defer l.Close()
- if ls.BindDN != "" && ls.BindPassword != "" {
- err := l.Bind(ls.BindDN, ls.BindPassword)
+ if source.BindDN != "" && source.BindPassword != "" {
+ err := l.Bind(source.BindDN, source.BindPassword)
if err != nil {
- log.Debug("Failed to bind as BindDN[%s]: %v", ls.BindDN, err)
+ log.Debug("Failed to bind as BindDN[%s]: %v", source.BindDN, err)
return nil, err
}
- log.Trace("Bound as BindDN %s", ls.BindDN)
+ log.Trace("Bound as BindDN %s", source.BindDN)
} else {
log.Trace("Proceeding with anonymous LDAP search.")
}
- userFilter := fmt.Sprintf(ls.Filter, "*")
+ userFilter := fmt.Sprintf(source.Filter, "*")
- isAttributeSSHPublicKeySet := len(strings.TrimSpace(ls.AttributeSSHPublicKey)) > 0
- isAtributeAvatarSet := len(strings.TrimSpace(ls.AttributeAvatar)) > 0
+ isAttributeSSHPublicKeySet := len(strings.TrimSpace(source.AttributeSSHPublicKey)) > 0
+ isAtributeAvatarSet := len(strings.TrimSpace(source.AttributeAvatar)) > 0
- attribs := []string{ls.AttributeUsername, ls.AttributeName, ls.AttributeSurname, ls.AttributeMail, ls.UserUID}
+ attribs := []string{source.AttributeUsername, source.AttributeName, source.AttributeSurname, source.AttributeMail, source.UserUID}
if isAttributeSSHPublicKeySet {
- attribs = append(attribs, ls.AttributeSSHPublicKey)
+ attribs = append(attribs, source.AttributeSSHPublicKey)
}
if isAtributeAvatarSet {
- attribs = append(attribs, ls.AttributeAvatar)
+ attribs = append(attribs, source.AttributeAvatar)
}
- log.Trace("Fetching attributes '%v', '%v', '%v', '%v', '%v', '%v' with filter %s and base %s", ls.AttributeUsername, ls.AttributeName, ls.AttributeSurname, ls.AttributeMail, ls.AttributeSSHPublicKey, ls.AttributeAvatar, userFilter, ls.UserBase)
+ log.Trace("Fetching attributes '%v', '%v', '%v', '%v', '%v', '%v' with filter %s and base %s", source.AttributeUsername, source.AttributeName, source.AttributeSurname, source.AttributeMail, source.AttributeSSHPublicKey, source.AttributeAvatar, userFilter, source.UserBase)
search := ldap.NewSearchRequest(
- ls.UserBase, ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false, userFilter,
+ source.UserBase, ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false, userFilter,
attribs, nil)
var sr *ldap.SearchResult
- if ls.UsePagedSearch() {
- sr, err = l.SearchWithPaging(search, ls.SearchPageSize)
+ if source.UsePagedSearch() {
+ sr, err = l.SearchWithPaging(search, source.SearchPageSize)
} else {
sr, err = l.Search(search)
}
@@ -526,30 +526,30 @@ func (ls *Source) SearchEntries() ([]*SearchResult, error) {
for i, v := range sr.Entries {
teamsToAdd := make(map[string][]string)
teamsToRemove := make(map[string][]string)
- if ls.GroupsEnabled && (ls.GroupTeamMap != "" || ls.GroupTeamMapRemoval) {
- userAttributeListedInGroup := v.GetAttributeValue(ls.UserUID)
- if ls.UserUID == "dn" || ls.UserUID == "DN" {
+ if source.GroupsEnabled && (source.GroupTeamMap != "" || source.GroupTeamMapRemoval) {
+ userAttributeListedInGroup := v.GetAttributeValue(source.UserUID)
+ if source.UserUID == "dn" || source.UserUID == "DN" {
userAttributeListedInGroup = v.DN
}
- teamsToAdd, teamsToRemove = ls.getMappedMemberships(l, userAttributeListedInGroup)
+ teamsToAdd, teamsToRemove = source.getMappedMemberships(l, userAttributeListedInGroup)
}
result[i] = &SearchResult{
- Username: v.GetAttributeValue(ls.AttributeUsername),
- Name: v.GetAttributeValue(ls.AttributeName),
- Surname: v.GetAttributeValue(ls.AttributeSurname),
- Mail: v.GetAttributeValue(ls.AttributeMail),
- IsAdmin: checkAdmin(l, ls, v.DN),
+ Username: v.GetAttributeValue(source.AttributeUsername),
+ Name: v.GetAttributeValue(source.AttributeName),
+ Surname: v.GetAttributeValue(source.AttributeSurname),
+ Mail: v.GetAttributeValue(source.AttributeMail),
+ IsAdmin: checkAdmin(l, source, v.DN),
LdapTeamAdd: teamsToAdd,
LdapTeamRemove: teamsToRemove,
}
if !result[i].IsAdmin {
- result[i].IsRestricted = checkRestricted(l, ls, v.DN)
+ result[i].IsRestricted = checkRestricted(l, source, v.DN)
}
if isAttributeSSHPublicKeySet {
- result[i].SSHPublicKey = v.GetAttributeValues(ls.AttributeSSHPublicKey)
+ result[i].SSHPublicKey = v.GetAttributeValues(source.AttributeSSHPublicKey)
}
if isAtributeAvatarSet {
- result[i].Avatar = v.GetRawAttributeValue(ls.AttributeAvatar)
+ result[i].Avatar = v.GetRawAttributeValue(source.AttributeAvatar)
}
result[i].LowerName = strings.ToLower(result[i].Username)
}
diff --git a/services/auth/sspi_windows.go b/services/auth/sspi_windows.go
index 7c9529a76b..7e31378b6c 100644
--- a/services/auth/sspi_windows.go
+++ b/services/auth/sspi_windows.go
@@ -180,7 +180,7 @@ func (s *SSPI) shouldAuthenticate(req *http.Request) (shouldAuth bool) {
} else if middleware.IsAPIPath(req) || isAttachmentDownload(req) {
shouldAuth = true
}
- return
+ return shouldAuth
}
// newUser creates a new user object for the purpose of automatic registration
diff --git a/services/automerge/automerge.go b/services/automerge/automerge.go
index d0f83f4a93..ca008ebfe6 100644
--- a/services/automerge/automerge.go
+++ b/services/automerge/automerge.go
@@ -82,7 +82,7 @@ func ScheduleAutoMerge(ctx context.Context, doer *user_model.User, pull *issues_
_, err = issues_model.CreateAutoMergeComment(ctx, issues_model.CommentTypePRScheduledToAutoMerge, pull, doer)
return err
}, ctx)
- return
+ return scheduled, err
}
// RemoveScheduledAutoMerge cancels a previously scheduled pull request
diff --git a/services/gitdiff/gitdiff.go b/services/gitdiff/gitdiff.go
index 37dc0e114d..6e8c149dab 100644
--- a/services/gitdiff/gitdiff.go
+++ b/services/gitdiff/gitdiff.go
@@ -1011,7 +1011,7 @@ parsingLoop:
func skipToNextDiffHead(input *bufio.Reader) (line string, err error) {
// need to skip until the next cmdDiffHead
- isFragment, wasFragment := false, false
+ var isFragment, wasFragment bool
var lineBytes []byte
for {
lineBytes, isFragment, err = input.ReadLine()
@@ -1036,7 +1036,7 @@ func skipToNextDiffHead(input *bufio.Reader) (line string, err error) {
}
line += tail
}
- return
+ return line, err
}
func parseHunks(curFile *DiffFile, maxLines, maxLineCharacters int, input *bufio.Reader) (lineBytes []byte, isFragment bool, err error) {
@@ -1257,8 +1257,7 @@ func createDiffFile(diff *Diff, line string) *DiffFile {
rd := strings.NewReader(line[len(cmdDiffHead):] + " ")
curFile.Type = DiffFileChange
- oldNameAmbiguity := false
- newNameAmbiguity := false
+ var oldNameAmbiguity, newNameAmbiguity bool
curFile.OldName, oldNameAmbiguity = readFileName(rd)
curFile.Name, newNameAmbiguity = readFileName(rd)
diff --git a/services/issue/assignee.go b/services/issue/assignee.go
index 7c00f472dd..aefd8cff9a 100644
--- a/services/issue/assignee.go
+++ b/services/issue/assignee.go
@@ -59,7 +59,7 @@ func ToggleAssignee(issue *issues_model.Issue, doer *user_model.User, assigneeID
notification.NotifyIssueChangeAssignee(doer, issue, assignee, removed, comment)
- return
+ return removed, comment, err
}
// ReviewRequest add or remove a review request from a user for this PR, and make comment for it.
@@ -78,7 +78,7 @@ func ReviewRequest(issue *issues_model.Issue, doer, reviewer *user_model.User, i
notification.NotifyPullReviewRequest(doer, issue, reviewer, isAdd, comment)
}
- return
+ return comment, err
}
// IsValidReviewRequest Check permission for ReviewRequest
@@ -262,5 +262,5 @@ func TeamReviewRequest(issue *issues_model.Issue, doer *user_model.User, reviewe
notification.NotifyPullReviewRequest(doer, issue, member, isAdd, comment)
}
- return
+ return comment, err
}
diff --git a/services/issue/issue.go b/services/issue/issue.go
index 467bc14b84..7131829b03 100644
--- a/services/issue/issue.go
+++ b/services/issue/issue.go
@@ -129,7 +129,7 @@ func UpdateAssignees(issue *issues_model.Issue, oneAssignee string, multipleAssi
}
}
- return
+ return err
}
// DeleteIssue deletes an issue
diff --git a/services/mailer/mail.go b/services/mailer/mail.go
index 81cfb2e31a..f936229551 100644
--- a/services/mailer/mail.go
+++ b/services/mailer/mail.go
@@ -287,7 +287,7 @@ func composeIssueCommentMessages(ctx *mailCommentContext, lang string, recipient
}
var mailSubject bytes.Buffer
- if err := subjectTemplates.ExecuteTemplate(&mailSubject, string(tplName), mailMeta); err == nil {
+ if err := subjectTemplates.ExecuteTemplate(&mailSubject, tplName, mailMeta); err == nil {
subject = sanitizeSubject(mailSubject.String())
if subject == "" {
subject = fallback
@@ -302,8 +302,8 @@ func composeIssueCommentMessages(ctx *mailCommentContext, lang string, recipient
var mailBody bytes.Buffer
- if err := bodyTemplates.ExecuteTemplate(&mailBody, string(tplName), mailMeta); err != nil {
- log.Error("ExecuteTemplate [%s]: %v", string(tplName)+"/body", err)
+ if err := bodyTemplates.ExecuteTemplate(&mailBody, tplName, mailMeta); err != nil {
+ log.Error("ExecuteTemplate [%s]: %v", tplName+"/body", err)
}
// Make sure to compose independent messages to avoid leaking user emails
@@ -498,5 +498,5 @@ func actionToTemplate(issue *issues_model.Issue, actionType models.ActionType,
if !ok {
template = "issue/default"
}
- return
+ return typeName, name, template
}
diff --git a/services/mailer/mail_test.go b/services/mailer/mail_test.go
index 83955a5896..93837ba8c4 100644
--- a/services/mailer/mail_test.go
+++ b/services/mailer/mail_test.go
@@ -61,7 +61,7 @@ func prepareMailerTest(t *testing.T) (doer *user_model.User, repo *repo_model.Re
issue = unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: 1, Repo: repo, Poster: doer}).(*issues_model.Issue)
assert.NoError(t, issue.LoadRepo(db.DefaultContext))
comment = unittest.AssertExistsAndLoadBean(t, &issues_model.Comment{ID: 2, Issue: issue}).(*issues_model.Comment)
- return
+ return doer, repo, issue, comment
}
func TestComposeIssueCommentMessage(t *testing.T) {
diff --git a/services/migrations/onedev.go b/services/migrations/onedev.go
index d4b30939ce..a46ba35f72 100644
--- a/services/migrations/onedev.go
+++ b/services/migrations/onedev.go
@@ -38,7 +38,7 @@ func (f *OneDevDownloaderFactory) New(ctx context.Context, opts base.MigrateOpti
return nil, err
}
- repoName := ""
+ var repoName string
fields := strings.Split(strings.Trim(u.Path, "/"), "/")
if len(fields) == 2 && fields[0] == "projects" {
diff --git a/services/pull/merge.go b/services/pull/merge.go
index e8bb3a1cdd..4cd4e3bd7e 100644
--- a/services/pull/merge.go
+++ b/services/pull/merge.go
@@ -358,7 +358,7 @@ func rawMerge(ctx context.Context, pr *issues_model.PullRequest, doer *user_mode
committer := sig
// Determine if we should sign
- signArg := ""
+ var signArg string
sign, keyID, signer, _ := asymkey_service.SignMerge(ctx, pr, doer, tmpBasePath, "HEAD", trackingBranch)
if sign {
signArg = "-S" + keyID
@@ -858,7 +858,7 @@ func MergedManually(pr *issues_model.PullRequest, doer *user_model.User, baseGit
pr.Merger = doer
pr.MergerID = doer.ID
- merged := false
+ var merged bool
if merged, err = pr.SetMerged(ctx); err != nil {
return err
} else if !merged {
diff --git a/services/pull/review.go b/services/pull/review.go
index 9cb58fa3a1..6bb8877b0f 100644
--- a/services/pull/review.go
+++ b/services/pull/review.go
@@ -318,5 +318,5 @@ func DismissReview(ctx context.Context, reviewID int64, message string, doer *us
notification.NotifyPullRevieweDismiss(doer, review, comment)
- return
+ return comment, err
}
diff --git a/services/task/migrate.go b/services/task/migrate.go
index 6f35134525..651681ef65 100644
--- a/services/task/migrate.go
+++ b/services/task/migrate.go
@@ -139,5 +139,5 @@ func runMigrateTask(t *models.Task) (err error) {
// do not be tempted to coalesce this line with the return
err = handleCreateError(t.Owner, err)
- return
+ return err
}
diff --git a/services/webhook/webhook.go b/services/webhook/webhook.go
index 68cfe147aa..767c3701f3 100644
--- a/services/webhook/webhook.go
+++ b/services/webhook/webhook.go
@@ -70,7 +70,7 @@ var webhooks = map[webhook_model.HookType]*webhook{
// RegisterWebhook registers a webhook
func RegisterWebhook(name string, webhook *webhook) {
- webhooks[webhook_model.HookType(name)] = webhook
+ webhooks[name] = webhook
}
// IsValidHookTaskType returns true if a webhook registered
@@ -78,7 +78,7 @@ func IsValidHookTaskType(name string) bool {
if name == webhook_model.GITEA || name == webhook_model.GOGS {
return true
}
- _, ok := webhooks[webhook_model.HookType(name)]
+ _, ok := webhooks[name]
return ok
}