You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// go:build ruleguard
package ruleguard
import "github.com/quasilyte/go-ruleguard/dsl"
func StringsSimplify(m dsl.Matcher) {
// Some issues have simple fixes that can be expressed as
// a replacement pattern. Rules can use Suggest() function
// to add a quickfix action for such issues.
m.Match(`strings.Replace($s, $old, $new, -1)`).
Report(`this Replace call can be simplified`).
Suggest(`strings.ReplaceAll($s, $old, $new)`)
}
Workaround
Execute the following command. This installs the required dependency in the go cache. go get github.com/quasilyte/go-ruleguard/dsl
Additional Information
It turns out that two days prior to installing golangci-lint, I cleaned up the go cache by running go clean -modcache. This had the effect of removing github.com/quasilyte/go-ruleguard/dsl from the cache. The same problem would probably occur when doing a fresh installation of golangci-lint, because the ruleguard dependency would not be installed.
I'm not sure if this is a regression.
Proposed changes
Should gocritic automatically execute go get github.com/quasilyte/go-ruleguard/dsl? It does not seem right that the user has to manually install ruleguard. Also, the error is quite obscure, it's not obvious what needs to be done to workaround the problem.
The text was updated successfully, but these errors were encountered:
Symptom
When running ruleguard from golangci-lint, ruleguard is unable to import the
github.com/quasilyte/go-ruleguard/dsl
package. An error is returned.Steps to reproduce
golangci-lint -c golangci-lint.yaml run
with gocritic/ruleguard enabled.Environment
golangci.yaml config:
${configDir}/gorules/myrule.go:
Workaround
Execute the following command. This installs the required dependency in the go cache.
go get github.com/quasilyte/go-ruleguard/dsl
Additional Information
It turns out that two days prior to installing golangci-lint, I cleaned up the go cache by running
go clean -modcache
. This had the effect of removinggithub.com/quasilyte/go-ruleguard/dsl
from the cache. The same problem would probably occur when doing a fresh installation ofgolangci-lint
, because the ruleguard dependency would not be installed.I'm not sure if this is a regression.
Proposed changes
Should gocritic automatically execute
go get github.com/quasilyte/go-ruleguard/dsl
? It does not seem right that the user has to manually install ruleguard. Also, the error is quite obscure, it's not obvious what needs to be done to workaround the problem.The text was updated successfully, but these errors were encountered: