/
.golangci.yml
172 lines (168 loc) · 5.51 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
run:
timeout: 20m
linters:
enable:
- errcheck
- exhaustive
- forbidigo
- gci
- gofmt
- gofumpt
- gosimple
- govet
- ineffassign
- lll
- loggercheck
- misspell
- revive
- unused
- usestdlibvars
- wsl
disable:
# Consumes a large amount of memory when running with Graph SDK in the
# project causing OOM failures in Github actions.
- staticcheck
linters-settings:
exhaustive:
check:
- switch
default-signifies-exhaustive: false
explicit-exhaustive-switch: true
gci:
sections:
- standard
- default
- prefix(github.com/alcionai/corso)
skip-generated: true
forbidigo:
forbid:
# Don't allow creating contexts without logging in tests. Use an ignore
# lower down to ensure usages of this outside of tests aren't reported.
- 'context\.(Background|TODO)(# tests should use tester\.NewContext)?'
# Don't allow use of path as it hardcodes separator to `/`.
# Use filepath instead.
- '\bpath\.(Ext|Base|Dir|Join)'
# Don't allow the typo m356 to be used in place of m365.
- '[Mm]356(# typo: should be 365)?'
# Don't allow use of testify suite directly. Use one of the wrappers from
# tester/suite.go instead. Use an ignore lower down to exclude packages
# that result in import cycles if they try to use the wrapper.
- 'suite\.Suite(# tests should use one of the Suite wrappers in tester package)?'
# All errors should be constructed and wrapped with the clues package.
# String formatting should be avoided in favor of structured errors (ie: err.With(k, v)).
- '(errors|fmt)\.(New|Stack|Wrap|Error)f?\((# error handling should use clues pkg)?'
# Avoid Warn-level logging in favor of Info or Error.
- 'Warnw?f?\((# logging should use Info or Error)?'
# Prefer suite.Run(name, func() {}) for subtests as testify has it instead
# of suite.T().Run(name, func(t *testing.T) {}).
- '(T\(\)|\st[a-zA-Z0-9]*)\.Run(# prefer testify suite.Run(name, func()) )?'
# Prefer packing ctx values into the error using NewWC, WrapWC, or StackWC
# instead of New|Stack|Wrap().WithClues(ctx)
- 'WithClues(# prefer the builderWC variant - ex: StackWC(ctx, ...))?'
lll:
line-length: 120
revive:
max-open-files: 2048
# Don't know why, but false means ignore generated files.
ignore-generated-header: false
rules:
- name: blank-imports
- name: bool-literal-in-expr
- name: constant-logical-expr
- name: context-as-argument
- name: context-keys-type
- name: duplicated-imports
- name: early-return
- name: empty-block
- name: errorf
- name: error-naming
- name: error-return
- name: error-strings
- name: exported
- name: identical-branches
- name: if-return
- name: import-shadowing
- name: increment-decrement
- name: indent-error-flow
- name: modifies-value-receiver
- name: package-comments
- name: range
- name: receiver-naming
- name: redefines-builtin-id
- name: superfluous-else
- name: time-equal
- name: time-naming
- name: unreachable-code
- name: use-any
- name: useless-break
- name: var-declaration
- name: var-naming
issues:
# Limit on number of errors with identical text reported.
max-same-issues: 50
exclude-rules:
- linters:
- revive
text: "exported:.*details.DetailsModel by other packages, and that stutters"
- linters:
- revive
text: "exported:.*details.DetailsEntry by other packages, and that stutters"
- linters:
- revive
text: "exported:.*mock.MockModelStore by other packages, and that stutters"
- linters:
- revive
text: "unexported-return:.*unexported type selectors.exchangeCategory"
- linters:
- revive
text: "unexported-return:.*unexported type.*kopia.conn"
- path: _test\.go
linters:
- revive
text: "import-shadowing:.*'suite' shadows"
# Don't output about context.Background or context.TODO in non-test files.
# Need complicated multi-part regex because golang doesn't support not regex
# operators for sequences of characters (only character sets). The below
# basically boils down to:
# 1. anything 4 characters long with .go suffix
# 2. anything >= 5 characters long that doesn't end in _test.go
- path: ^.{4}\.go|.*([^_].{4}|_[^t].{3}|_t[^e].{2}|_te[^s].{1}|_tes[^t])\.go
linters:
- forbidigo
text: "context.(Background|TODO)"
- path: internal/m365/collection/drive/collections_test.go
linters:
- lll
- path: internal/m365/collection/drive/collections_tree_test.go
linters:
- lll
- path: pkg/services/m365/api/graph/betasdk
linters:
- wsl
- revive
- gci
- lll
- gofmt
- gofumpt
- misspell
- errcheck
- forbidigo
- path: internal/tester/suite.go
linters:
- forbidigo
text: "suite.Suite"
# account package creates an import cycle with tester package.
- path: pkg/account
linters:
- forbidigo
text: "suite.Suite"
# storage package creates an import cycle with tester package.
- path: pkg/storage
linters:
- forbidigo
text: "suite.Suite"
# Not yet updated. Unclear if it should be updated.
- path: pkg/repository/loadtest
linters:
- forbidigo
text: "suite.Suite"