testingTParamName returns the name of the *testing.T parameter, or "" if not found.
(fn *ast.FuncDecl)
| 132 | |
| 133 | // testingTParamName returns the name of the *testing.T parameter, or "" if not found. |
| 134 | func testingTParamName(fn *ast.FuncDecl) string { |
| 135 | if fn.Type.Params == nil || len(fn.Type.Params.List) == 0 { |
| 136 | return "" |
| 137 | } |
| 138 | for _, field := range fn.Type.Params.List { |
| 139 | starExpr, ok := field.Type.(*ast.StarExpr) |
| 140 | if !ok { |
| 141 | continue |
| 142 | } |
| 143 | selExpr, ok := starExpr.X.(*ast.SelectorExpr) |
| 144 | if !ok { |
| 145 | continue |
| 146 | } |
| 147 | pkg, ok := selExpr.X.(*ast.Ident) |
| 148 | if !ok { |
| 149 | continue |
| 150 | } |
| 151 | if pkg.Name == "testing" && selExpr.Sel.Name == "T" { |
| 152 | if len(field.Names) > 0 { |
| 153 | return field.Names[0].Name |
| 154 | } |
| 155 | } |
| 156 | } |
| 157 | return "" |
| 158 | } |
| 159 | |
| 160 | // hasNoLintComment checks for //parallelize:ignore in the function's doc comment. |
| 161 | func hasNoLintComment(fn *ast.FuncDecl) bool { |
no outgoing calls
no test coverage detected