-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
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
Add a way to debug rules #98
Comments
quasilyte
added a commit
that referenced
this issue
Oct 30, 2020
When ruleguard is called with -debug-group=<string> arg, it'll print rejected matches explanations to the stderr for the specified rules group. By default, this argument is an empty string that means "no debug". Explanation includes: * Submatch nodes (with types) * Rejection reason (sometimes approx) * Rejected node location Here is an example of how explanations can look like: example.go:4: rejected ($s type filter) $s [10]int: a example2.go:9: rejected ($s2 is const) $s1 string: v1 $s2 string: "" example2.go:7: rejected ($s1 is not const) $s1 string: v1 $s2 string: v2 The debug output format is experimental and can change over time. Any feedback is appreciated. Refs #98 Signed-off-by: Iskander Sharipov <[email protected]>
quasilyte
added a commit
that referenced
this issue
Oct 30, 2020
When ruleguard is called with -debug-group=<string> arg, it'll print rejected matches explanations to the stderr for the specified rules group. By default, this argument is an empty string that means "no debug". Explanation includes: * Submatch nodes (with types) * Rejection reason (sometimes approx) * Rejected node location Here is an example of how explanations can look like: example.go:4: rejected ($s type filter) $s [10]int: a example2.go:9: rejected ($s2 is const) $s1 string: v1 $s2 string: "" example2.go:7: rejected ($s1 is not const) $s1 string: v1 $s2 string: v2 The debug output format is experimental and can change over time. Any feedback is appreciated. Refs #98 Signed-off-by: Iskander Sharipov <[email protected]>
quasilyte
added a commit
that referenced
this issue
Oct 30, 2020
When ruleguard is called with -debug-group=<string> arg, it'll print rejected matches explanations to the stderr for the specified rules group. By default, this argument is an empty string that means "no debug". Explanation includes: * Submatch nodes (with types) * Rejection reason (sometimes approx) * Rejected node location Here is an example of how explanations can look like: example.go:4: rejected ($s type filter) $s [10]int: a example2.go:9: rejected ($s2 is const) $s1 string: v1 $s2 string: "" example2.go:7: rejected ($s1 is not const) $s1 string: v1 $s2 string: v2 The debug output format is experimental and can change over time. Any feedback is appreciated. Refs #98 Signed-off-by: Iskander Sharipov <[email protected]>
quasilyte
added a commit
that referenced
this issue
Oct 30, 2020
When ruleguard is called with -debug-group=<string> arg, it'll print rejected matches explanations to the stderr for the specified rules group. By default, this argument is an empty string that means "no debug". Explanation includes: * Submatch nodes (with types) * Rejection reason (sometimes approx) * Rejected node location Here is an example of how explanations can look like: example.go:4: rejected ($s type filter) $s [10]int: a example2.go:9: rejected ($s2 is const) $s1 string: v1 $s2 string: "" example2.go:7: rejected ($s1 is not const) $s1 string: v1 $s2 string: v2 The debug output format is experimental and can change over time. Any feedback is appreciated. This change also adds Line:int and Group:string fields to the rules info. Line is a rules file line that declared this rule Group is a containing function name Refs #98 Signed-off-by: Iskander Sharipov <[email protected]>
quasilyte
added a commit
that referenced
this issue
Oct 30, 2020
When ruleguard is called with -debug-group=<string> arg, it'll print rejected matches explanations to the stderr for the specified rules group. By default, this argument is an empty string that means "no debug". Explanation includes: * Submatch nodes (with types) * Rejection reason (sometimes approx) * Rejected node location Here is an example of how explanations can look like: example.go:4: rejected by rules.go:6 ($s type filter) $s [10]int: a example2.go:9: rejected rules2.go:8 ($s2 is const) $s1 string: v1 $s2 string: "" example2.go:7: rejected rules2.go:8 ($s1 is not const) $s1 string: v1 $s2 string: v2 The debug output format is experimental and can change over time. Any feedback is appreciated. This change also adds Line:int and Group:string fields to the rules info. Line is a rules file line that declared this rule Group is a containing function name Refs #98 Signed-off-by: Iskander Sharipov <[email protected]>
quasilyte
added a commit
that referenced
this issue
Oct 30, 2020
When ruleguard is called with -debug-group=<string> arg, it'll print rejected matches explanations to the stderr for the specified rules group. By default, this argument is an empty string that means "no debug". Explanation includes: * Submatch nodes (with types) * Rejection reason (sometimes approx) * Rejected node location Here is an example of how explanations can look like: example.go:4: rejected by rules.go:6 ($s type filter) $s [10]int: a example2.go:9: rejected rules2.go:8 ($s2 is const) $s1 string: v1 $s2 string: "" example2.go:7: rejected rules2.go:8 ($s1 is not const) $s1 string: v1 $s2 string: v2 The debug output format is experimental and can change over time. Any feedback is appreciated. This change also adds Line:int and Group:string fields to the rules info. Line is a rules file line that declared this rule Group is a containing function name Refs #98 Signed-off-by: Iskander Sharipov <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's especially important to have a mechanism to debug how the rule is being executed, what types submatches have, etc.
Suppose we have a rule file like this:
And a test Go file like this:
Debug output could look like:
The text was updated successfully, but these errors were encountered: