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 :
2021-04-27 05:12:58 +08:00
# - telegraflinter
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
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
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 :
# Kind of list is passed in.
# Allowed values: allowlist|denylist
# Default: denylist
list-type : denylist
# Check the list against standard lib.
# Default: false
include-go-root : true
# A list of packages for the list type specified.
# Can accept both string prefixes and string glob patterns.
# Default: []
packages :
- log
# A list of packages for the list type specified.
# Specify an error message to output when a denied package is used.
# Default: []
packages-with-error-message :
- log : 'Use injected telegraf.Logger instead'
# Specify rules by which the linter ignores certain files for consideration.
# Can accept both string prefixes and string glob patterns.
# The ! character in front of the rule is a special character
# which signals that the linter should negate the rule.
# This allows for more precise control, but it is only available for glob patterns.
# Default: []
ignore-file-rules :
- "**/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 :
- argOrder
- badCall
- badCond
- badLock
- badSorting
- builtinShadowDecl
- caseOrder
- codegenComment
2023-05-19 15:55:08 +08:00
- deferInLoop
2023-05-18 00:30:10 +08:00
- dupBranchBody
- dupCase
- dupSubExpr
- emptyDecl
- evalOrder
2023-05-19 15:55:08 +08:00
- exitAfterDefer
2023-05-18 00:30:10 +08:00
- externalErrorReassign
- nilValReturn
- regexpPattern
- sloppyTypeAssert
- sortSlice
- sqlQuery
- uncheckedInlineErr
2023-05-19 15:55:08 +08:00
- unnecessaryDefer
2023-05-18 00:30:10 +08:00
- weakCond
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"
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
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*
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
2022-10-26 18:06:08 +08:00
- path : cmd/telegraf/(main|printer).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