From 209c5189092619436b051994a29d7786919e7f41 Mon Sep 17 00:00:00 2001 From: MalteHerrmann Date: Tue, 7 May 2024 22:18:39 +0200 Subject: [PATCH] address linters --- .golangci.yml | 25 +++++-------------------- gov/vote.go | 5 +++-- utils/utils.go | 8 ++++---- 3 files changed, 12 insertions(+), 26 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index ad6f070..0ba135b 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -9,36 +9,21 @@ linters: disable: # unwanted linters - depguard # would have loved to add but doesn't seem to work correctly + - err113 - exhaustruct - - gomoddirectives - - goerr113 - - gomnd - # discontinued linters - - deadcode - - exhaustivestruct - gochecknoglobals - gochecknoinits - - golint - - ifshort - - interfacer - - nosnakecase - - maligned - - scopelint - - structcheck - - varcheck + - gomnd + - gomoddirectives + - mnd linters-settings: dogsled: - max-blank-identifiers: 3 - gofumpt: - lang-version: "1.21" - maligned: - suggest-new: true + max-blank-identifiers: 1 misspell: locale: US nolintlint: allow-unused: false - allow-leading-space: true require-explanation: true require-specific: true varnamelen: diff --git a/gov/vote.go b/gov/vote.go index 195972a..0b64785 100644 --- a/gov/vote.go +++ b/gov/vote.go @@ -31,7 +31,7 @@ func SubmitAllVotesForProposal(bin *utils.Binary, proposalID int) error { } if err := utils.WaitNBlocks(bin, 1); err != nil { - return err + return errors.Wrapf(err, "error waiting for blocks") } bin.Logger.Info().Msgf("voting for proposal %d", proposalID) @@ -55,7 +55,8 @@ func SubmitAllVotesForProposal(bin *utils.Binary, proposalID int) error { bin.Logger.Error().Msgf("could not vote using key %s: %v", acc.Name, err) } else { bin.Logger.Info().Msgf("voted using key %s", acc.Name) - successfulVotes += 1 + + successfulVotes++ } } diff --git a/utils/utils.go b/utils/utils.go index ffa1031..d259b0f 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -67,7 +67,6 @@ type BinaryCmdArgs struct { func ExecuteBinaryCmd(bin *Binary, args BinaryCmdArgs) (string, error) { fullCommand := args.Subcommand - fmt.Println("Command: ", bin.Config.Appd, strings.Join(fullCommand, " ")) //#nosec G204 // no risk of injection here because only internal commands are passed cmd := exec.Command(bin.Config.Appd, fullCommand...) @@ -192,21 +191,22 @@ func GetTxHashFromTxResponse(cdc *codec.ProtoCodec, out string) (string, error) // WaitNBlocks waits for the specified amount of blocks being produced // on the connected network. -func WaitNBlocks(bin *Binary, n int) error { +func WaitNBlocks(bin *Binary, nBlocks int) error { currentHeight, err := GetCurrentHeight(bin) if err != nil { return err } for { - bin.Logger.Debug().Msgf("waiting for %d blocks\n", n) + bin.Logger.Debug().Msgf("waiting for %d blocks\n", nBlocks) time.Sleep(2 * time.Second) + height, err := GetCurrentHeight(bin) if err != nil { return err } - if height >= currentHeight+n { + if height >= currentHeight+nBlocks { break } }