aboutsummaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
Diffstat (limited to 'routers')
-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
20 files changed, 24 insertions, 26 deletions
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() {