aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-10-18 03:47:12 +0800
committerGitHub <noreply@github.com>2021-10-17 20:47:12 +0100
commit4a57c9ea17a86e579751025cd0a7c2e6de374726 (patch)
treed9de60079592c541c9e6f2a983ec754199739a2f
parent5326f4c9c59cce8a1d8f78afd486ebb8688b45ab (diff)
downloadgitea-4a57c9ea17a86e579751025cd0a7c2e6de374726.tar.gz
gitea-4a57c9ea17a86e579751025cd0a7c2e6de374726.zip
Fix some lints (#17337)
Fix some linting problems.
-rw-r--r--modules/git/submodule.go4
-rw-r--r--modules/gitgraph/graph_models.go2
-rw-r--r--modules/graceful/restart_unix.go4
-rw-r--r--modules/indexer/stats/queue.go2
-rw-r--r--modules/lfs/endpoint.go4
-rw-r--r--modules/markup/common/footnote.go6
-rw-r--r--services/pull/check.go2
-rw-r--r--services/repository/push.go5
8 files changed, 14 insertions, 15 deletions
diff --git a/modules/git/submodule.go b/modules/git/submodule.go
index 231827f1e9..ee61f61179 100644
--- a/modules/git/submodule.go
+++ b/modules/git/submodule.go
@@ -52,9 +52,7 @@ func getRefURL(refURL, urlPrefix, repoFullName, sshDomain string) string {
urlPrefixHostname = prefixURL.Host
}
- if strings.HasSuffix(urlPrefix, "/") {
- urlPrefix = urlPrefix[:len(urlPrefix)-1]
- }
+ urlPrefix = strings.TrimSuffix(urlPrefix, "/")
// FIXME: Need to consider branch - which will require changes in modules/git/commit.go:GetSubModules
// Relative url prefix check (according to git submodule documentation)
diff --git a/modules/gitgraph/graph_models.go b/modules/gitgraph/graph_models.go
index 86bd8cb237..95f761742e 100644
--- a/modules/gitgraph/graph_models.go
+++ b/modules/gitgraph/graph_models.go
@@ -220,7 +220,7 @@ func newRefsFromRefNames(refNames []byte) []git.Reference {
refName := string(refNameBytes)
if strings.HasPrefix(refName, "tag: ") {
refName = strings.TrimPrefix(refName, "tag: ")
- } else if strings.HasPrefix(refName, "HEAD -> ") {
+ } else {
refName = strings.TrimPrefix(refName, "HEAD -> ")
}
refs = append(refs, git.Reference{
diff --git a/modules/graceful/restart_unix.go b/modules/graceful/restart_unix.go
index 392ed60cb3..9969e007c3 100644
--- a/modules/graceful/restart_unix.go
+++ b/modules/graceful/restart_unix.go
@@ -55,7 +55,9 @@ func RestartProcess() (int, error) {
unixListener.SetUnlinkOnClose(false)
}
// Remember to close these at the end.
- defer files[i].Close()
+ defer func(i int) {
+ _ = files[i].Close()
+ }(i)
}
// Use the original binary location. This works with symlinks such that if
diff --git a/modules/indexer/stats/queue.go b/modules/indexer/stats/queue.go
index 8309cfcd3b..fde3f2ff01 100644
--- a/modules/indexer/stats/queue.go
+++ b/modules/indexer/stats/queue.go
@@ -27,7 +27,7 @@ func handle(data ...queue.Data) {
}
func initStatsQueue() error {
- statsQueue = queue.CreateUniqueQueue("repo_stats_update", handle, int64(0)).(queue.UniqueQueue)
+ statsQueue = queue.CreateUniqueQueue("repo_stats_update", handle, int64(0))
if statsQueue == nil {
return fmt.Errorf("Unable to create repo_stats_update Queue")
}
diff --git a/modules/lfs/endpoint.go b/modules/lfs/endpoint.go
index add16ce9f1..943966ed15 100644
--- a/modules/lfs/endpoint.go
+++ b/modules/lfs/endpoint.go
@@ -29,9 +29,7 @@ func endpointFromCloneURL(rawurl string) *url.URL {
return ep
}
- if strings.HasSuffix(ep.Path, "/") {
- ep.Path = ep.Path[:len(ep.Path)-1]
- }
+ ep.Path = strings.TrimSuffix(ep.Path, "/")
if ep.Scheme == "file" {
return ep
diff --git a/modules/markup/common/footnote.go b/modules/markup/common/footnote.go
index 9baf8a4998..bc53d56f2b 100644
--- a/modules/markup/common/footnote.go
+++ b/modules/markup/common/footnote.go
@@ -125,9 +125,9 @@ type Footnote struct {
// Dump implements Node.Dump.
func (n *Footnote) Dump(source []byte, level int) {
m := map[string]string{}
- m["Index"] = fmt.Sprintf("%v", n.Index)
- m["Ref"] = fmt.Sprintf("%s", n.Ref)
- m["Name"] = fmt.Sprintf("%v", n.Name)
+ m["Index"] = strconv.Itoa(n.Index)
+ m["Ref"] = string(n.Ref)
+ m["Name"] = string(n.Name)
ast.DumpHelper(n, source, level, m, nil)
}
diff --git a/services/pull/check.go b/services/pull/check.go
index e819b09cf3..c55b177e1c 100644
--- a/services/pull/check.go
+++ b/services/pull/check.go
@@ -253,7 +253,7 @@ func CheckPrsForBaseBranch(baseRepo *models.Repository, baseBranchName string) e
// Init runs the task queue to test all the checking status pull requests
func Init() error {
- prQueue = queue.CreateUniqueQueue("pr_patch_checker", handle, "").(queue.UniqueQueue)
+ prQueue = queue.CreateUniqueQueue("pr_patch_checker", handle, "")
if prQueue == nil {
return fmt.Errorf("Unable to create pr_patch_checker Queue")
diff --git a/services/repository/push.go b/services/repository/push.go
index 4d86667539..ab1b404609 100644
--- a/services/repository/push.go
+++ b/services/repository/push.go
@@ -5,6 +5,7 @@
package repository
import (
+ "errors"
"fmt"
"time"
@@ -36,9 +37,9 @@ func handle(data ...queue.Data) {
}
func initPushQueue() error {
- pushQueue = queue.CreateQueue("push_update", handle, []*repo_module.PushUpdateOptions{}).(queue.Queue)
+ pushQueue = queue.CreateQueue("push_update", handle, []*repo_module.PushUpdateOptions{})
if pushQueue == nil {
- return fmt.Errorf("Unable to create push_update Queue")
+ return errors.New("unable to create push_update Queue")
}
go graceful.GetManager().RunWithShutdownFns(pushQueue.Run)