Empty string test can be improved CRT-A0004
Anti-pattern
Major
5 occurrences in this check
replace len(data) == 0 with data == ""
35	if err != nil {
36		return errors.WithStack(err)
37	}
38	if len(data) == 0 {39		*s = []string{}
40		return nil
41	}
replace len(cfg.PushAddress) == 0 with cfg.PushAddress == ""
 82
 83// Push metrics in background.
 84func Push(cfg *MetricConfig) {
 85	if cfg.PushInterval.Duration == zeroDuration || len(cfg.PushAddress) == 0 { 86		log.Info("disable Prometheus push client")
 87		return
 88	}
replace len(t) == 0 with t == ""
482// ParseTime parses a time string with the format "1694580288"
483// If the string is empty, it returns a zero time.
484func ParseTime(t string) (time.Time, error) {
485	if len(t) == 0 {486		return time.Time{}, nil
487	}
488	i, err := strconv.ParseInt(t, 10, 64)
replace len(pathPrefix) == 0 with pathPrefix == ""
384	if _, ok := registerMap[pathPrefix]; ok {
385		return errs.ErrServiceRegistered.FastGenByArgs(pathPrefix)
386	}
387	if len(pathPrefix) == 0 {388		return errs.ErrAPIInformationInvalid.FastGenByArgs(group.Name, group.Version)
389	}
390	registerMap[pathPrefix] = handler
replace len(componentName) == 0 with componentName == ""
144// GetComponentNameOnHTTP returns component name from Request Header
145func GetComponentNameOnHTTP(r *http.Request) string {
146	componentName := r.Header.Get(componentSignatureKey)
147	if len(componentName) == 0 {148		componentName = componentAnonymousValue
149	}
150	return componentName