-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy path.golangci.yml
336 lines (333 loc) · 10.4 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
# Options for analysis running. Details: https://golangci-lint.run/usage/configuration/#run-configuration
run:
timeout: 5m
go: "1.22"
# Configures linters. Details: https://golangci-lint.run/usage/linters
linters-settings:
# Pick up duplicate code after severe repetition.
dupl:
threshold: 200
# Only allow certain modules to be imported.
gomodguard:
allowed:
modules:
- github.com/nextmv-io/sdk
- gonum.org/v1/gonum
# Functions cannot exceed this cyclomatic complexity.
gocyclo:
min-complexity: 20
# Set correct go version.
gosimple:
go: "1.22"
staticcheck:
go: "1.22"
stylecheck:
go: "1.22"
# Check case of struct tags
tagliatelle:
case:
use-field-name: true
rules:
json: snake
# Check line length
lll:
line-length: 120
# Specifies which linters are enabled. Full list: https://golangci-lint.run/usage/linters/
linters:
# Some linters are just too strict.
disable-all: true
enable:
# Checks whether HTTP response body is closed successfully.
- bodyclose
# containedctx is a linter that detects struct contained context.Context field.
- containedctx
# Check the function whether use a non-inherited context.
- contextcheck
# Finds unused code. WARN [runner] The linter 'deadcode' is deprecated
# (since v1.49.0) due to: The owner seems to have abandoned the linter.
# Replaced by unused.
# - deadcode
# check declaration order and count of types, constants, variables and functions.
- decorder
# Checks assignments with too many blank identifiers (e.g. x, , , _, := f())
- dogsled
# Tool for code clone detection
- dupl
# Errcheck is a program for checking for unchecked errors in go programs.
# These unchecked errors can be critical bugs in some cases.
- errcheck
# Gci controls golang package import order and makes it always deterministic.
- gci
# Finds repeated strings that could be replaced by a constant.
- goconst
# Provides diagnostics that check for bugs, performance and style issues.
# Extensible without recompilation through dynamic rules. Dynamic rules are
# written declaratively with AST patterns, filters, report message and
# optional suggestion.
- gocritic
# Computes and checks the cyclomatic complexity of functions.
- gocyclo
# Check if comments end in a period.
- godot
# Gofmt checks whether code was gofmt-ed. By default this tool runs with -s
# option to check for code simplification.
- gofmt
# In addition to fixing imports, goimports also formats your code in the
# same style as gofmt.
- goimports
# Allow and block list linter for direct Go module dependencies. This is
# different from depguard where there are different block types for example
# version constraints and module recommendations.
- gomodguard
# Linter for Go source code that specializes in simplifying a code.
- gosimple
# Vet examines Go source code and reports suspicious constructs, such as
# Printf calls whose arguments do not align with the format string.
- govet
# Enforces consistent import aliases.
- importas
# Detects when assignments to existing variables are not used.
- ineffassign
# Reports long lines.
- lll
# Finds commonly misspelled English words in comments.
- misspell
# Finds naked returns in functions greater than a specified function length.
- nakedret
# Reports deeply nested if statements.
- nestif
# Finds the code that returns nil even if it checks that the error is not nil.
- nilerr
# noctx finds sending http request without context.Context.
- noctx
# Finds slice declarations that could potentially be preallocated.
- prealloc
# Find code that shadows one of Go's predeclared identifiers.
- predeclared
# Fast, configurable, extensible, flexible, and beautiful linter for Go.
# Drop-in replacement of golint.
- revive
# Staticcheck is a go vet on steroids, applying a ton of static analysis checks.
- staticcheck
# Finds unused struct fields. WARN [runner] The linter 'structcheck' is
# deprecated (since v1.49.0) due to: The owner seems to have abandoned the
# linter. Replaced by unused.
# - structcheck
# Stylecheck is a replacement for golint.
- stylecheck
# Checks the struct tags.
- tagliatelle
# Like the front-end of a Go compiler, parses and type-checks Go code.
- typecheck
# Remove unnecessary type conversions.
- unconvert
# Reports unused function parameters.
- unparam
# Checks Go code for unused constants, variables, functions and types.
- unused
# Finds unused global variables and constants. WARN [runner] The linter
# 'varcheck' is deprecated (since v1.49.0) due to: The owner seems to have
# abandoned the linter. Replaced by unused.
# - varcheck
# wastedassign finds wasted assignment statements.
# wastedassign is disabled because of generics. You can track the evolution
# of the generics support by following the https://github.com/golangci/golangci-lint/issues/2649.
# - wastedassign
# Tool for detection of leading and trailing whitespace.
- whitespace
# List of regexps of issue texts to exclude. Details: https://golangci-lint.run/usage/configuration/#issues-configuration
issues:
# Disable default exclude patterns to surface commonly-ignored linting errors.
exclude-use-default: false
exclude-rules:
# Ignore cyclomatic complexity of tests
- path: '.*_test\.go'
linters:
- gocyclo
# Next route tests and methods contain complex code hard to simplify.
- path: model_expression_time_dependent_test\.go
linters:
- gocyclo
- path: solution_construction_cluster\.go
linters:
- gocyclo
- path: model_constraint_no_mix_test\.go
linters:
- gocyclo
- path: check/check\.go
linters:
- gocyclo
- nestif
- path: solution_move\.go
linters:
- gocyclo
- path: solution_move_stops\.go
linters:
- gocyclo
- path: solve_solver_parallel\.go
linters:
- gocyclo
- path: solution\.go
linters:
- gocyclo
# False alarm from staticcheck.
- path: solution_vehicle\.go
linters:
- staticcheck
text: SA6002
- path: model_plan_unit_test\.go
linters:
- gocyclo
- path: model_plan_units_unit_test\.go
linters:
- gocyclo
- path: model_plan_stops_unit_test\.go
linters:
- gocyclo
- path: model_constraint_maximum_test\.go
linters:
- gocyclo
- path: model\.go
linters:
- nestif
- path: model_test\.go
linters:
- gocyclo
# Next route stop generator - too complex to simplify at this point.
- path: solution_stop_generator\.go
linters:
- nestif
# Model factory.
- path: model_factory\.go
linters:
- nestif
# Next route solver cancel on context.
- path: solver\.go
linters:
- govet
- path: solver_parallel.go
linters:
- govet
# Function name is too long but cannot be broken up.
- path: solution_observer\.go
linters:
- lll
# Carried over validations from cloud and it is hard to simplify.
- path: factory/validate\.go
linters:
- gocyclo
# Construction complexity.
- path: factory/construction\.go
linters:
- gocyclo
- nestif
# Model factory.
- path: factory/constraint_no_mix\.go
linters:
- nestif
# Complex code that is hard to simplify.
- path: factory/plan_units\.go
linters:
- gocyclo
- nestif
# Complex code that is hard to simplify.
- path: factory/format\.go
linters:
- nestif
# TemporalValues has 4 return values, but only need one here.
- path: model_objective_vehicles_duration\.go
linters:
- dogsled
# The expression cannot be simplified with switch.
- path: factory/validate\.go
linters:
- gocritic
# The expression cannot be simplified with switch.
- path: factory/plan_units\.go
linters:
- gocritic
text: ifElseChain
# Solution isFeasible test is critical code
- path: solution_vehicle\.go
linters:
- nestif
# Model constraint parameters are used in apps
- path: model_constraint\.go
linters:
- unparam
- path: solution_stop_generator\.go
linters:
- unparam
# Deactivate line length in solver.go because of go tags
- path: solver\.go
linters:
- lll
- path: solve_solver_parallel\.go
linters:
- lll
- path: solve_solver\.go
linters:
- lll
# Deactivate line length because of go tags
- path: check/options\.go
linters:
- lll
# Deactivate lll in schema due to go tags.
- path: schema
linters:
- lll
# Deactivate line length in model.go because of go tags
- path: model\.go
linters:
- lll
# Deactivate gocyclo in model.go for lock func.
- path: model\.go
linters:
- gocyclo
# Deactivate line length in factory/model.go because of go tags
- path: factory/model\.go
linters:
- lll
# Deactivate line length in construction.go because of go tags
- path: factory/construction\.go
linters:
- lll
# Cloud code for compatibility
- path: schema/fleet_defaults\.go
linters:
- gocyclo
- path: schema/router\.go
linters:
- staticcheck
# This tag is used by our validation engine and it is valid.
- path: schema/input\.go
linters:
- govet
text: structtag
# We want to keep the error message as is.
- path: precedence\.go
linters:
- goconst
- path: model_directed_acyclic_graph\.go
linters:
- nestif
- path: solution_move_stops_generator\.go
linters:
- nestif
- path: solution_sequence_generator\.go
linters:
- nestif
- path: factory/vehicles\.go
linters:
- gocyclo
# 'vehicle_ids' want 'vehicle_i_ds' <- no, we don't want this
- path: schema/input\.go
linters:
- tagliatelle
# We do not need the context check here
- path: check/format\.go
linters:
- contextcheck
- path: factory/validate\.go
linters:
- nestif