build: fix gocritic lint issue wrapperfunc

This commit is contained in:
albertony 2024-05-31 15:25:27 +02:00 committed by Nick Craig-Wood
parent e82b5b11af
commit 33bff6fe71
9 changed files with 17 additions and 19 deletions

View File

@ -2219,7 +2219,7 @@ func (f *Fs) ListR(ctx context.Context, dir string, callback fs.ListRCallback) (
case in <- job:
default:
overflow = append(overflow, job)
wg.Add(-1)
wg.Done()
}
}

View File

@ -85,7 +85,7 @@ to an encrypted one. Cannot be used in combination with implicit FTPS.`,
Default: false,
}, {
Name: "concurrency",
Help: strings.Replace(`Maximum number of FTP simultaneous connections, 0 for unlimited.
Help: strings.ReplaceAll(`Maximum number of FTP simultaneous connections, 0 for unlimited.
Note that setting this is very likely to cause deadlocks so it should
be used with care.
@ -99,7 +99,7 @@ maximum of |--checkers| and |--transfers|.
So for |concurrency 3| you'd use |--checkers 2 --transfers 2
--check-first| or |--checkers 1 --transfers 1|.
`, "|", "`", -1),
`, "|", "`"),
Default: 0,
Advanced: true,
}, {

View File

@ -344,7 +344,7 @@ cost of using more memory.
Advanced: true,
}, {
Name: "connections",
Help: strings.Replace(`Maximum number of SFTP simultaneous connections, 0 for unlimited.
Help: strings.ReplaceAll(`Maximum number of SFTP simultaneous connections, 0 for unlimited.
Note that setting this is very likely to cause deadlocks so it should
be used with care.
@ -358,7 +358,7 @@ maximum of |--checkers| and |--transfers|.
So for |connections 3| you'd use |--checkers 2 --transfers 2
--check-first| or |--checkers 1 --transfers 1|.
`, "|", "`", -1),
`, "|", "`"),
Default: 0,
Advanced: true,
}, {

View File

@ -1742,8 +1742,8 @@ func (b *bisyncTest) newReplacer(mangle bool) *strings.Replacer {
b.path2, "{path2/}",
b.replaceHex(b.path1), "{path1/}",
b.replaceHex(b.path2), "{path2/}",
"//?/" + strings.TrimSuffix(strings.Replace(b.path1, slash, "/", -1), "/"), "{path1}", // fix windows-specific issue
"//?/" + strings.TrimSuffix(strings.Replace(b.path2, slash, "/", -1), "/"), "{path2}",
"//?/" + strings.TrimSuffix(strings.ReplaceAll(b.path1, slash, "/"), "/"), "{path1}", // fix windows-specific issue
"//?/" + strings.TrimSuffix(strings.ReplaceAll(b.path2, slash, "/"), "/"), "{path2}",
strings.TrimSuffix(b.path1, slash), "{path1}", // ensure it's still recognized without trailing slash
strings.TrimSuffix(b.path2, slash), "{path2}",
b.workDir, "{workdir}",

View File

@ -39,8 +39,8 @@ func (b *bisyncRun) indent(tag, file, msg string) {
tag = Color(terminal.BlueFg, tag)
}
msg = Color(terminal.MagentaFg, msg)
msg = strings.Replace(msg, "Queue copy to", Color(terminal.GreenFg, "Queue copy to"), -1)
msg = strings.Replace(msg, "Queue delete", Color(terminal.RedFg, "Queue delete"), -1)
msg = strings.ReplaceAll(msg, "Queue copy to", Color(terminal.GreenFg, "Queue copy to"))
msg = strings.ReplaceAll(msg, "Queue delete", Color(terminal.RedFg, "Queue delete"))
file = Color(terminal.CyanFg, escapePath(file, false))
logf(nil, "- %-18s%-43s - %s", tag, msg, file)
}

View File

@ -23,7 +23,7 @@ import (
)
// Help contains text describing how to use the proxy
var Help = strings.Replace(`### Auth Proxy
var Help = strings.ReplaceAll(`### Auth Proxy
If you supply the parameter |--auth-proxy /path/to/program| then
rclone will use that program to generate backends on the fly which
@ -104,7 +104,7 @@ before it takes effect.
This can be used to build general purpose proxies to any kind of
backend that rclone supports.
`, "|", "`", -1)
`, "|", "`")
// Options is options for creating the proxy
type Options struct {

View File

@ -100,10 +100,7 @@ func convertMountHelperArgs(origArgs []string) ([]string, error) {
continue
}
param, value := opt, ""
if idx := strings.Index(opt, "="); idx != -1 {
param, value = opt[:idx], opt[idx+1:]
}
param, value, _ := strings.Cut(opt, "=")
// Set environment variables
if strings.HasPrefix(param, "env.") {

View File

@ -1807,7 +1807,7 @@ func copyURLFn(ctx context.Context, dstFileName string, url string, autoFilename
if autoFilename {
if dstFileNameFromHeader {
_, params, err := mime.ParseMediaType(resp.Header.Get("Content-Disposition"))
headerFilename := path.Base(strings.Replace(params["filename"], "\\", "/", -1))
headerFilename := path.Base(strings.ReplaceAll(params["filename"], "\\", "/"))
if err != nil || headerFilename == "" {
return fmt.Errorf("CopyURL failed: filename not found in the Content-Disposition header")
}

View File

@ -87,9 +87,10 @@ func argsToEnv(origArgs, origEnv []string) (args, env []string) {
}
arg = arg[2:]
key, val := arg, "true"
if idx := strings.Index(arg, "="); idx != -1 {
key, val = arg[:idx], arg[idx+1:]
var key, val string
var ok bool
if key, val, ok = strings.Cut(arg, "="); !ok {
val = "true"
}
name := "RCLONE_" + strings.ToUpper(strings.ReplaceAll(key, "-", "_"))