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: case in <- job:
default: default:
overflow = append(overflow, job) 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, Default: false,
}, { }, {
Name: "concurrency", 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 Note that setting this is very likely to cause deadlocks so it should
be used with care. be used with care.
@ -99,7 +99,7 @@ maximum of |--checkers| and |--transfers|.
So for |concurrency 3| you'd use |--checkers 2 --transfers 2 So for |concurrency 3| you'd use |--checkers 2 --transfers 2
--check-first| or |--checkers 1 --transfers 1|. --check-first| or |--checkers 1 --transfers 1|.
`, "|", "`", -1), `, "|", "`"),
Default: 0, Default: 0,
Advanced: true, Advanced: true,
}, { }, {

View file

@ -344,7 +344,7 @@ cost of using more memory.
Advanced: true, Advanced: true,
}, { }, {
Name: "connections", 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 Note that setting this is very likely to cause deadlocks so it should
be used with care. be used with care.
@ -358,7 +358,7 @@ maximum of |--checkers| and |--transfers|.
So for |connections 3| you'd use |--checkers 2 --transfers 2 So for |connections 3| you'd use |--checkers 2 --transfers 2
--check-first| or |--checkers 1 --transfers 1|. --check-first| or |--checkers 1 --transfers 1|.
`, "|", "`", -1), `, "|", "`"),
Default: 0, Default: 0,
Advanced: true, Advanced: true,
}, { }, {

View file

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

View file

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

View file

@ -23,7 +23,7 @@ import (
) )
// Help contains text describing how to use the proxy // 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 If you supply the parameter |--auth-proxy /path/to/program| then
rclone will use that program to generate backends on the fly which 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 This can be used to build general purpose proxies to any kind of
backend that rclone supports. backend that rclone supports.
`, "|", "`", -1) `, "|", "`")
// Options is options for creating the proxy // Options is options for creating the proxy
type Options struct { type Options struct {

View file

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

View file

@ -1807,7 +1807,7 @@ func copyURLFn(ctx context.Context, dstFileName string, url string, autoFilename
if autoFilename { if autoFilename {
if dstFileNameFromHeader { if dstFileNameFromHeader {
_, params, err := mime.ParseMediaType(resp.Header.Get("Content-Disposition")) _, 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 == "" { if err != nil || headerFilename == "" {
return fmt.Errorf("CopyURL failed: filename not found in the Content-Disposition header") 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:] arg = arg[2:]
key, val := arg, "true" var key, val string
if idx := strings.Index(arg, "="); idx != -1 { var ok bool
key, val = arg[:idx], arg[idx+1:] if key, val, ok = strings.Cut(arg, "="); !ok {
val = "true"
} }
name := "RCLONE_" + strings.ToUpper(strings.ReplaceAll(key, "-", "_")) name := "RCLONE_" + strings.ToUpper(strings.ReplaceAll(key, "-", "_"))