2023-05-23 01:35:36 +08:00
|
|
|
# note: GolangCI-Lint also searches for config files in all directories from the directory of the first analyzed path up to the root.
|
2023-05-18 21:47:14 +08:00
|
|
|
run:
|
|
|
|
# Timeout for analysis, e.g. 30s, 5m.
|
|
|
|
# gobot is very expensive, on a machine with heavy load it takes some minutes
|
|
|
|
# for first run or after empty the cache by 'golangci-lint cache clean'
|
|
|
|
# Default: 1m
|
|
|
|
timeout: 5m
|
|
|
|
|
|
|
|
# If set we pass it to "go list -mod={option}". From "go help modules":
|
|
|
|
# If invoked with -mod=readonly, the go command is disallowed from the implicit
|
|
|
|
# automatic updating of go.mod described above. Instead, it fails when any changes
|
|
|
|
# to go.mod are needed. This setting is most useful to check that go.mod does
|
|
|
|
# not need updates, such as in a continuous integration and testing system.
|
|
|
|
# If invoked with -mod=vendor, the go command assumes that the vendor
|
|
|
|
# directory holds the correct copies of dependencies and ignores
|
|
|
|
# the dependency descriptions in go.mod.
|
|
|
|
#
|
|
|
|
# Allowed values: readonly|vendor|mod
|
|
|
|
# By default, it isn't set.
|
|
|
|
modules-download-mode: readonly
|
|
|
|
|
|
|
|
# Enables skipping of directories:
|
|
|
|
# - vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
|
|
|
|
# Default: true
|
|
|
|
skip-dirs-use-default: false
|
|
|
|
|
|
|
|
# note: examples will be currently omitted by the build tag
|
|
|
|
skip-dirs:
|
|
|
|
- platforms/opencv
|
|
|
|
|
|
|
|
linters:
|
2023-06-19 00:10:46 +08:00
|
|
|
# currently active linters:
|
|
|
|
#
|
2023-10-21 02:50:42 +08:00
|
|
|
#INFO [lintersdb] Active 42 linters: [asasalint asciicheck bidichk contextcheck decorder depguard dupword durationcheck errcheck exportloopref
|
|
|
|
# gocheckcompilerdirectives gofmt gofumpt goimports gomoddirectives gomodguard goprintffuncname gosec gosimple govet grouper ineffassign makezero mirror
|
|
|
|
# misspell musttag nilerr nilnil nolintlint nosprintfhostport prealloc reassign revive staticcheck tagalign tenv testableexamples tparallel unconvert unparam
|
|
|
|
# unused wastedassign]
|
2023-06-19 00:10:46 +08:00
|
|
|
|
|
|
|
enable-all: true
|
|
|
|
|
2023-05-18 21:47:14 +08:00
|
|
|
# https://golangci-lint.run/usage/linters/#enabled-by-default
|
|
|
|
# note: typecheck can not be disabled, it is used to check code compilation
|
2023-06-19 00:10:46 +08:00
|
|
|
disable:
|
|
|
|
# deprecated
|
|
|
|
- deadcode # deprecated
|
|
|
|
- exhaustivestruct # deprecated
|
|
|
|
- golint # deprecated
|
|
|
|
- ifshort # deprecated
|
|
|
|
- interfacer # deprecated
|
|
|
|
- maligned # deprecated
|
|
|
|
- nosnakecase # deprecated
|
|
|
|
- scopelint # deprecated
|
|
|
|
- structcheck # deprecated
|
|
|
|
- varcheck # deprecated
|
|
|
|
# not used for any reason
|
|
|
|
- execinquery # not needed (no sql)
|
|
|
|
- exhaustive # not used (we allow incomplete usage of enum switch, e.g. with default case)
|
|
|
|
- forbidigo # not used (we allow print statements)
|
|
|
|
- ginkgolinter # not needed (enforces standards of using ginkgo and gomega)
|
|
|
|
- gochecknoglobals # not used (we allow definition of unexposed variables at top level)
|
|
|
|
- godot # not used (seems to be counting peas)
|
|
|
|
- godox # not used (we have many TODOs, so not useful)
|
|
|
|
- goerr113 # not used (we allow error creation at return statement)
|
|
|
|
- gosmopolitan # not needed (report i18n/l10n anti-patterns)
|
2023-06-19 22:06:44 +08:00
|
|
|
- importas # not needed (there is no alias rule at the moment)
|
2023-06-19 00:10:46 +08:00
|
|
|
- ireturn # not used (we allow return interfaces)
|
|
|
|
- loggercheck # not needed (relates to kitlog, klog, logr, zap)
|
|
|
|
- paralleltest # not used
|
|
|
|
- promlinter # not needed (prometheus metrics naming)
|
|
|
|
- rowserrcheck # not needed (sql related)
|
|
|
|
- sqlclosecheck # not needed (sql related)
|
|
|
|
- testpackage # not needed, we use the same name for test package to have access to unexposed items
|
|
|
|
- wrapcheck # not needed (we allow errors from interface methods)
|
|
|
|
- zerologlint # not needed (related to zerolog package)
|
|
|
|
# important to have
|
2023-10-21 02:50:42 +08:00
|
|
|
- errorlint # useful (reduce bugs), but suppress the "Use `%w` to format errors" check
|
|
|
|
- forcetypeassert # useful (reduce bugs)
|
2023-06-19 00:10:46 +08:00
|
|
|
- nakedret # very useful together with "nonamedreturns" (reduce bugs)
|
|
|
|
- nonamedreturns # very useful (reduce bugs)
|
|
|
|
# useful for the future
|
|
|
|
- bodyclose # maybe useful (reduce bugs), exclusions for tests needed
|
|
|
|
- containedctx # useful (structs are not for context wrapping)
|
|
|
|
- cyclop # useful with some tweeks (better understandable code), see also gocyclo
|
|
|
|
- dogsled # useful with some tweeks (e.g. exclude tests)
|
|
|
|
- dupl # useful with some tweeks (reduce bugs and lines of code)
|
|
|
|
- errchkjson # useful (reduce bugs)
|
|
|
|
- errname # useful for common style
|
|
|
|
- exhaustruct # useful with some exclusions for existing code (e.g. mavlink/common/common.go)
|
|
|
|
- funlen # useful with some tweeks (reduce bugs, simplify code, better understandable code)
|
|
|
|
- gci # useful (improve readability)
|
|
|
|
- gocognit # useful with some tweeks (better understandable code)
|
|
|
|
- goconst # useful (reduce bugs)
|
|
|
|
- gocritic # useful with some exclusions for existing code (e.g. mavlink/common/common.go)
|
|
|
|
- gocyclo # useful with some tweeks (better understandable code)
|
|
|
|
- goheader # useful, if we introduce a common header (e.g. for copyright)
|
|
|
|
- gomnd # useful with some exclusions for existing code (e.g. mavlink.go)
|
|
|
|
- interfacebloat # useful with some exclusions at usage of external packages
|
|
|
|
- lll # useful with some exclusions for existing code (e.g. mavlink/common/common.go)
|
|
|
|
- maintidx # useful with some tweeks (better understandable code), maybe use instead "gocyclo", "gocognit" , "cyclop"
|
|
|
|
- nestif # useful (reduce bugs, simplify code, better understandable code)
|
|
|
|
- nlreturn # more common style, but could become annoying
|
|
|
|
- noctx # maybe good (show used context explicit)
|
|
|
|
- predeclared # useful (reduce bugs)
|
|
|
|
- stylecheck # useful with some tweaking (e.g. underscores in names should be allowed - we use it for constants retrieved from C/C++)
|
|
|
|
- tagliatelle # maybe useful with some tweaking or excluding
|
|
|
|
- thelper # useful
|
|
|
|
- usestdlibvars # useful
|
|
|
|
- varnamelen # maybe useful with some tweaking, but many findings
|
|
|
|
- whitespace # more common style, but could become annoying
|
|
|
|
- wsl # more common style, but could become annoying
|
2023-05-19 20:16:22 +08:00
|
|
|
|
|
|
|
linters-settings:
|
2023-06-19 00:10:46 +08:00
|
|
|
depguard:
|
|
|
|
# Rules to apply.
|
|
|
|
#
|
|
|
|
# Variables:
|
|
|
|
# - File Variables
|
|
|
|
# you can still use and exclamation mark ! in front of a variable to say not to use it.
|
|
|
|
# Example !$test will match any file that is not a go test file.
|
|
|
|
#
|
|
|
|
# `$all` - matches all go files
|
|
|
|
# `$test` - matches all go test files
|
|
|
|
#
|
|
|
|
# - Package Variables
|
|
|
|
#
|
|
|
|
# `$gostd` - matches all of go's standard library (Pulled from `GOROOT`)
|
|
|
|
#
|
|
|
|
# Default: Only allow $gostd in all files.
|
|
|
|
rules:
|
|
|
|
main:
|
|
|
|
# Packages that are not allowed where the value is a suggestion.
|
|
|
|
deny:
|
|
|
|
- pkg: "github.com/pkg/errors"
|
|
|
|
desc: Should be replaced by standard lib errors package
|
|
|
|
|
2023-10-21 02:50:42 +08:00
|
|
|
dupword:
|
|
|
|
# Keywords for detecting duplicate words.
|
|
|
|
# If this list is not empty, only the words defined in this list will be detected.
|
|
|
|
# Default: []
|
|
|
|
keywords:
|
|
|
|
- "the"
|
|
|
|
- "and"
|
|
|
|
- "a"
|
|
|
|
|
2023-05-19 20:16:22 +08:00
|
|
|
nolintlint:
|
|
|
|
# Enable to require an explanation of nonzero length after each nolint directive.
|
|
|
|
# Default: false
|
|
|
|
require-explanation: true
|
|
|
|
# Enable to require nolint directives to mention the specific linter being suppressed.
|
|
|
|
# Default: false
|
|
|
|
require-specific: true
|
|
|
|
|
|
|
|
revive:
|
|
|
|
rules:
|
|
|
|
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unexported-return
|
|
|
|
# disable this rule, because sometimes it has its justification
|
|
|
|
- name: unexported-return
|
|
|
|
severity: warning
|
|
|
|
disabled: true
|