checkOrphanDirectives returns an error for the first comment that matches re but whose source line was not consumed by a declaration.
(file *ast.File, fset *token.FileSet, re *regexp.Regexp, consumed map[int]bool, directiveLabel string)
| 36 | // checkOrphanDirectives returns an error for the first comment that matches re |
| 37 | // but whose source line was not consumed by a declaration. |
| 38 | func checkOrphanDirectives(file *ast.File, fset *token.FileSet, re *regexp.Regexp, consumed map[int]bool, directiveLabel string) error { |
| 39 | for _, group := range file.Comments { |
| 40 | for _, comment := range group.List { |
| 41 | if !re.MatchString(comment.Text) { |
| 42 | continue |
| 43 | } |
| 44 | line := fset.Position(comment.Pos()).Line |
| 45 | if !consumed[line] { |
| 46 | return fmt.Errorf("%s directive at line %d is not followed by a function declaration", directiveLabel, line) |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | return nil |
| 51 | } |
no outgoing calls
no test coverage detected