From 7d723148ab9c426db99c00f110240fed0fad948d Mon Sep 17 00:00:00 2001 From: Jim McDonald Date: Mon, 5 Jun 2023 20:41:04 +0100 Subject: [PATCH] linting. --- .golangci.yml | 1 + cmd/account/create/process.go | 2 +- cmd/validator/credentials/set/process.go | 2 +- cmd/validator/exit/process.go | 2 +- util/account.go | 2 +- util/misc.go | 2 +- 6 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 82d6e3e..99b0a23 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -128,6 +128,7 @@ linters: - contextcheck - cyclop - deadcode + - depguard - dupl - errorlint - exhaustive diff --git a/cmd/account/create/process.go b/cmd/account/create/process.go index 8d465f5..aaf2e2b 100644 --- a/cmd/account/create/process.go +++ b/cmd/account/create/process.go @@ -86,7 +86,7 @@ func processPathed(ctx context.Context, data *dataIn) (*dataOut, error) { if data.passphrase == "" { return nil, errors.New("passphrase is required") } - match, err := regexp.Match("^m/[0-9]+/[0-9]+(/[0-9+])+", []byte(data.path)) + match, err := regexp.MatchString("^m/[0-9]+/[0-9]+(/[0-9+])+", data.path) if err != nil { return nil, errors.Wrap(err, "unable to match path to regular expression") } diff --git a/cmd/validator/credentials/set/process.go b/cmd/validator/credentials/set/process.go index a4f8414..42762b4 100644 --- a/cmd/validator/credentials/set/process.go +++ b/cmd/validator/credentials/set/process.go @@ -163,7 +163,7 @@ func (c *command) generateOperationFromMnemonicAndPath(ctx context.Context) erro } validatorKeyPath := c.path - match := validatorPath.Match([]byte(c.path)) + match := validatorPath.MatchString(c.path) if !match { return fmt.Errorf("path %s does not match EIP-2334 format for a validator", c.path) } diff --git a/cmd/validator/exit/process.go b/cmd/validator/exit/process.go index 833a576..e9e0bb1 100644 --- a/cmd/validator/exit/process.go +++ b/cmd/validator/exit/process.go @@ -144,7 +144,7 @@ func (c *command) generateOperationFromMnemonicAndPath(ctx context.Context) erro } validatorKeyPath := c.path - match := validatorPath.Match([]byte(c.path)) + match := validatorPath.MatchString(c.path) if !match { return fmt.Errorf("path %s does not match EIP-2334 format for a validator", c.path) } diff --git a/util/account.go b/util/account.go index eb07347..68032b2 100644 --- a/util/account.go +++ b/util/account.go @@ -252,7 +252,7 @@ func accountFromMnemonicAndPath(mnemonic string, path string) (e2wtypes.Account, } // Ensure the path is valid. - match := hdPathRegex.Match([]byte(path)) + match := hdPathRegex.MatchString(path) if !match { return nil, errors.New("path does not match expected format m/…") } diff --git a/util/misc.go b/util/misc.go index a869dd5..e4a0352 100644 --- a/util/misc.go +++ b/util/misc.go @@ -196,7 +196,7 @@ func WalletAndAccountsFromPath(ctx context.Context, path string) (e2wtypes.Walle accounts := make([]e2wtypes.Account, 0) for account := range wallet.Accounts(ctx) { - if re.Match([]byte(account.Name())) { + if re.MatchString(account.Name()) { accounts = append(accounts, account) } }