1
0
mirror of https://github.com/mgechev/revive.git synced 2025-07-15 01:04:40 +02:00

fix issue 664 (#665)

This commit is contained in:
chavacava
2022-03-31 17:40:26 +02:00
committed by GitHub
parent 639d12bb4f
commit b6c86a274f
2 changed files with 18 additions and 3 deletions

View File

@ -47,15 +47,25 @@ func (l *lintNestedStructs) Visit(n ast.Node) ast.Visitor {
} }
return nil return nil
case *ast.Field: case *ast.Field:
if _, ok := v.Type.(*ast.StructType); ok { filter := func(n ast.Node) bool {
switch n.(type) {
case *ast.StructType:
return true
default:
return false
}
}
structs := pick(v, filter, nil)
for _, s := range structs {
l.onFailure(lint.Failure{ l.onFailure(lint.Failure{
Failure: "no nested structs are allowed", Failure: "no nested structs are allowed",
Category: "style", Category: "style",
Node: v, Node: s,
Confidence: 1, Confidence: 1,
}) })
break
} }
return nil // no need to visit (again) the field
} }
return l return l
} }

View File

@ -30,3 +30,8 @@ func fred() interface{} {
return s return s
} }
// issue 664
type Bad struct {
Field []struct{} // MATCH /no nested structs are allowed/
}