Skip to content

Commit aec710b

Browse files
authored
Merge pull request #903 from Mixalight/Switch-golangci-config-from-opt-in-linters-to-opt-out
Change golangci to enable all
2 parents 5377536 + cdad252 commit aec710b

File tree

12 files changed

+132
-80
lines changed

12 files changed

+132
-80
lines changed

.golangci.yml

Lines changed: 20 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -225,66 +225,27 @@ linters-settings:
225225
# Default: false
226226
checkExported: true
227227
linters:
228-
disable-all: true
229-
enable:
230-
# - cyclop
228+
enable-all: true
229+
disable:
230+
- godot
231+
- varnamelen
232+
- wrapcheck
233+
- nosnakecase
234+
- deadcode
235+
- golint
236+
- interfacer
237+
- maligned
238+
- ifshort
239+
- structcheck
240+
- exhaustivestruct
241+
- scopelint
242+
- varcheck
243+
- ireturn
231244
- depguard
232-
- dogsled
233-
# - dupl
234-
- errcheck
235-
- errorlint
236-
# - exhaustive
237-
# - exhaustivestruct
238-
# - forbidigo
239-
# - funlen
240-
# - gci
241-
# - gocognit
242-
- goconst
243-
- gocritic
244-
- gocyclo
245-
# - godot
246-
- godox
247-
- gofmt # On why gofmt when goimports is enabled - https://github.com/golang/go/issues/21476
248-
- gofumpt
249-
- goheader
250-
- goimports
251-
# - gomnd
252-
# - gomoddirectives
253-
# - gomodguard
254-
- gosec
255-
- gosimple
256-
- govet
257-
- depguard
258-
# - ifshort
259-
# - ireturn
260-
- lll
261-
- makezero
262-
- misspell
263-
- ineffassign
264-
- misspell
265-
- nakedret
266-
- nestif
267-
# - nilnil
268-
# - nlreturn
269-
- nolintlint
270-
- prealloc
271-
- predeclared
272-
- rowserrcheck
273-
- revive
274-
- staticcheck
275-
- stylecheck
276-
# - tagliatelle
277-
# - testpackage
278-
# - thelper
279-
# - tenv
280-
- typecheck
281-
- unconvert
282-
- unparam
283-
- unused
284-
# - varnamelen
285-
- whitespace
286-
# - wrapcheck
287-
# - wsl
245+
- wsl
246+
- exhaustruct
247+
- gci
248+
- paralleltest #need be enabled
288249

289250
issues:
290251
# List of regexps of issue texts to exclude, empty list by default.

connection.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import (
1616
// Interface and list of clients may be changed in the future
1717
//
1818
// Deprecated: use directly *Driver type from ydb.Open instead
19+
//
20+
//nolint:interfacebloat
1921
type Connection interface {
2022
// Endpoint returns initial endpoint
2123
Endpoint() string

driver.go

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,13 @@ func (d *Driver) trace() *trace.Driver {
101101
if d.config != nil {
102102
return d.config.Trace()
103103
}
104+
104105
return &trace.Driver{}
105106
}
106107

107108
// Close closes Driver and clear resources
109+
//
110+
//nolint:nonamedreturns
108111
func (d *Driver) Close(ctx context.Context) (finalErr error) {
109112
onDone := trace.DriverOnClose(d.trace(), &ctx, stack.FunctionID(""))
110113
defer func() {
@@ -214,6 +217,8 @@ func (d *Driver) Topic() topic.Client {
214217
// "grpc[s]://{endpoint}/{database}[?param=value]"
215218
//
216219
// See sugar.DSN helper for make dsn from endpoint and database
220+
//
221+
//nolint:nonamedreturns
217222
func Open(ctx context.Context, dsn string, opts ...Option) (_ *Driver, err error) {
218223
d, err := newConnectionFromOptions(ctx, append(
219224
[]Option{
@@ -246,12 +251,15 @@ func MustOpen(ctx context.Context, dsn string, opts ...Option) *Driver {
246251
if err != nil {
247252
panic(err)
248253
}
254+
249255
return db
250256
}
251257

252258
// New connects to database and return driver runtime holder
253259
//
254260
// Deprecated: use Open with required param connectionString instead
261+
//
262+
//nolint:nonamedreturns
255263
func New(ctx context.Context, opts ...Option) (_ *Driver, err error) {
256264
d, err := newConnectionFromOptions(ctx, opts...)
257265
if err != nil {
@@ -274,6 +282,7 @@ func New(ctx context.Context, opts ...Option) (_ *Driver, err error) {
274282
return d, nil
275283
}
276284

285+
//nolint:cyclop, nonamedreturns
277286
func newConnectionFromOptions(ctx context.Context, opts ...Option) (_ *Driver, err error) {
278287
ctx, driverCtxCancel := xcontext.WithCancel(xcontext.WithoutDeadline(ctx))
279288
defer func() {
@@ -321,16 +330,16 @@ func newConnectionFromOptions(ctx context.Context, opts ...Option) (_ *Driver, e
321330
}
322331
if d.logger != nil {
323332
for _, opt := range []Option{
324-
WithTraceDriver(log.Driver(d.logger, d.loggerDetails, d.loggerOpts...)),
325-
WithTraceTable(log.Table(d.logger, d.loggerDetails, d.loggerOpts...)),
326-
WithTraceScripting(log.Scripting(d.logger, d.loggerDetails, d.loggerOpts...)),
333+
WithTraceDriver(log.Driver(d.logger, d.loggerDetails, d.loggerOpts...)), //nolint:contextcheck
334+
WithTraceTable(log.Table(d.logger, d.loggerDetails, d.loggerOpts...)), //nolint:contextcheck
335+
WithTraceScripting(log.Scripting(d.logger, d.loggerDetails, d.loggerOpts...)), //nolint:contextcheck
327336
WithTraceScheme(log.Scheme(d.logger, d.loggerDetails, d.loggerOpts...)),
328337
WithTraceCoordination(log.Coordination(d.logger, d.loggerDetails, d.loggerOpts...)),
329338
WithTraceRatelimiter(log.Ratelimiter(d.logger, d.loggerDetails, d.loggerOpts...)),
330-
WithTraceDiscovery(log.Discovery(d.logger, d.loggerDetails, d.loggerOpts...)),
331-
WithTraceTopic(log.Topic(d.logger, d.loggerDetails, d.loggerOpts...)),
332-
WithTraceDatabaseSQL(log.DatabaseSQL(d.logger, d.loggerDetails, d.loggerOpts...)),
333-
WithTraceRetry(log.Retry(d.logger, d.loggerDetails, d.loggerOpts...)),
339+
WithTraceDiscovery(log.Discovery(d.logger, d.loggerDetails, d.loggerOpts...)), //nolint:contextcheck
340+
WithTraceTopic(log.Topic(d.logger, d.loggerDetails, d.loggerOpts...)), //nolint:contextcheck
341+
WithTraceDatabaseSQL(log.DatabaseSQL(d.logger, d.loggerDetails, d.loggerOpts...)), //nolint:contextcheck
342+
WithTraceRetry(log.Retry(d.logger, d.loggerDetails, d.loggerOpts...)), //nolint:contextcheck
334343
} {
335344
if opt != nil {
336345
err = opt(ctx, d)
@@ -341,16 +350,18 @@ func newConnectionFromOptions(ctx context.Context, opts ...Option) (_ *Driver, e
341350
}
342351
}
343352
d.config = config.New(d.options...)
353+
344354
return d, nil
345355
}
346356

357+
//nolint:cyclop, nonamedreturns, funlen
347358
func (d *Driver) connect(ctx context.Context) (err error) {
348359
if d.config.Endpoint() == "" {
349-
return xerrors.WithStackTrace(errors.New("configuration: empty dial address"))
360+
return xerrors.WithStackTrace(errors.New("configuration: empty dial address")) //nolint:goerr113
350361
}
351362

352363
if d.config.Database() == "" {
353-
return xerrors.WithStackTrace(errors.New("configuration: empty database"))
364+
return xerrors.WithStackTrace(errors.New("configuration: empty database")) //nolint:goerr113
354365
}
355366

356367
if d.userInfo != nil {

errors.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ func IsOperationErrorSchemeError(err error) bool {
8383
}
8484

8585
// IsOperationErrorTransactionLocksInvalidated checks does err a TLI issue
86+
//
87+
//nolint:nonamedreturns
8688
func IsOperationErrorTransactionLocksInvalidated(err error) (isTLI bool) {
8789
return xerrors.IsOperationErrorTransactionLocksInvalidated(err)
8890
}

0 commit comments

Comments
 (0)