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:
# - EXC0002 # disable excluding of issues about comments from golint
linters-settings:
cyclop:
# the maximal code complexity to report
max-complexity: 15
linters:
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
disable-all: true
enable:
- asciicheck
- bodyclose
- cyclop
- deadcode
- depguard
- dogsled
- dupl
- durationcheck
- errcheck
- errname
- errorlint
- exportloopref
- forbidigo
- forcetypeassert
- funlen
- gci
- gocognit
- goconst
- gocritic
- gocyclo
- gofmt
- gofumpt
- goimports
- golint
- gomoddirectives
- gomodguard
- goprintffuncname
- gosec
- gosimple
- govet
- ifshort
- importas
- ineffassign
# - ireturn # will be added in 1.43.0 (accept interfaces, return structs)
- makezero
- misspell
- nakedret
- nilerr
# - nilnil # will be added in 1.43.0
- nolintlint
- paralleltest
- predeclared
- revive
- rowserrcheck
- scopelint
- staticcheck
- structcheck
- stylecheck
@ -41,19 +65,29 @@ linters:
- unparam
- unused
- varcheck
- wastedassign
- whitespace
# - wrapcheck
# 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
# - gochecknoinits # this is too aggressive
# - godot
# - godox
# - goerr113
# - goerr113 # does not allow use of dynamic errors
# - golint # replaced by revive
# - gomnd # this is too aggressive
# - 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
# - 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
# - scopelint # replaced by exportloopref
# - tagliatelle # too presumptive at which struct tag conventions should be used
# - 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
bootstrap-tools: $(TEMPDIR)
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 -sfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | sh -s -- -b $(TEMPDIR)/ v0.177.0