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

fix/Update and fix linter #2493

Merged
merged 4 commits into from
Aug 11, 2023
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
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.50.0
version: v1.54.0
args: --timeout=5m
only-new-issues: true
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ HUB_IMAGE ?= nspccdev/neofs
HUB_TAG ?= "$(shell echo ${VERSION} | sed 's/^v//')"

GO_VERSION ?= 1.20
LINT_VERSION ?= 1.50.0
LINT_VERSION ?= 1.54.0
ARCH = amd64

BIN = bin
Expand Down
2 changes: 1 addition & 1 deletion cmd/neofs-adm/internal/modules/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ credentials:
{{.}}: password{{end}}
`

func initConfig(cmd *cobra.Command, args []string) error {
func initConfig(cmd *cobra.Command, _ []string) error {
configPath, err := readConfigPathFromArgs(cmd)
if err != nil {
return nil
Expand Down
4 changes: 2 additions & 2 deletions cmd/neofs-adm/internal/modules/morph/balance.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func dumpBalances(cmd *cobra.Command, _ []string) error {
}
}

irList, err := fetchIRNodes(c, nmHash, rolemgmt.Hash)
irList, err := fetchIRNodes(c, rolemgmt.Hash)
if err != nil {
return err
}
Expand Down Expand Up @@ -158,7 +158,7 @@ func dumpBalances(cmd *cobra.Command, _ []string) error {
return nil
}

func fetchIRNodes(c Client, nmHash, desigHash util.Uint160) ([]accBalancePair, error) {
func fetchIRNodes(c Client, desigHash util.Uint160) ([]accBalancePair, error) {
inv := invoker.New(c, nil)

height, err := c.GetBlockCount()
Expand Down
6 changes: 3 additions & 3 deletions cmd/neofs-adm/internal/modules/morph/dump_hashes.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func dumpContractHashes(cmd *cobra.Command, _ []string) error {
}

fillContractVersion(cmd, c, infos)
fillContractExpiration(cmd, c, infos)
fillContractExpiration(c, infos)
printContractInfo(cmd, infos)

return nil
Expand Down Expand Up @@ -178,7 +178,7 @@ func dumpCustomZoneHashes(cmd *cobra.Command, nnsHash util.Uint160, zone string,
}

fillContractVersion(cmd, c, infos)
fillContractExpiration(cmd, c, infos)
fillContractExpiration(c, infos)
printContractInfo(cmd, infos)

return nil
Expand Down Expand Up @@ -259,7 +259,7 @@ func fillContractVersion(cmd *cobra.Command, c Client, infos []contractDumpInfo)
}
}

func fillContractExpiration(cmd *cobra.Command, c Client, infos []contractDumpInfo) {
func fillContractExpiration(c Client, infos []contractDumpInfo) {
n11r := nep11.NewNonDivisibleReader(invoker.New(c, nil), infos[0].hash)
for i := range infos {
if infos[i].hash.Equals(util.Uint160{}) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/neofs-adm/internal/modules/morph/epoch.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/spf13/viper"
)

func forceNewEpochCmd(cmd *cobra.Command, args []string) error {
func forceNewEpochCmd(cmd *cobra.Command, _ []string) error {
wCtx, err := newInitializeContext(cmd, viper.GetViper())
if err != nil {
return fmt.Errorf("can't to initialize context: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion cmd/neofs-adm/internal/modules/morph/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const (
consensusAccountName = "consensus"
)

func generateAlphabetCreds(cmd *cobra.Command, args []string) error {
func generateAlphabetCreds(cmd *cobra.Command, _ []string) error {
// alphabet size is not part of the config
size, err := cmd.Flags().GetUint(alphabetSizeFlag)
if err != nil {
Expand Down
34 changes: 17 additions & 17 deletions cmd/neofs-adm/internal/modules/morph/initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type initializeContext struct {
ContractPath string
}

func initializeSideChainCmd(cmd *cobra.Command, args []string) error {
func initializeSideChainCmd(cmd *cobra.Command, _ []string) error {
initCtx, err := newInitializeContext(cmd, viper.GetViper())
if err != nil {
return fmt.Errorf("initialization error: %w", err)
Expand All @@ -52,45 +52,45 @@ func initializeSideChainCmd(cmd *cobra.Command, args []string) error {

// 1. Transfer funds to committee accounts.
cmd.Println("Stage 1: transfer GAS to alphabet nodes.")
if err := initCtx.transferFunds(); err != nil {
return err
if err = initCtx.transferFunds(); err != nil {
return fmt.Errorf("transferring GAS to alphabet nodes: %w", err)
}

cmd.Println("Stage 2: set notary and alphabet nodes in designate contract.")
if err := initCtx.setNotaryAndAlphabetNodes(); err != nil {
return err
if err = initCtx.setNotaryAndAlphabetNodes(); err != nil {
return fmt.Errorf("setting notary and alphabet roles: %w", err)
}

// 3. Deploy NNS contract.
cmd.Println("Stage 3: deploy NNS contract.")
if err := initCtx.deployNNS(deployMethodName); err != nil {
return err
if err = initCtx.deployNNS(deployMethodName); err != nil {
return fmt.Errorf("deploying NNS: %w", err)
}

// 4. Deploy NeoFS contracts.
cmd.Println("Stage 4: deploy NeoFS contracts.")
if err := initCtx.deployContracts(); err != nil {
return err
if err = initCtx.deployContracts(); err != nil {
return fmt.Errorf("deploying NeoFS contracts: %w", err)
}

cmd.Println("Stage 4.1: Transfer GAS to proxy contract.")
if err := initCtx.transferGASToProxy(); err != nil {
return err
if err = initCtx.transferGASToProxy(); err != nil {
return fmt.Errorf("topping up proxy contract: %w", err)
}

cmd.Println("Stage 5: register candidates.")
if err := initCtx.registerCandidates(); err != nil {
return err
if err = initCtx.registerCandidates(); err != nil {
return fmt.Errorf("candidate registration: %w", err)
}

cmd.Println("Stage 6: transfer NEO to alphabet contracts.")
if err := initCtx.transferNEOToAlphabetContracts(); err != nil {
return err
if err = initCtx.transferNEOToAlphabetContracts(); err != nil {
return fmt.Errorf(": %w", err)
}

cmd.Println("Stage 7: set addresses in NNS.")
if err := initCtx.setNNS(); err != nil {
return err
if err = initCtx.setNNS(); err != nil {
return fmt.Errorf("filling NNS with contract hashes: %w", err)
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/neofs-adm/internal/modules/morph/local_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func (l *localClient) GetVersion() (*result.Version, error) {
return &result.Version{}, nil
}

func (l *localClient) InvokeContractVerify(contract util.Uint160, params []smartcontract.Parameter, signers []transaction.Signer, witnesses ...transaction.Witness) (*result.Invoke, error) {
func (l *localClient) InvokeContractVerify(_ util.Uint160, _ []smartcontract.Parameter, _ []transaction.Signer, _ ...transaction.Witness) (*result.Invoke, error) {
// not used by `morph init` command
panic("unexpected call")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/neofs-adm/internal/modules/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func Execute() error {
return rootCmd.Execute()
}

func entryPoint(cmd *cobra.Command, args []string) error {
func entryPoint(cmd *cobra.Command, _ []string) error {
printVersion, _ := cmd.Flags().GetBool("version")
if printVersion {
cmd.Print(misc.BuildInfo("NeoFS Adm"))
Expand Down
12 changes: 6 additions & 6 deletions cmd/neofs-cli/internal/client/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,25 @@ var errInvalidEndpoint = errors.New("provided RPC endpoint is incorrect")
// GetSDKClientByFlag returns default neofs-sdk-go client using the specified flag for the address.
// On error, outputs to stderr of cmd and exits with non-zero code.
func GetSDKClientByFlag(ctx context.Context, cmd *cobra.Command, endpointFlag string) *client.Client {
cli, err := getSDKClientByFlag(ctx, cmd, endpointFlag)
cli, err := getSDKClientByFlag(ctx, endpointFlag)
if err != nil {
common.ExitOnErr(cmd, "can't create API client: %w", err)
}
return cli
}

func getSDKClientByFlag(ctx context.Context, cmd *cobra.Command, endpointFlag string) (*client.Client, error) {
func getSDKClientByFlag(ctx context.Context, endpointFlag string) (*client.Client, error) {
var addr network.Address

err := addr.FromString(viper.GetString(endpointFlag))
if err != nil {
return nil, fmt.Errorf("%v: %w", errInvalidEndpoint, err)
}
return GetSDKClient(ctx, cmd, addr)
return GetSDKClient(ctx, addr)
}

// GetSDKClient returns default neofs-sdk-go client.
func GetSDKClient(ctx context.Context, cmd *cobra.Command, addr network.Address) (*client.Client, error) {
func GetSDKClient(ctx context.Context, addr network.Address) (*client.Client, error) {
var (
prmInit client.PrmInit
prmDial client.PrmDial
Expand Down Expand Up @@ -88,14 +88,14 @@ func GetSDKClient(ctx context.Context, cmd *cobra.Command, addr network.Address)
}

// GetCurrentEpoch returns current epoch.
func GetCurrentEpoch(ctx context.Context, cmd *cobra.Command, endpoint string) (uint64, error) {
func GetCurrentEpoch(ctx context.Context, endpoint string) (uint64, error) {
var addr network.Address

if err := addr.FromString(endpoint); err != nil {
return 0, fmt.Errorf("can't parse RPC endpoint: %w", err)
}

c, err := GetSDKClient(ctx, cmd, addr)
c, err := GetSDKClient(ctx, addr)
if err != nil {
return 0, err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/neofs-cli/modules/bearer/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func createToken(cmd *cobra.Command, _ []string) {
defer cancel()

endpoint, _ := cmd.Flags().GetString(commonflags.RPC)
currEpoch, err := internalclient.GetCurrentEpoch(ctx, cmd, endpoint)
currEpoch, err := internalclient.GetCurrentEpoch(ctx, endpoint)
common.ExitOnErr(cmd, "can't fetch current epoch: %w", err)

if iatRelative {
Expand Down
2 changes: 1 addition & 1 deletion cmd/neofs-cli/modules/object/lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ var objectLockCmd = &cobra.Command{

endpoint, _ := cmd.Flags().GetString(commonflags.RPC)

currEpoch, err := internalclient.GetCurrentEpoch(ctx, cmd, endpoint)
currEpoch, err := internalclient.GetCurrentEpoch(ctx, endpoint)
common.ExitOnErr(cmd, "Request current epoch: %w", err)

exp = currEpoch + lifetime
Expand Down
2 changes: 1 addition & 1 deletion cmd/neofs-cli/modules/session/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func createSession(cmd *cobra.Command, _ []string) {
addrStr, _ := cmd.Flags().GetString(commonflags.RPC)
common.ExitOnErr(cmd, "can't parse endpoint: %w", netAddr.FromString(addrStr))

c, err := internalclient.GetSDKClient(ctx, cmd, netAddr)
c, err := internalclient.GetSDKClient(ctx, netAddr)
common.ExitOnErr(cmd, "can't create client: %w", err)

lifetime := uint64(defaultLifetime)
Expand Down
8 changes: 5 additions & 3 deletions pkg/local_object_storage/blobovnicza/sizes.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package blobovnicza
import (
"encoding/binary"
"fmt"
"math/bits"
"strconv"
)

Expand Down Expand Up @@ -31,11 +32,12 @@ func bucketForSize(sz uint64) []byte {
return bucketKeyFromBounds(upperPowerOfTwo(sz))
}

func upperPowerOfTwo(v uint64) (upperBound uint64) {
for upperBound = firstBucketBound; upperBound < v; upperBound *= 2 {
func upperPowerOfTwo(v uint64) uint64 {
if v <= firstBucketBound {
return firstBucketBound
}

return
return 1 << bits.Len64(v-1)
}

func (b *Blobovnicza) incSize(sz uint64) {
Expand Down
14 changes: 7 additions & 7 deletions pkg/local_object_storage/blobstor/blobovniczatree/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (b *Blobovniczas) Delete(prm common.DeletePrm) (res common.DeleteRes, err e
return res, err
}

return b.deleteObject(blz, bPrm, prm)
return b.deleteObject(blz, bPrm)
}

activeCache := make(map[string]struct{})
Expand All @@ -41,7 +41,7 @@ func (b *Blobovniczas) Delete(prm common.DeletePrm) (res common.DeleteRes, err e
// don't process active blobovnicza of the level twice
_, ok := activeCache[dirPath]

res, err = b.deleteObjectFromLevel(bPrm, p, !ok, prm)
res, err = b.deleteObjectFromLevel(bPrm, p, !ok)
if err != nil {
if !blobovnicza.IsErrNotFound(err) {
b.log.Debug("could not remove object from level",
Expand Down Expand Up @@ -72,15 +72,15 @@ func (b *Blobovniczas) Delete(prm common.DeletePrm) (res common.DeleteRes, err e
// tries to delete object from particular blobovnicza.
//
// returns no error if object was removed from some blobovnicza of the same level.
func (b *Blobovniczas) deleteObjectFromLevel(prm blobovnicza.DeletePrm, blzPath string, tryActive bool, dp common.DeletePrm) (common.DeleteRes, error) {
func (b *Blobovniczas) deleteObjectFromLevel(prm blobovnicza.DeletePrm, blzPath string, tryActive bool) (common.DeleteRes, error) {
lvlPath := filepath.Dir(blzPath)

// try to remove from blobovnicza if it is opened
b.lruMtx.Lock()
v, ok := b.opened.Get(blzPath)
b.lruMtx.Unlock()
if ok {
if res, err := b.deleteObject(v, prm, dp); err == nil {
if res, err := b.deleteObject(v, prm); err == nil {
return res, err
} else if !blobovnicza.IsErrNotFound(err) {
b.log.Debug("could not remove object from opened blobovnicza",
Expand All @@ -99,7 +99,7 @@ func (b *Blobovniczas) deleteObjectFromLevel(prm blobovnicza.DeletePrm, blzPath
b.activeMtx.RUnlock()

if ok && tryActive {
if res, err := b.deleteObject(active.blz, prm, dp); err == nil {
if res, err := b.deleteObject(active.blz, prm); err == nil {
return res, err
} else if !blobovnicza.IsErrNotFound(err) {
b.log.Debug("could not remove object from active blobovnicza",
Expand All @@ -124,11 +124,11 @@ func (b *Blobovniczas) deleteObjectFromLevel(prm blobovnicza.DeletePrm, blzPath
return common.DeleteRes{}, err
}

return b.deleteObject(blz, prm, dp)
return b.deleteObject(blz, prm)
}

// removes object from blobovnicza and returns common.DeleteRes.
func (b *Blobovniczas) deleteObject(blz *blobovnicza.Blobovnicza, prm blobovnicza.DeletePrm, dp common.DeletePrm) (common.DeleteRes, error) {
func (b *Blobovniczas) deleteObject(blz *blobovnicza.Blobovnicza, prm blobovnicza.DeletePrm) (common.DeleteRes, error) {
_, err := blz.Delete(prm)
return common.DeleteRes{}, err
}
2 changes: 1 addition & 1 deletion pkg/local_object_storage/blobstor/fstree/fstree.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,6 @@ func (t *FSTree) SetCompressor(cc *compression.Config) {
}

// SetReportErrorFunc implements common.Storage.
func (t *FSTree) SetReportErrorFunc(f func(string, error)) {
func (t *FSTree) SetReportErrorFunc(_ func(string, error)) {
// Do nothing, FSTree can encounter only one error which is returned.
}
2 changes: 1 addition & 1 deletion pkg/network/cache/multi.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ func (x *multiClient) AnnounceIntermediateTrust(ctx context.Context, epoch uint6
})
}

func (x *multiClient) ExecRaw(f func(client *rawclient.Client) error) error {
func (x *multiClient) ExecRaw(_ func(client *rawclient.Client) error) error {
panic("multiClient.ExecRaw() must not be called")
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/services/accounting/morph/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func NewExecutor(client *balance.Client) accountingSvc.ServiceExecutor {
}
}

func (s *morphExecutor) Balance(ctx context.Context, body *accounting.BalanceRequestBody) (*accounting.BalanceResponseBody, error) {
func (s *morphExecutor) Balance(_ context.Context, body *accounting.BalanceRequestBody) (*accounting.BalanceResponseBody, error) {
idV2 := body.GetOwnerID()
if idV2 == nil {
return nil, errors.New("missing account")
Expand Down
8 changes: 4 additions & 4 deletions pkg/services/container/morph/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (s *morphExecutor) Delete(_ context.Context, tokV2 *sessionV2.Token, body *
return new(container.DeleteResponseBody), nil
}

func (s *morphExecutor) Get(ctx context.Context, body *container.GetRequestBody) (*container.GetResponseBody, error) {
func (s *morphExecutor) Get(_ context.Context, body *container.GetRequestBody) (*container.GetResponseBody, error) {
idV2 := body.GetContainerID()
if idV2 == nil {
return nil, errors.New("missing container ID")
Expand Down Expand Up @@ -176,7 +176,7 @@ func (s *morphExecutor) Get(ctx context.Context, body *container.GetRequestBody)
return res, nil
}

func (s *morphExecutor) List(ctx context.Context, body *container.ListRequestBody) (*container.ListResponseBody, error) {
func (s *morphExecutor) List(_ context.Context, body *container.ListRequestBody) (*container.ListResponseBody, error) {
idV2 := body.GetOwnerID()
if idV2 == nil {
return nil, fmt.Errorf("missing user ID")
Expand Down Expand Up @@ -205,7 +205,7 @@ func (s *morphExecutor) List(ctx context.Context, body *container.ListRequestBod
return res, nil
}

func (s *morphExecutor) SetExtendedACL(ctx context.Context, tokV2 *sessionV2.Token, body *container.SetExtendedACLRequestBody) (*container.SetExtendedACLResponseBody, error) {
func (s *morphExecutor) SetExtendedACL(_ context.Context, tokV2 *sessionV2.Token, body *container.SetExtendedACLRequestBody) (*container.SetExtendedACLResponseBody, error) {
sigV2 := body.GetSignature()
if sigV2 == nil {
// TODO(@cthulhu-rider): #1387 use "const" error
Expand Down Expand Up @@ -238,7 +238,7 @@ func (s *morphExecutor) SetExtendedACL(ctx context.Context, tokV2 *sessionV2.Tok
return new(container.SetExtendedACLResponseBody), nil
}

func (s *morphExecutor) GetExtendedACL(ctx context.Context, body *container.GetExtendedACLRequestBody) (*container.GetExtendedACLResponseBody, error) {
func (s *morphExecutor) GetExtendedACL(_ context.Context, body *container.GetExtendedACLRequestBody) (*container.GetExtendedACLResponseBody, error) {
idV2 := body.GetContainerID()
if idV2 == nil {
return nil, errors.New("missing container ID")
Expand Down
Loading
Loading