Skip to content

Commit ca11e3e

Browse files
committed
review: remove a switch
1 parent e102282 commit ca11e3e

File tree

1 file changed

+22
-23
lines changed
  • pkg/commands/internal/migrate/cloner

1 file changed

+22
-23
lines changed

Diff for: pkg/commands/internal/migrate/cloner/cloner.go

+22-23
Original file line numberDiff line numberDiff line change
@@ -85,34 +85,33 @@ func processFile(file *ast.File) {
8585

8686
var newDecls []ast.Decl
8787
for _, decl := range file.Decls {
88-
switch d := decl.(type) {
89-
case *ast.FuncDecl:
88+
d, ok := decl.(*ast.GenDecl)
89+
if !ok {
9090
continue
91+
}
9192

92-
case *ast.GenDecl:
93-
switch d.Tok {
94-
case token.CONST, token.VAR:
95-
continue
96-
case token.TYPE:
97-
for _, spec := range d.Specs {
98-
typeSpec, ok := spec.(*ast.TypeSpec)
99-
if !ok {
100-
continue
101-
}
102-
103-
structType, ok := typeSpec.Type.(*ast.StructType)
104-
if !ok {
105-
continue
106-
}
107-
108-
processStructFields(structType)
93+
switch d.Tok {
94+
case token.CONST, token.VAR:
95+
continue
96+
case token.TYPE:
97+
for _, spec := range d.Specs {
98+
typeSpec, ok := spec.(*ast.TypeSpec)
99+
if !ok {
100+
continue
109101
}
110-
default:
111-
// noop
112-
}
113102

114-
newDecls = append(newDecls, decl)
103+
structType, ok := typeSpec.Type.(*ast.StructType)
104+
if !ok {
105+
continue
106+
}
107+
108+
processStructFields(structType)
109+
}
110+
default:
111+
// noop
115112
}
113+
114+
newDecls = append(newDecls, decl)
116115
}
117116

118117
file.Decls = newDecls

0 commit comments

Comments
 (0)