Empty string test can be improved CRT-A0004
Anti-pattern
Major
13 occurrences in this check
replace len(addr) == 0 with addr == ""
105
106func WithVectorizerTargets(addr string) Option {
107	return func(s *server) {
108		if len(addr) == 0 {109			return
110		}
111		s.Vectorizer = addr
replace len(name) != 0 with name != ""
 57// WithName returns the option to set the name for server.
 58func WithName(name string) Option {
 59	return func(s *server) {
 60		if len(name) != 0 { 61			s.name = name
 62		}
 63	}
replace len(ip) != 0 with ip != ""
 48// WithIP returns the option to set the IP for server.
 49func WithIP(ip string) Option {
 50	return func(s *server) {
 51		if len(ip) != 0 { 52			s.ip = ip
 53		}
 54	}
replace len(s.Vectorizer) == 0 with s.Vectorizer == ""
1128	}
1129	target := fmt.Sprintf("%s:%d", vr.GetHost(), vr.GetPort())
1130	if len(target) == 0 {
1131		if len(s.Vectorizer) == 0 {1132			err := errors.ErrFilterNotFound
1133			err = status.WrapWithInvalidArgument(vald.UpsertObjectRPCName+" API vectorizer configuration is invalid", err,
1134				&errdetails.RequestInfo{
replace len(target) == 0 with target == ""
1127		vr.Host = "localhost"
1128	}
1129	target := fmt.Sprintf("%s:%d", vr.GetHost(), vr.GetPort())
1130	if len(target) == 0 {1131		if len(s.Vectorizer) == 0 {
1132			err := errors.ErrFilterNotFound
1133			err = status.WrapWithInvalidArgument(vald.UpsertObjectRPCName+" API vectorizer configuration is invalid", err,
replace len(s.Vectorizer) == 0 with s.Vectorizer == ""
 876
 877	target := fmt.Sprintf("%s:%d", vr.GetHost(), vr.GetPort())
 878	if len(target) == 0 {
 879		if len(s.Vectorizer) == 0 { 880			err := errors.ErrFilterNotFound
 881			err = status.WrapWithInvalidArgument(vald.UpdateObjectRPCName+" API vectorizer configuration is invalid", err,
 882				&errdetails.RequestInfo{
replace len(target) == 0 with target == ""
 875	}
 876
 877	target := fmt.Sprintf("%s:%d", vr.GetHost(), vr.GetPort())
 878	if len(target) == 0 { 879		if len(s.Vectorizer) == 0 {
 880			err := errors.ErrFilterNotFound
 881			err = status.WrapWithInvalidArgument(vald.UpdateObjectRPCName+" API vectorizer configuration is invalid", err,
replace len(s.Vectorizer) == 0 with s.Vectorizer == ""
 622	}
 623	target := fmt.Sprintf("%s:%d", vr.GetHost(), vr.GetPort())
 624	if len(target) == 0 {
 625		if len(s.Vectorizer) == 0 { 626			err := errors.ErrFilterNotFound
 627			err = status.WrapWithInvalidArgument(vald.InsertObjectRPCName+" API vectorizer configuration is invalid", err,
 628				&errdetails.RequestInfo{
replace len(target) == 0 with target == ""
 621		vr.Host = "localhost"
 622	}
 623	target := fmt.Sprintf("%s:%d", vr.GetHost(), vr.GetPort())
 624	if len(target) == 0 { 625		if len(s.Vectorizer) == 0 {
 626			err := errors.ErrFilterNotFound
 627			err = status.WrapWithInvalidArgument(vald.InsertObjectRPCName+" API vectorizer configuration is invalid", err,
replace len(s.Vectorizer) == 0 with s.Vectorizer == ""
 366	}
 367	target := fmt.Sprintf("%s:%d", vr.GetHost(), vr.GetPort())
 368	if len(target) == 0 {
 369		if len(s.Vectorizer) == 0 { 370			err := errors.ErrFilterNotFound
 371			err = status.WrapWithInvalidArgument(vald.LinearSearchObjectRPCName+" API vectorizer configuration is invalid", err,
 372				&errdetails.RequestInfo{
replace len(target) == 0 with target == ""
 365		vr.Host = "localhost"
 366	}
 367	target := fmt.Sprintf("%s:%d", vr.GetHost(), vr.GetPort())
 368	if len(target) == 0 { 369		if len(s.Vectorizer) == 0 {
 370			err := errors.ErrFilterNotFound
 371			err = status.WrapWithInvalidArgument(vald.LinearSearchObjectRPCName+" API vectorizer configuration is invalid", err,
replace len(s.Vectorizer) == 0 with s.Vectorizer == ""
 115	}
 116	target := fmt.Sprintf("%s:%d", vr.GetHost(), vr.GetPort())
 117	if len(target) == 0 {
 118		if len(s.Vectorizer) == 0 { 119			err := errors.ErrFilterNotFound
 120			err = status.WrapWithInvalidArgument(vald.SearchObjectRPCName+" API vectorizer configuration is invalid", err,
 121				&errdetails.RequestInfo{
replace len(target) == 0 with target == ""
 114		vr.Host = "localhost"
 115	}
 116	target := fmt.Sprintf("%s:%d", vr.GetHost(), vr.GetPort())
 117	if len(target) == 0 { 118		if len(s.Vectorizer) == 0 {
 119			err := errors.ErrFilterNotFound
 120			err = status.WrapWithInvalidArgument(vald.SearchObjectRPCName+" API vectorizer configuration is invalid", err,