Fix some lints (#17337)

Fix some linting problems.
This commit is contained in:
Lunny Xiao 2021-10-18 03:47:12 +08:00 committed by GitHub
parent 5326f4c9c5
commit 4a57c9ea17
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 14 additions and 15 deletions

View file

@ -52,9 +52,7 @@ func getRefURL(refURL, urlPrefix, repoFullName, sshDomain string) string {
urlPrefixHostname = prefixURL.Host urlPrefixHostname = prefixURL.Host
} }
if strings.HasSuffix(urlPrefix, "/") { urlPrefix = strings.TrimSuffix(urlPrefix, "/")
urlPrefix = urlPrefix[:len(urlPrefix)-1]
}
// FIXME: Need to consider branch - which will require changes in modules/git/commit.go:GetSubModules // FIXME: Need to consider branch - which will require changes in modules/git/commit.go:GetSubModules
// Relative url prefix check (according to git submodule documentation) // Relative url prefix check (according to git submodule documentation)

View file

@ -220,7 +220,7 @@ func newRefsFromRefNames(refNames []byte) []git.Reference {
refName := string(refNameBytes) refName := string(refNameBytes)
if strings.HasPrefix(refName, "tag: ") { if strings.HasPrefix(refName, "tag: ") {
refName = strings.TrimPrefix(refName, "tag: ") refName = strings.TrimPrefix(refName, "tag: ")
} else if strings.HasPrefix(refName, "HEAD -> ") { } else {
refName = strings.TrimPrefix(refName, "HEAD -> ") refName = strings.TrimPrefix(refName, "HEAD -> ")
} }
refs = append(refs, git.Reference{ refs = append(refs, git.Reference{

View file

@ -55,7 +55,9 @@ func RestartProcess() (int, error) {
unixListener.SetUnlinkOnClose(false) unixListener.SetUnlinkOnClose(false)
} }
// Remember to close these at the end. // 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 // Use the original binary location. This works with symlinks such that if

View file

@ -27,7 +27,7 @@ func handle(data ...queue.Data) {
} }
func initStatsQueue() error { 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 { if statsQueue == nil {
return fmt.Errorf("Unable to create repo_stats_update Queue") return fmt.Errorf("Unable to create repo_stats_update Queue")
} }

View file

@ -29,9 +29,7 @@ func endpointFromCloneURL(rawurl string) *url.URL {
return ep return ep
} }
if strings.HasSuffix(ep.Path, "/") { ep.Path = strings.TrimSuffix(ep.Path, "/")
ep.Path = ep.Path[:len(ep.Path)-1]
}
if ep.Scheme == "file" { if ep.Scheme == "file" {
return ep return ep

View file

@ -125,9 +125,9 @@ type Footnote struct {
// Dump implements Node.Dump. // Dump implements Node.Dump.
func (n *Footnote) Dump(source []byte, level int) { func (n *Footnote) Dump(source []byte, level int) {
m := map[string]string{} m := map[string]string{}
m["Index"] = fmt.Sprintf("%v", n.Index) m["Index"] = strconv.Itoa(n.Index)
m["Ref"] = fmt.Sprintf("%s", n.Ref) m["Ref"] = string(n.Ref)
m["Name"] = fmt.Sprintf("%v", n.Name) m["Name"] = string(n.Name)
ast.DumpHelper(n, source, level, m, nil) ast.DumpHelper(n, source, level, m, nil)
} }

View file

@ -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 // Init runs the task queue to test all the checking status pull requests
func Init() error { func Init() error {
prQueue = queue.CreateUniqueQueue("pr_patch_checker", handle, "").(queue.UniqueQueue) prQueue = queue.CreateUniqueQueue("pr_patch_checker", handle, "")
if prQueue == nil { if prQueue == nil {
return fmt.Errorf("Unable to create pr_patch_checker Queue") return fmt.Errorf("Unable to create pr_patch_checker Queue")

View file

@ -5,6 +5,7 @@
package repository package repository
import ( import (
"errors"
"fmt" "fmt"
"time" "time"
@ -36,9 +37,9 @@ func handle(data ...queue.Data) {
} }
func initPushQueue() error { 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 { 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) go graceful.GetManager().RunWithShutdownFns(pushQueue.Run)