-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
.golangci.yml
735 lines (728 loc) · 29.3 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
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-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
exclude-dirs:
- pkg/proto/patches
- tasks/unit_tests/testdata/components_src
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
- "Error return value of `c.logErrorNotImplemented` is not checked" # 'errcheck' errors in pkg/config/nodetreemodel/config.go
- "Error return value of `n.logErrorNotImplemented` is not checked" # 'errcheck' errors in pkg/config/nodetreemodel/config.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]
# 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]
# Treat this list as a TODO for fixing issues with pkgconfigusage custom linter
# DO NOT ADD NEW ENTRIES
- path: comp/api/api/apiimpl/internal/config/endpoint.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/component.go
linters:
- pkgconfigusage
- path: comp/process/forwarders/forwardersimpl/forwarders.go
linters:
- pkgconfigusage
- path: comp/process/profiler/profilerimpl/profiler.go
linters:
- pkgconfigusage
- path: comp/logs/agent/agentimpl/agent.go
linters:
- pkgconfigusage
- path: comp/logs/agent/agentimpl/agent_core_init.go
linters:
- pkgconfigusage
- path: comp/logs/agent/agentimpl/serverless.go
linters:
- pkgconfigusage
- path: comp/logs/agent/agentimpl/agent_test.go
linters:
- pkgconfigusage
- path: comp/core/workloadmeta/collectors/internal/cloudfoundry/vm/cf_vm.go
linters:
- pkgconfigusage
- path: comp/core/workloadmeta/collectors/internal/kubemetadata/kubemetadata.go
linters:
- pkgconfigusage
- path: comp/trace/config/component.go
linters:
- pkgconfigusage
- path: comp/trace/config/config.go
linters:
- pkgconfigusage
- path: comp/trace/config/config_mock.go
linters:
- pkgconfigusage
- path: comp/trace/config/hostname.go
linters:
- pkgconfigusage
- path: comp/trace/config/remote.go
linters:
- pkgconfigusage
- path: comp/trace/config/setup.go
linters:
- pkgconfigusage
- path: comp/trace/config/config_test.go
linters:
- pkgconfigusage
- path: comp/remote-config/rcclient/rcclientimpl/rcclient.go
linters:
- pkgconfigusage
- path: comp/remote-config/rcclient/rcclientimpl/rcclient_test.go
linters:
- pkgconfigusage
- path: comp/agent/cloudfoundrycontainer/cloudfoundrycontainerimpl/cloudfoundrycontainer.go
linters:
- pkgconfigusage
- path: comp/metadata/internal/util/inventory_enabled.go
linters:
- pkgconfigusage
- path: comp/process/expvars/expvarsimpl/expvars.go
linters:
- pkgconfigusage
- path: comp/core/workloadmeta/collectors/internal/cloudfoundry/container/cf_container.go
linters:
- pkgconfigusage
- path: comp/api/api/apiimpl/listener.go
linters:
- pkgconfigusage
- path: comp/api/api/apiimpl/server.go
linters:
- pkgconfigusage
- path: comp/api/api/apiimpl/server_cmd.go
linters:
- pkgconfigusage
- path: comp/api/api/apiimpl/server_ipc.go
linters:
- pkgconfigusage
- path: comp/metadata/host/hostimpl/utils/common.go
linters:
- pkgconfigusage
- path: comp/metadata/host/hostimpl/utils/host.go
linters:
- pkgconfigusage
- path: comp/metadata/host/hostimpl/utils/meta.go
linters:
- pkgconfigusage
- path: comp/metadata/host/hostimpl/utils/host_test.go
linters:
- pkgconfigusage
- path: comp/core/workloadmeta/collectors/internal/remote/processcollector/process_collector.go
linters:
- pkgconfigusage
- path: comp/core/workloadmeta/collectors/internal/remote/processcollector/process_collector_test.go
linters:
- pkgconfigusage
- path: comp/aggregator/demultiplexer/demultiplexerimpl/test_agent_demultiplexer.go
linters:
- pkgconfigusage
- path: comp/metadata/host/hostimpl/host.go
linters:
- pkgconfigusage
- path: comp/metadata/host/hostimpl/payload.go
linters:
- pkgconfigusage
- path: comp/core/tagger/taggerimpl/collectors/ecs_common.go
linters:
- pkgconfigusage
- path: comp/core/tagger/taggerimpl/collectors/workloadmeta_extract.go
linters:
- pkgconfigusage
- path: comp/core/tagger/taggerimpl/collectors/workloadmeta_main.go
linters:
- pkgconfigusage
- path: comp/core/tagger/taggerimpl/collectors/ecs_common_test.go
linters:
- pkgconfigusage
- path: comp/core/workloadmeta/collectors/internal/kubelet/kubelet.go
linters:
- pkgconfigusage
- path: comp/metadata/inventoryotel/inventoryotelimpl/inventoryotel_test.go
linters:
- pkgconfigusage
- path: comp/metadata/host/hostimpl/hosttags/tags.go
linters:
- pkgconfigusage
- path: comp/metadata/host/hostimpl/hosttags/tags_test.go
linters:
- pkgconfigusage
- path: comp/dogstatsd/listeners/ratelimit/mem_based_rate_limiter.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/cloudfoundry.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/clusterchecks.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/config_reader.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/consul.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/container.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/endpointschecks.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/etcd.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/kube_endpoints.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/kube_endpoints_file.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/kube_services.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/kube_services_file.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/prometheus_common.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/prometheus_pods.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/prometheus_services.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/providers.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/remote_config.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/utils.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/zookeeper.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/file_test.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/kube_endpoints_test.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/kube_services_test.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/prometheus_common_test.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/prometheus_services_test.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/utils_test.go
linters:
- pkgconfigusage
- path: comp/dogstatsd/listeners/named_pipe_nowindows.go
linters:
- pkgconfigusage
- path: comp/dogstatsd/listeners/udp.go
linters:
- pkgconfigusage
- path: comp/dogstatsd/listeners/uds_common.go
linters:
- pkgconfigusage
- path: comp/dogstatsd/listeners/uds_datagram.go
linters:
- pkgconfigusage
- path: comp/dogstatsd/listeners/uds_stream.go
linters:
- pkgconfigusage
- path: comp/metadata/inventoryagent/inventoryagentimpl/inventoryagent_test.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/common/utils/container_collect_all.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/common/utils/prometheus.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/common/utils/prometheus_apiserver_test.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/common/utils/prometheus_kubelet_test.go
linters:
- pkgconfigusage
- path: comp/dogstatsd/serverDebug/serverdebugimpl/debug.go
linters:
- pkgconfigusage
- path: comp/otelcol/otlp/collector_test.go
linters:
- pkgconfigusage
- path: comp/core/hostname/remotehostnameimpl/hostname.go
linters:
- pkgconfigusage
- path: comp/trace/agent/impl/agent.go
linters:
- pkgconfigusage
- path: comp/trace/agent/impl/run.go
linters:
- pkgconfigusage
- path: comp/dogstatsd/server/batch.go
linters:
- pkgconfigusage
- path: comp/dogstatsd/server/float64_list_pool.go
linters:
- pkgconfigusage
- path: comp/dogstatsd/server/parse.go
linters:
- pkgconfigusage
- path: comp/dogstatsd/server/server.go
linters:
- pkgconfigusage
- path: comp/dogstatsd/server/serverless.go
linters:
- pkgconfigusage
- path: comp/dogstatsd/server/server_bench_test.go
linters:
- pkgconfigusage
- path: comp/dogstatsd/server/server_test.go
linters:
- pkgconfigusage
- path: comp/process/agent/agentimpl/agent.go
linters:
- pkgconfigusage
- path: comp/process/apiserver/apiserver.go
linters:
- pkgconfigusage
- path: comp/remote-config/rcservice/rcserviceimpl/rcservice.go
linters:
- pkgconfigusage
- path: comp/netflow/config/config_test.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/listeners/common.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/listeners/container.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/listeners/environment.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/listeners/kubelet.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/listeners/service.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/listeners/staticconfig.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/listeners/snmp_test.go
linters:
- pkgconfigusage
- path: comp/core/tagger/params.go
linters:
- pkgconfigusage
- path: comp/remote-config/rcservicemrf/rcservicemrfimpl/rcservicemrf.go
linters:
- pkgconfigusage
- path: comp/process/status/statusimpl/status.go
linters:
- pkgconfigusage
- path: comp/agent/jmxlogger/jmxloggerimpl/jmxlogger.go
linters:
- pkgconfigusage
- path: comp/core/tagger/taggerimpl/remote/tagger.go
linters:
- pkgconfigusage
- path: comp/dogstatsd/mapper/mapper.go
linters:
- pkgconfigusage
- path: comp/dogstatsd/mapper/mapper_test.go
linters:
- pkgconfigusage
- path: comp/core/workloadmeta/collectors/internal/remote/workloadmeta/workloadmeta.go
linters:
- pkgconfigusage
- path: comp/core/workloadmeta/collectors/internal/remote/workloadmeta/workloadmeta_test.go
linters:
- pkgconfigusage
- path: comp/forwarder/eventplatform/eventplatformimpl/epforwarder.go
linters:
- pkgconfigusage
- path: comp/core/gui/guiimpl/checks.go
linters:
- pkgconfigusage
- path: comp/dogstatsd/replay/impl/capture.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/autodiscoveryimpl/autoconfig.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/autodiscoveryimpl/secrets.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/autodiscoveryimpl/autoconfig_test.go
linters:
- pkgconfigusage
- path: comp/dogstatsd/packets/pool.go
linters:
- pkgconfigusage
- path: comp/process/agent/status.go
linters:
- pkgconfigusage
- path: comp/core/sysprobeconfig/component.go
linters:
- pkgconfigusage
- path: comp/core/tagger/taglist/taglist.go
linters:
- pkgconfigusage
- path: comp/core/workloadmeta/collectors/internal/remote/generic.go
linters:
- pkgconfigusage
- path: comp/core/hostname/hostnameimpl/service_test.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/status/status.go
linters:
- pkgconfigusage
- path: comp/core/sysprobeconfig/sysprobeconfigimpl/config.go
linters:
- pkgconfigusage
- path: comp/core/workloadmeta/collectors/internal/docker/docker.go
linters:
- pkgconfigusage
- path: comp/core/workloadmeta/collectors/internal/docker/image_sbom_trivy.go
linters:
- pkgconfigusage
- path: comp/core/workloadmeta/collectors/internal/containerd/containerd.go
linters:
- pkgconfigusage
- path: comp/core/workloadmeta/collectors/internal/containerd/image_sbom_trivy.go
linters:
- pkgconfigusage
- path: comp/core/workloadmeta/collectors/internal/containerd/network_linux.go
linters:
- pkgconfigusage
- path: comp/core/workloadmeta/collectors/internal/ecs/ecs.go
linters:
- pkgconfigusage
- path: comp/core/workloadmeta/collectors/internal/ecsfargate/ecsfargate.go
linters:
- pkgconfigusage
- path: comp/core/workloadmeta/collectors/internal/podman/podman.go
linters:
- pkgconfigusage
- path: comp/core/workloadmeta/collectors/internal/process/process_collector.go
linters:
- pkgconfigusage
- path: comp/core/workloadmeta/collectors/util/process_util_linux.go
linters:
- pkgconfigusage
- path: comp/dogstatsd/listeners/ratelimit/cgroup_memory_usage_linux.g
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/cloudfoundry_nop.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/consul_nop.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/endpointschecks_nop.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/etcd_nop.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/kube_endpoints_file_nop.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/kube_endpoints_nop.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/kube_services_file_nop.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/kube_services_nop.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/prometheus_pods_nop.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/prometheus_services_nop.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/zookeeper_nop.go
linters:
- pkgconfigusage
- path: comp/otelcol/otlp/no_otlp.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/cloudfoundry_nop.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/consul_nop.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/etcd_nop.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/kube_endpoints_file_nop.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/kube_endpoints_nop.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/kube_services_file_nop.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/kube_services_nop.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/prometheus_services_nop.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/zookeeper_nop.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/cloudfoundry_nop.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/endpointschecks_nop.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/kube_endpoints_file_nop.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/kube_endpoints_nop.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/kube_services_file_nop.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/kube_services_nop.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/prometheus_pods_nop.go
linters:
- pkgconfigusage
- path: comp/core/autodiscovery/providers/prometheus_services_nop.go
linters:
- pkgconfigusage
- path: comp/systray/systray/systrayimpl/doflare.go
linters:
- pkgconfigusage
- path: comp/dogstatsd/listeners/named_pipe_windows.go
linters:
- pkgconfigusage
- path: comp/dogstatsd/packets/packet_manager_windows.go
linters:
- pkgconfigusage
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.
- gocheckcompilerdirectives # Checks Go compiler directives syntax
- pkgconfigusage # Linter for checking usage of pkgconfig inside components folder
- forbidigo # prevent usage of unwanted/deprecated symbol in the code base
linters-settings:
depguard:
rules:
main:
files:
- $all
deny:
- pkg: "io/ioutil"
desc: "Deprecated since Go 1.16. Use package io or os instead."
- pkg: "github.com/golang/glog"
desc: "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
- pkg: "gotest.tools/assert"
desc: "Not really forbidden to use, but it is usually imported by mistake instead of github.com/stretchr/testify/assert"
- pkg: "github.com/tj/assert"
desc: "Not really forbidden to use, but it is usually imported by mistake instead of github.com/stretchr/testify/assert, and confusing since it actually has the behavior of github.com/stretchr/testify/require"
- pkg: "debug/elf"
desc: "prefer pkg/util/safeelf to prevent panics during parsing"
errcheck:
exclude-functions:
- (*github.com/DataDog/datadog-agent/pkg/collector/corechecks.CheckBase).Warn
- (*github.com/DataDog/datadog-agent/pkg/collector/corechecks.CheckBase).Warnf
- (*github.com/lxn/walk.NotifyIcon).Dispose
- (*golang.org/x/sys/windows/svc/mgr.Mgr).Disconnect
- (github.com/DataDog/datadog-agent/comp/core/flare/builder.FlareBuilder).AddFile
- (github.com/DataDog/datadog-agent/comp/core/flare/builder.FlareBuilder).AddFileFromFunc
- (github.com/DataDog/datadog-agent/comp/core/flare/builder.FlareBuilder).AddFileWithoutScrubbing
- (github.com/DataDog/datadog-agent/comp/core/flare/builder.FlareBuilder).CopyDir
- (github.com/DataDog/datadog-agent/comp/core/flare/builder.FlareBuilder).CopyDirTo
- (github.com/DataDog/datadog-agent/comp/core/flare/builder.FlareBuilder).CopyDirToWithoutScrubbing
- (github.com/DataDog/datadog-agent/comp/core/flare/builder.FlareBuilder).CopyFile
- (github.com/DataDog/datadog-agent/comp/core/flare/builder.FlareBuilder).CopyFileTo
- (github.com/DataDog/datadog-agent/comp/core/log/def.Component).ChangeLogLevel
- (github.com/DataDog/datadog-agent/comp/core/log/def.Component).Critical
- (github.com/DataDog/datadog-agent/comp/core/log/def.Component).Criticalf
- (github.com/DataDog/datadog-agent/comp/core/log/def.Component).Error
- (github.com/DataDog/datadog-agent/comp/core/log/def.Component).Errorf
- (github.com/DataDog/datadog-agent/comp/core/log/def.Component).Warn
- (github.com/DataDog/datadog-agent/comp/core/log/def.Component).Warnf
- (net/http.ResponseWriter).Write
- fmt.Sscanf
- github.com/cihub/seelog.Warnf
- github.com/DataDog/datadog-agent/pkg/util/log.ChangeLogLevel
- github.com/DataDog/datadog-agent/pkg/util/log.Critical
- github.com/DataDog/datadog-agent/pkg/util/log.Criticalc
- github.com/DataDog/datadog-agent/pkg/util/log.Criticalf
- github.com/DataDog/datadog-agent/pkg/util/log.CriticalStackDepth
- github.com/DataDog/datadog-agent/pkg/util/log.Error
- github.com/DataDog/datadog-agent/pkg/util/log.Errorc
- github.com/DataDog/datadog-agent/pkg/util/log.Errorf
- github.com/DataDog/datadog-agent/pkg/util/log.ErrorStackDepth
- github.com/DataDog/datadog-agent/pkg/util/log.JMXError
- github.com/DataDog/datadog-agent/pkg/util/log.logContextWithError
- github.com/DataDog/datadog-agent/pkg/util/log.logFormatWithError
- github.com/DataDog/datadog-agent/pkg/util/log.Warn
- github.com/DataDog/datadog-agent/pkg/util/log.Warnc
- github.com/DataDog/datadog-agent/pkg/util/log.Warnf
- github.com/DataDog/datadog-agent/pkg/util/log.WarnStackDepth
- golang.org/x/sys/windows.CloseHandle
- golang.org/x/sys/windows.FreeLibrary
- golang.org/x/sys/windows.FreeSid
- golang.org/x/sys/windows.LocalFree
- golang.org/x/sys/windows.RegCloseKey
- golang.org/x/sys/windows.SetEvent
- golang.org/x/sys/windows/registry.Close
- golang.org/x/sys/windows/svc/debug.Close
- golang.org/x/sys/windows/svc/debug.Error
- golang.org/x/sys/windows/svc/debug.Info
- golang.org/x/sys/windows/svc/debug.Warning
- pkg/util/log.JMXError
- syscall.CloseHandle
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
"-SA4023" # Fix the lint_macos_gitlab_amd64 linter discrepancy while we find the issue (see https://github.com/dominikh/go-tools/issues/847)
]
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
revive:
# in order to change revive config, the default configuration must be explicitly defined
# https://github.com/mgechev/revive/blob/master/defaults.toml
#
# see https://github.com/golangci/golangci-lint/blob/master/.golangci.reference.yml for the golangci-lint config syntax
ignore-generated-header: false
severity: "warning"
confidence: 0.8
rules:
- name: blank-imports
- name: context-as-argument
- name: context-keys-type
- name: dot-imports
- name: empty-block
- name: error-naming
- name: error-return
- name: error-strings
- name: errorf
- name: exported
- name: increment-decrement
- name: indent-error-flow
- name: package-comments
- name: range
- name: receiver-naming
- name: redefines-builtin-id
- name: superfluous-else
- name: time-naming
- name: unexported-return
- name: unreachable-code
- name: unused-parameter
arguments:
- allowRegex: "^_"
- name: var-declaration
- name: var-naming
# non-default rules:
- name: duplicated-imports
forbidigo:
forbid:
- p: ^model.NewConfig.*$
pkg: ^github.com/DataDog/datadog-agent/pkg/config/model$
msg: use pkg/config/mock instead in tests or the config component
- p: ^setup.SetDatadog.*$
pkg: ^github.com/DataDog/datadog-agent/pkg/config/setup$
msg: use pkg/config/mock instead for tests or the config component
- p: ^setup.SetSystemProbe.*$
pkg: ^github.com/DataDog/datadog-agent/pkg/config/setup$
msg: use pkg/config/mock instead for tests or the config component
analyze-types: true
custom:
pkgconfigusage:
type: "module"
description: "Check usage of pkgconfig in components folder"