Skip to content

Commit

Permalink
chore: PRT - Fix linter warn and err (#1836)
Browse files Browse the repository at this point in the history
* update go version

* sdk tests go version

* Fix linter warning for the config

* Fix linter errors

---------

Co-authored-by: Yarom Swisa <[email protected] git config --global user.name Yarom>
  • Loading branch information
shleikes and Yarom Swisa authored Dec 15, 2024
1 parent 4085338 commit 5639e67
Show file tree
Hide file tree
Showing 12 changed files with 9 additions and 51 deletions.
13 changes: 1 addition & 12 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion protocol/chainlib/chainproxy/rpcclient/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 0 additions & 8 deletions protocol/chainlib/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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{}
Expand Down
7 changes: 1 addition & 6 deletions protocol/parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 == "" {
Expand Down
2 changes: 1 addition & 1 deletion x/downtime/v1/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion x/epochstorage/client/cli/query_epoch_details_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions x/spec/ante/ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
1 change: 0 additions & 1 deletion x/spec/client/cli/query_spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 5639e67

Please sign in to comment.