Go

Go

Made by DeepSource

Function call can be replaced with helper function CRT-A0010

Anti-pattern
Major
Autofix

Certain functions, for a particular set of arguments, have shorthands (helpers) that can be used instead.

We currently support Autofix for, Format: x => y where "x" is recommended to be replaced with "y" helper function.

Supported Autofix for the following: strings.SplitN(s, ".", -1) => strings.Split(s, ".") strings.Map(unicode.ToTitle, s) => strings.ToTitle(s) strings.Replace(s, "a", "b", -1) => strings.ReplaceAll(s, "a", "b") bytes.SplitN(b, []byte("."), -1) => bytes.Split(b, []byte(".")) bytes.Map(unicode.ToUpper, b) => bytes.ToUpper(b) bytes.Map(unicode.ToLower, b) => bytes.ToLower(b) bytes.Map(unicode.ToTitle, b) => bytes.ToTitle(b) bytes.Replace(b, b, b, -1) => bytes.ReplaceAll(b, b, b) http.HandlerFunc(http.NotFound) => http.NotFoundHandler() draw.DrawMask(i, r, i, p, nil, image.Point{}, o) => draw.Draw(i, r, i, p, o)

Bad practice

wg.Add(1)
// some code
wg.Add(-1)

Recommended

wg.Add(1)
// some code
wg.Done()

Bad practice

strings.SplitN(str, splitChar, -1)

Recommended

strings.Split(str, splitChar)

Bad practice

http.HandlerFunc("/non-existent", http404)

Recommended

http.NotFoundHandler("/non-existent")