forked from LFDT-Panurus/panurus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.golangci.yml
More file actions
221 lines (220 loc) · 10.9 KB
/
Copy path.golangci.yml
File metadata and controls
221 lines (220 loc) · 10.9 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
version: "2"
linters:
enable:
- containedctx
- asasalint # Check for pass []any as any in variadic func(...any).
- canonicalheader # Canonicalheader checks whether net/http.Header uses canonical header. [auto-fix]
- copyloopvar # A linter detects places where loop variables are copied. [fast, auto-fix]
- depguard # Go linter that checks if package imports are in a list of acceptable packages. [fast]
- dupword # Checks for duplicate words in the source code. [fast, auto-fix]
- durationcheck # Check for two durations multiplied together.
- errorlint # Find code that can cause problems with the error wrapping scheme introduced in Go 1.13. [auto-fix]
- exptostd # Detects functions from golang.org/x/exp/ that can be replaced by std functions. [auto-fix]
- fatcontext # Detects nested contexts in loops and function literals. [auto-fix]
- ginkgolinter # Enforces standards of using ginkgo and gomega. [auto-fix]
- goheader # Check if file header matches to pattern. [fast, auto-fix]
- iface # Detects incorrect use of interfaces.
- gosec # Inspects source code for security problems.
- govet # Vet examines Go source code and reports suspicious constructs. It is roughly the same as 'go vet' and uses its passes. [auto-fix]
- importas # Enforces consistent import aliases. [auto-fix]
- intrange # Intrange is a linter to find places where for loops could make use of an integer range. [auto-fix]
- ireturn # Accept Interfaces, Return Concrete Types.
- loggercheck # Checks key value pairs for common logger libraries (kitlog,klog,logr,slog,zap).
- lll # Reports long lines. [fast]
- mirror # Reports wrong mirror patterns of bytes/strings usage. [auto-fix]
- misspell # Finds commonly misspelled English words. [fast, auto-fix]
- nakedret # Checks that functions with naked returns are not longer than a maximum size (can be zero). [fast, auto-fix]
- nilerr # Find the code that returns nil even if it checks that the error is not nil.
- nilnesserr # Reports constructs that checks for err != nil, but returns a different nil value error.
- nlreturn # Checks for a new line before return and branch statements to increase code clarity. [fast, auto-fix]
- nolintlint # Reports ill-formed or insufficient nolint directives. [fast, auto-fix]
- perfsprint # Checks that fmt.Sprintf can be replaced with a faster alternative. [auto-fix]
- reassign # Checks that package variables are not reassigned.
- revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. [auto-fix]
- rowserrcheck # Checks whether Rows.Err of rows is checked successfully.
- sloglint # Ensure consistent code style when using log/slog. [auto-fix]
- spancheck # Checks for mistakes with OpenTelemetry/Census spans.
- staticcheck # It's the set of rules from staticcheck. [auto-fix]
- tagalign # Check that struct tags are well aligned. [fast, auto-fix]
- testifylint # Checks usage of github.com/stretchr/testify. [auto-fix]
- thelper # Thelper detects tests helpers which do not start with the t.Helper() method.
- unconvert # Remove unnecessary type conversions.
- usestdlibvars # A linter that detect the possibility to use variables/constants from the Go standard library. [fast, auto-fix]
- usetesting # Reports uses of functions with replacement inside the testing package. [auto-fix]
- wastedassign # Finds wasted assignment statements.
- whitespace # Whitespace is a linter that checks for unnecessary newlines at the start and end of functions, if, for, etc. [fast, auto-fix]
- zerologlint # Detects the wrong usage of `zerolog` that a user forgets to dispatch with `Send` or `Msg`.
settings:
depguard:
rules:
main:
deny:
- pkg: github.com/pkg/errors
desc: github.com/pkg/errors is no longer maintained
errcheck:
# Report about not checking of errors in type assertions: `a := b.(MyStruct)`.
check-type-assertions: false
errorlint:
# Check whether fmt.Errorf uses the %w verb for formatting errors.
errorf: true
# Check for plain type assertions and type switches.
asserts: false
# Check for plain error comparisons.
comparison: true
fatcontext:
check-struct-pointers: true
gocognit:
min-complexity: 15
gosec:
excludes:
- G204
- G404
- G306
govet:
disable:
- fieldalignment
# Enable all analyzers.
enable-all: false
iface:
# Only "identical" is enabled. The other two checks do not fit this codebase:
#
# "unused" only looks inside the declaring package, and the driver pattern puts SPI
# interfaces in dedicated driver/api packages that are implemented and consumed from
# other modules, so they are unused at home by construction. It reported 66 of these;
# 61 had between 1 and 79 referencing files elsewhere in the tree. The 5 that had none
# were genuinely dead and have been deleted.
#
# "opaque" wants constructors to return their concrete type, but in 14 of its 17 reports
# that type is unexported, so callers could not name the result and revive's
# unexported-return rule below would reject it. One is impossible outright: the concrete
# type is an unexported generic in fabric-smart-client.
enable:
- identical # Identifies interfaces in the same package that have identical method sets.
ireturn:
# By default, it allows using errors, empty interfaces, anonymous interfaces,
# and interfaces provided by the standard library.
allow:
- error
- empty
- anon
- stdlib
- generic
- (or|er)$
- T
- github.com/prometheus/client_golang/prometheus.Counter
- github.com/prometheus/client_golang/prometheus.Gauge
- github.com/prometheus/client_golang/prometheus.Histogram
# Third-party interfaces we are obliged to return: either the signature is fixed by an
# interface we implement (Pagination, bccsp.Key, KeyStore) or it is the framework's own
# constructor convention (view.View, view.Session). Returning a concrete type instead is
# not an option in these cases, so allow them rather than carry a nolint at every site.
- github.com/hyperledger-labs/fabric-smart-client/platform/common/driver.Pagination
- github.com/hyperledger-labs/fabric-smart-client/platform/view/view.View
- github.com/hyperledger-labs/fabric-smart-client/platform/view/view.Session
- github.com/hyperledger/fabric-lib-go/bccsp.Key
- github.com/hyperledger/fabric-lib-go/bccsp.BCCSP
- github.com/hyperledger/fabric-lib-go/bccsp.HashOpts
- github.com/IBM/idemix/bccsp/types.BCCSP
- github.com/IBM/idemix/bccsp/types.KeyStore
- go.opentelemetry.io/otel/trace.Span
- github.com/hyperledger/fabric-lib-go/common/metrics.Gauge
- github.com/hyperledger/fabric-lib-go/common/metrics.Histogram
- github.com/hyperledger-labs/fabric-smart-client/platform/view/services/metrics.Gauge
- github.com/hyperledger-labs/fabric-smart-client/platform/common/driver.ConfigService
- github.com/hyperledger-labs/fabric-smart-client/integration/nwo/api.ViewClient
- github.com/hyperledger-labs/fabric-smart-client/integration/nwo/api.Platform
- github.com/hyperledger-labs/fabric-smart-client/integration/nwo/api.Context
lll:
# Max line length, lines longer will be reported.
line-length: 240
nolintlint:
require-specific: true
revive:
# enable-all-rules was never on, because revive itself was never enabled. Turning it on
# as-is reports 3452 issues over 688 files, so instead of one unreviewable change this
# lists the rules explicitly. Everything below is already clean tree-wide, which makes
# revive a ratchet against new code rather than a backlog.
#
# Deliberately not listed yet, with their current counts, each wants its own change:
# exported (1568), unused-parameter (362), unused-receiver (334), import-shadowing (328),
# unchecked-type-assertion (125), argument-limit (103), unexported-naming (62),
# var-naming (59), defer (59), redundant-import-alias (51), function-result-limit (49).
#
# Not listed because another enabled linter already covers them: line-length-limit (lll),
# imports-blocklist (depguard), file-header (goheader). Omitted as no-ops at their default
# settings: comments-density, file-length-limit, enforce-map-style, enforce-slice-style,
# enforce-repeated-arg-type-style, string-format.
rules:
- name: atomic
- name: bool-literal-in-expr
- name: comment-spacings
arguments:
- 'nolint:'
- name: constant-logical-expr
- name: context-keys-type
- name: datarace
- name: deep-exit
- name: duplicated-imports
- name: epoch-naming
- name: error-return
- name: errorf
- name: filename-format
- name: forbidden-call-in-wg-go
- name: get-return
- name: identical-ifelseif-conditions
- name: identical-switch-conditions
- name: inefficient-map-lookup
- name: modifies-parameter
- name: modifies-value-receiver
- name: optimize-operands-order
- name: range
- name: range-val-address
- name: range-val-in-closure
- name: redundant-build-tag
- name: redundant-test-main-exit
- name: string-of-int
- name: time-date
- name: time-equal
- name: time-naming
- name: unconditional-recursion
- name: unhandled-error
arguments:
- fmt.Printf
- fmt.Println
- name: unnecessary-if
- name: unreachable-code
- name: unsecure-url-scheme
- name: use-any
- name: use-errors-new
- name: useless-break
- name: waitgroup-by-value
rowserrcheck:
packages:
- github.com/jackc/pgx/v5
- github.com/jackc/pgx/v4
wrapcheck:
# An array of strings specifying additional substrings of signatures to ignore.
extra-ignore-sigs:
- .CustomError(
- .SpecificWrap(
# An array of strings that specify substrings of signatures to ignore.
ignore-sigs:
- errors.New(
- errors.Newf(
- errors.Unwrap(
- errors.Join(
- .Wrap(
- .Wrapf(
- status.Error(
- .Wait() # The error reported by errorgroup.Wait() (external) actually originates from the internal code.
# An array of strings that specify regular expressions of signatures to ignore.
ignore-sig-regexps:
- \.New.*Error\(
exclusions:
# Mode of the generated files analysis.
generated: lax
# Log a warning if an exclusion rule is unused.
warn-unused: true
# Predefined exclusion rules.
presets:
- common-false-positives