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
2024-06-21 04:43:02 +08:00
- copyloopvar
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
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
2024-06-17 22:21:30 +08:00
- mirror
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 :
2024-09-11 23:19:12 +08:00
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`.
# Such cases aren't reported by default.
# Default: false
check-blank : true
2023-04-03 21:19:43 +08:00
# 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"
2024-07-10 18:51:25 +08:00
- "(*github.com/influxdata/telegraf/plugins/outputs/postgresql/sqltemplate.Template).UnmarshalText"
2024-09-11 23:19:12 +08:00
2023-05-18 00:30:10 +08:00
gocritic :
2024-03-30 02:27:10 +08:00
# Disable all checks.
# Default: false
disable-all : true
# Which checks should be enabled in addition to default checks; can't be combined with 'disabled-checks'.
2025-01-14 16:36:04 +08:00
# By default, list of stable checks is used (https://go-critic.com/overview#checks-overview).
2024-03-30 02:27:10 +08:00
# To see which checks are enabled run `GL_DEBUG=gocritic golangci-lint run --enable=gocritic`.
2023-05-18 00:30:10 +08:00
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
2024-06-17 22:24:01 +08:00
- badSyncOnceFunc
2023-05-18 00:30:10 +08:00
- builtinShadowDecl
- caseOrder
- codegenComment
2023-08-04 00:58:27 +08:00
- commentedOutCode
2023-05-19 15:55:08 +08:00
- deferInLoop
2023-08-04 00:58:27 +08:00
- deprecatedComment
2024-11-13 05:49:39 +08:00
- dupArg
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
2024-06-17 22:23:32 +08:00
- sloppyLen
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
- hugeParam
2024-11-13 05:49:39 +08:00
- indexAlloc
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.
2025-01-14 16:36:04 +08:00
# The list of supported checkers can be find in https://go-critic.com/overview.
2023-12-15 22:36:34 +08:00
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 :
2025-01-14 16:36:04 +08:00
- G101 # Look for hard coded credentials
- G102 # Bind to all interfaces
- G103 # Audit the use of unsafe block
- G106 # Audit the use of ssh.InsecureIgnoreHostKey
- G107 # Url provided to HTTP request as taint input
- G108 # Profiling endpoint automatically exposed on /debug/pprof
- G109 # Potential Integer overflow made by strconv.Atoi result conversion to int16/32
- G110 # Potential DoS vulnerability via decompression bomb
- G111 # Potential directory traversal
- G112 # Potential slowloris attack
- G114 # Use of net/http serve function that has no support for setting timeouts
- G201 # SQL query construction using format string
- G202 # SQL query construction using string concatenation
- G203 # Use of unescaped data in HTML templates
- G301 # Poor file permissions used when creating a directory
- G302 # Poor file permissions used with chmod
- G303 # Creating tempfile using a predictable path
- G305 # File traversal when extracting zip/tar archive
- G306 # Poor file permissions used when writing to a new file
- G401 # Detect the usage of MD5 or SHA1
- G403 # Ensure minimum RSA key length of 2048 bits
- G404 # Insecure random number source (rand)
- G405 # Detect the usage of DES or RC4
- G406 # Detect the usage of MD4 or RIPEMD160
- G501 # Import blocklist : crypto/md5
- G502 # Import blocklist : crypto/des
- G503 # Import blocklist : crypto/rc4
- G505 # Import blocklist : crypto/sha1
- G506 # Import blocklist : golang.org/x/crypto/md4
- G507 # Import blocklist : golang.org/x/crypto/ripemd160
- G601 # Implicit memory aliasing of items from a range statement
- G602 # Slice access out of bounds
2023-05-02 23:40:37 +08:00
# G104, G105, G113, G204, G304, G307, G402, G504 were not enabled intentionally
2024-09-11 23:19:12 +08:00
# TODO: review G115 when reporting false positives is fixed (https://github.com/securego/gosec/issues/1212)
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 :
2024-03-30 02:27:10 +08:00
# Comma-separated list of print function names to check (in addition to default, see `go tool vet help printf`).
# Default: []
2023-08-10 05:02:36 +08:00
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
2024-03-30 02:27:10 +08:00
nakedret :
# Make an issue if func has more lines of code than this setting, and it has naked returns.
# Default: 30
max-func-lines : 1
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
2024-09-24 00:20:25 +08:00
- name : comment-spacings
2021-03-13 02:14:31 +08:00
- 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
2024-10-08 17:10:39 +08:00
- name : datarace
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
2024-10-28 20:59:26 +08:00
- name : enforce-map-style
arguments : [ "make" ]
exclude : [ "TEST" ]
2024-11-14 23:14:40 +08:00
- name : enforce-repeated-arg-type-style
arguments : [ "short" ]
2024-11-13 15:24:35 +08:00
- name : enforce-slice-style
arguments : [ "make" ]
2021-03-13 02:14:31 +08:00
- 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 ]
2024-09-13 05:01:48 +08:00
- name : get-return
2021-03-13 02:14:31 +08:00
- name : identical-branches
2021-02-19 00:56:10 +08:00
- name : if-return
2024-10-02 02:49:53 +08:00
- name : import-alias-naming
arguments :
- "^[a-z][a-z0-9_]*[a-z0-9]+$"
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
2024-12-05 22:31:11 +08:00
- name : max-public-structs
exclude : [ "TEST" ]
arguments : [ 5 ]
2021-03-13 02:14:31 +08:00
- name : modifies-parameter
- name : modifies-value-receiver
2024-09-05 00:02:50 +08:00
- name : optimize-operands-order
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
2024-10-02 02:49:53 +08:00
- name : redundant-import-alias
2024-10-09 15:07:46 +08:00
- name : string-format
arguments :
2024-11-13 05:49:39 +08:00
- - 'fmt.Errorf[0],errors.New[0]'
2024-10-09 15:07:46 +08:00
- '/^([^A-Z]|$)/'
- 'Error string must not start with a capital letter.'
2024-11-13 05:49:39 +08:00
- - 'fmt.Errorf[0],errors.New[0]'
2024-10-09 15:07:46 +08:00
- '/(^|[^\.!?])$/'
- 'Error string must not end in punctuation.'
- - 'panic'
- '/^[^\n]*$/'
- 'Must not contain line breaks.'
2021-03-13 02:14:31 +08:00
- name : string-of-int
- name : struct-tag
2021-02-19 00:56:10 +08:00
- name : superfluous-else
2024-09-06 00:19:17 +08:00
- name : time-equal
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
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
2024-03-30 02:27:10 +08:00
# Enable checkers by name
2023-11-02 20:40:30 +08:00
enable :
2024-07-01 21:00:13 +08:00
- blank-import
2023-11-02 20:40:30 +08:00
- bool-compare
- compares
2024-12-12 04:32:16 +08:00
- contains
2023-11-02 20:40:30 +08:00
- empty
2024-12-12 04:32:16 +08:00
- encoded-compare
2023-11-02 20:40:30 +08:00
- error-is-as
- error-nil
- expected-actual
2024-07-01 21:00:13 +08:00
- float-compare
2024-09-04 00:40:34 +08:00
- formatter
2024-11-13 15:32:57 +08:00
- go-require
2023-11-02 20:40:30 +08:00
- len
2024-07-01 21:00:13 +08:00
- negative-positive
- nil-compare
2024-12-12 04:32:16 +08:00
- regexp
2023-11-02 20:40:30 +08:00
- require-error
2024-09-04 00:40:34 +08:00
- suite-broken-parallel
2023-11-02 20:40:30 +08:00
- suite-dont-use-pkg
- suite-extra-assert-call
2024-09-04 00:40:34 +08:00
- suite-subtest-run
2023-11-02 20:40:30 +08:00
- suite-thelper
2024-07-01 21:00:13 +08:00
- useless-assert
2021-02-19 00:56:10 +08:00
issues :
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
2024-03-30 02:27:10 +08:00
# 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
2024-07-10 18:51:25 +08:00
- path : plugins/inputs/win_perf_counters/pdh.go
2024-06-12 21:52:42 +08:00
linters :
- errcheck
2024-06-04 16:33:37 +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
2024-09-17 05:22:27 +08:00
- path-except : ^plugins/(aggregators|inputs|outputs|parsers|processors|serializers)/...
2024-12-05 22:31:11 +08:00
text : "max-public-structs: you have exceeded the maximum number" #revive:max-public-structs
2024-09-17 05:22:27 +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`.
2024-03-30 02:27:10 +08:00
# Default: true
2023-03-29 15:50:00 +08:00
exclude-use-default : false
2024-03-30 02:27:10 +08:00
# Which dirs to exclude: issues from them won't be reported.
# Can use regexp here: `generated.*`, regexp is applied on full path,
# including the path prefix if one is set.
# Default dirs are skipped independently of this option's value (see exclude-dirs-use-default).
# "/" will be replaced by current OS file path separator to properly work on Windows.
# Default: []
exclude-dirs :
- assets
- docs
- etc
# Which files to exclude: they will be analyzed, but issues from them won't be reported.
# 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.
# Default: []
exclude-files :
- plugins/parsers/influx/machine.go*
# Maximum issues count per one linter.
# Set to 0 to disable.
# Default: 50
max-issues-per-linter : 0
# Maximum count of issues with the same text.
# Set to 0 to disable.
# Default: 3
max-same-issues : 0
2025-01-14 16:36:04 +08:00
# Make issues output unique by line.
# Default: true
uniq-by-line : false
2023-02-02 21:16:21 +08:00
# output configuration options
2021-03-13 02:14:31 +08:00
output :
2024-03-30 02:27:10 +08:00
# The formats used to render issues.
2024-06-11 16:38:08 +08:00
# Formats:
# - `colored-line-number`
# - `line-number`
# - `json`
# - `colored-tab`
# - `tab`
# - `html`
# - `checkstyle`
# - `code-climate`
# - `junit-xml`
2024-09-11 23:19:12 +08:00
# - `junit-xml-extended`
2024-06-11 16:38:08 +08:00
# - `github-actions`
# - `teamcity`
# - `sarif`
2023-02-02 21:16:21 +08:00
# Output path can be either `stdout`, `stderr` or path to the file to write to.
#
2024-03-30 02:27:10 +08:00
# For the CLI flag (`--out-format`), multiple formats can be specified by separating them by comma.
# The output can be specified for each of them by separating format name and path by colon symbol.
# Example: "--out-format=checkstyle:report.xml,json:stdout,colored-line-number"
# The CLI flag (`--out-format`) override the configuration file.
#
# Default:
# formats:
# - format: colored-line-number
# path: stdout
formats :
- format : tab
path : stdout
# Sort results by the order defined in `sort-order`.
# Default: false
2023-02-02 21:16:21 +08:00
sort-results : true
2024-03-30 02:27:10 +08:00
# Show statistics per linter.
# Default: false
show-stats : true
2024-11-13 05:49:39 +08:00
2025-01-14 16:36:04 +08:00
# Options for analysis running.
2024-11-13 05:49:39 +08:00
run :
# Timeout for analysis, e.g. 30s, 5m.
2025-01-14 16:36:04 +08:00
# If the value is lower or equal to 0, the timeout is disabled.
2024-11-13 05:49:39 +08:00
# Default: 1m
timeout : 10m