Skip to content

Commit

Permalink
Merge pull request timakin#33 from korotin/no-import
Browse files Browse the repository at this point in the history
Do not filter out files without net/http
  • Loading branch information
timakin authored Jul 4, 2021
2 parents cb62158 + 4a3e399 commit f498879
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
5 changes: 0 additions & 5 deletions passes/bodyclose/bodyclose.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,6 @@ func (r runner) run(pass *analysis.Pass) (interface{}, error) {

r.skipFile = map[*ast.File]bool{}
for _, f := range funcs {
if r.noImportedNetHTTP(f) {
// skip this
continue
}

// skip if the function is just referenced
var isreffunc bool
for i := 0; i < f.Signature.Results().Len(); i++ {
Expand Down
7 changes: 7 additions & 0 deletions passes/bodyclose/testdata/src/a/helper.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package a

import "net/http"

func doRequestWithoutClose() (*http.Response, error) {
return http.Get("https://example.com")
}
5 changes: 5 additions & 0 deletions passes/bodyclose/testdata/src/a/no_import.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package a

func doRequestInHelperFunc() {
_, _ = doRequestWithoutClose() // want "response body must be closed"
}

0 comments on commit f498879

Please sign in to comment.