all: Fix check for empty string (#8456)

Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
This commit is contained in:
deepsource-autofix[bot] 2022-07-28 16:51:03 +02:00 committed by GitHub
parent a2c5d901f2
commit 80ec4acb53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 13 additions and 13 deletions

View File

@ -90,7 +90,7 @@ func handleFailureFn(dsn, failureDir string) func(w http.ResponseWriter, req *ht
for k, v := range r.Extra {
pkt.Extra[k] = v
}
if len(r.Goroutines) != 0 {
if r.Goroutines != "" {
url, err := saveFailureWithGoroutines(r.FailureData, failureDir)
if err != nil {
log.Println("Saving failure report:", err)

View File

@ -647,7 +647,7 @@ func syncthingMain(options serveOptions) {
setupSignalHandling(app)
if len(os.Getenv("GOMAXPROCS")) == 0 {
if os.Getenv("GOMAXPROCS") == "" {
runtime.GOMAXPROCS(runtime.NumCPU())
}

View File

@ -16,7 +16,7 @@ import (
func ParseSize(s string) (Size, error) {
s = strings.TrimSpace(s)
if len(s) == 0 {
if s == "" {
return Size{}, nil
}

View File

@ -64,7 +64,7 @@ func NewLocal(id protocol.DeviceID, addr string, addrList AddressLister, evLogge
return nil, err
}
if len(host) == 0 {
if host == "" {
// A broadcast client
c.name = "IPv4 local"
bcPort, err := strconv.Atoi(port)

View File

@ -55,7 +55,7 @@ func WindowsInvalidFilename(name string) error {
// None of the path components should end in space or period, or be a
// reserved name.
for _, part := range strings.Split(name, `\`) {
if len(part) == 0 {
if part == "" {
continue
}
switch part[len(part)-1] {

View File

@ -737,7 +737,7 @@ func (f *sendReceiveFolder) handleSymlink(file protocol.FileInfo, snap *db.Snaps
l.Debugf("need symlink\n\t%v\n\t%v", file, curFile)
}
if len(file.SymlinkTarget) == 0 {
if file.SymlinkTarget == "" {
// Index entry from a Syncthing predating the support for including
// the link target in the index entry. We log this as an error.
f.newPullError(file.Name, errIncompatibleSymlink)

View File

@ -511,7 +511,7 @@ func (m *model) cleanupFolderLocked(cfg config.FolderConfiguration) {
}
func (m *model) restartFolder(from, to config.FolderConfiguration, cacheIgnoredFiles bool) error {
if len(to.ID) == 0 {
if to.ID == "" {
panic("bug: cannot restart empty folder ID")
}
if to.ID != from.ID {

View File

@ -547,7 +547,7 @@ func slashify(s string) string {
// deslashify removes slashes and encrypted file extensions from the string.
// This is the inverse of slashify().
func deslashify(s string) (string, error) {
if len(s) == 0 || !strings.HasPrefix(s[1:], encryptedDirExtension) {
if s == "" || !strings.HasPrefix(s[1:], encryptedDirExtension) {
return "", fmt.Errorf("invalid encrypted path: %q", s)
}
s = s[:1] + s[1+len(encryptedDirExtension):]
@ -575,7 +575,7 @@ func IsEncryptedParent(pathComponents []string) bool {
} else if l == 0 {
return false
}
if len(pathComponents[0]) == 0 {
if pathComponents[0] == "" {
return false
}
if pathComponents[0][1:] != encryptedDirExtension {

View File

@ -748,12 +748,12 @@ func TestStopWalk(t *testing.T) {
f := res.File
t.Log("Scanned", f)
if f.IsDirectory() {
if len(f.Name) == 0 || f.Permissions == 0 {
if f.Name == "" || f.Permissions == 0 {
t.Error("Bad directory entry", f)
}
dirs++
} else {
if len(f.Name) == 0 || len(f.Blocks) == 0 || f.Permissions == 0 {
if f.Name == "" || len(f.Blocks) == 0 || f.Permissions == 0 {
t.Error("Bad file entry", f)
}
files++

View File

@ -383,7 +383,7 @@ func getIGDServices(deviceUUID string, localIPAddress net.IP, rootURL string, de
l.Debugln(rootURL, "- no services of type", URN, " found on connection.")
for _, service := range services {
if len(service.ControlURL) == 0 {
if service.ControlURL == "" {
l.Infoln(rootURL+"- malformed", service.Type, "description: no control URL.")
} else {
u, _ := url.Parse(rootURL)

View File

@ -410,7 +410,7 @@ func clear(v interface{}, since int) error {
tag := t.Field(i).Tag
v := tag.Get("since")
if len(v) == 0 {
if v == "" {
f.Set(reflect.Zero(f.Type()))
continue
}