Skip to content

Commit 41ad014

Browse files
feat: add examples in pkgFunArgs function
1 parent fdf62cc commit 41ad014

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pkg/analyzer/analyzer.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ func pkgFunArgs(pass *analysis.Pass, pkg *ast.Ident, fun *ast.SelectorExpr, args
219219
switch pkg.Name {
220220
case "http":
221221
switch fun.Sel.Name {
222+
// http.NewRequest(http.MethodGet, "localhost", http.NoBody)
222223
case "NewRequest":
223224
if !lookupFlag(pass, HTTPMethodFlag) {
224225
return
@@ -228,6 +229,7 @@ func pkgFunArgs(pass *analysis.Pass, pkg *ast.Ident, fun *ast.SelectorExpr, args
228229
checkHTTPMethod(pass, basicLit)
229230
}
230231

232+
// http.NewRequestWithContext(context.Background(), http.MethodGet, "localhost", http.NoBody)
231233
case "NewRequestWithContext":
232234
if !lookupFlag(pass, HTTPMethodFlag) {
233235
return
@@ -237,6 +239,7 @@ func pkgFunArgs(pass *analysis.Pass, pkg *ast.Ident, fun *ast.SelectorExpr, args
237239
checkHTTPMethod(pass, basicLit)
238240
}
239241

242+
// http.Error(w, err, http.StatusInternalServerError)
240243
case "Error":
241244
if !lookupFlag(pass, HTTPStatusCodeFlag) {
242245
return
@@ -246,6 +249,7 @@ func pkgFunArgs(pass *analysis.Pass, pkg *ast.Ident, fun *ast.SelectorExpr, args
246249
checkHTTPStatusCode(pass, basicLit)
247250
}
248251

252+
// http.StatusText(http.StatusOK)
249253
case "StatusText":
250254
if !lookupFlag(pass, HTTPStatusCodeFlag) {
251255
return
@@ -255,6 +259,7 @@ func pkgFunArgs(pass *analysis.Pass, pkg *ast.Ident, fun *ast.SelectorExpr, args
255259
checkHTTPStatusCode(pass, basicLit)
256260
}
257261

262+
// http.Redirect(w, r, "localhost", http.StatusMovedPermanently)
258263
case "Redirect":
259264
if !lookupFlag(pass, HTTPStatusCodeFlag) {
260265
return
@@ -264,6 +269,7 @@ func pkgFunArgs(pass *analysis.Pass, pkg *ast.Ident, fun *ast.SelectorExpr, args
264269
checkHTTPStatusCode(pass, basicLit)
265270
}
266271

272+
// http.RedirectHandler("localhost", http.StatusMovedPermanently)
267273
case "RedirectHandler":
268274
if !lookupFlag(pass, HTTPStatusCodeFlag) {
269275
return
@@ -274,6 +280,7 @@ func pkgFunArgs(pass *analysis.Pass, pkg *ast.Ident, fun *ast.SelectorExpr, args
274280
}
275281
}
276282
default:
283+
// w.WriteHeader(http.StatusOk)
277284
if fun.Sel.Name == "WriteHeader" {
278285
if !lookupFlag(pass, HTTPStatusCodeFlag) {
279286
return

0 commit comments

Comments
 (0)