Skip to content

Commit 4a57c9e

Browse files
authored
Fix some lints (#17337)
Fix some linting problems.
1 parent 5326f4c commit 4a57c9e

File tree

8 files changed

+14
-15
lines changed

8 files changed

+14
-15
lines changed

modules/git/submodule.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ func getRefURL(refURL, urlPrefix, repoFullName, sshDomain string) string {
5252
urlPrefixHostname = prefixURL.Host
5353
}
5454

55-
if strings.HasSuffix(urlPrefix, "/") {
56-
urlPrefix = urlPrefix[:len(urlPrefix)-1]
57-
}
55+
urlPrefix = strings.TrimSuffix(urlPrefix, "/")
5856

5957
// FIXME: Need to consider branch - which will require changes in modules/git/commit.go:GetSubModules
6058
// Relative url prefix check (according to git submodule documentation)

modules/gitgraph/graph_models.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ func newRefsFromRefNames(refNames []byte) []git.Reference {
220220
refName := string(refNameBytes)
221221
if strings.HasPrefix(refName, "tag: ") {
222222
refName = strings.TrimPrefix(refName, "tag: ")
223-
} else if strings.HasPrefix(refName, "HEAD -> ") {
223+
} else {
224224
refName = strings.TrimPrefix(refName, "HEAD -> ")
225225
}
226226
refs = append(refs, git.Reference{

modules/graceful/restart_unix.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ func RestartProcess() (int, error) {
5555
unixListener.SetUnlinkOnClose(false)
5656
}
5757
// Remember to close these at the end.
58-
defer files[i].Close()
58+
defer func(i int) {
59+
_ = files[i].Close()
60+
}(i)
5961
}
6062

6163
// Use the original binary location. This works with symlinks such that if

modules/indexer/stats/queue.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func handle(data ...queue.Data) {
2727
}
2828

2929
func initStatsQueue() error {
30-
statsQueue = queue.CreateUniqueQueue("repo_stats_update", handle, int64(0)).(queue.UniqueQueue)
30+
statsQueue = queue.CreateUniqueQueue("repo_stats_update", handle, int64(0))
3131
if statsQueue == nil {
3232
return fmt.Errorf("Unable to create repo_stats_update Queue")
3333
}

modules/lfs/endpoint.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ func endpointFromCloneURL(rawurl string) *url.URL {
2929
return ep
3030
}
3131

32-
if strings.HasSuffix(ep.Path, "/") {
33-
ep.Path = ep.Path[:len(ep.Path)-1]
34-
}
32+
ep.Path = strings.TrimSuffix(ep.Path, "/")
3533

3634
if ep.Scheme == "file" {
3735
return ep

modules/markup/common/footnote.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ type Footnote struct {
125125
// Dump implements Node.Dump.
126126
func (n *Footnote) Dump(source []byte, level int) {
127127
m := map[string]string{}
128-
m["Index"] = fmt.Sprintf("%v", n.Index)
129-
m["Ref"] = fmt.Sprintf("%s", n.Ref)
130-
m["Name"] = fmt.Sprintf("%v", n.Name)
128+
m["Index"] = strconv.Itoa(n.Index)
129+
m["Ref"] = string(n.Ref)
130+
m["Name"] = string(n.Name)
131131
ast.DumpHelper(n, source, level, m, nil)
132132
}
133133

services/pull/check.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ func CheckPrsForBaseBranch(baseRepo *models.Repository, baseBranchName string) e
253253

254254
// Init runs the task queue to test all the checking status pull requests
255255
func Init() error {
256-
prQueue = queue.CreateUniqueQueue("pr_patch_checker", handle, "").(queue.UniqueQueue)
256+
prQueue = queue.CreateUniqueQueue("pr_patch_checker", handle, "")
257257

258258
if prQueue == nil {
259259
return fmt.Errorf("Unable to create pr_patch_checker Queue")

services/repository/push.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package repository
66

77
import (
8+
"errors"
89
"fmt"
910
"time"
1011

@@ -36,9 +37,9 @@ func handle(data ...queue.Data) {
3637
}
3738

3839
func initPushQueue() error {
39-
pushQueue = queue.CreateQueue("push_update", handle, []*repo_module.PushUpdateOptions{}).(queue.Queue)
40+
pushQueue = queue.CreateQueue("push_update", handle, []*repo_module.PushUpdateOptions{})
4041
if pushQueue == nil {
41-
return fmt.Errorf("Unable to create push_update Queue")
42+
return errors.New("unable to create push_update Queue")
4243
}
4344

4445
go graceful.GetManager().RunWithShutdownFns(pushQueue.Run)

0 commit comments

Comments
 (0)