Skip to content
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

Merged

Conversation

Sushisource
Copy link
Member

Allows //workflowcheck:ignore to work on workflow function registration sites

@Sushisource Sushisource requested a review from a team as a code owner June 10, 2023 00:08
@@ -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]
Copy link
Member

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.

@Sushisource Sushisource enabled auto-merge (squash) June 12, 2023 16:27
@Sushisource Sushisource merged commit 11c2cb9 into temporalio:master Jun 12, 2023
5 checks passed
@Sushisource Sushisource deleted the workflowcheck-ignore-fn-refs branch June 12, 2023 16:45
Comment on lines +161 to +167
_, isIgnored := ignoreMap[n]
for k := range ignoreMap {
asExprStmt, _ := k.(*ast.ExprStmt)
if asExprStmt != nil && asExprStmt.X == n {
isIgnored = true
}
}
Copy link
Member

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:

Suggested change
_, 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
}

Copy link
Member Author

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

Copy link
Member

@cretz cretz Jun 13, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants