Skip to content

Commit 698c9eb

Browse files
feat: use ifstmt func in switchstmt case
1 parent 7e6178f commit 698c9eb

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

pkg/analyzer/analyzer.go

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -256,35 +256,22 @@ func run(pass *analysis.Pass) (interface{}, error) {
256256
}
257257

258258
for _, expr := range caseClause.List {
259-
binaryExpr, ok := expr.(*ast.BinaryExpr)
259+
e, ok := expr.(*ast.BinaryExpr)
260260
if !ok {
261261
continue
262262
}
263263

264-
selectorExpr, ok := binaryExpr.X.(*ast.SelectorExpr)
264+
x, ok := e.X.(*ast.SelectorExpr)
265265
if !ok {
266266
continue
267267
}
268268

269-
basicLit, ok := binaryExpr.Y.(*ast.BasicLit)
269+
y, ok := e.Y.(*ast.BasicLit)
270270
if !ok {
271271
continue
272272
}
273273

274-
switch selectorExpr.Sel.Name {
275-
case "StatusCode":
276-
if !lookupFlag(pass, HTTPStatusCodeFlag) {
277-
continue
278-
}
279-
280-
checkHTTPStatusCode(pass, basicLit)
281-
case "Method":
282-
if !lookupFlag(pass, HTTPMethodFlag) {
283-
continue
284-
}
285-
286-
checkHTTPMethod(pass, basicLit)
287-
}
274+
ifstmt(pass, x, y)
288275
}
289276
}
290277
}

0 commit comments

Comments
 (0)