1
0
mirror of https://github.com/mgechev/revive.git synced 2024-11-24 08:32:22 +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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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
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{
Failure: "no nested structs are allowed",
Category: "style",
Node: v,
Node: s,
Confidence: 1,
})
break
}
return nil // no need to visit (again) the field
}
return l
}

View File

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