1 package stylecheck // import "honnef.co/go/tools/stylecheck"
15 "honnef.co/go/tools/code"
16 "honnef.co/go/tools/config"
17 "honnef.co/go/tools/edit"
18 "honnef.co/go/tools/internal/passes/buildir"
19 "honnef.co/go/tools/ir"
20 . "honnef.co/go/tools/lint/lintdsl"
21 "honnef.co/go/tools/pattern"
22 "honnef.co/go/tools/report"
24 "golang.org/x/tools/go/analysis"
25 "golang.org/x/tools/go/analysis/passes/inspect"
26 "golang.org/x/tools/go/ast/inspector"
27 "golang.org/x/tools/go/types/typeutil"
30 func CheckPackageComment(pass *analysis.Pass) (interface{}, error) {
31 // - At least one file in a non-main package should have a package comment
33 // - The comment should be of the form
34 // "Package x ...". This has a slight potential for false
35 // positives, as multiple files can have package comments, in
36 // which case they get appended. But that doesn't happen a lot in
39 if pass.Pkg.Name() == "main" {
43 for _, f := range pass.Files {
44 if code.IsInTest(pass, f) {
47 if f.Doc != nil && len(f.Doc.List) > 0 {
49 prefix := "Package " + f.Name.Name + " "
50 if !strings.HasPrefix(strings.TrimSpace(f.Doc.Text()), prefix) {
51 report.Report(pass, f.Doc, fmt.Sprintf(`package comment should be of the form "%s..."`, prefix))
58 for _, f := range pass.Files {
59 if code.IsInTest(pass, f) {
62 report.Report(pass, f, "at least one file in a package should have a package comment", report.ShortRange())
68 func CheckDotImports(pass *analysis.Pass) (interface{}, error) {
69 for _, f := range pass.Files {
71 for _, imp := range f.Imports {
72 path := imp.Path.Value
73 path = path[1 : len(path)-1]
74 for _, w := range config.For(pass).DotImportWhitelist {
80 if imp.Name != nil && imp.Name.Name == "." && !code.IsInTest(pass, f) {
81 report.Report(pass, imp, "should not use dot imports", report.FilterGenerated())
88 func CheckDuplicatedImports(pass *analysis.Pass) (interface{}, error) {
89 for _, f := range pass.Files {
90 // Collect all imports by their import path
91 imports := make(map[string][]*ast.ImportSpec, len(f.Imports))
92 for _, imp := range f.Imports {
93 imports[imp.Path.Value] = append(imports[imp.Path.Value], imp)
96 for path, value := range imports {
97 if path[1:len(path)-1] == "unsafe" {
98 // Don't flag unsafe. Cgo generated code imports
99 // unsafe using the blank identifier, and most
100 // user-written cgo code also imports unsafe
104 // If there's more than one import per path, we flag that
106 s := fmt.Sprintf("package %s is being imported more than once", path)
107 opts := []report.Option{report.FilterGenerated()}
108 for _, imp := range value[1:] {
109 opts = append(opts, report.Related(imp, fmt.Sprintf("other import of %s", path)))
111 report.Report(pass, value[0], s, opts...)
118 func CheckBlankImports(pass *analysis.Pass) (interface{}, error) {
120 for _, f := range pass.Files {
121 if code.IsMainLike(pass) || code.IsInTest(pass, f) {
125 // Collect imports of the form `import _ "foo"`, i.e. with no
126 // parentheses, as their comment will be associated with the
127 // (paren-free) GenDecl, not the import spec itself.
129 // We don't directly process the GenDecl so that we can
130 // correctly handle the following:
135 // where only the first import should get flagged.
136 skip := map[ast.Spec]bool{}
137 ast.Inspect(f, func(node ast.Node) bool {
138 switch node := node.(type) {
142 if node.Tok != token.IMPORT {
145 if node.Lparen == token.NoPos && node.Doc != nil {
146 skip[node.Specs[0]] = true
152 for i, imp := range f.Imports {
153 pos := fset.Position(imp.Pos())
155 if !code.IsBlank(imp.Name) {
158 // Only flag the first blank import in a group of imports,
159 // or don't flag any of them, if the first one is
162 prev := f.Imports[i-1]
163 prevPos := fset.Position(prev.Pos())
164 if pos.Line-1 == prevPos.Line && code.IsBlank(prev.Name) {
169 if imp.Doc == nil && imp.Comment == nil && !skip[imp] {
170 report.Report(pass, imp, "a blank import should be only in a main or test package, or have a comment justifying it")
177 func CheckIncDec(pass *analysis.Pass) (interface{}, error) {
178 // TODO(dh): this can be noisy for function bodies that look like this:
184 fn := func(node ast.Node) {
185 assign := node.(*ast.AssignStmt)
186 if assign.Tok != token.ADD_ASSIGN && assign.Tok != token.SUB_ASSIGN {
189 if (len(assign.Lhs) != 1 || len(assign.Rhs) != 1) ||
190 !code.IsIntLiteral(assign.Rhs[0], "1") {
196 case token.ADD_ASSIGN:
198 case token.SUB_ASSIGN:
202 report.Report(pass, assign, fmt.Sprintf("should replace %s with %s%s", report.Render(pass, assign), report.Render(pass, assign.Lhs[0]), suffix))
204 code.Preorder(pass, fn, (*ast.AssignStmt)(nil))
208 func CheckErrorReturn(pass *analysis.Pass) (interface{}, error) {
210 for _, fn := range pass.ResultOf[buildir.Analyzer].(*buildir.IR).SrcFuncs {
211 sig := fn.Type().(*types.Signature)
212 rets := sig.Results()
213 if rets == nil || rets.Len() < 2 {
217 if rets.At(rets.Len()-1).Type() == types.Universe.Lookup("error").Type() {
218 // Last return type is error. If the function also returns
219 // errors in other positions, that's fine.
222 for i := rets.Len() - 2; i >= 0; i-- {
223 if rets.At(i).Type() == types.Universe.Lookup("error").Type() {
224 report.Report(pass, rets.At(i), "error should be returned as the last argument", report.ShortRange())
232 // CheckUnexportedReturn checks that exported functions on exported
233 // types do not return unexported types.
234 func CheckUnexportedReturn(pass *analysis.Pass) (interface{}, error) {
235 for _, fn := range pass.ResultOf[buildir.Analyzer].(*buildir.IR).SrcFuncs {
236 if fn.Synthetic != "" || fn.Parent() != nil {
239 if !ast.IsExported(fn.Name()) || code.IsMain(pass) || code.IsInTest(pass, fn) {
242 sig := fn.Type().(*types.Signature)
243 if sig.Recv() != nil && !ast.IsExported(code.Dereference(sig.Recv().Type()).(*types.Named).Obj().Name()) {
247 for i := 0; i < res.Len(); i++ {
248 if named, ok := code.DereferenceR(res.At(i).Type()).(*types.Named); ok &&
249 !ast.IsExported(named.Obj().Name()) &&
250 named != types.Universe.Lookup("error").Type() {
251 report.Report(pass, fn, "should not return unexported type")
258 func CheckReceiverNames(pass *analysis.Pass) (interface{}, error) {
259 irpkg := pass.ResultOf[buildir.Analyzer].(*buildir.IR).Pkg
260 for _, m := range irpkg.Members {
261 if T, ok := m.Object().(*types.TypeName); ok && !T.IsAlias() {
262 ms := typeutil.IntuitiveMethodSet(T.Type(), nil)
263 for _, sel := range ms {
264 fn := sel.Obj().(*types.Func)
265 recv := fn.Type().(*types.Signature).Recv()
266 if code.Dereference(recv.Type()) != T.Type() {
267 // skip embedded methods
270 if recv.Name() == "self" || recv.Name() == "this" {
271 report.Report(pass, recv, `receiver name should be a reflection of its identity; don't use generic names such as "this" or "self"`, report.FilterGenerated())
273 if recv.Name() == "_" {
274 report.Report(pass, recv, "receiver name should not be an underscore, omit the name if it is unused", report.FilterGenerated())
282 func CheckReceiverNamesIdentical(pass *analysis.Pass) (interface{}, error) {
283 irpkg := pass.ResultOf[buildir.Analyzer].(*buildir.IR).Pkg
284 for _, m := range irpkg.Members {
285 names := map[string]int{}
287 var firstFn *types.Func
288 if T, ok := m.Object().(*types.TypeName); ok && !T.IsAlias() {
289 ms := typeutil.IntuitiveMethodSet(T.Type(), nil)
290 for _, sel := range ms {
291 fn := sel.Obj().(*types.Func)
292 recv := fn.Type().(*types.Signature).Recv()
293 if code.IsGenerated(pass, recv.Pos()) {
294 // Don't concern ourselves with methods in generated code
297 if code.Dereference(recv.Type()) != T.Type() {
298 // skip embedded methods
304 if recv.Name() != "" && recv.Name() != "_" {
312 for name, count := range names {
313 seen = append(seen, fmt.Sprintf("%dx %q", count, name))
317 report.Report(pass, firstFn, fmt.Sprintf("methods on the same type should have the same receiver name (seen %s)", strings.Join(seen, ", ")))
323 func CheckContextFirstArg(pass *analysis.Pass) (interface{}, error) {
324 // TODO(dh): this check doesn't apply to test helpers. Example from the stdlib:
325 // func helperCommandContext(t *testing.T, ctx context.Context, s ...string) (cmd *exec.Cmd) {
327 for _, fn := range pass.ResultOf[buildir.Analyzer].(*buildir.IR).SrcFuncs {
328 if fn.Synthetic != "" || fn.Parent() != nil {
331 params := fn.Signature.Params()
332 if params.Len() < 2 {
335 if types.TypeString(params.At(0).Type(), nil) == "context.Context" {
338 for i := 1; i < params.Len(); i++ {
339 param := params.At(i)
340 if types.TypeString(param.Type(), nil) == "context.Context" {
341 report.Report(pass, param, "context.Context should be the first argument of a function", report.ShortRange())
349 func CheckErrorStrings(pass *analysis.Pass) (interface{}, error) {
350 objNames := map[*ir.Package]map[string]bool{}
351 irpkg := pass.ResultOf[buildir.Analyzer].(*buildir.IR).Pkg
352 objNames[irpkg] = map[string]bool{}
353 for _, m := range irpkg.Members {
354 if typ, ok := m.(*ir.Type); ok {
355 objNames[irpkg][typ.Name()] = true
358 for _, fn := range pass.ResultOf[buildir.Analyzer].(*buildir.IR).SrcFuncs {
359 objNames[fn.Package()][fn.Name()] = true
362 for _, fn := range pass.ResultOf[buildir.Analyzer].(*buildir.IR).SrcFuncs {
363 if code.IsInTest(pass, fn) {
364 // We don't care about malformed error messages in tests;
365 // they're usually for direct human consumption, not part
369 for _, block := range fn.Blocks {
371 for _, ins := range block.Instrs {
372 call, ok := ins.(*ir.Call)
376 if !code.IsCallToAny(call.Common(), "errors.New", "fmt.Errorf") {
380 k, ok := call.Common().Args[0].(*ir.Const)
385 s := constant.StringVal(k.Value)
390 case '.', ':', '!', '\n':
391 report.Report(pass, call, "error strings should not end with punctuation or a newline")
393 idx := strings.IndexByte(s, ' ')
395 // single word error message, probably not a real
396 // error but something used in tests or during
401 first, n := utf8.DecodeRuneInString(word)
402 if !unicode.IsUpper(first) {
405 for _, c := range word[n:] {
406 if unicode.IsUpper(c) {
407 // Word is probably an initialism or
408 // multi-word function name
413 word = strings.TrimRightFunc(word, func(r rune) bool { return unicode.IsPunct(r) })
414 if objNames[fn.Package()][word] {
415 // Word is probably the name of a function or type in this package
418 // First word in error starts with a capital
419 // letter, and the word doesn't contain any other
420 // capitals, making it unlikely to be an
421 // initialism or multi-word function name.
423 // It could still be a proper noun, though.
425 report.Report(pass, call, "error strings should not be capitalized")
432 func CheckTimeNames(pass *analysis.Pass) (interface{}, error) {
433 suffixes := []string{
434 "Sec", "Secs", "Seconds",
436 "Milli", "Millis", "Milliseconds",
437 "Usec", "Usecs", "Microseconds",
440 fn := func(names []*ast.Ident) {
441 for _, name := range names {
442 if _, ok := pass.TypesInfo.Defs[name]; !ok {
445 T := pass.TypesInfo.TypeOf(name)
446 if !code.IsType(T, "time.Duration") && !code.IsType(T, "*time.Duration") {
449 for _, suffix := range suffixes {
450 if strings.HasSuffix(name.Name, suffix) {
451 report.Report(pass, name, fmt.Sprintf("var %s is of type %v; don't use unit-specific suffix %q", name.Name, T, suffix))
458 fn2 := func(node ast.Node) {
459 switch node := node.(type) {
463 for _, field := range node.List {
466 case *ast.AssignStmt:
467 if node.Tok != token.DEFINE {
470 var names []*ast.Ident
471 for _, lhs := range node.Lhs {
472 if lhs, ok := lhs.(*ast.Ident); ok {
473 names = append(names, lhs)
480 code.Preorder(pass, fn2, (*ast.ValueSpec)(nil), (*ast.FieldList)(nil), (*ast.AssignStmt)(nil))
484 func CheckErrorVarNames(pass *analysis.Pass) (interface{}, error) {
485 for _, f := range pass.Files {
486 for _, decl := range f.Decls {
487 gen, ok := decl.(*ast.GenDecl)
488 if !ok || gen.Tok != token.VAR {
491 for _, spec := range gen.Specs {
492 spec := spec.(*ast.ValueSpec)
493 if len(spec.Names) != len(spec.Values) {
497 for i, name := range spec.Names {
498 val := spec.Values[i]
499 if !code.IsCallToAnyAST(pass, val, "errors.New", "fmt.Errorf") {
503 if pass.Pkg.Path() == "net/http" && strings.HasPrefix(name.Name, "http2err") {
504 // special case for internal variable names of
505 // bundled HTTP 2 code in net/http
509 if name.IsExported() {
512 if !strings.HasPrefix(name.Name, prefix) {
513 report.Report(pass, name, fmt.Sprintf("error var %s should have name of the form %sFoo", name.Name, prefix))
522 var httpStatusCodes = map[int]string{
523 100: "StatusContinue",
524 101: "StatusSwitchingProtocols",
525 102: "StatusProcessing",
527 201: "StatusCreated",
528 202: "StatusAccepted",
529 203: "StatusNonAuthoritativeInfo",
530 204: "StatusNoContent",
531 205: "StatusResetContent",
532 206: "StatusPartialContent",
533 207: "StatusMultiStatus",
534 208: "StatusAlreadyReported",
536 300: "StatusMultipleChoices",
537 301: "StatusMovedPermanently",
539 303: "StatusSeeOther",
540 304: "StatusNotModified",
541 305: "StatusUseProxy",
542 307: "StatusTemporaryRedirect",
543 308: "StatusPermanentRedirect",
544 400: "StatusBadRequest",
545 401: "StatusUnauthorized",
546 402: "StatusPaymentRequired",
547 403: "StatusForbidden",
548 404: "StatusNotFound",
549 405: "StatusMethodNotAllowed",
550 406: "StatusNotAcceptable",
551 407: "StatusProxyAuthRequired",
552 408: "StatusRequestTimeout",
553 409: "StatusConflict",
555 411: "StatusLengthRequired",
556 412: "StatusPreconditionFailed",
557 413: "StatusRequestEntityTooLarge",
558 414: "StatusRequestURITooLong",
559 415: "StatusUnsupportedMediaType",
560 416: "StatusRequestedRangeNotSatisfiable",
561 417: "StatusExpectationFailed",
563 422: "StatusUnprocessableEntity",
565 424: "StatusFailedDependency",
566 426: "StatusUpgradeRequired",
567 428: "StatusPreconditionRequired",
568 429: "StatusTooManyRequests",
569 431: "StatusRequestHeaderFieldsTooLarge",
570 451: "StatusUnavailableForLegalReasons",
571 500: "StatusInternalServerError",
572 501: "StatusNotImplemented",
573 502: "StatusBadGateway",
574 503: "StatusServiceUnavailable",
575 504: "StatusGatewayTimeout",
576 505: "StatusHTTPVersionNotSupported",
577 506: "StatusVariantAlsoNegotiates",
578 507: "StatusInsufficientStorage",
579 508: "StatusLoopDetected",
580 510: "StatusNotExtended",
581 511: "StatusNetworkAuthenticationRequired",
584 func CheckHTTPStatusCodes(pass *analysis.Pass) (interface{}, error) {
585 whitelist := map[string]bool{}
586 for _, code := range config.For(pass).HTTPStatusCodeWhitelist {
587 whitelist[code] = true
589 fn := func(node ast.Node) {
590 call := node.(*ast.CallExpr)
593 switch code.CallNameAST(pass, call) {
594 case "net/http.Error":
596 case "net/http.Redirect":
598 case "net/http.StatusText":
600 case "net/http.RedirectHandler":
605 lit, ok := call.Args[arg].(*ast.BasicLit)
609 if whitelist[lit.Value] {
613 n, err := strconv.Atoi(lit.Value)
617 s, ok := httpStatusCodes[n]
621 report.Report(pass, lit, fmt.Sprintf("should use constant http.%s instead of numeric literal %d", s, n),
622 report.FilterGenerated(),
623 report.Fixes(edit.Fix(fmt.Sprintf("use http.%s instead of %d", s, n), edit.ReplaceWithString(pass.Fset, lit, "http."+s))))
625 code.Preorder(pass, fn, (*ast.CallExpr)(nil))
629 func CheckDefaultCaseOrder(pass *analysis.Pass) (interface{}, error) {
630 fn := func(node ast.Node) {
631 stmt := node.(*ast.SwitchStmt)
632 list := stmt.Body.List
633 for i, c := range list {
634 if c.(*ast.CaseClause).List == nil && i != 0 && i != len(list)-1 {
635 report.Report(pass, c, "default case should be first or last in switch statement", report.FilterGenerated())
640 code.Preorder(pass, fn, (*ast.SwitchStmt)(nil))
645 checkYodaConditionsQ = pattern.MustParse(`(BinaryExpr left@(BasicLit _ _) tok@(Or "==" "!=") right@(Not (BasicLit _ _)))`)
646 checkYodaConditionsR = pattern.MustParse(`(BinaryExpr right tok left)`)
649 func CheckYodaConditions(pass *analysis.Pass) (interface{}, error) {
650 fn := func(node ast.Node) {
651 if _, edits, ok := MatchAndEdit(pass, checkYodaConditionsQ, checkYodaConditionsR, node); ok {
652 report.Report(pass, node, "don't use Yoda conditions",
653 report.FilterGenerated(),
654 report.Fixes(edit.Fix("un-Yoda-fy", edits...)))
657 code.Preorder(pass, fn, (*ast.BinaryExpr)(nil))
661 func CheckInvisibleCharacters(pass *analysis.Pass) (interface{}, error) {
662 fn := func(node ast.Node) {
663 lit := node.(*ast.BasicLit)
664 if lit.Kind != token.STRING {
668 type invalid struct {
672 var invalids []invalid
675 for off, r := range lit.Value {
676 if unicode.Is(unicode.Cf, r) {
677 invalids = append(invalids, invalid{r, off})
679 } else if unicode.Is(unicode.Cc, r) && r != '\n' && r != '\t' && r != '\r' {
680 invalids = append(invalids, invalid{r, off})
685 switch len(invalids) {
692 } else if hasControl {
699 msg := fmt.Sprintf("string literal contains the Unicode %s character %U, consider using the %q escape sequence instead", kind, r.r, r.r)
701 replacement := strconv.QuoteRune(r.r)
702 replacement = replacement[1 : len(replacement)-1]
703 edit := analysis.SuggestedFix{
704 Message: fmt.Sprintf("replace %s character %U with %q", kind, r.r, r.r),
705 TextEdits: []analysis.TextEdit{{
706 Pos: lit.Pos() + token.Pos(r.off),
707 End: lit.Pos() + token.Pos(r.off) + token.Pos(utf8.RuneLen(r.r)),
708 NewText: []byte(replacement),
711 delete := analysis.SuggestedFix{
712 Message: fmt.Sprintf("delete %s character %U", kind, r),
713 TextEdits: []analysis.TextEdit{{
714 Pos: lit.Pos() + token.Pos(r.off),
715 End: lit.Pos() + token.Pos(r.off) + token.Pos(utf8.RuneLen(r.r)),
718 report.Report(pass, lit, msg, report.Fixes(edit, delete))
721 if hasFormat && hasControl {
722 kind = "format and control"
723 } else if hasFormat {
725 } else if hasControl {
731 msg := fmt.Sprintf("string literal contains Unicode %s characters, consider using escape sequences instead", kind)
732 var edits []analysis.TextEdit
733 var deletions []analysis.TextEdit
734 for _, r := range invalids {
735 replacement := strconv.QuoteRune(r.r)
736 replacement = replacement[1 : len(replacement)-1]
737 edits = append(edits, analysis.TextEdit{
738 Pos: lit.Pos() + token.Pos(r.off),
739 End: lit.Pos() + token.Pos(r.off) + token.Pos(utf8.RuneLen(r.r)),
740 NewText: []byte(replacement),
742 deletions = append(deletions, analysis.TextEdit{
743 Pos: lit.Pos() + token.Pos(r.off),
744 End: lit.Pos() + token.Pos(r.off) + token.Pos(utf8.RuneLen(r.r)),
747 edit := analysis.SuggestedFix{
748 Message: fmt.Sprintf("replace all %s characters with escape sequences", kind),
751 delete := analysis.SuggestedFix{
752 Message: fmt.Sprintf("delete all %s characters", kind),
753 TextEdits: deletions,
755 report.Report(pass, lit, msg, report.Fixes(edit, delete))
758 code.Preorder(pass, fn, (*ast.BasicLit)(nil))
762 func CheckExportedFunctionDocs(pass *analysis.Pass) (interface{}, error) {
763 fn := func(node ast.Node) {
764 if code.IsInTest(pass, node) {
768 decl := node.(*ast.FuncDecl)
772 if !ast.IsExported(decl.Name.Name) {
776 if decl.Recv != nil {
778 switch T := decl.Recv.List[0].Type.(type) {
780 if !ast.IsExported(T.X.(*ast.Ident).Name) {
784 if !ast.IsExported(T.Name) {
788 ExhaustiveTypeSwitch(T)
791 prefix := decl.Name.Name + " "
792 if !strings.HasPrefix(decl.Doc.Text(), prefix) {
793 report.Report(pass, decl.Doc, fmt.Sprintf(`comment on exported %s %s should be of the form "%s..."`, kind, decl.Name.Name, prefix), report.FilterGenerated())
797 code.Preorder(pass, fn, (*ast.FuncDecl)(nil))
801 func CheckExportedTypeDocs(pass *analysis.Pass) (interface{}, error) {
802 var genDecl *ast.GenDecl
803 fn := func(node ast.Node, push bool) bool {
808 if code.IsInTest(pass, node) {
812 switch node := node.(type) {
814 if node.Tok == token.IMPORT {
820 if !ast.IsExported(node.Name.Name) {
826 if len(genDecl.Specs) != 1 {
827 // more than one spec in the GenDecl, don't validate the
831 if genDecl.Lparen.IsValid() {
832 // 'type ( T )' is weird, don't guess the user's intention
842 articles := [...]string{"A", "An", "The"}
843 for _, a := range articles {
844 if strings.HasPrefix(s, a+" ") {
849 if !strings.HasPrefix(s, node.Name.Name+" ") {
850 report.Report(pass, doc, fmt.Sprintf(`comment on exported type %s should be of the form "%s ..." (with optional leading article)`, node.Name.Name, node.Name.Name), report.FilterGenerated())
853 case *ast.FuncLit, *ast.FuncDecl:
856 ExhaustiveTypeSwitch(node)
861 pass.ResultOf[inspect.Analyzer].(*inspector.Inspector).Nodes([]ast.Node{(*ast.GenDecl)(nil), (*ast.TypeSpec)(nil), (*ast.FuncLit)(nil), (*ast.FuncDecl)(nil)}, fn)
865 func CheckExportedVarDocs(pass *analysis.Pass) (interface{}, error) {
866 var genDecl *ast.GenDecl
867 fn := func(node ast.Node, push bool) bool {
872 if code.IsInTest(pass, node) {
876 switch node := node.(type) {
878 if node.Tok == token.IMPORT {
884 if genDecl.Lparen.IsValid() || len(node.Names) > 1 {
885 // Don't try to guess the user's intention
888 name := node.Names[0].Name
889 if !ast.IsExported(name) {
892 if genDecl.Doc == nil {
896 if !strings.HasPrefix(genDecl.Doc.Text(), prefix) {
898 if genDecl.Tok == token.CONST {
901 report.Report(pass, genDecl.Doc, fmt.Sprintf(`comment on exported %s %s should be of the form "%s..."`, kind, name, prefix), report.FilterGenerated())
904 case *ast.FuncLit, *ast.FuncDecl:
907 ExhaustiveTypeSwitch(node)
912 pass.ResultOf[inspect.Analyzer].(*inspector.Inspector).Nodes([]ast.Node{(*ast.GenDecl)(nil), (*ast.ValueSpec)(nil), (*ast.FuncLit)(nil), (*ast.FuncDecl)(nil)}, fn)