From 708d933fe36a1def64e39ee24eb76caed97d1e24 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Fri, 7 Apr 2023 08:12:41 +0300 Subject: [PATCH] [#47] .golangci.yml: Unify with other FrostFS repos Signed-off-by: Evgenii Stratonikov --- .golangci.yml | 31 +++++++++++++++++++------------ client/client.go | 2 ++ client/container.go | 2 ++ container/acl/acl.go | 2 ++ container/acl/util.go | 2 ++ container/container.go | 2 ++ netmap/policy.go | 2 ++ object/transformer/transformer.go | 1 + pool/pool.go | 7 +++++++ 9 files changed, 39 insertions(+), 12 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index eda5e5f..fae355a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -4,10 +4,10 @@ # options for analysis running run: # timeout for analysis, e.g. 30s, 5m, default is 1m - timeout: 5m + timeout: 10m # include test files or not, default is true - tests: true + tests: false # output configuration options output: @@ -26,7 +26,11 @@ linters-settings: check-shadowing: false staticcheck: checks: ["all", "-SA1019"] # TODO Enable SA1019 after deprecated warning are fixed. - + funlen: + lines: 80 # default 60 + statements: 60 # default 40 + gocognit: + min-complexity: 40 # default 30 linters: enable: @@ -37,23 +41,26 @@ linters: # some default golangci-lint linters - errcheck - gosimple + - godot - ineffassign - staticcheck - typecheck - unused # extra linters + - bidichk + - durationcheck - exhaustive - - godot + - exportloopref - gofmt - - whitespace - goimports + - misspell + - predeclared + - reassign + - whitespace + - containedctx + - funlen + - gocognit + - contextcheck disable-all: true fast: false - -issues: - include: - - EXC0002 # should have a comment - - EXC0003 # test/Test ... consider calling this - - EXC0004 # govet - - EXC0005 # C-style breaks diff --git a/client/client.go b/client/client.go index 77f33c2..59de8ab 100644 --- a/client/client.go +++ b/client/client.go @@ -180,6 +180,8 @@ func (x *PrmInit) SetResponseInfoCallback(f func(ResponseMetaInfo) error) { // PrmDial groups connection parameters for the Client. // // See also Dial. +// +// nolint: containedctx type PrmDial struct { endpoint string diff --git a/client/container.go b/client/container.go index 080e44d..9c1ccf8 100644 --- a/client/container.go +++ b/client/container.go @@ -82,6 +82,8 @@ func (x ResContainerPut) ID() cid.ID { // // Return statuses: // - global (see Client docs). +// +// nolint: funlen func (c *Client) ContainerPut(ctx context.Context, prm PrmContainerPut) (*ResContainerPut, error) { // check parameters switch { diff --git a/container/acl/acl.go b/container/acl/acl.go index 1df713f..eedec57 100644 --- a/container/acl/acl.go +++ b/container/acl/acl.go @@ -9,6 +9,7 @@ import "strconv" // use corresponding constants and/or methods instead. type Op uint32 +// nolint: unused const ( opZero Op = iota // extreme value for testing @@ -53,6 +54,7 @@ func (x Op) String() string { // use corresponding constants and/or methods instead. type Role uint32 +// nolint: unused const ( roleZero Role = iota // extreme value for testing diff --git a/container/acl/util.go b/container/acl/util.go index 91c4b21..79b5134 100644 --- a/container/acl/util.go +++ b/container/acl/util.go @@ -8,6 +8,8 @@ func setBit(num *uint32, n uint8) { } // resets n-th bit in num (starting at 0). +// +// nolint: unused func resetBit(num *uint32, n uint8) { var mask uint32 setBit(&mask, n) diff --git a/container/container.go b/container/container.go index 1f5afdf..11cd097 100644 --- a/container/container.go +++ b/container/container.go @@ -50,6 +50,8 @@ const ( // reads Container from the container.Container message. If checkFieldPresence is set, // returns an error on absence of any protocol-required field. +// +// nolint: funlen func (x *Container) readFromV2(m container.Container, checkFieldPresence bool) error { var err error diff --git a/netmap/policy.go b/netmap/policy.go index 14e3e11..114866f 100644 --- a/netmap/policy.go +++ b/netmap/policy.go @@ -393,6 +393,8 @@ func (p *PlacementPolicy) AddFilters(fs ...Filter) { // the result into w. Returns w's errors directly. // // See also DecodeString. +// +// nolint: funlen, gocognit func (p PlacementPolicy) WriteStringTo(w io.StringWriter) (err error) { writtenSmth := false diff --git a/object/transformer/transformer.go b/object/transformer/transformer.go index 098d38f..efe3d98 100644 --- a/object/transformer/transformer.go +++ b/object/transformer/transformer.go @@ -131,6 +131,7 @@ func (s *payloadSizeLimiter) initPayloadHashers() { } } +// nolint: funlen func (s *payloadSizeLimiter) release(finalize bool) (*AccessIdentifiers, error) { // Arg finalize is true only when called from Close method. // We finalize parent and generate linking objects only if it is more diff --git a/pool/pool.go b/pool/pool.go index 772afc1..ef6ccf0 100644 --- a/pool/pool.go +++ b/pool/pool.go @@ -1938,6 +1938,7 @@ func initSessionForDuration(ctx context.Context, dst *session.Object, c client, return nil } +// nolint: containedctx type callContext struct { // base context for RPC context.Context @@ -2072,6 +2073,7 @@ func (p *Pool) PutObject(ctx context.Context, prm PrmObjectPut) (oid.ID, error) if ctxCall.sessionDefault { ctxCall.sessionTarget = prm.UseSession + // nolint: contextcheck if err := p.openDefaultSession(&ctxCall); err != nil { return oid.ID{}, fmt.Errorf("open default session: %w", err) } @@ -2124,6 +2126,7 @@ func (p *Pool) DeleteObject(ctx context.Context, prm PrmObjectDelete) error { return err } + // nolint: contextcheck return p.call(&cc, func() error { if err = cc.client.objectDelete(ctx, prm); err != nil { return fmt.Errorf("remove object via client: %w", err) @@ -2176,6 +2179,7 @@ func (p *Pool) GetObject(ctx context.Context, prm PrmObjectGet) (ResGetObject, e return res, err } + // nolint: contextcheck return res, p.call(&cc, func() error { res, err = cc.client.objectGet(ctx, prm) return err @@ -2200,6 +2204,7 @@ func (p *Pool) HeadObject(ctx context.Context, prm PrmObjectHead) (object.Object return obj, err } + // nolint: contextcheck return obj, p.call(&cc, func() error { obj, err = cc.client.objectHead(ctx, prm) return err @@ -2249,6 +2254,7 @@ func (p *Pool) ObjectRange(ctx context.Context, prm PrmObjectRange) (ResObjectRa return res, err } + // nolint: contextcheck return res, p.call(&cc, func() error { res, err = cc.client.objectRange(ctx, prm) return err @@ -2312,6 +2318,7 @@ func (p *Pool) SearchObjects(ctx context.Context, prm PrmObjectSearch) (ResObjec return res, err } + // nolint: contextcheck return res, p.call(&cc, func() error { res, err = cc.client.objectSearch(ctx, prm) return err