Skip to content

Commit

Permalink
feat: add examples in pkgFunArgs function
Browse files Browse the repository at this point in the history
  • Loading branch information
sashamelentyev committed Aug 26, 2022
1 parent fdf62cc commit 41ad014
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/analyzer/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ func pkgFunArgs(pass *analysis.Pass, pkg *ast.Ident, fun *ast.SelectorExpr, args
switch pkg.Name {
case "http":
switch fun.Sel.Name {
// http.NewRequest(http.MethodGet, "localhost", http.NoBody)
case "NewRequest":
if !lookupFlag(pass, HTTPMethodFlag) {
return
Expand All @@ -228,6 +229,7 @@ func pkgFunArgs(pass *analysis.Pass, pkg *ast.Ident, fun *ast.SelectorExpr, args
checkHTTPMethod(pass, basicLit)
}

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

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

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

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

// http.RedirectHandler("localhost", http.StatusMovedPermanently)
case "RedirectHandler":
if !lookupFlag(pass, HTTPStatusCodeFlag) {
return
Expand All @@ -274,6 +280,7 @@ func pkgFunArgs(pass *analysis.Pass, pkg *ast.Ident, fun *ast.SelectorExpr, args
}
}
default:
// w.WriteHeader(http.StatusOk)
if fun.Sel.Name == "WriteHeader" {
if !lookupFlag(pass, HTTPStatusCodeFlag) {
return
Expand Down

0 comments on commit 41ad014

Please sign in to comment.