golangci-lint/test/ruleguard/rangeExprCopy.go
Anton Telyshev c65868c105
gocritic: support of enable-all and disable-all options (#4335)
Co-authored-by: Ludovic Fernandez <ldez@users.noreply.github.com>
2024-02-19 14:50:25 +01:00

16 lines
339 B
Go

//go:build ruleguard
package ruleguard
import (
"github.com/quasilyte/go-ruleguard/dsl"
)
func rangeExprCopy(m dsl.Matcher) {
m.Match(`for _, $_ := range $x { $*_ }`, `for _, $_ = range $x { $*_ }`).
Where(m["x"].Addressable && m["x"].Type.Size >= 512).
Report(`$x copy can be avoided with &$x`).
At(m["x"]).
Suggest(`&$x`)
}