We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
To reproduce
func BadRule(m dsl.Matcher) { m.Match("fmt.$method($arg, $*args)").Suggest("log.$method($arg, $args)") }
package gorules import ( "github.com/quasilyte/go-ruleguard/dsl" ) func ZapPreferNoWith(m dsl.Matcher) { m.Import("go.uber.org/zap") m.Match("$l.With($arg, $*args).$method($*msg_args)").Where( m["l"].Type.Is("*zap.Logger") && m["method"].Text.Matches("Debug|Info|Warn|Error|DPanic|Panic|Fatal"), ).Suggest("$l.$method($msg_args, $arg, $args)") }
panic: runtime error: index out of range [0] with length 0 goroutine 3525 [running]: github.com/quasilyte/go-ruleguard/internal/mvdan.cc/gogrep.exprList.Pos(...) C:/Users/tdakkota/go/pkg/mod/github.com/quasilyte/go-ruleguard@v0.3.1-0.20210125091851-f953b71a3ba3/internal/mvdan.cc/gogrep/match.go:1098 github.com/quasilyte/go-ruleguard/ruleguard.(*rulesRunner).nodeText(0xc010f1ab00, 0x509720, 0xc010d87ea0, 0x5, 0x34, 0xc00b7a8990) C:/Users/tdakkota/go/pkg/mod/github.com/quasilyte/go-ruleguard@v0.3.1-0.20210125091851-f953b71a3ba3/ruleguard/runner.go:57 +0x65 github.com/quasilyte/go-ruleguard/ruleguard.(*rulesRunner).renderMessage(0xc010f1ab00, 0xc0006836b0, 0x2e, 0x5083a0, 0xc00b7afd00, 0xc010f2cea0, 0xc010f1ab01, 0x508c60, 0x387888) C:/Users/tdakkota/go/pkg/mod/github.com/quasilyte/go-ruleguard@v0.3.1-0.20210125091851-f953b71a3ba3/ruleguard/runner.go:232 +0x472 github.com/quasilyte/go-ruleguard/ruleguard.(*rulesRunner).handleMatch(0xc010f1ab00, 0xc00b399f80, 0xf, 0xc0000a0160, 0x12, 0x14, 0xc010d87e20, 0xc0006836b0, 0x2e, 0x0, ...) C:/Users/tdakkota/go/pkg/mod/github.com/quasilyte/go-ruleguard@v0.3.1-0.20210125091851-f953b71a3ba3/ruleguard/runner.go:174 +0xf4 github.com/quasilyte/go-ruleguard/ruleguard.(*rulesRunner).run.func2.1(0x5083a0, 0xc00b7afd00, 0xc010f2cea0) C:/Users/tdakkota/go/pkg/mod/github.com/quasilyte/go-ruleguard@v0.3.1-0.20210125091851-f953b71a3ba3/ruleguard/runner.go:107 +0xe8 github.com/quasilyte/go-ruleguard/internal/mvdan.cc/gogrep.(*Pattern).MatchNode(0xc010d87e20, 0x5083a0, 0xc00b7afd00, 0xc00b7a8d78) C:/Users/tdakkota/go/pkg/mod/github.com/quasilyte/go-ruleguard@v0.3.1-0.20210125091851-f953b71a3ba3/internal/mvdan.cc/gogrep/kludge.go:50 +0xbb github.com/quasilyte/go-ruleguard/ruleguard.(*rulesRunner).run.func2(0x5083a0, 0xc00b7afd00, 0x508801) C:/Users/tdakkota/go/pkg/mod/github.com/quasilyte/go-ruleguard@v0.3.1-0.20210125091851-f953b71a3ba3/ruleguard/runner.go:106 +0x19f go/ast.inspector.Visit(0xc010de2c40, 0x5083a0, 0xc00b7afd00, 0x5069c0, 0xc010de2c40) c:/go/src/go/ast/walk.go:373 +0x42
The text was updated successfully, but these errors were encountered:
It's simple to fix a panic, but a proper solution would require some changes to the gogrep. I'll see what I can do.
Sorry, something went wrong.
gogrep: add more capture tests
c5cda3a
TODO refs #192
gogrep: add more capture tests (#200)
f65190a
gogrep: save and restore wildcard positions during backtracking
a4a9265
Fixes #192
gogrep: save and restore wildcard positions during backtracking (#211)
2e26303
quasilyte
Successfully merging a pull request may close this issue.
To reproduce
Original rule for zap
Partial stacktrace
The text was updated successfully, but these errors were encountered: