btwiuse / k0s

Empty string test can be improved CRT-A0004
Anti-pattern
3 months ago3 years old
replace len(ansiCode) == 0 with ansiCode == ""
213	}
214
215	ansiCode = ansiCode[2 : len(ansiCode)-1]
216	if len(ansiCode) == 0 {217		init()
218	}
219	for _, code := range strings.Split(ansiCode, ";") {
replace len(key) == 0 with key == ""
53}
54
55func (cc *ChunkCache) Search(chunk *Chunk, key string) []Result {
56	if len(key) == 0 || !chunk.IsFull() {57		return nil
58	}
59
replace len(key) == 0 with key == ""
18
19// Add adds the list to the cache
20func (cc *ChunkCache) Add(chunk *Chunk, key string, list []Result) {
21	if len(key) == 0 || !chunk.IsFull() || len(list) > queryCacheMax {22		return
23	}
24
replace len(key) == 0 with key == ""
35
36// Lookup is called to lookup ChunkCache
37func (cc *ChunkCache) Lookup(chunk *Chunk, key string) []Result {
38	if len(key) == 0 || !chunk.IsFull() {39		return nil
40	}
41
replace len(line) == 0 with line == ""
53
54func (h *History) append(line string) error {
55	// We don't append empty lines
56	if len(line) == 0 {57		return nil
58	}
59