[lbry] ci: update golangci settings

This commit is contained in:
Roy Lee 2022-05-24 10:05:11 -07:00
parent 5c8800691c
commit 57e8d9cdd2

View file

@ -1,54 +1,152 @@
run:
# timeout for analysis
deadline: 10m
linters-settings: linters-settings:
depguard:
list-type: blacklist
packages:
# logging is allowed only by logutils.Log, logrus
# is allowed to use only in logutils package
- github.com/sirupsen/logrus
packages-with-error-message:
- github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
dupl:
threshold: 100
funlen:
lines: 100
statements: 50
gci:
local-prefixes: github.com/golangci/golangci-lint
goconst:
min-len: 2
min-occurrences: 2
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
disabled-checks:
- dupImport # https://github.com/go-critic/go-critic/issues/845
- ifElseChain
- octalLiteral
- whyNoLint
- wrapperFunc
gocyclo:
min-complexity: 15
goimports:
local-prefixes: github.com/golangci/golangci-lint
gomnd:
settings:
mnd:
# don't include the "operation" and "assign"
checks:
- argument
- case
- condition
- return
govet: govet:
# Don't report about shadowed variables check-shadowing: true
check-shadowing: false settings:
gofmt: printf:
# simplify code: gofmt with `-s` option, true by default funcs:
simplify: true - (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
lll:
line-length: 140
maligned:
suggest-new: true
misspell:
locale: US
nolintlint:
allow-leading-space: true # don't require machine-readable nolint directives (i.e. with no leading space)
allow-unused: false # report any unused nolint directives
require-explanation: false # don't require an explanation for nolint directives
require-specific: false # don't require nolint directives to be specific about which linter is being skipped
linters: linters:
enable-all: true disable-all: true
disable: enable:
# Global variables are used in many places throughout the code base. - asciicheck
- gochecknoglobals - bodyclose
# - deadcode
# Some lines are over 80 characters on purpose and we don't want to make them - depguard
# even longer by marking them as 'nolint'. # - dogsled
- lll # - dupl
# - errcheck
# We don't care (enough) about misaligned structs to lint that. # - exhaustive
- maligned - exportloopref
# - funlen
# We have long functions, especially in tests. Moving or renaming those would # - gochecknoglobals
# trigger funlen problems that we may not want to solve at that time. # - gochecknoinits
- funlen # - gocognit
# - goconst
# Disable for now as we haven't yet tuned the sensitivity to our codebase # - gocritic
# yet. Enabling by default for example, would also force new contributors to # - gocyclo
# potentially extensively refactor code, when they want to smaller change to # - godot
# land. # - godox
- gocyclo # - goerr113
- gofmt
# Instances of table driven tests that don't pre-allocate shouldn't trigger - goimports
# the linter. # - gomnd
- prealloc - goprintffuncname
# - gosec
# Init functions are used by loggers throughout the codebase. # - gosimple
- gochecknoinits # - govet
# - ineffassign
# Explicit types are okay. # - interfacer
- interfacer # - lll
# - maligned
# - misspell
- nakedret
# - nestif
# - noctx
# - nolintlint
# - prealloc
- rowserrcheck
# - revive
# - scopelint
# - staticcheck
# - structcheck
# - stylecheck
# - testpackage
# - typecheck
- unconvert
# - unparam
# - unused
# - varcheck
# - whitespace
# - wsl
issues: issues:
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules: exclude-rules:
# Exclude gosec from running for tests so that tests with weak randomness
# (math/rand) will pass the linter.
- path: _test\.go - path: _test\.go
linters: linters:
- gosec - gomnd
- errcheck
- dupl - path: pkg/golinters/errcheck.go
text: "SA1019: errCfg.Exclude is deprecated: use ExcludeFunctions instead"
- path: pkg/commands/run.go
text: "SA1019: lsc.Errcheck.Exclude is deprecated: use ExcludeFunctions instead"
# TODO must be removed after the release of the next version (v1.41.0)
- path: pkg/commands/run.go
linters:
- gomnd
# TODO must be removed after the release of the next version (v1.41.0)
- path: pkg/golinters/nolintlint/nolintlint.go
linters:
- gomnd
# TODO must be removed after the release of the next version (v1.41.0)
- path: pkg/printers/tab.go
linters:
- gomnd
run:
skip-dirs:
- test/testdata_etc
- internal/cache
- internal/renameio
- internal/robustio