2021-02-19 00:56:10 +08:00
linters :
2021-03-23 01:21:36 +08:00
disable-all : true
2021-02-19 00:56:10 +08:00
enable :
2022-11-07 18:07:10 +08:00
- asasalint
2022-11-22 04:11:07 +08:00
- asciicheck
2022-11-07 18:07:10 +08:00
- bidichk
2021-03-13 02:14:31 +08:00
- bodyclose
2022-11-07 18:34:05 +08:00
- depguard
2021-03-13 02:14:31 +08:00
- dogsled
2022-10-26 18:06:08 +08:00
- errcheck
2022-11-22 04:11:07 +08:00
- errname
2023-03-06 19:27:03 +08:00
- errorlint
2022-11-22 04:11:07 +08:00
- exportloopref
2023-02-03 17:27:47 +08:00
- gocheckcompilerdirectives
2023-05-18 00:30:10 +08:00
- gocritic
2021-03-13 02:14:31 +08:00
- goprintffuncname
2023-03-28 17:44:03 +08:00
- gosec
2021-03-13 02:14:31 +08:00
- gosimple
- govet
- ineffassign
2022-11-11 02:41:11 +08:00
- interfacebloat
2022-11-11 23:17:15 +08:00
- lll
2022-12-20 18:42:09 +08:00
- makezero
2021-03-13 02:14:31 +08:00
- nakedret
- nilerr
2023-02-08 00:06:12 +08:00
- nolintlint
2023-10-30 20:14:16 +08:00
- perfsprint
2022-11-22 04:53:55 +08:00
- prealloc
2021-03-13 02:14:31 +08:00
- predeclared
2021-02-19 00:56:10 +08:00
- revive
2021-03-13 02:14:31 +08:00
- sqlclosecheck
- staticcheck
2023-02-08 00:12:42 +08:00
- tenv
2023-11-02 20:40:30 +08:00
- testifylint
2022-11-07 18:06:00 +08:00
- tparallel
2021-03-13 02:14:31 +08:00
- typecheck
- unconvert
2022-11-09 03:04:12 +08:00
- unparam
2021-03-13 02:14:31 +08:00
- unused
2021-02-19 00:56:10 +08:00
linters-settings :
2022-11-07 18:34:05 +08:00
depguard :
2023-06-15 03:38:04 +08:00
rules :
# Name of a rule.
main :
# Packages that are not allowed where the value is a suggestion.
deny :
- pkg : log
desc : 'Use injected telegraf.Logger instead'
# List of file globs that will match this list of settings to compare against.
# Default: $all
files :
- "!**/agent/**"
- "!**/cmd/**"
- "!**/config/**"
- "!**/filter/**"
- "!**/internal/**"
- "!**/logger/**"
- "!**/metric/**"
- "!**/models/**"
- "!**/plugins/serializers/**"
- "!**/scripts/**"
- "!**/selfstat/**"
- "!**/testutil/**"
- "!**/tools/**"
- "!**/*_test.go"
2023-04-03 21:19:43 +08:00
errcheck :
# List of functions to exclude from checking, where each entry is a single function to exclude.
# See https://github.com/kisielk/errcheck#excluding-functions for details.
exclude-functions :
- "(*hash/maphash.Hash).Write"
- "(*hash/maphash.Hash).WriteByte"
- "(*hash/maphash.Hash).WriteString"
2023-05-18 00:30:10 +08:00
gocritic :
# Which checks should be enabled; can't be combined with 'disabled-checks'.
# See https://go-critic.github.io/overview#checks-overview.
# To check which checks are enabled run `GL_DEBUG=gocritic golangci-lint run`.
# By default, list of stable checks is used.
enabled-checks :
2023-12-15 21:25:10 +08:00
# diagnostic
2023-05-18 00:30:10 +08:00
- argOrder
- badCall
- badCond
- badLock
2023-11-16 03:35:41 +08:00
- badRegexp
2023-05-18 00:30:10 +08:00
- badSorting
- builtinShadowDecl
- caseOrder
- codegenComment
2023-08-04 00:58:27 +08:00
- commentedOutCode
2023-05-19 15:55:08 +08:00
- deferInLoop
2023-08-03 22:11:26 +08:00
- dupArg
2023-08-04 00:58:27 +08:00
- deprecatedComment
2023-05-18 00:30:10 +08:00
- dupBranchBody
- dupCase
- dupSubExpr
2023-06-09 16:11:52 +08:00
- dynamicFmtString
2023-05-18 00:30:10 +08:00
- emptyDecl
- evalOrder
2023-05-19 15:55:08 +08:00
- exitAfterDefer
2023-05-18 00:30:10 +08:00
- externalErrorReassign
2023-08-15 05:18:20 +08:00
- filepathJoin
2023-08-03 22:11:26 +08:00
- flagName
- mapKey
2023-05-18 00:30:10 +08:00
- nilValReturn
2023-08-03 22:11:26 +08:00
- offBy1
2023-05-18 00:30:10 +08:00
- regexpPattern
2023-08-04 00:57:18 +08:00
- sloppyReassign
2023-05-18 00:30:10 +08:00
- sloppyTypeAssert
- sortSlice
2023-06-09 16:11:52 +08:00
- sprintfQuotedString
2023-05-18 00:30:10 +08:00
- sqlQuery
2023-08-03 23:07:48 +08:00
- syncMapLoadAndDelete
- truncateCmp
2023-05-18 00:30:10 +08:00
- uncheckedInlineErr
2023-05-19 15:55:08 +08:00
- unnecessaryDefer
2023-05-18 00:30:10 +08:00
- weakCond
2023-12-15 21:25:10 +08:00
# performance
2024-01-03 22:16:26 +08:00
- appendCombine
2023-12-15 21:25:10 +08:00
- equalFold
2024-01-02 19:29:04 +08:00
- indexAlloc
- hugeParam
2023-12-15 22:01:25 +08:00
- preferDecodeRune
2024-01-02 19:29:04 +08:00
- preferFprint
2023-12-15 21:25:10 +08:00
- preferStringWriter
2024-01-02 19:29:04 +08:00
- preferWriteByte
- rangeExprCopy
- rangeValCopy
- sliceClear
2023-12-15 21:25:10 +08:00
- stringXbytes
2024-01-02 19:29:04 +08:00
2023-12-15 22:36:34 +08:00
# Settings passed to gocritic.
# The settings key is the name of a supported gocritic checker.
# The list of supported checkers can be find in https://go-critic.github.io/overview.
settings :
hugeParam :
# Size in bytes that makes the warning trigger.
# Default: 80
sizeThreshold : 512
rangeValCopy :
# Size in bytes that makes the warning trigger.
# Default: 128
sizeThreshold : 512
2023-03-28 17:44:03 +08:00
gosec :
# To select a subset of rules to run.
# Available rules: https://github.com/securego/gosec#available-rules
# Default: [] - means include all rules
includes :
2023-04-04 02:31:08 +08:00
- G101
2023-03-29 15:47:57 +08:00
- G102
2023-04-12 21:32:46 +08:00
- G103
2023-03-28 17:44:03 +08:00
- G106
2023-04-04 02:29:58 +08:00
- G107
2023-03-28 17:44:03 +08:00
- G108
- G109
2023-04-14 23:14:55 +08:00
- G110
2023-03-28 17:44:03 +08:00
- G111
2023-04-03 21:23:05 +08:00
- G112
- G114
2023-03-28 17:44:03 +08:00
- G201
2023-04-03 21:21:26 +08:00
- G202
2023-03-28 17:44:03 +08:00
- G203
2023-04-04 22:51:08 +08:00
- G301
- G302
2023-04-05 20:31:23 +08:00
- G303
- G305
2023-04-04 22:51:08 +08:00
- G306
2023-04-04 19:17:38 +08:00
- G401
- G403
2023-05-02 20:31:50 +08:00
- G404
2023-04-04 19:17:38 +08:00
- G501
- G502
- G503
- G505
2023-04-12 22:56:07 +08:00
- G601
2023-05-02 23:40:37 +08:00
# G104, G105, G113, G204, G304, G307, G402, G504 were not enabled intentionally
2023-04-04 22:51:08 +08:00
# To specify the configuration of rules.
config :
# Maximum allowed permissions mode for os.OpenFile and os.Chmod
# Default: "0600"
G302 : "0640"
# Maximum allowed permissions mode for os.WriteFile and ioutil.WriteFile
# Default: "0600"
G306 : "0640"
2023-08-10 05:02:36 +08:00
govet :
settings :
## Check the logging function like it would be a printf
printf :
funcs :
- (github.com/influxdata/telegraf.Logger).Debugf
- (github.com/influxdata/telegraf.Logger).Infof
- (github.com/influxdata/telegraf.Logger).Warnf
- (github.com/influxdata/telegraf.Logger).Errorf
- (github.com/influxdata/telegraf.Logger).Debug
- (github.com/influxdata/telegraf.Logger).Info
- (github.com/influxdata/telegraf.Logger).Warn
- (github.com/influxdata/telegraf.Logger).Error
2022-11-11 23:17:15 +08:00
lll :
# Max line length, lines longer will be reported.
# '\t' is counted as 1 character by default, and can be changed with the tab-width option.
# Default: 120.
line-length : 160
# Tab width in spaces.
# Default: 1
tab-width : 4
2023-02-08 00:06:12 +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
2022-11-22 04:53:55 +08:00
prealloc :
# Report pre-allocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
# Default: true
simple : false
2021-02-19 00:56:10 +08:00
revive :
rules :
2021-03-13 02:14:31 +08:00
- name : argument-limit
arguments : [ 6 ]
- name : atomic
- name : bare-return
2021-02-19 00:56:10 +08:00
- name : blank-imports
2021-03-13 02:14:31 +08:00
- name : bool-literal-in-expr
- name : call-to-gc
- name : confusing-naming
- name : confusing-results
- name : constant-logical-expr
2021-02-19 00:56:10 +08:00
- name : context-as-argument
- name : context-keys-type
2021-03-13 02:14:31 +08:00
- name : deep-exit
- name : defer
2021-02-19 00:56:10 +08:00
- name : dot-imports
2021-03-13 02:14:31 +08:00
- name : duplicated-imports
- name : early-return
- name : empty-block
- name : empty-lines
- name : error-naming
2021-02-19 00:56:10 +08:00
- name : error-return
- name : error-strings
2021-03-13 02:14:31 +08:00
- name : errorf
- name : function-result-limit
arguments : [ 3 ]
- name : identical-branches
2021-02-19 00:56:10 +08:00
- name : if-return
2021-03-13 02:14:31 +08:00
- name : import-shadowing
2021-02-19 00:56:10 +08:00
- name : increment-decrement
2021-03-13 02:14:31 +08:00
- name : indent-error-flow
- name : modifies-parameter
- name : modifies-value-receiver
2021-02-19 00:56:10 +08:00
- name : package-comments
- name : range
2021-03-13 02:14:31 +08:00
- name : range-val-address
- name : range-val-in-closure
2021-02-19 00:56:10 +08:00
- name : receiver-naming
2021-03-13 02:14:31 +08:00
- name : redefines-builtin-id
- name : string-of-int
- name : struct-tag
2021-02-19 00:56:10 +08:00
- name : superfluous-else
2021-03-13 02:14:31 +08:00
- name : time-naming
- name : unconditional-recursion
- name : unexported-naming
- name : unnecessary-stmt
2021-02-19 00:56:10 +08:00
- name : unreachable-code
2022-11-09 03:04:12 +08:00
- name : unused-parameter
2021-03-13 02:14:31 +08:00
- name : var-declaration
- name : var-naming
- name : waitgroup-by-value
nakedret :
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30
max-func-lines : 1
2023-02-08 00:12:42 +08:00
tenv :
# The option `all` will run against whole test files (`_test.go`) regardless of method/function signatures.
# Otherwise, only methods that take `*testing.T`, `*testing.B`, and `testing.TB` as arguments are checked.
# Default: false
all : true
2023-11-02 20:40:30 +08:00
testifylint :
2024-02-12 22:47:15 +08:00
# Disable all checkers (https://github.com/Antonboom/testifylint#checkers).
# Default: false
disable-all : true
2023-11-02 20:40:30 +08:00
# Enable specific checkers.
# https://github.com/Antonboom/testifylint#checkers
# Default: ["bool-compare", "compares", "empty", "error-is-as", "error-nil", "expected-actual", "float-compare", "len", "require-error", "suite-dont-use-pkg", "suite-extra-assert-call"]
enable :
- bool-compare
- compares
- empty
- error-is-as
- error-nil
- expected-actual
- len
- require-error
- suite-dont-use-pkg
- suite-extra-assert-call
- suite-thelper
2021-02-19 00:56:10 +08:00
run :
2021-03-13 02:14:31 +08:00
# timeout for analysis, e.g. 30s, 5m, default is 1m
2021-03-23 01:21:36 +08:00
timeout : 10m
2021-03-13 02:14:31 +08:00
2021-03-02 05:04:35 +08:00
# which dirs to skip: issues from them won't be reported;
# can use regexp here: generated.*, regexp is applied on full path;
# default value is empty list, but default dirs are skipped independently
# from this option's value (see skip-dirs-use-default).
# "/" will be replaced by current OS file path separator to properly work
# on Windows.
2021-02-19 00:56:10 +08:00
skip-dirs :
2021-03-13 02:14:31 +08:00
- assets
2021-02-19 00:56:10 +08:00
- docs
- etc
2021-03-02 05:04:35 +08:00
# which files to skip: they will be analyzed, but issues from them
# won't be reported. Default value is empty list, but there is
# no need to include all autogenerated files, we confidently recognize
# autogenerated files. If it's not please let us know.
# "/" will be replaced by current OS file path separator to properly work
# on Windows.
2021-02-19 00:56:10 +08:00
skip-files :
- plugins/parsers/influx/machine.go*
2024-02-12 22:47:15 +08:00
# Show statistics per linter.
# Default: false
show-stats : true
2021-02-19 00:56:10 +08:00
issues :
2021-03-02 05:04:35 +08:00
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
max-issues-per-linter : 0
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
max-same-issues : 0
2021-03-13 02:14:31 +08:00
2023-03-29 15:50:00 +08:00
# List of regexps of issue texts to exclude.
#
# But independently of this option we use default exclude patterns,
# it can be disabled by `exclude-use-default: false`.
# To list all excluded by default patterns execute `golangci-lint run --help`
#
# Default: https://golangci-lint.run/usage/false-positives/#default-exclusions
2021-03-13 02:14:31 +08:00
exclude :
2023-03-29 15:50:00 +08:00
# revive:var-naming
- don't use an underscore in package name
# EXC0001 errcheck: Almost all programs ignore errors on these functions and in most cases it's ok
2023-04-25 21:15:55 +08:00
- Error return value of .((os\.)?std(out|err)\..*|.*Close.*|.*Flush|.*Disconnect|.*Clear|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked
2023-03-29 15:50:00 +08:00
# EXC0013 revive: Annoying issue about not having a comment. The rare codebase has such comments
- package comment should be of the form "(.+)...
# EXC0015 revive: Annoying issue about not having a comment. The rare codebase has such comments
- should have a package comment
2021-03-13 02:14:31 +08:00
2023-03-29 15:50:00 +08:00
# Excluding configuration per-path, per-linter, per-text and per-source
2021-03-13 02:14:31 +08:00
exclude-rules :
- path : plugins/parsers/influx
linters :
- govet
2023-08-29 22:05:34 +08:00
- path : cmd/telegraf/(main|printer|cmd_plugins).go
2023-05-02 20:31:50 +08:00
text : "Error return value of `outputBuffer.Write` is not checked" #errcheck
2022-10-26 18:06:08 +08:00
2023-05-02 20:31:50 +08:00
- path : _test\.go
text : "Potential hardcoded credentials" #gosec:G101
2023-02-03 17:27:47 +08:00
2023-04-04 02:31:08 +08:00
- path : _test\.go
2023-05-02 20:31:50 +08:00
text : "Use of weak random number generator" #gosec:G404
2023-04-04 02:31:08 +08:00
2023-03-29 15:50:00 +08:00
# Independently of option `exclude` we use default exclude patterns,
# it can be disabled by this option.
# To list all excluded by default patterns execute `golangci-lint run --help`.
# Default: true.
exclude-use-default : false
2023-02-02 21:16:21 +08:00
# output configuration options
2021-03-13 02:14:31 +08:00
output :
2023-02-02 21:16:21 +08:00
# Format: colored-line-number|line-number|json|tab|checkstyle|code-climate|junit-xml|github-actions
#
# Multiple can be specified by separating them by comma, output can be provided
# for each of them by separating format name and path by colon symbol.
# Output path can be either `stdout`, `stderr` or path to the file to write to.
# Example: "checkstyle:report.json,colored-line-number"
#
# Default: colored-line-number
2021-03-13 02:14:31 +08:00
format : tab
2023-02-02 21:16:21 +08:00
# Make issues output unique by line.
# Default: true
uniq-by-line : false
# Sort results by: filepath, line and column.
sort-results : true