-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.golangci.yml
206 lines (200 loc) · 7.71 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
# 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
- github.com/nextmv-io/sdk/measure/here
- github.com/nextmv-io/sdk/measure/osrm
- github.com/nextmv-io/sdk/measure/google
- github.com/nextmv-io/sdk/measure/routingkit
- googlemaps.github.io/maps
- github.com/dgraph-io/ristretto
- go.uber.org/mock
- github.com/google/go-cmp
- github.com/hashicorp/golang-lru
- github.com/nextmv-io/go-routingkit
- github.com/twpayne/go-polyline
- googlemaps.github.io/maps
- github.com/itzg/go-flagsfiller
- github.com/gorilla/schema
- github.com/google/uuid
- github.com/xeipuuv/gojsonschema
- github.com/danielgtaylor/huma
- github.com/sergi/go-diff
# 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
# gosec offers another set of security checks in addition to govet
- gosec
# 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
# 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:
# Tag should be 'measure' in both cases ByPoint and ByIndex
- path: measure/load\.go
linters:
- tagliatelle
text: measure
# Complexity is fine here because of the nature of the code
- path: measure/osrm/matrix_test\.go
linters:
- gosec
text: G404
# Please note that other Go modules have issues that are ignored but are
# not listed here. The reason is that linting must be done standing on the
# Go module and excluding issues here uses relative paths. That means that
# the relative paths from this file start from the root of sdk but for
# other modules the relative path start from that module. For that reason,
# linting is ignored by using the following syntax on a line: //nolint. If
# you look for uses of //nolint you will find the other linting issues
# being excluided.
# Deactivating gocritic because of a gocritic bug that was fixed on October
# 6th, but the fix has not yet been released
# https://github.com/go-critic/go-critic/pull/1273
- path: run/run\.go
linters:
- gocritic
text: newDeref
# Deactivate line length in http_runner_config.go because of go tags
- path: run/http_runner_config\.go
linters:
- lll
# The golden file testing framework is only used internally and doesn't need
# to meet the same standards as the rest of the codebase for now.
- path: golden/.+\.go
linters:
- gocyclo
- nestif
- gosec
# The test is only used internally and doesn't need
# to meet the same standards as the rest of the codebase for now.
- path: run/tests/http/async/main\.go
linters:
- gosec