[#47] .golangci.yml: Unify with other FrostFS repos

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2023-04-07 08:12:41 +03:00
parent 4fa52312c7
commit 708d933fe3
9 changed files with 39 additions and 12 deletions

View file

@ -4,10 +4,10 @@
# options for analysis running # options for analysis running
run: run:
# timeout for analysis, e.g. 30s, 5m, default is 1m # timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 5m timeout: 10m
# include test files or not, default is true # include test files or not, default is true
tests: true tests: false
# output configuration options # output configuration options
output: output:
@ -26,7 +26,11 @@ linters-settings:
check-shadowing: false check-shadowing: false
staticcheck: staticcheck:
checks: ["all", "-SA1019"] # TODO Enable SA1019 after deprecated warning are fixed. 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: linters:
enable: enable:
@ -37,23 +41,26 @@ linters:
# some default golangci-lint linters # some default golangci-lint linters
- errcheck - errcheck
- gosimple - gosimple
- godot
- ineffassign - ineffassign
- staticcheck - staticcheck
- typecheck - typecheck
- unused - unused
# extra linters # extra linters
- bidichk
- durationcheck
- exhaustive - exhaustive
- godot - exportloopref
- gofmt - gofmt
- whitespace
- goimports - goimports
- misspell
- predeclared
- reassign
- whitespace
- containedctx
- funlen
- gocognit
- contextcheck
disable-all: true disable-all: true
fast: false fast: false
issues:
include:
- EXC0002 # should have a comment
- EXC0003 # test/Test ... consider calling this
- EXC0004 # govet
- EXC0005 # C-style breaks

View file

@ -180,6 +180,8 @@ func (x *PrmInit) SetResponseInfoCallback(f func(ResponseMetaInfo) error) {
// PrmDial groups connection parameters for the Client. // PrmDial groups connection parameters for the Client.
// //
// See also Dial. // See also Dial.
//
// nolint: containedctx
type PrmDial struct { type PrmDial struct {
endpoint string endpoint string

View file

@ -82,6 +82,8 @@ func (x ResContainerPut) ID() cid.ID {
// //
// Return statuses: // Return statuses:
// - global (see Client docs). // - global (see Client docs).
//
// nolint: funlen
func (c *Client) ContainerPut(ctx context.Context, prm PrmContainerPut) (*ResContainerPut, error) { func (c *Client) ContainerPut(ctx context.Context, prm PrmContainerPut) (*ResContainerPut, error) {
// check parameters // check parameters
switch { switch {

View file

@ -9,6 +9,7 @@ import "strconv"
// use corresponding constants and/or methods instead. // use corresponding constants and/or methods instead.
type Op uint32 type Op uint32
// nolint: unused
const ( const (
opZero Op = iota // extreme value for testing opZero Op = iota // extreme value for testing
@ -53,6 +54,7 @@ func (x Op) String() string {
// use corresponding constants and/or methods instead. // use corresponding constants and/or methods instead.
type Role uint32 type Role uint32
// nolint: unused
const ( const (
roleZero Role = iota // extreme value for testing roleZero Role = iota // extreme value for testing

View file

@ -8,6 +8,8 @@ func setBit(num *uint32, n uint8) {
} }
// resets n-th bit in num (starting at 0). // resets n-th bit in num (starting at 0).
//
// nolint: unused
func resetBit(num *uint32, n uint8) { func resetBit(num *uint32, n uint8) {
var mask uint32 var mask uint32
setBit(&mask, n) setBit(&mask, n)

View file

@ -50,6 +50,8 @@ const (
// reads Container from the container.Container message. If checkFieldPresence is set, // reads Container from the container.Container message. If checkFieldPresence is set,
// returns an error on absence of any protocol-required field. // returns an error on absence of any protocol-required field.
//
// nolint: funlen
func (x *Container) readFromV2(m container.Container, checkFieldPresence bool) error { func (x *Container) readFromV2(m container.Container, checkFieldPresence bool) error {
var err error var err error

View file

@ -393,6 +393,8 @@ func (p *PlacementPolicy) AddFilters(fs ...Filter) {
// the result into w. Returns w's errors directly. // the result into w. Returns w's errors directly.
// //
// See also DecodeString. // See also DecodeString.
//
// nolint: funlen, gocognit
func (p PlacementPolicy) WriteStringTo(w io.StringWriter) (err error) { func (p PlacementPolicy) WriteStringTo(w io.StringWriter) (err error) {
writtenSmth := false writtenSmth := false

View file

@ -131,6 +131,7 @@ func (s *payloadSizeLimiter) initPayloadHashers() {
} }
} }
// nolint: funlen
func (s *payloadSizeLimiter) release(finalize bool) (*AccessIdentifiers, error) { func (s *payloadSizeLimiter) release(finalize bool) (*AccessIdentifiers, error) {
// Arg finalize is true only when called from Close method. // Arg finalize is true only when called from Close method.
// We finalize parent and generate linking objects only if it is more // We finalize parent and generate linking objects only if it is more

View file

@ -1938,6 +1938,7 @@ func initSessionForDuration(ctx context.Context, dst *session.Object, c client,
return nil return nil
} }
// nolint: containedctx
type callContext struct { type callContext struct {
// base context for RPC // base context for RPC
context.Context context.Context
@ -2072,6 +2073,7 @@ func (p *Pool) PutObject(ctx context.Context, prm PrmObjectPut) (oid.ID, error)
if ctxCall.sessionDefault { if ctxCall.sessionDefault {
ctxCall.sessionTarget = prm.UseSession ctxCall.sessionTarget = prm.UseSession
// nolint: contextcheck
if err := p.openDefaultSession(&ctxCall); err != nil { if err := p.openDefaultSession(&ctxCall); err != nil {
return oid.ID{}, fmt.Errorf("open default session: %w", err) 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 return err
} }
// nolint: contextcheck
return p.call(&cc, func() error { return p.call(&cc, func() error {
if err = cc.client.objectDelete(ctx, prm); err != nil { if err = cc.client.objectDelete(ctx, prm); err != nil {
return fmt.Errorf("remove object via client: %w", err) 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 return res, err
} }
// nolint: contextcheck
return res, p.call(&cc, func() error { return res, p.call(&cc, func() error {
res, err = cc.client.objectGet(ctx, prm) res, err = cc.client.objectGet(ctx, prm)
return err return err
@ -2200,6 +2204,7 @@ func (p *Pool) HeadObject(ctx context.Context, prm PrmObjectHead) (object.Object
return obj, err return obj, err
} }
// nolint: contextcheck
return obj, p.call(&cc, func() error { return obj, p.call(&cc, func() error {
obj, err = cc.client.objectHead(ctx, prm) obj, err = cc.client.objectHead(ctx, prm)
return err return err
@ -2249,6 +2254,7 @@ func (p *Pool) ObjectRange(ctx context.Context, prm PrmObjectRange) (ResObjectRa
return res, err return res, err
} }
// nolint: contextcheck
return res, p.call(&cc, func() error { return res, p.call(&cc, func() error {
res, err = cc.client.objectRange(ctx, prm) res, err = cc.client.objectRange(ctx, prm)
return err return err
@ -2312,6 +2318,7 @@ func (p *Pool) SearchObjects(ctx context.Context, prm PrmObjectSearch) (ResObjec
return res, err return res, err
} }
// nolint: contextcheck
return res, p.call(&cc, func() error { return res, p.call(&cc, func() error {
res, err = cc.client.objectSearch(ctx, prm) res, err = cc.client.objectSearch(ctx, prm)
return err return err