Skip to content

Commit 6160ff2

Browse files
committed
Cache go/analysis facts
Don't load unneeded packages for go/analysis. Repeated run of go/analysis linters now 10x faster (2s vs 20s on this repo) than before.
1 parent 93bb0fd commit 6160ff2

35 files changed

+3322
-709
lines changed

.golangci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ linters-settings:
1111
golint:
1212
min-confidence: 0
1313
gocyclo:
14-
min-complexity: 10
14+
min-complexity: 15
1515
maligned:
1616
suggest-new: true
1717
dupl:
@@ -86,7 +86,7 @@ linters:
8686
run:
8787
skip-dirs:
8888
- test/testdata_etc
89-
- pkg/golinters/goanalysis/(checker|passes)
89+
- internal/(cache|renameio|robustio)
9090

9191
issues:
9292
exclude-rules:

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ test: export GOLANGCI_LINT_INSTALLED = true
1919

2020
test: build
2121
GL_TEST_RUN=1 time ./golangci-lint run -v
22-
GL_TEST_RUN=1 time ./golangci-lint run --fast --no-config -v --skip-dirs 'test/testdata_etc,pkg/golinters/goanalysis/(checker|passes)'
23-
GL_TEST_RUN=1 time ./golangci-lint run --no-config -v --skip-dirs 'test/testdata_etc,pkg/golinters/goanalysis/(checker|passes)'
22+
GL_TEST_RUN=1 time ./golangci-lint run --fast --no-config -v --skip-dirs 'test/testdata_etc,internal/(cache|renameio|robustio)'
23+
GL_TEST_RUN=1 time ./golangci-lint run --no-config -v --skip-dirs 'test/testdata_etc,internal/(cache|renameio|robustio)'
2424
GL_TEST_RUN=1 time go test -v ./...
2525

2626
.PHONY: test

README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,10 @@ $ golangci-lint help linters
177177
Enabled by default linters:
178178
deadcode: Finds unused code [fast: true, auto-fix: false]
179179
errcheck: Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases [fast: true, auto-fix: false]
180-
gosimple: Linter for Go source code that specializes in simplifying a code [fast: false, auto-fix: false]
181-
govet (vet, vetshadow): Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string [fast: false, auto-fix: false]
180+
gosimple: Linter for Go source code that specializes in simplifying a code [fast: true, auto-fix: false]
181+
govet (vet, vetshadow): Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string [fast: true, auto-fix: false]
182182
ineffassign: Detects when assignments to existing variables are not used [fast: true, auto-fix: false]
183-
staticcheck: Staticcheck is a go vet on steroids, applying a ton of static analysis checks [fast: false, auto-fix: false]
183+
staticcheck: Staticcheck is a go vet on steroids, applying a ton of static analysis checks [fast: true, auto-fix: false]
184184
structcheck: Finds unused struct fields [fast: true, auto-fix: false]
185185
typecheck: Like the front-end of a Go compiler, parses and type-checks Go code [fast: true, auto-fix: false]
186186
unused: Checks Go code for unused constants, variables, functions and types [fast: false, auto-fix: false]
@@ -193,7 +193,7 @@ and the following linters are disabled by default:
193193
$ golangci-lint help linters
194194
...
195195
Disabled by default linters:
196-
bodyclose: checks whether HTTP response body is closed successfully [fast: false, auto-fix: false]
196+
bodyclose: checks whether HTTP response body is closed successfully [fast: true, auto-fix: false]
197197
depguard: Go linter that checks if package imports are in a list of acceptable packages [fast: true, auto-fix: false]
198198
dupl: Tool for code clone detection [fast: true, auto-fix: false]
199199
funlen: Tool for detection of long functions [fast: true, auto-fix: false]
@@ -214,7 +214,7 @@ misspell: Finds commonly misspelled English words in comments [fast: true, auto-
214214
nakedret: Finds naked returns in functions greater than a specified function length [fast: true, auto-fix: false]
215215
prealloc: Finds slice declarations that could potentially be preallocated [fast: true, auto-fix: false]
216216
scopelint: Scopelint checks for unpinned variables in go programs [fast: true, auto-fix: false]
217-
stylecheck: Stylecheck is a replacement for golint [fast: false, auto-fix: false]
217+
stylecheck: Stylecheck is a replacement for golint [fast: true, auto-fix: false]
218218
unconvert: Remove unnecessary type conversions [fast: true, auto-fix: false]
219219
unparam: Reports unused function parameters [fast: false, auto-fix: false]
220220
whitespace: Tool for detection of leading and trailing whitespace [fast: true, auto-fix: true]
@@ -878,7 +878,7 @@ linters-settings:
878878
golint:
879879
min-confidence: 0
880880
gocyclo:
881-
min-complexity: 10
881+
min-complexity: 15
882882
maligned:
883883
suggest-new: true
884884
dupl:
@@ -953,7 +953,7 @@ linters:
953953
run:
954954
skip-dirs:
955955
- test/testdata_etc
956-
- pkg/golinters/goanalysis/(checker|passes)
956+
- internal/(cache|renameio|robustio)
957957
958958
issues:
959959
exclude-rules:

go.sum

-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40T
187187
github.com/quasilyte/go-consistent v0.0.0-20190521200055-c6f3937de18c/go.mod h1:5STLWrekHfjyYwxBRVRXNOSewLJ3PWfDJd1VyTS21fI=
188188
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
189189
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
190-
github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
191190
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
192191
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
193192
github.com/securego/gosec v0.0.0-20190912120752-140048b2a218 h1:O0yPHYL49quNL4Oj2wVq+zbGMu4dAM6iLoOQtm49TrQ=

0 commit comments

Comments
 (0)