-
Notifications
You must be signed in to change notification settings - Fork 41
Open
Description
I have a usecase where I need to check if a Recover func is called in the defer statement in a go routine. I am currently doing this using this rule:
func checkGoStmtUsedInAnonymousFunc(m dsl.Matcher) {
m.Match(`go func(){$expr; $*_}()`).
Where(!(m["expr"].Node.Is(`DeferStmt`) && m["expr"].Contains("safeconc.Recover"))).
Report("anonymous function called in a go routine doesn't have a defer recover function as the first expression")
}
I am getting the safeconc.Recover func from a different package. Currently this rule is matching this func using text matching, I wanted to check if there is a better way to do that which uses the actual func in the package
Metadata
Metadata
Assignees
Labels
No labels