Empty string test can be improved CRT-A0004
Anti-pattern
Major
3 days ago4 years old
replace len(cfgData) == 0 with cfgData == ""
129	if err != nil {
130		return err
131	}
132	if len(cfgData) == 0 {133		return nil
134	}
135	newCfg := &shuffleHotRegionSchedulerConfig{}
replace len(cfgData) == 0 with cfgData == ""
167	if err != nil {
168		return err
169	}
170	if len(cfgData) == 0 {171		return nil
172	}
173	newCfg := &grantHotRegionSchedulerConfig{}
replace len(cfgData) == 0 with cfgData == ""
 273	if err != nil {
 274		return err
 275	}
 276	if len(cfgData) == 0 { 277		return nil
 278	}
 279	newCfg := &hotRegionSchedulerConfig{}
replace len(s) == 0 with s == ""
80
81// StringToBytes converts string to slice of bytes without copy.
82func StringToBytes(s string) []byte {
83	if len(s) == 0 {84		return nil
85	}
86	return unsafe.Slice(unsafe.StringData(s), len(s))
replace len(*v) == 0 with *v == ""
121
122// AdjustString adjusts the value of a string variable.
123func AdjustString(v *string, defValue string) {
124	if len(*v) == 0 {125		*v = defValue
126	}
127}