Skip to content

Commit 66d4a16

Browse files
authored
Merge branch 'master' into lukeshu/reproduce
2 parents 2508856 + 88af709 commit 66d4a16

File tree

19 files changed

+552
-9
lines changed

19 files changed

+552
-9
lines changed

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,6 @@ issues:
6161
# golangci.com configuration
6262
# https://github.com/golangci/golangci/wiki/Configuration
6363
service:
64-
golangci-lint-version: 1.15.x # use the fixed version to not introduce new linters unexpectedly
64+
golangci-lint-version: 1.16.x # use the fixed version to not introduce new linters unexpectedly
6565
prepare:
6666
- echo "here I can run custom commands, but no preparation needed for this repo"

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ and the following linters are disabled by default:
204204
$ golangci-lint help linters
205205
...
206206
Disabled by default linters:
207+
bodyclose: checks whether HTTP response body is closed successfully [fast: false, auto-fix: false]
207208
depguard: Go linter that checks if package imports are in a list of acceptable packages [fast: true, auto-fix: false]
208209
dupl: Tool for code clone detection [fast: true, auto-fix: false]
209210
gochecknoglobals: Checks that no globals are present in Go code [fast: true, auto-fix: false]
@@ -344,7 +345,7 @@ Read [this section](#internals) for details.
344345
345346
### Memory Usage of Golangci-lint
346347
347-
A trade-off between memory usage and execution time can be controlled by [`GOCC`](https://golang.org/pkg/runtime/#hdr-Environment_Variables) environment variable.
348+
A trade-off between memory usage and execution time can be controlled by [`GOGC`](https://golang.org/pkg/runtime/#hdr-Environment_Variables) environment variable.
348349
Less `GOGC` values trigger garbage collection more frequently and golangci-lint consumes less memory and more CPU. Below is the trade-off table for running on this repo:
349350
350351
|`GOGC`|Peak Memory, GB|Executon Time, s|
@@ -416,6 +417,7 @@ golangci-lint help linters
416417
417418
### Disabled By Default Linters (`-E/--enable`)
418419
420+
- [bodyclose](https://github.com/timakin/bodyclose) - checks whether HTTP response body is closed successfully
419421
- [golint](https://github.com/golang/lint) - Golint differs from gofmt. Gofmt reformats Go source code, whereas golint prints out style mistakes
420422
- [stylecheck](https://github.com/dominikh/go-tools/tree/master/stylecheck) - Stylecheck is a replacement for golint
421423
- [gosec](https://github.com/securego/gosec) - Inspects source code for security problems
@@ -871,7 +873,7 @@ issues:
871873
# golangci.com configuration
872874
# https://github.com/golangci/golangci/wiki/Configuration
873875
service:
874-
golangci-lint-version: 1.15.x # use the fixed version to not introduce new linters unexpectedly
876+
golangci-lint-version: 1.16.x # use the fixed version to not introduce new linters unexpectedly
875877
prepare:
876878
- echo "here I can run custom commands, but no preparation needed for this repo"
877879
```
@@ -926,8 +928,8 @@ Short answer: go 1.11 and newer are oficially supported.
926928
Long answer:
927929
1. go < 1.9 isn't supported
928930
2. go 1.9 is supported by golangci-lint <= v1.10.2
929-
3. go 1.10 is oficially supported by golangci-lint <= 1.15.0.
930-
4. go1.11 and go1.12 are oficially supported by the latest version of golangci-lint.
931+
3. go 1.10 is officially supported by golangci-lint <= 1.15.0.
932+
4. go1.11 and go1.12 are officially supported by the latest version of golangci-lint.
931933
932934
**`golangci-lint` doesn't work**
933935
@@ -946,6 +948,7 @@ Thanks to [alecthomas/gometalinter](https://github.com/alecthomas/gometalinter)
946948
Thanks to [bradleyfalzon/revgrep](https://github.com/bradleyfalzon/revgrep) for cool diff tool.
947949
948950
Thanks to developers and authors of used linters:
951+
- [timakin](https://github.com/timakin)
949952
- [kisielk](https://github.com/kisielk)
950953
- [golang](https://github.com/golang)
951954
- [dominikh](https://github.com/dominikh)

README.tmpl.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ Read [this section](#internals) for details.
313313

314314
### Memory Usage of Golangci-lint
315315

316-
A trade-off between memory usage and execution time can be controlled by [`GOCC`](https://golang.org/pkg/runtime/#hdr-Environment_Variables) environment variable.
316+
A trade-off between memory usage and execution time can be controlled by [`GOGC`](https://golang.org/pkg/runtime/#hdr-Environment_Variables) environment variable.
317317
Less `GOGC` values trigger garbage collection more frequently and golangci-lint consumes less memory and more CPU. Below is the trade-off table for running on this repo:
318318

319319
|`GOGC`|Peak Memory, GB|Executon Time, s|
@@ -475,8 +475,8 @@ Short answer: go 1.11 and newer are oficially supported.
475475
Long answer:
476476
1. go < 1.9 isn't supported
477477
2. go 1.9 is supported by golangci-lint <= v1.10.2
478-
3. go 1.10 is oficially supported by golangci-lint <= 1.15.0.
479-
4. go1.11 and go1.12 are oficially supported by the latest version of golangci-lint.
478+
3. go 1.10 is officially supported by golangci-lint <= 1.15.0.
479+
4. go1.11 and go1.12 are officially supported by the latest version of golangci-lint.
480480

481481
**`golangci-lint` doesn't work**
482482

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ require (
5050
github.com/spf13/viper v1.0.2
5151
github.com/stretchr/testify v1.2.2
5252
github.com/valyala/quicktemplate v1.1.1
53+
github.com/timakin/bodyclose v0.0.0-20190407043127-4a873e97b2bb
5354
golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a // indirect
5455
golang.org/x/net v0.0.0-20190313220215-9f648a60d977 // indirect
5556
golang.org/x/sys v0.0.0-20190312061237-fead79001313 // indirect

go.sum

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ github.com/golangci/unconvert v0.0.0-20180507085042-28b1c447d1f4/go.mod h1:Izgrg
7777
github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ=
7878
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
7979
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
80+
github.com/gostaticanalysis/analysisutil v0.0.0-20190318220348-4088753ea4d3 h1:JVnpOZS+qxli+rgVl98ILOXVNbW+kb5wcxeGx8ShUIw=
81+
github.com/gostaticanalysis/analysisutil v0.0.0-20190318220348-4088753ea4d3/go.mod h1:eEOZF4jCKGi+aprrirO9e7WKB3beBRtWgqGunKl6pKE=
8082
github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce h1:xdsDDbiBDQTKASoGEZ+pEmF1OnWuu8AQ9I8iNbHNeno=
8183
github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce/go.mod h1:oZtUIOe8dh44I2q6ScRibXws4Ajl+d+nod3AaR9vL5w=
8284
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
@@ -160,6 +162,8 @@ github.com/valyala/fasthttp v1.2.0/go.mod h1:4vX61m6KN+xDduDNwXrhIAVZaZaZiQ1luJk
160162
github.com/valyala/quicktemplate v1.1.1 h1:C58y/wN0FMTi2PR0n3onltemfFabany53j7M6SDDB8k=
161163
github.com/valyala/quicktemplate v1.1.1/go.mod h1:EH+4AkTd43SvgIbQHYu59/cJyxDoOVRUAfrukLPuGJ4=
162164
github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio=
165+
github.com/timakin/bodyclose v0.0.0-20190407043127-4a873e97b2bb h1:lI9ufgFfvuqRctP9Ny8lDDLbSWCMxBPletcSqrnyFYM=
166+
github.com/timakin/bodyclose v0.0.0-20190407043127-4a873e97b2bb/go.mod h1:Qimiffbc6q9tBWlVV6x0P9sat/ao1xEkREYPPj9hphk=
163167
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
164168
golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a h1:YX8ljsm6wXlHZO+aRz9Exqr0evNhKRNe5K/gi+zKh4U=
165169
golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
@@ -188,6 +192,8 @@ golang.org/x/tools v0.0.0-20181117154741-2ddaf7f79a09/go.mod h1:n7NCudcB/nEzxVGm
188192
golang.org/x/tools v0.0.0-20181205014116-22934f0fdb62/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
189193
golang.org/x/tools v0.0.0-20190121143147-24cd39ecf745/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
190194
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
195+
golang.org/x/tools v0.0.0-20190311215038-5c2858a9cfe5/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
196+
golang.org/x/tools v0.0.0-20190322203728-c1a832b0ad89/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
191197
golang.org/x/tools v0.0.0-20190420000508-685fecacd0a0 h1:pa1CyBALPFjblgkNQp7T7gEcFcG/GOG5Ck8IcnSVWGs=
192198
golang.org/x/tools v0.0.0-20190420000508-685fecacd0a0/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
193199
gopkg.in/airbrake/gobrake.v2 v2.0.9 h1:7z2uVWwn7oVeeugY1DtlPAy5H+KYgB1KeKTnqjNatLo=

install.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ log_crit() {
172172
uname_os() {
173173
os=$(uname -s | tr '[:upper:]' '[:lower:]')
174174
case "$os" in
175-
msys_nt) os="windows" ;;
175+
msys_nt*) os="windows" ;;
176+
mingw*) os="windows" ;;
176177
esac
177178
echo "$os"
178179
}

pkg/golinters/bodyclose.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package golinters
2+
3+
import (
4+
"github.com/timakin/bodyclose/passes/bodyclose"
5+
"golang.org/x/tools/go/analysis"
6+
7+
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
8+
)
9+
10+
func NewBodyclose() *goanalysis.Linter {
11+
analyzers := []*analysis.Analyzer{
12+
bodyclose.Analyzer,
13+
}
14+
15+
return goanalysis.NewLinter(
16+
"bodyclose",
17+
"checks whether HTTP response body is closed successfully",
18+
analyzers,
19+
nil,
20+
)
21+
}

pkg/lint/lintersdb/manager.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
8989
WithSpeed(4).
9090
WithAlternativeNames("vet", "vetshadow").
9191
WithURL("https://golang.org/cmd/vet/"),
92+
linter.NewConfig(golinters.NewBodyclose()).
93+
WithSSA().
94+
WithPresets(linter.PresetPerformance, linter.PresetBugs).
95+
WithSpeed(4).
96+
WithURL("https://github.com/timakin/bodyclose"),
9297
linter.NewConfig(golinters.Errcheck{}).
9398
WithTypeInfo().
9499
WithPresets(linter.PresetBugs).

test/testdata/bodyclose.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//args: -Ebodyclose
2+
package testdata
3+
4+
import (
5+
"io/ioutil"
6+
"net/http"
7+
)
8+
9+
func BodycloseNotClosed() {
10+
resp, _ := http.Get("https://google.com") // ERROR "bodyclose: response body must be closed"
11+
_, _ = ioutil.ReadAll(resp.Body)
12+
}

vendor/github.com/gostaticanalysis/analysisutil/LICENSE

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/gostaticanalysis/analysisutil/README.md

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/gostaticanalysis/analysisutil/file.go

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/gostaticanalysis/analysisutil/go.mod

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/gostaticanalysis/analysisutil/go.sum

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/gostaticanalysis/analysisutil/pkg.go

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/gostaticanalysis/analysisutil/ssa.go

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/timakin/bodyclose/LICENSE

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)