-
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
doesn't match already declared in previous expression variable in new expression #339
Comments
This is probably because the first match stops the other rules from being applied. Maybe it should be fixed for stmtList and exprList nodes, I'm not sure yet. As a side note, patterns like that (from your referenced example) are quite fragile and should not be relied upon too much. ruleguard works best for the expression level and single statement level. It's also good enough for the |
As a side note, will this pattern be good enough in your case?
Without surrounding |
yes, i also thougth about this pattern after your comment, also i split rule into two unrelated groups, but problem still reproducable: delivery-club/delivery-club-rules@f77c82c |
This is probably a temporary and sub-optimal solution, but it should do for now. Since matches are much more rare than pattern misses, we do the check under the `matched` condition. Extra condition shouldn't make anything measurably slower there. Fixes #339
This is probably a temporary and sub-optimal solution, but it should do for now. Since matches are much more rare than pattern misses, we do the check under the `matched` condition. Extra condition shouldn't make anything measurably slower there. Fixes #339
rule doesn't match variable initialized through
:=
declaration in previous expressionrule: https://github.com/delivery-club/delivery-club-rules/blob/simplifyErrCheck/rules.go#L413
testdata: https://github.com/delivery-club/delivery-club-rules/blob/simplifyErrCheck/testdata/src/simplifyErrorCheck/a.go#L13
used ruleguard version 0.3.14
The text was updated successfully, but these errors were encountered: