-
Notifications
You must be signed in to change notification settings - Fork 141
Expand file tree
/
Copy path.golangci.yml
More file actions
87 lines (77 loc) · 3.19 KB
/
Copy path.golangci.yml
File metadata and controls
87 lines (77 loc) · 3.19 KB
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
version: "2"
linters:
enable:
- contextcheck
- errorlint
- exhaustive
- forbidigo
- gocognit
- gocritic
- gocyclo
- nilerr
- revive
- unparam
- unused
settings:
gocyclo:
# TODO: lower to 25 as complex functions are refactored.
min-complexity: 42
gocognit:
# TODO: lower to 40 as complex functions are refactored.
min-complexity: 62
gocritic:
# TODO: Enable more checks, it is detecting actual potential issues.
disable-all: true
enabled-checks:
- appendAssign
- exitAfterDefer
- offBy1
# Enabled for the custom rules below.
- ruleguard
settings:
ruleguard:
rules: '${base-path}/scripts/ruleguard/rules/rules.go'
failOn: all
forbidigo:
forbid:
- pattern: 'os\.Chdir'
msg: "use t.Chdir in tests; os.Chdir mutates global process state"
revive:
rules:
# TODO: lower to default 8 once BuildIntegrationPackagePolicy, CreatePackagePolicy,
# and processResults are refactored to use option structs.
- name: argument-limit
arguments: [11]
exclusions:
rules:
# defer x.Close() errors are conventionally ignored.
- linters: [errcheck]
text: 'Error return value of `.+\.Close` is not checked'
# fmt.Fprint* write to io.Writer sinks (stderr, logs) where errors are
# not actionable — callers cannot recover from a write failure there.
- linters: [errcheck]
text: 'Error return value of `fmt\.Fprint'
# Test helpers: network mock servers ignore conn.Write, io.ReadFull errors.
- linters: [errcheck]
path: '_test\.go'
# go-pretty's SetTitle has a printf-style signature but is not a format function;
# govet incorrectly flags non-constant strings passed to it.
- linters: [govet]
text: 'printf: non-constant format string in call to.*SetTitle'
# NewProject and NewKibanaClientFromProfile are constructors that intentionally do not
# take a context: NewProject does file I/O only, and NewKibanaClientFromProfile calls
# checkClientStackAvailability which deliberately uses context.Background() to avoid
# cancellation on initial availability checks.
# NewForPackage makes a network call (kibanaVersion) and could accept a context in future.
- linters: [contextcheck]
text: 'Function `.*\b(NewProject|NewKibanaClientFromProfile|NewElasticsearchClientFromProfile|NewForPackage|NewKibanaClient|checkClientStackAvailability)\b.*` should pass the context parameter'
# elastic-go-common MapStr/mapstr operations: Put/Delete errors are structural
# (wrong value type), not runtime failures.
# TODO: consider replacing MapStr with a typed API to eliminate these error returns entirely.
- linters: [errcheck]
text: 'Error return value of `.*\.(Put|Delete)` is not checked'
# testscript command handlers must match the testscript.Cmd signature (neg bool is required).
# TODO: upstream a linter exception or type alias so the interface is explicit.
- linters: [unparam]
path: 'internal/testrunner/script/'
text: 'neg is unused'