Skip to content

Fix some lints #17337

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions modules/git/submodule.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion modules/gitgraph/graph_models.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
4 changes: 3 additions & 1 deletion modules/graceful/restart_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion modules/indexer/stats/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
4 changes: 1 addition & 3 deletions modules/lfs/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions modules/markup/common/footnote.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion services/pull/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
5 changes: 3 additions & 2 deletions services/repository/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package repository

import (
"errors"
"fmt"
"time"

Expand Down Expand Up @@ -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)
Expand Down