update golangci + add additional lint rules

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
This commit is contained in:
Alex Goodman 2021-10-05 22:50:57 -04:00
parent 9189ed68df
commit 053768c6c6
No known key found for this signature in database
GPG Key ID: 5CB45AE22BAB7EA7
2 changed files with 40 additions and 6 deletions

View File

@ -4,35 +4,59 @@
# include: # include:
# - EXC0002 # disable excluding of issues about comments from golint # - EXC0002 # disable excluding of issues about comments from golint
linters-settings:
cyclop:
# the maximal code complexity to report
max-complexity: 15
linters: linters:
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint # inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
disable-all: true disable-all: true
enable: enable:
- asciicheck - asciicheck
- bodyclose - bodyclose
- cyclop
- deadcode - deadcode
- depguard - depguard
- dogsled - dogsled
- dupl - dupl
- durationcheck
- errcheck - errcheck
- errname
- errorlint
- exportloopref
- forbidigo
- forcetypeassert
- funlen - funlen
- gci
- gocognit - gocognit
- goconst - goconst
- gocritic - gocritic
- gocyclo - gocyclo
- gofmt - gofmt
- gofumpt
- goimports - goimports
- golint - gomoddirectives
- gomodguard
- goprintffuncname - goprintffuncname
- gosec - gosec
- gosimple - gosimple
- govet - govet
- ifshort
- importas
- ineffassign - ineffassign
# - ireturn # will be added in 1.43.0 (accept interfaces, return structs)
- makezero
- misspell - misspell
- nakedret - nakedret
- nilerr
# - nilnil # will be added in 1.43.0
- nolintlint - nolintlint
- paralleltest
- predeclared
- revive
- rowserrcheck - rowserrcheck
- scopelint
- staticcheck - staticcheck
- structcheck - structcheck
- stylecheck - stylecheck
@ -41,19 +65,29 @@ linters:
- unparam - unparam
- unused - unused
- varcheck - varcheck
- wastedassign
- whitespace - whitespace
# - wrapcheck
# do not enable... # do not enable...
# - exhaustive # makes to many assumptions about enums and if a switch case should contain all enum instances
# - exhaustivestruct # we like to depend on zero values
# - gochecknoglobals # - gochecknoglobals
# - gochecknoinits # this is too aggressive # - gochecknoinits # this is too aggressive
# - godot # - godot
# - godox # - godox
# - goerr113 # - goerr113 # does not allow use of dynamic errors
# - golint # replaced by revive
# - gomnd # this is too aggressive # - gomnd # this is too aggressive
# - interfacer # this is a good idea, but is no longer supported and is prone to false positives # - interfacer # this is a good idea, but is no longer supported and is prone to false positives
# - lll # without a way to specify per-line exception cases, this is not usable # - lll # without a way to specify per-line exception cases, this is not usable
# - maligned # this is an excellent linter, but tricky to optimize and we are not sensitive to memory layout optimizations # - maligned # this is an excellent linter, but tricky to optimize and we are not sensitive to memory layout optimizations
# - nestif # - nestif # other complexity linters already cover this well
# - nlreturn # no robust auto-fixers supported
# - noctx # we don't use context a lot
# - prealloc # following this rule isn't consistently a good idea, as it sometimes forces unnecessary allocations that result in less idiomatic code # - prealloc # following this rule isn't consistently a good idea, as it sometimes forces unnecessary allocations that result in less idiomatic code
# - scopelint # replaced by exportloopref
# - tagliatelle # too presumptive at which struct tag conventions should be used
# - testpackage # - testpackage
# - wsl # - wsl # very verbose and there is no auto-fixer for this project yet https://github.com/bombsimon/wsl/issues/90

View File

@ -101,7 +101,7 @@ $(TEMPDIR):
.PHONY: bootstrap-tools .PHONY: bootstrap-tools
bootstrap-tools: $(TEMPDIR) bootstrap-tools: $(TEMPDIR)
GO111MODULE=off GOBIN=$(shell realpath $(TEMPDIR)) go get -u golang.org/x/perf/cmd/benchstat GO111MODULE=off GOBIN=$(shell realpath $(TEMPDIR)) go get -u golang.org/x/perf/cmd/benchstat
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(TEMPDIR)/ v1.26.0 curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(TEMPDIR)/ v1.42.1
curl -sSfL https://raw.githubusercontent.com/wagoodman/go-bouncer/master/bouncer.sh | sh -s -- -b $(TEMPDIR)/ v0.2.0 curl -sSfL https://raw.githubusercontent.com/wagoodman/go-bouncer/master/bouncer.sh | sh -s -- -b $(TEMPDIR)/ v0.2.0
curl -sfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | sh -s -- -b $(TEMPDIR)/ v0.177.0 curl -sfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | sh -s -- -b $(TEMPDIR)/ v0.177.0