Go

Go

Made by DeepSource

Found unnecessary guard around call to delete SCC-S1033

Anti-pattern
Major
Autofix

Calling delete on a nil map does not do anything (no-op), and it can be safely removed, or there is a potential bug introduced with a typo.

Bad practice

func fn(m map[int]int) {
    if _, ok := m[0]; ok {
        delete(m, 0)
    }
}

Recommended

func fn(m map[int]int) {
    delete(m, 0)
}

Using just delete is the more idiomatic recommended version.