forked from DataDog/datadog-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.golangci.yml
121 lines (112 loc) · 7.34 KB
/
.golangci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
run:
skip-files:
- pkg/util/cloudproviders/cloudfoundry/bbscache_test.go # implements interface from imported package whose method names fail linting
- pkg/util/intern/string.go # TODO: fix govet 'unsafeptr' error
- pkg/serverless/trace/inferredspan/constants.go # TODO: fox revive exported const error
skip-dirs:
- pkg/proto/patches
issues:
exclude-use-default: false
# Do not limit the number of issues per linter.
max-issues-per-linter: 0
# Do not limit the number of times a same issue is reported.
max-same-issues: 0
exclude:
- "Error return value of `io.WriteString` is not checked" # 'errcheck' errors in tools/dep_tree_resolver/go_deps.go
- "Error return value of `pem.Encode` is not checked" # 'errcheck' errors in test/integration/utils/certificates.go
- "exported: exported const Exec should have comment \\(or a comment on this block\\) or be unexported" # 'revive' errors in pkg/process/events/model/model_common.go
- "exported: exported const APIName should have comment \\(or a comment on this block\\) or be unexported" # 'revive' errors in pkg/serverless/trace/inferredspan/constants.go
- "unnecessary conversion" # 'unconvert' errors in test/integration/utils/certificates_test.go
- "Error return value of .((os\\.)?std(out|err)\\..*|.*Close|.*Flush|os\\.Remove(All)?|.*print(f|ln)?|os\\.(Un)?Setenv). is not checked"
- "`eventContext` is unused"
- "`\\(\\*DatadogLogger\\).changeLogLevel` is unused"
- "`defaultRetryDuration` is unused" # used by APM and Process
- "`defaultRetries` is unused" # used by APM and Process
- "python._Ctype_char, which can be annoying to use" # ignore warning about returning unexported field from CGO
# ignore warning on linux about fields used only on windows
- "`context` is unused"
- "`id` is unused"
exclude-rules:
# Exclude some linters from running on tests files.
- path: _test\.go
linters:
- errcheck
# disable typecheck in folder where it breaks because of build tags
- path: "pkg/security/"
linters: [typecheck]
- path: "pkg/process/"
linters: [typecheck]
# Ignore name repetition for checks (docker.Docker*, jmx.JMX*, etc.)
- path: pkg/collector/corechecks/
text: "name will be used as .* by other packages, and that stutters"
- path: pkg/util/docker/
text: "name will be used as .* by other packages, and that stutters"
- path: pkg/util/containers/cri
text: "name will be used as .* by other packages, and that stutters"
- path: pkg/util/containerd
text: "name will be used as .* by other packages, and that stutters"
# Should be replaced by google.golang.org/protobuf but is not a drop-in replacement
- text: "\"github.com/golang/protobuf/proto\" is deprecated"
linters: [staticcheck]
# Can't rely on getting the same elements after calling Seed because dependencies could be using
# it too. Should be replaced by using a local source, but there are too many uses in the repo.
- text: "rand.Seed has been deprecated since Go 1.20"
linters: [staticcheck]
# net.Error.Temporary() isn't properly defined and was thus deprecated.
# We are using it and it's not clear how to replace it.
- text: "Temporary has been deprecated since Go 1.18"
linters: [staticcheck]
# We're enabling the revive and the gosimple linters on the whole codebase
# TODO [After 7.48.0 freeze removal]: Remove the new-from-rev key
# TODO [After 7.48.0 freeze removal]: Tweak the KUBERNETES_MEMORY_LIMIT in .tests_linux_ebpf for runners not to fail running on the whole codebase (and not just the small diff induced by new-from-rev).
new-from-rev: f40667d3841c6339be0d00d53e54a4a63f43f11e
linters:
disable-all: true
enable:
- unconvert # Remove unnecessary type conversions
- unused # Checks Go code for unused constants, variables, functions and types
- ineffassign # Detects when assignments to existing variables are not used
- misspell # Finds commonly misspelled English words in comments
- gofmt # Gofmt checks whether code was gofmt-ed
- revive # Revive is a replacement for golint, a coding style checker
- errcheck # errcheck is a program for checking for unchecked errors in go programs.
- staticcheck # staticcheck is a go vet on steroids, applying a ton of static analysis checks
- govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
- depguard # Depguard is useful for preventing specific packages from being used
- bodyclose # checks whether HTTP response body is closed successfully
- gosimple # Linter for Go source code that specializes in simplifying code.
linters-settings:
depguard:
include-go-root: true
packages-with-error-message:
- sync/atomic: "Use go.uber.org/atomic instead; see docs/dev/atomics.md"
- io/ioutil: "Deprecated since Go 1.16. Use package io or os instead."
- github.com/golang/glog: "Crashes Windows nanoserver and significantly delays Agent startup on Windows Domain Controllers."
# IDE auto-imports often import `gotest.tools/assert` instead of `testify/assert` by default
# feel free to remove the following line if you really need it in several files as opposed to testify/assert
# note that if it's just for a single file, you can just add `//nolint:depguard` before the import
# the goal is just to limit the risk of accidental imports
- gotest.tools/assert: "Not really forbidden to use, but it is usually imported by mistake instead of github.com/stretchr/testify/assert"
errcheck:
# Disable warnings for `fmt`, `log` and `seelog` packages. Also ignore `Write` functions from `net/http` package.
# Disable warnings for select Windows functions
ignore: fmt:.*,github.com/DataDog/datadog-agent/pkg/util/log:.*,github.com/DataDog/datadog-agent/comp/core/log:.*,github.com/cihub/seelog:.*,net/http:Write,github.com/DataDog/datadog-agent/pkg/trace/metrics:.*,github.com/DataDog/datadog-agent/pkg/collector/corechecks:Warnf?,golang.org/x/sys/windows:(CloseHandle|FreeLibrary|FreeSid|RegCloseKey|SetEvent|LocalFree),syscall:CloseHandle,golang.org/x/sys/windows/svc/mgr:Disconnect,golang.org/x/sys/windows/svc/debug:(Close|Error|Info|Warning),github.com/lxn/walk:Dispose,github.com/DataDog/datadog-agent/comp/core/flare/types:(AddFile.*|CopyDir.*|CopyFile.*),golang.org/x/sys/windows/registry:Close
staticcheck:
checks: ["all",
"-ST1000", "-ST1003", "-ST1016", "-ST1020", "-ST1021", "-ST1022", # These ones are disabled by default on staticcheck
"-ST1013", # Use HTTP code enums instead of integers
# Actual issues that should be fixed eventually
"-SA6002", # TODO: Fix sync.Pools
"-SA4025", # TODO: Fix trace unit test
"-SA4011", "-SA4031" # Disabling these to re-enable golanci-lint default tests
]
govet:
settings:
printf:
funcs:
- github.com/DataDog/datadog-agent/pkg/util/log.Tracef
- github.com/DataDog/datadog-agent/pkg/util/log.Debugf
- github.com/DataDog/datadog-agent/pkg/util/log.Infof
- github.com/DataDog/datadog-agent/pkg/util/log.Printf
- github.com/DataDog/datadog-agent/pkg/util/log.Warnf
- github.com/DataDog/datadog-agent/pkg/util/log.Errorf