Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change golangci to enable all #903

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 20 additions & 59 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -225,66 +225,27 @@ linters-settings:
# Default: false
checkExported: true
linters:
disable-all: true
enable:
# - cyclop
enable-all: true
disable:
- godot
- varnamelen
- wrapcheck
- nosnakecase
- deadcode
- golint
- interfacer
- maligned
- ifshort
- structcheck
- exhaustivestruct
- scopelint
- varcheck
- ireturn
- depguard
- dogsled
# - dupl
- errcheck
- errorlint
# - exhaustive
# - exhaustivestruct
# - forbidigo
# - funlen
# - gci
# - gocognit
- goconst
- gocritic
- gocyclo
# - godot
- godox
- gofmt # On why gofmt when goimports is enabled - https://github.com/golang/go/issues/21476
- gofumpt
- goheader
- goimports
# - gomnd
# - gomoddirectives
# - gomodguard
- gosec
- gosimple
- govet
- depguard
# - ifshort
# - ireturn
- lll
- makezero
- misspell
- ineffassign
- misspell
- nakedret
- nestif
# - nilnil
# - nlreturn
- nolintlint
- prealloc
- predeclared
- rowserrcheck
- revive
- staticcheck
- stylecheck
# - tagliatelle
# - testpackage
# - thelper
# - tenv
- typecheck
- unconvert
- unparam
- unused
# - varnamelen
- whitespace
# - wrapcheck
# - wsl
- wsl
- exhaustruct
- gci
- paralleltest #need be enabled

issues:
# List of regexps of issue texts to exclude, empty list by default.
Expand Down
2 changes: 2 additions & 0 deletions connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import (
// Interface and list of clients may be changed in the future
//
// Deprecated: use directly *Driver type from ydb.Open instead
//
//nolint:interfacebloat
type Connection interface {
// Endpoint returns initial endpoint
Endpoint() string
Expand Down
29 changes: 20 additions & 9 deletions driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,13 @@ func (d *Driver) trace() *trace.Driver {
if d.config != nil {
return d.config.Trace()
}

return &trace.Driver{}
}

// Close closes Driver and clear resources
//
//nolint:nonamedreturns
func (d *Driver) Close(ctx context.Context) (finalErr error) {
onDone := trace.DriverOnClose(d.trace(), &ctx, stack.FunctionID(""))
defer func() {
Expand Down Expand Up @@ -207,6 +210,8 @@ func (d *Driver) Topic() topic.Client {
// "grpc[s]://{endpoint}/{database}[?param=value]"
//
// See sugar.DSN helper for make dsn from endpoint and database
//
//nolint:nonamedreturns
func Open(ctx context.Context, dsn string, opts ...Option) (_ *Driver, err error) {
d, err := newConnectionFromOptions(ctx, append(
[]Option{
Expand Down Expand Up @@ -239,12 +244,15 @@ func MustOpen(ctx context.Context, dsn string, opts ...Option) *Driver {
if err != nil {
panic(err)
}

return db
}

// New connects to database and return driver runtime holder
//
// Deprecated: use Open with required param connectionString instead
//
//nolint:nonamedreturns
func New(ctx context.Context, opts ...Option) (_ *Driver, err error) {
d, err := newConnectionFromOptions(ctx, opts...)
if err != nil {
Expand All @@ -267,6 +275,7 @@ func New(ctx context.Context, opts ...Option) (_ *Driver, err error) {
return d, nil
}

//nolint:cyclop, nonamedreturns
func newConnectionFromOptions(ctx context.Context, opts ...Option) (_ *Driver, err error) {
d := &Driver{
children: make(map[uint64]*Driver),
Expand Down Expand Up @@ -304,16 +313,16 @@ func newConnectionFromOptions(ctx context.Context, opts ...Option) (_ *Driver, e
}
if d.logger != nil {
for _, opt := range []Option{
WithTraceDriver(log.Driver(d.logger, d.loggerDetails, d.loggerOpts...)),
WithTraceTable(log.Table(d.logger, d.loggerDetails, d.loggerOpts...)),
WithTraceScripting(log.Scripting(d.logger, d.loggerDetails, d.loggerOpts...)),
WithTraceDriver(log.Driver(d.logger, d.loggerDetails, d.loggerOpts...)), //nolint:contextcheck
WithTraceTable(log.Table(d.logger, d.loggerDetails, d.loggerOpts...)), //nolint:contextcheck
WithTraceScripting(log.Scripting(d.logger, d.loggerDetails, d.loggerOpts...)), //nolint:contextcheck
WithTraceScheme(log.Scheme(d.logger, d.loggerDetails, d.loggerOpts...)),
WithTraceCoordination(log.Coordination(d.logger, d.loggerDetails, d.loggerOpts...)),
WithTraceRatelimiter(log.Ratelimiter(d.logger, d.loggerDetails, d.loggerOpts...)),
WithTraceDiscovery(log.Discovery(d.logger, d.loggerDetails, d.loggerOpts...)),
WithTraceTopic(log.Topic(d.logger, d.loggerDetails, d.loggerOpts...)),
WithTraceDatabaseSQL(log.DatabaseSQL(d.logger, d.loggerDetails, d.loggerOpts...)),
WithTraceRetry(log.Retry(d.logger, d.loggerDetails, d.loggerOpts...)),
WithTraceDiscovery(log.Discovery(d.logger, d.loggerDetails, d.loggerOpts...)), //nolint:contextcheck
WithTraceTopic(log.Topic(d.logger, d.loggerDetails, d.loggerOpts...)), //nolint:contextcheck
WithTraceDatabaseSQL(log.DatabaseSQL(d.logger, d.loggerDetails, d.loggerOpts...)), //nolint:contextcheck
WithTraceRetry(log.Retry(d.logger, d.loggerDetails, d.loggerOpts...)), //nolint:contextcheck
} {
if opt != nil {
err = opt(ctx, d)
Expand All @@ -324,16 +333,18 @@ func newConnectionFromOptions(ctx context.Context, opts ...Option) (_ *Driver, e
}
}
d.config = config.New(d.options...)

return d, nil
}

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

if d.config.Database() == "" {
return xerrors.WithStackTrace(errors.New("configuration: empty database"))
return xerrors.WithStackTrace(errors.New("configuration: empty database")) //nolint:goerr113
}

if d.userInfo != nil {
Expand Down
2 changes: 2 additions & 0 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ func IsOperationErrorSchemeError(err error) bool {
}

// IsOperationErrorTransactionLocksInvalidated checks does err a TLI issue
//
//nolint:nonamedreturns
func IsOperationErrorTransactionLocksInvalidated(err error) (isTLI bool) {
return xerrors.IsOperationErrorTransactionLocksInvalidated(err)
}
Expand Down
Loading
Loading