diff --git a/.golangci.yml b/.golangci.yml index b20f0d794f..3978152b41 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,6 +1,6 @@ run: # timeout for analysis - deadline: 10m + timeout: 10m linters-settings: govet: @@ -11,31 +11,89 @@ linters-settings: simplify: true linters: - disable-all: true - enable: - - asciicheck - - deadcode - - dupl - - errcheck - - goimports - - gosec - - gosimple - - govet - - ineffassign - - nolintlint + enable-all: true + disable: + # Global variables are used in many places throughout the code base. + - gochecknoglobals + + # We want to allow short variable names. + - varnamelen + + # We want to allow TODOs. + - godox + + # Instances of table driven tests that don't pre-allocate shouldn't trigger + # the linter. - prealloc - - staticcheck - - structcheck - - typecheck - - unconvert - - unused - - varcheck + + # Init functions are used by loggers throughout the codebase. + - gochecknoinits + + # Deprecated linters. See https://golangci-lint.run/usage/linters/. + - bodyclose + - contextcheck + - nilerr + - noctx + - rowserrcheck + - sqlclosecheck + - tparallel + - unparam + - wastedassign + - execinquery + + # Disable gofumpt as it has weird behavior regarding formatting multiple + # lines for a function which is in conflict with our contribution + # guidelines. See https://github.com/mvdan/gofumpt/issues/235. + - gofumpt + + # Disable whitespace linter as it has conflict rules against our + # contribution guidelines. See https://github.com/bombsimon/wsl/issues/109. + - wsl + + # Allow using default empty values. + - exhaustruct + + # Allow exiting case select faster by putting everything in default. + - exhaustive + + # Allow tests to be put in the same package. + - testpackage + + # Don't run the cognitive related linters. + - gocognit + - gocyclo + - maintidx + - cyclop + + # Allow customized interfaces to be returned from functions. + - ireturn + + # Disable too many blank identifiers check. We won't be able to run this + # unless a large refactor has been applied to old code. + - dogsled + + # We don't wrap errors. + - wrapcheck + + # We use ErrXXX instead. + - errname + + # Disable nil check to allow returning multiple nil values. + - nilnil - # Others to consider that do not pass presently: - # - nilerr - # - makezero + # We often split tests into separate test functions. If we are forced to + # call t.Helper() within those functions, we lose the information where + # exactly a test failed in the generated failure stack trace. + - thelper + + # The linter is too aggressive and doesn't add much value since reviewers + # will also catch magic numbers that make sense to extract. + - gomnd issues: + # Only check issues in the new code. + new-from-rev: HEAD~1 + exclude-rules: # Exclude gosec from running for tests so that tests with weak randomness # (math/rand) will pass the linter.