From ffe2f6b7327a458baf3680b3dcd7ff3633331333 Mon Sep 17 00:00:00 2001 From: Justin Traglia <95511699+jtraglia@users.noreply.github.com> Date: Mon, 18 Dec 2023 06:16:26 -0600 Subject: [PATCH] Enable mirror linter and fix findings (#13342) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Enable mirror linter and fix findings * Use latest version of golangci-lint * Use v1.55.2 instead of latest --------- Co-authored-by: terence Co-authored-by: Radosław Kapka --- .github/workflows/go.yml | 4 ++-- .golangci.yml | 1 + validator/rpc/auth_token.go | 8 ++++---- validator/rpc/handlers_keymanager.go | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 2449dc3a9..ef95349e9 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -5,7 +5,7 @@ on: branches: [ master ] pull_request: branches: [ '*' ] - merge_group: + merge_group: types: [checks_requested] jobs: @@ -54,7 +54,7 @@ jobs: - name: Golangci-lint uses: golangci/golangci-lint-action@v3 with: - version: v1.52.2 + version: v1.55.2 args: --config=.golangci.yml --out-${NO_FUTURE}format colored-line-number build: diff --git a/.golangci.yml b/.golangci.yml index c18c3c3fc..3c6a45799 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -21,6 +21,7 @@ linters: - nilerr - whitespace - misspell + - mirror - usestdlibvars - errname diff --git a/validator/rpc/auth_token.go b/validator/rpc/auth_token.go index 23eb042be..390dad193 100644 --- a/validator/rpc/auth_token.go +++ b/validator/rpc/auth_token.go @@ -137,16 +137,16 @@ func logValidatorWebAuth(validatorWebAddr, token string, tokenPath string) { func saveAuthToken(walletDirPath string, jwtKey []byte, token string) error { hashFilePath := filepath.Join(walletDirPath, AuthTokenFileName) bytesBuf := new(bytes.Buffer) - if _, err := bytesBuf.Write([]byte(fmt.Sprintf("%x", jwtKey))); err != nil { + if _, err := bytesBuf.WriteString(fmt.Sprintf("%x", jwtKey)); err != nil { return err } - if _, err := bytesBuf.Write([]byte("\n")); err != nil { + if _, err := bytesBuf.WriteString("\n"); err != nil { return err } - if _, err := bytesBuf.Write([]byte(token)); err != nil { + if _, err := bytesBuf.WriteString(token); err != nil { return err } - if _, err := bytesBuf.Write([]byte("\n")); err != nil { + if _, err := bytesBuf.WriteString("\n"); err != nil { return err } return file.WriteFile(hashFilePath, bytesBuf.Bytes()) diff --git a/validator/rpc/handlers_keymanager.go b/validator/rpc/handlers_keymanager.go index 6d26058df..1977962f5 100644 --- a/validator/rpc/handlers_keymanager.go +++ b/validator/rpc/handlers_keymanager.go @@ -132,7 +132,7 @@ func (s *Server) ImportKeystores(w http.ResponseWriter, r *http.Request) { } if req.SlashingProtection != "" { if err := slashingprotection.ImportStandardProtectionJSON( - ctx, s.valDB, bytes.NewBuffer([]byte(req.SlashingProtection)), + ctx, s.valDB, bytes.NewBufferString(req.SlashingProtection), ); err != nil { statuses := make([]*keymanager.KeyStatus, len(req.Keystores)) for i := 0; i < len(req.Keystores); i++ {