From 5639e67a1d06ac592366cb910d4cc9eff9b7ef84 Mon Sep 17 00:00:00 2001 From: Elad Gildnur <6321801+shleikes@users.noreply.github.com> Date: Sun, 15 Dec 2024 13:18:08 +0200 Subject: [PATCH] chore: PRT - Fix linter warn and err (#1836) * update go version * sdk tests go version * Fix linter warning for the config * Fix linter errors --------- Co-authored-by: Yarom Swisa --- .golangci.yml | 13 +------------ .../rpcInterfaceMessages/grpcMessage_test.go | 8 ++------ .../rpcInterfaceMessages/jsonRPCMessage_test.go | 2 -- .../rpcInterfaceMessages/restMessage_test.go | 2 -- .../tendermintRPCMessage_test.go | 11 ++--------- .../chainlib/chainproxy/rpcclient/types_test.go | 1 - protocol/chainlib/common_test.go | 8 -------- protocol/parser/parser_test.go | 7 +------ x/downtime/v1/genesis_test.go | 2 +- .../client/cli/query_epoch_details_test.go | 2 +- x/spec/ante/ante_test.go | 3 +-- x/spec/client/cli/query_spec_test.go | 1 - 12 files changed, 9 insertions(+), 51 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index a6939f5b2d..c89230b521 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -2,21 +2,13 @@ run: tests: true # timeout for analysis, e.g. 30s, 5m, default is 1m timeout: 7m - skip-files: - - "protocol/chainlib/chainproxy/rpcInterfaceMessages/grpcMessage.go" - - "protocol/chainlib/grpc.go" - - "protocol/chainlib/grpcproxy/dyncodec/remote_grpc_reflection.go" - - "protocol/chainlib/grpcproxy/dyncodec/remote_relayer.go" - - "protocol/chainlib/grpcproxy/dyncodec/remotes_test.go" - - "ecosystem/lavajs/*" - - "ecosystem/lava-sdk/*" linters: disable-all: true #for list of linters and what they do: https://golangci-lint.run/usage/linters/ enable: - dogsled - - exportloopref + - copyloopvar - gocritic - gofumpt - gosimple @@ -78,9 +70,6 @@ issues: linters-settings: dogsled: max-blank-identifiers: 5 - maligned: - # print struct with more effective memory layout or not, false by default - suggest-new: true nolintlint: allow-unused: false require-explanation: false diff --git a/protocol/chainlib/chainproxy/rpcInterfaceMessages/grpcMessage_test.go b/protocol/chainlib/chainproxy/rpcInterfaceMessages/grpcMessage_test.go index f049e1c793..2104585c0a 100644 --- a/protocol/chainlib/chainproxy/rpcInterfaceMessages/grpcMessage_test.go +++ b/protocol/chainlib/chainproxy/rpcInterfaceMessages/grpcMessage_test.go @@ -36,8 +36,6 @@ func TestGRPCParseBlock(t *testing.T) { } for _, testCase := range testTable { - testCase := testCase - t.Run(testCase.name, func(t *testing.T) { t.Parallel() @@ -81,9 +79,8 @@ func TestReflectionSupport(t *testing.T) { } for _, testCase := range testTable { - testCase := testCase - t.Run(testCase.name, func(t *testing.T) { + t.Parallel() result := ReflectionSupport(testCase.err) if testCase.err == nil { @@ -132,9 +129,8 @@ func TestParseSymbol(t *testing.T) { } for _, testCase := range testTable { - testCase := testCase - t.Run(testCase.name, func(t *testing.T) { + t.Parallel() s, m := ParseSymbol(testCase.input) if s != testCase.expectedS { t.Errorf("expected %q, but got %q", testCase.expectedS, s) diff --git a/protocol/chainlib/chainproxy/rpcInterfaceMessages/jsonRPCMessage_test.go b/protocol/chainlib/chainproxy/rpcInterfaceMessages/jsonRPCMessage_test.go index f4113932fc..837969aa5e 100644 --- a/protocol/chainlib/chainproxy/rpcInterfaceMessages/jsonRPCMessage_test.go +++ b/protocol/chainlib/chainproxy/rpcInterfaceMessages/jsonRPCMessage_test.go @@ -77,8 +77,6 @@ func TestJsonrpcMessage_ParseBlock(t *testing.T) { } for _, testCase := range testTable { - testCase := testCase - t.Run(testCase.name, func(t *testing.T) { t.Parallel() diff --git a/protocol/chainlib/chainproxy/rpcInterfaceMessages/restMessage_test.go b/protocol/chainlib/chainproxy/rpcInterfaceMessages/restMessage_test.go index 3cef8aba0c..1c13605453 100644 --- a/protocol/chainlib/chainproxy/rpcInterfaceMessages/restMessage_test.go +++ b/protocol/chainlib/chainproxy/rpcInterfaceMessages/restMessage_test.go @@ -50,8 +50,6 @@ func TestRestParseBlock(t *testing.T) { } for _, testCase := range testTable { - testCase := testCase - t.Run(testCase.name, func(t *testing.T) { t.Parallel() diff --git a/protocol/chainlib/chainproxy/rpcInterfaceMessages/tendermintRPCMessage_test.go b/protocol/chainlib/chainproxy/rpcInterfaceMessages/tendermintRPCMessage_test.go index 59c355e506..6c8f4b88d6 100644 --- a/protocol/chainlib/chainproxy/rpcInterfaceMessages/tendermintRPCMessage_test.go +++ b/protocol/chainlib/chainproxy/rpcInterfaceMessages/tendermintRPCMessage_test.go @@ -59,8 +59,6 @@ func TestTendermintrpcMessage_ParseBlock(t *testing.T) { } for _, testCase := range testTable { - testCase := testCase - t.Run(testCase.name, func(t *testing.T) { t.Parallel() @@ -111,8 +109,6 @@ func TestGetTendermintRPCError(t *testing.T) { } for _, testCase := range testTable { - testCase := testCase - t.Run(testCase.name, func(t *testing.T) { t.Parallel() @@ -153,8 +149,8 @@ func TestConvertErrorToRPCError(t *testing.T) { } for _, testCase := range testTable { - testCase := testCase t.Run(testCase.name, func(t *testing.T) { + t.Parallel() errMsg := "" if testCase.err != nil { @@ -205,9 +201,8 @@ func TestIdFromRawMessage(t *testing.T) { } for _, testCase := range testTable { - testCase := testCase - t.Run(testCase.name, func(t *testing.T) { + t.Parallel() result, err := IdFromRawMessage(testCase.rawID) if testCase.expectedErr == false { assert.Equal(t, testCase.expectedResult, result) @@ -308,8 +303,6 @@ func TestConvertTendermintMsg(t *testing.T) { }, } for _, testCase := range testTable { - testCase := testCase - t.Run(testCase.name, func(t *testing.T) { t.Parallel() res, err := ConvertTendermintMsg(testCase.rpcMsg) diff --git a/protocol/chainlib/chainproxy/rpcclient/types_test.go b/protocol/chainlib/chainproxy/rpcclient/types_test.go index 9ccf87853c..e7f8a57bb2 100755 --- a/protocol/chainlib/chainproxy/rpcclient/types_test.go +++ b/protocol/chainlib/chainproxy/rpcclient/types_test.go @@ -137,7 +137,6 @@ func TestBlockNumberOrHash_WithNumber_MarshalAndUnmarshal(t *testing.T) { {"earliest", int64(EarliestBlockNumber)}, } for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { bnh := BlockNumberOrHashWithNumber(BlockNumber(test.number)) marshalled, err := json.Marshal(bnh) diff --git a/protocol/chainlib/common_test.go b/protocol/chainlib/common_test.go index 2d7a9631ca..762f05f74d 100644 --- a/protocol/chainlib/common_test.go +++ b/protocol/chainlib/common_test.go @@ -93,8 +93,6 @@ func TestMatchSpecApiByName(t *testing.T) { }, } for _, testCase := range testTable { - testCase := testCase - t.Run(testCase.name, func(t *testing.T) { t.Parallel() @@ -125,8 +123,6 @@ func TestConvertToJsonError(t *testing.T) { } for _, testCase := range testTable { - testCase := testCase - t.Run(testCase.name, func(t *testing.T) { t.Parallel() @@ -158,8 +154,6 @@ func TestAddAttributeToError(t *testing.T) { } for _, testCase := range testTable { - testCase := testCase - t.Run(testCase.name, func(t *testing.T) { t.Parallel() result := addAttributeToError(testCase.key, testCase.value, testCase.errorMessage) @@ -210,8 +204,6 @@ func TestExtractDappIDFromWebsocketConnection(t *testing.T) { }() time.Sleep(time.Millisecond * 20) // let the server go up for _, testCase := range testCases { - testCase := testCase - t.Run(testCase.name, func(t *testing.T) { url := "ws://127.0.0.1:3000" + testCase.route dialer := &websocket2.Dialer{} diff --git a/protocol/parser/parser_test.go b/protocol/parser/parser_test.go index e0e57371ff..5b739a6a2f 100644 --- a/protocol/parser/parser_test.go +++ b/protocol/parser/parser_test.go @@ -75,7 +75,6 @@ func TestAppendInterfaceToInterfaceArray(t *testing.T) { }, } for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { t.Parallel() @@ -126,7 +125,6 @@ func TestParseArrayOfInterfaces(t *testing.T) { }, } for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { t.Parallel() @@ -585,7 +583,6 @@ func TestParseBlockFromParams(t *testing.T) { } for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { t.Parallel() result := ParseBlockFromParams(test.rpcInput, test.blockParser, test.genericParsers) @@ -763,7 +760,6 @@ func TestParseBlockFromReply(t *testing.T) { } for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { t.Parallel() parsedInput := ParseBlockFromReply(test.rpcInput, test.blockParser, test.genericParsers) @@ -827,9 +823,8 @@ func TestParseBlockFromParamsHash(t *testing.T) { } for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { - // t.Parallel() + t.Parallel() parsedInput := ParseBlockFromParams(test.rpcInput, test.blockParser, test.genericParsers) parsedHashes, err := parsedInput.GetBlockHashes() if test.expectedHash == "" { diff --git a/x/downtime/v1/genesis_test.go b/x/downtime/v1/genesis_test.go index 0e3a2ca76e..066f5bb37f 100644 --- a/x/downtime/v1/genesis_test.go +++ b/x/downtime/v1/genesis_test.go @@ -58,8 +58,8 @@ func TestGenesis_Validate(t *testing.T) { } for name, tc := range tests { - tc := tc t.Run(name, func(t *testing.T) { + t.Parallel() err := tc.Genesis.Validate() if tc.ExpError == "" { require.NoError(t, err) diff --git a/x/epochstorage/client/cli/query_epoch_details_test.go b/x/epochstorage/client/cli/query_epoch_details_test.go index fd55bafaa4..775d0ded21 100644 --- a/x/epochstorage/client/cli/query_epoch_details_test.go +++ b/x/epochstorage/client/cli/query_epoch_details_test.go @@ -49,8 +49,8 @@ func TestShowEpochDetails(t *testing.T) { obj: obj, }, } { - tc := tc t.Run(tc.desc, func(t *testing.T) { + t.Parallel() var args []string args = append(args, tc.args...) out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdShowEpochDetails(), args) diff --git a/x/spec/ante/ante_test.go b/x/spec/ante/ante_test.go index bc90cce63c..1080918ce1 100644 --- a/x/spec/ante/ante_test.go +++ b/x/spec/ante/ante_test.go @@ -178,9 +178,8 @@ func TestNewExpeditedProposalFilterAnteDecorator(t *testing.T) { } for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { + t.Parallel() k, ctx := specutils.SpecKeeper(t) params := spectypes.DefaultParams() params.AllowlistedExpeditedMsgs = []string{ diff --git a/x/spec/client/cli/query_spec_test.go b/x/spec/client/cli/query_spec_test.go index cf648aba25..5c187a7762 100644 --- a/x/spec/client/cli/query_spec_test.go +++ b/x/spec/client/cli/query_spec_test.go @@ -70,7 +70,6 @@ func TestShowSpec(t *testing.T) { err: status.Error(codes.InvalidArgument, "not found"), }, } { - tc := tc t.Run(tc.desc, func(t *testing.T) { args := []string{ tc.idIndex,