Skip to content

Commit

Permalink
golangci: update config file
Browse files Browse the repository at this point in the history
  • Loading branch information
yyforyongyu committed Aug 21, 2024
1 parent 149511d commit 2791bac
Showing 1 changed file with 80 additions and 22 deletions.
102 changes: 80 additions & 22 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
run:
# timeout for analysis
deadline: 10m
timeout: 10m

linters-settings:
govet:
Expand All @@ -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: master

exclude-rules:
# Exclude gosec from running for tests so that tests with weak randomness
# (math/rand) will pass the linter.
Expand Down

0 comments on commit 2791bac

Please sign in to comment.