forked from shopspring/decimal
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.golangci.yml
More file actions
276 lines (267 loc) · 11 KB
/
Copy path.golangci.yml
File metadata and controls
276 lines (267 loc) · 11 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
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
# options for analysis running
run:
# timeout for analysis, e.g. 30s, 5m, default is 1m
deadline: 5m
# exit code when at least one issue was found, default is 1
issues-exit-code: 1
# include test files or not, default is true
tests: true
# which files to skip: they will be analyzed, but issues from them
# won't be reported. Default value is empty list, but there is
# no need to include all autogenerated files, we confidently recognize
# autogenerated files. If it's not please let us know.
skip-files:
- easyjson
issues:
# Independently from option `exclude` we use default exclude patterns,
# it can be disabled by this option. To list all
# excluded by default patterns execute `golangci-lint run --help`.
# Default value for this option is true.
exclude-use-default: false
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
# Exclude constructions like _ error = (*Error)(nil)
- linters:
- errcheck
source: "_ error = \\(.*\\)\\(nil\\)"
# Exclude some linters from running on tests files.
- path: _test\.go
linters:
- prealloc
- errcheck
- bodyclose
# output configuration options
output:
# colored-line-number|line-number|json|tab|checkstyle, default is "colored-line-number"
format: colored-line-number
# print lines of code with issue, default is true
print-issued-lines: true
# print linter name in the end of issue text, default is true
print-linter-name: true
# all available settings of specific linters
linters-settings:
govet:
# report about shadowed variables
check-shadowing: true
enable:
# report mismatches between assembly files and Go declarations
- asmdecl
# check for useless assignments
- assign
# check for common mistakes using the sync/atomic package
- atomic
# check for non-64-bits-aligned arguments to sync/atomic functions
- atomicalign
# check for common mistakes involving boolean operators
- bools
# check that +build tags are well-formed and correctly located
- buildtag
# detect some violations of the cgo pointer passing rules
- cgocall
# check for unkeyed composite literals
- composites
# check for locks erroneously passed by value
- copylocks
# check for calls of reflect.DeepEqual on error values
- deepequalerrors
# report passing non-pointer or non-error values to errors.As
- errorsas
# find calls to a particular function
- findcall
# report assembly that clobbers the frame pointer before saving it
- framepointer
# check for mistakes using HTTP responses
- httpresponse
# detect impossible interface-to-interface type assertions
- ifaceassert
# check references to loop variables from within nested functions
- loopclosure
# check cancel func returned by context.WithCancel is called
- lostcancel
# check for useless comparisons between functions and nil
- nilfunc
# check for redundant or impossible nil comparisons
- nilness
# check consistency of Printf format strings and arguments
- printf
# check for comparing reflect.Value values with == or reflect.DeepEqual
- reflectvaluecompare
# check for possible unintended shadowing of variables
- shadow
# check for shifts that equal or exceed the width of the integer
- shift
# check for unbuffered channel of os.Signal
- sigchanyzer
# check the argument type of sort.Slice
- sortslice
# check signature of methods of well-known interfaces
- stdmethods
# check for string(int) conversions
- stringintconv
# check that struct field tags conform to reflect.StructTag.Get
- structtag
# report calls to (*testing.T).Fatal from goroutines started by a test.
- testinggoroutine
# check for common mistaken usages of tests and examples
- tests
# report passing non-pointer or non-interface values to unmarshal
- unmarshal
# check for unreachable code
- unreachable
# check for invalid conversions of uintptr to unsafe.Pointer
- unsafeptr
# check for unused results of calls to some functions
- unusedresult
# checks for unused writes
- unusedwrite
disable:
# find structs that would use less memory if their fields were sorted
- fieldalignment
gofmt:
# simplify code: gofmt with `-s` option, true by default
simplify: true
errcheck:
# report about not checking of errors in type assetions: `a := b.(MyStruct)`;
# default is false: such cases aren't reported by default.
check-type-assertions: true
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
# default is false: such cases aren't reported by default.
check-blank: true
gocyclo:
# minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 14
misspell:
# Correct spellings using locale preferences for US or UK.
# Default is to use a neutral variety of English.
# Setting locale to US will correct the British spelling of 'colour' to 'color'.
locale: US
prealloc:
# XXX: we don't recommend using this linter before doing performance profiling.
# For most programs usage of prealloc will be a premature optimization.
# Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
# True by default.
simple: true
range-loops: true # Report preallocation suggestions on range loops, true by default
for-loops: true # Report preallocation suggestions on for loops, false by default
unparam:
# Inspect exported functions, default is false. Set to true if no external program/library imports your code.
# XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
# if it's called for subdir of a project it can't find external interfaces. All text editor integrations
# with golangci-lint call it on a directory with the changed file.
check-exported: false
revive:
rules:
# Blank import should be only in a main or test package, or have a comment justifying it.
# Disabled to avoid swearing at import _ "github.com/mailru/easyjson/gen"
# needed to generate easyjson when using a vendor folder
- name: blank-imports
disabled: true
# Since GO 1.18, interface{} has an alias: any. This rule proposes to replace instances of interface{} with any.
- name: use-any
disabled: false
# It is possible to unintentionally import the same package twice.
# This rule looks for packages that are imported two or more times.
- name: duplicated-imports
disabled: false
# Check for commonly mistaken usages of the sync/atomic package
- name: atomic
disabled: false
# Basic types should not be used as a key in context.WithValue.
- name: context-keys-type
disabled: false
# This rule spots potential dataraces caused by go-routines capturing (by-reference)
# particular identifiers of the function from which go-routines are created.
# The rule is able to spot two of such cases: go-routines capturing named return values,
# and capturing for-range values.
- name: datarace
disabled: false
# This rule warns on some common mistakes when using defer statement.
- name: defer
disabled: false
# It is possible to get a simpler program by replacing errors.New(fmt.Sprintf()) with fmt.Errorf().
- name: errorf
disabled: false
# an if-then-else conditional with identical implementations in both branches is an error.
- name: identical-branches
disabled: false
# Checking if an error is nil to just after return the error or nil is redundant.
- name: if-return
disabled: true
# A function that modifies its parameters can be hard to understand.
# It can also be misleading if the arguments are passed by value by the caller.
# This rule warns when a function modifies one or more of its parameters.
- name: modifies-parameter
disabled: false
# A method that modifies its receiver value can have undesired behavior.
# The modification can be also the root of a bug because the actual
# value receiver could be a copy of that used at the calling site.
# This rule warns when a method modifies its receiver.
- name: modifies-value-receiver
disabled: true
# Range variables in a loop are reused at each iteration;
# therefore a goroutine created in a loop will point to the range variable with from the upper scope.
# This way, the goroutine could use the variable with an undesired value.
# This rule warns when a range value (or index) is used inside a closure
- name: range-val-in-closure
disabled: false
# Range variables in a loop are reused at each iteration.
# This rule warns when assigning the address of the variable,
# passing the address to append() or using it in a map.
- name: range-val-address
disabled: false
# explicit type conversion string(i) where i has an integer type
# other than rune might behave not as expected by the developer (e.g. string(42) is not "42").
# This rule spot that kind of suspicious conversions.
- name: string-of-int
disabled: false
# This rule warns when using == and != for equality check time.Time and suggest to time.time.Equal method
- name: time-equal
disabled: false
# Using unit-specific suffix like "Secs", "Mins", ... when naming variables of type time.Duration
# can be misleading, this rule highlights those cases.
- name: time-naming
disabled: false
# Unconditional recursive calls will produce infinite recursion, thus program stack overflow.
# This rule detects and warns about unconditional (direct) recursive calls.
- name: unconditional-recursion
disabled: false
# This rule suggests to remove redundant statements like a break at the end of a case block,
# for improving the code's readability.
- name: unnecessary-stmt
disabled: false
# This rule warns on useless break statements in case clauses of switch and select statements.
- name: useless-break
disabled: false
# Function parameters that are passed by value, are in fact a copy of the original argument.
# Passing a copy of a sync.WaitGroup is usually not what the developer wants to do.
# This rule warns when a sync.WaitGroup expected as a by-value parameter in a function or method.
- name: waitgroup-by-value
disabled: false
gocritic:
enabled-checks:
- docStub
linters:
disable-all: true
enable:
- govet
- revive
- gofmt
- errcheck
- misspell
- ineffassign
- goimports
- nakedret
- unparam
- unused
- prealloc
- durationcheck
- nolintlint
- staticcheck
- makezero
- gocritic
- asasalint
- nilerr
- errorlint
- exportloopref
- wastedassign
fast: false