-
Notifications
You must be signed in to change notification settings - Fork 204
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
Allow ignoring function ref issues #1135
Allow ignoring function ref issues #1135
Conversation
@@ -176,7 +180,17 @@ func (c *Checker) Run(pass *analysis.Pass) error { | |||
} | |||
// Report if couldn't get type | |||
if fn == nil { | |||
pass.Reportf(callExpr.Args[0].Pos(), "unrecognized function reference format") | |||
_, isIgnored := ignoreMap[n] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a better impl is to change if callExpr == nil {
above to if callExpr == nil || isIgnored {
. You are ignoring RegisterWorkflow
call so check it early.
_, isIgnored := ignoreMap[n] | ||
for k := range ignoreMap { | ||
asExprStmt, _ := k.(*ast.ExprStmt) | ||
if asExprStmt != nil && asExprStmt.X == n { | ||
isIgnored = true | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In retrospect, you could have just:
_, isIgnored := ignoreMap[n] | |
for k := range ignoreMap { | |
asExprStmt, _ := k.(*ast.ExprStmt) | |
if asExprStmt != nil && asExprStmt.X == n { | |
isIgnored = true | |
} | |
} | |
if _, isIgnored := ignoreMap[n]; isIgnored { | |
return false | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That didn't seem to work when I was trying it - I needed to get this inner node for things to work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it was because we were returning true
which means "still traverse children" instead of false
which means "stop here". Bonus of the stop-here approach is you can workflowcheck-ignore an entire function.
Allows
//workflowcheck:ignore
to work on workflow function registration sites