mirror of
https://github.com/go-gitea/gitea
synced 2025-07-08 03:27:19 +00:00
enable staticcheck QFxxxx rules (#34064)
This commit is contained in:
@ -62,13 +62,14 @@ func GrepSearch(ctx context.Context, repo *Repository, search string, opts GrepO
|
||||
var results []*GrepResult
|
||||
cmd := NewCommand("grep", "--null", "--break", "--heading", "--line-number", "--full-name")
|
||||
cmd.AddOptionValues("--context", fmt.Sprint(opts.ContextLineNumber))
|
||||
if opts.GrepMode == GrepModeExact {
|
||||
switch opts.GrepMode {
|
||||
case GrepModeExact:
|
||||
cmd.AddArguments("--fixed-strings")
|
||||
cmd.AddOptionValues("-e", strings.TrimLeft(search, "-"))
|
||||
} else if opts.GrepMode == GrepModeRegexp {
|
||||
case GrepModeRegexp:
|
||||
cmd.AddArguments("--perl-regexp")
|
||||
cmd.AddOptionValues("-e", strings.TrimLeft(search, "-"))
|
||||
} else /* words */ {
|
||||
default: /* words */
|
||||
words := strings.Fields(search)
|
||||
cmd.AddArguments("--fixed-strings", "--ignore-case")
|
||||
for i, word := range words {
|
||||
|
@ -118,11 +118,12 @@ func (g *LogNameStatusRepoParser) Next(treepath string, paths2ids map[string]int
|
||||
g.buffull = false
|
||||
g.next, err = g.rd.ReadSlice('\x00')
|
||||
if err != nil {
|
||||
if err == bufio.ErrBufferFull {
|
||||
switch err {
|
||||
case bufio.ErrBufferFull:
|
||||
g.buffull = true
|
||||
} else if err == io.EOF {
|
||||
case io.EOF:
|
||||
return nil, nil
|
||||
} else {
|
||||
default:
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
@ -132,11 +133,12 @@ func (g *LogNameStatusRepoParser) Next(treepath string, paths2ids map[string]int
|
||||
if bytes.Equal(g.next, []byte("commit\000")) {
|
||||
g.next, err = g.rd.ReadSlice('\x00')
|
||||
if err != nil {
|
||||
if err == bufio.ErrBufferFull {
|
||||
switch err {
|
||||
case bufio.ErrBufferFull:
|
||||
g.buffull = true
|
||||
} else if err == io.EOF {
|
||||
case io.EOF:
|
||||
return nil, nil
|
||||
} else {
|
||||
default:
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
@ -214,11 +216,12 @@ diffloop:
|
||||
}
|
||||
g.next, err = g.rd.ReadSlice('\x00')
|
||||
if err != nil {
|
||||
if err == bufio.ErrBufferFull {
|
||||
switch err {
|
||||
case bufio.ErrBufferFull:
|
||||
g.buffull = true
|
||||
} else if err == io.EOF {
|
||||
case io.EOF:
|
||||
return &ret, nil
|
||||
} else {
|
||||
default:
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
@ -19,11 +19,12 @@ func (repo *Repository) GetRefs() ([]*Reference, error) {
|
||||
// refType should only be a literal "branch" or "tag" and nothing else
|
||||
func (repo *Repository) ListOccurrences(ctx context.Context, refType, commitSHA string) ([]string, error) {
|
||||
cmd := NewCommand()
|
||||
if refType == "branch" {
|
||||
switch refType {
|
||||
case "branch":
|
||||
cmd.AddArguments("branch")
|
||||
} else if refType == "tag" {
|
||||
case "tag":
|
||||
cmd.AddArguments("tag")
|
||||
} else {
|
||||
default:
|
||||
return nil, util.NewInvalidArgumentErrorf(`can only use "branch" or "tag" for refType, but got %q`, refType)
|
||||
}
|
||||
stdout, _, err := cmd.AddArguments("--no-color", "--sort=-creatordate", "--contains").AddDynamicArguments(commitSHA).RunStdString(ctx, &RunOpts{Dir: repo.Path})
|
||||
|
@ -133,12 +133,13 @@ func ParseRepositoryURL(ctx context.Context, repoURL string) (*RepositoryURL, er
|
||||
}
|
||||
}
|
||||
|
||||
if parsed.URL.Scheme == "http" || parsed.URL.Scheme == "https" {
|
||||
switch parsed.URL.Scheme {
|
||||
case "http", "https":
|
||||
if !httplib.IsCurrentGiteaSiteURL(ctx, repoURL) {
|
||||
return ret, nil
|
||||
}
|
||||
fillPathParts(strings.TrimPrefix(parsed.URL.Path, setting.AppSubURL))
|
||||
} else if parsed.URL.Scheme == "ssh" || parsed.URL.Scheme == "git+ssh" {
|
||||
case "ssh", "git+ssh":
|
||||
domainSSH := setting.SSH.Domain
|
||||
domainCur := httplib.GuessCurrentHostDomain(ctx)
|
||||
urlDomain, _, _ := net.SplitHostPort(parsed.URL.Host)
|
||||
@ -166,9 +167,10 @@ func MakeRepositoryWebLink(repoURL *RepositoryURL) string {
|
||||
// now, let's guess, for example:
|
||||
// * git@github.com:owner/submodule.git
|
||||
// * https://github.com/example/submodule1.git
|
||||
if repoURL.GitURL.Scheme == "http" || repoURL.GitURL.Scheme == "https" {
|
||||
switch repoURL.GitURL.Scheme {
|
||||
case "http", "https":
|
||||
return strings.TrimSuffix(repoURL.GitURL.String(), ".git")
|
||||
} else if repoURL.GitURL.Scheme == "ssh" || repoURL.GitURL.Scheme == "git+ssh" {
|
||||
case "ssh", "git+ssh":
|
||||
hostname, _, _ := net.SplitHostPort(repoURL.GitURL.Host)
|
||||
hostname = util.IfZero(hostname, repoURL.GitURL.Host)
|
||||
urlPath := strings.TrimSuffix(repoURL.GitURL.Path, ".git")
|
||||
|
Reference in New Issue
Block a user