From 429b05fdbe9f1a64df8feff8ee0c5cf4ac48707f Mon Sep 17 00:00:00 2001 From: Fernando Campos Date: Thu, 15 Aug 2024 18:06:43 -0300 Subject: [PATCH] Fix lint issues --- .github/workflows/golangci-lint.yml | 7 ++++--- .golangci.yml | 2 -- .../keeper/inference_synthesis/network_inferences.go | 4 ++-- x/emissions/keeper/keeper.go | 2 +- x/emissions/keeper/keeper_test.go | 2 +- x/mint/keeper/query_server.go | 4 ++-- 6 files changed, 10 insertions(+), 11 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index ca266ff77..aaf03e1fa 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -4,12 +4,13 @@ on: branches: - main - dev + - release-* pull_request: permissions: contents: read - # Optional: allow read access to pull request. Use with `only-new-issues` option. - # pull-requests: read + # Optional: allow write access to checks to allow the action to annotate code in the PR. + checks: write jobs: golangci: @@ -23,4 +24,4 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v6 with: - version: v1.59 + version: v1.60.1 diff --git a/.golangci.yml b/.golangci.yml index 97e670252..183873f61 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -69,8 +69,6 @@ issues: - linters: - stylecheck text: "ST1005:" # punctuation in error messages - - #lint:ignore SA1019 deprecated code breaking unit tests - linters: - staticcheck text: "SA1019: \"github.com/cosmos/ibc-go/v8/modules/core/02-client/types\" is deprecated`" diff --git a/x/emissions/keeper/inference_synthesis/network_inferences.go b/x/emissions/keeper/inference_synthesis/network_inferences.go index 8c858c50c..cccc6c9cd 100644 --- a/x/emissions/keeper/inference_synthesis/network_inferences.go +++ b/x/emissions/keeper/inference_synthesis/network_inferences.go @@ -45,7 +45,7 @@ func GetNetworkInferences( } } else { inferences, err = k.GetInferencesAtBlock(ctx, topicId, *inferencesNonce) - inferenceBlockHeight = int64(*inferencesNonce) + inferenceBlockHeight = *inferencesNonce if err != nil || len(inferences.Inferences) == 0 { return nil, nil, nil, nil, inferenceBlockHeight, lossBlockHeight, errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "no inferences found for topic %v at block %v", topicId, *inferencesNonce) } @@ -70,7 +70,7 @@ func GetNetworkInferences( } // Retrieve forecasts - forecasts, err := k.GetForecastsAtBlock(ctx, topicId, BlockHeight(inferenceBlockHeight)) + forecasts, err := k.GetForecastsAtBlock(ctx, topicId, inferenceBlockHeight) if err != nil { if errors.Is(err, collections.ErrNotFound) { forecasts = &emissions.Forecasts{ diff --git a/x/emissions/keeper/keeper.go b/x/emissions/keeper/keeper.go index c3cb6c66a..33755759f 100644 --- a/x/emissions/keeper/keeper.go +++ b/x/emissions/keeper/keeper.go @@ -1012,7 +1012,7 @@ func (k *Keeper) GetLatestNetworkLossBundle(ctx context.Context, topicId TopicId return &keyValue.Value, nil } - return nil, nil + return nil, types.ErrNoNetworkLossBundleFound } /// STAKING diff --git a/x/emissions/keeper/keeper_test.go b/x/emissions/keeper/keeper_test.go index 476341a43..ebc1ecb2e 100644 --- a/x/emissions/keeper/keeper_test.go +++ b/x/emissions/keeper/keeper_test.go @@ -1311,7 +1311,7 @@ func (s *KeeperTestSuite) TestGetLatestNetworkLossBundle() { // Initially, there should be no loss bundle, so we expect a zero result emptyLossBundle, err := keeper.GetLatestNetworkLossBundle(ctx, topicId) - s.Require().NoError(err, "Retrieving latest network loss bundle when none exist should not result in an error") + s.Require().ErrorIs(err, types.ErrNoNetworkLossBundleFound) s.Require().Nil(emptyLossBundle, "Expected no network loss bundle initially") // Insert first network loss bundle diff --git a/x/mint/keeper/query_server.go b/x/mint/keeper/query_server.go index dfd405b32..775b16ae2 100644 --- a/x/mint/keeper/query_server.go +++ b/x/mint/keeper/query_server.go @@ -96,8 +96,8 @@ func (q queryServer) EmissionInfo(ctx context.Context, _ *types.QueryEmissionInf sdkCtx := sdk.UnwrapSDKContext(ctx) blockHeight := uint64(sdkCtx.BlockHeight()) numberOfRecalcs := blockHeight / blocksPerMonth - blockHeightTarget_e_i_LastCalculated := numberOfRecalcs*blocksPerMonth + 1 - blockHeightTarget_e_i_Next := blockHeightTarget_e_i_LastCalculated + blocksPerMonth + blockHeightTarget_e_i_LastCalculated := numberOfRecalcs*blocksPerMonth + 1 //nolint:revive // var-naming: don't use underscores in Go names + blockHeightTarget_e_i_Next := blockHeightTarget_e_i_LastCalculated + blocksPerMonth //nolint:revive // var-naming: don't use underscores in Go names networkStakedTokens, err := GetNumStakedTokens(ctx, q.k) if err != nil {