diff --git a/.golangci.yml b/.golangci.yml index 9f1dcc9c9389..160f617659ff 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -69,8 +69,8 @@ linters: - revive - staticcheck - stylecheck - - typecheck - tagalign + - typecheck - unconvert - unparam - unused diff --git a/api/auth/auth_test.go b/api/auth/auth_test.go index e691b11d8686..d8b7a4cca59b 100644 --- a/api/auth/auth_test.go +++ b/api/auth/auth_test.go @@ -27,6 +27,7 @@ var ( hashedPassword = password.Hash{} unAuthorizedResponseRegex = `^{"jsonrpc":"2.0","error":{"code":-32600,"message":"(.*)"},"id":1}` errTest = errors.New("non-nil error") + hostName = "http://127.0.0.1:9650" ) func init() { @@ -161,8 +162,8 @@ func TestWrapHandlerHappyPath(t *testing.T) { wrappedHandler := auth.WrapHandler(dummyHandler) for _, endpoint := range endpoints { - req := httptest.NewRequest(http.MethodPost, "http://127.0.0.1:9650"+endpoint, strings.NewReader("")) - req.Header.Add("Authorization", "Bearer "+tokenStr) + req := httptest.NewRequest(http.MethodPost, hostName+endpoint, strings.NewReader("")) + req.Header.Add("Authorization", headerValStart+tokenStr) rr := httptest.NewRecorder() wrappedHandler.ServeHTTP(rr, req) require.Equal(http.StatusOK, rr.Code) @@ -184,8 +185,8 @@ func TestWrapHandlerRevokedToken(t *testing.T) { wrappedHandler := auth.WrapHandler(dummyHandler) for _, endpoint := range endpoints { - req := httptest.NewRequest(http.MethodPost, "http://127.0.0.1:9650"+endpoint, strings.NewReader("")) - req.Header.Add("Authorization", "Bearer "+tokenStr) + req := httptest.NewRequest(http.MethodPost, hostName+endpoint, strings.NewReader("")) + req.Header.Add("Authorization", headerValStart+tokenStr) rr := httptest.NewRecorder() wrappedHandler.ServeHTTP(rr, req) require.Equal(http.StatusUnauthorized, rr.Code) @@ -209,8 +210,8 @@ func TestWrapHandlerExpiredToken(t *testing.T) { wrappedHandler := auth.WrapHandler(dummyHandler) for _, endpoint := range endpoints { - req := httptest.NewRequest(http.MethodPost, "http://127.0.0.1:9650"+endpoint, strings.NewReader("")) - req.Header.Add("Authorization", "Bearer "+tokenStr) + req := httptest.NewRequest(http.MethodPost, hostName+endpoint, strings.NewReader("")) + req.Header.Add("Authorization", headerValStart+tokenStr) rr := httptest.NewRecorder() wrappedHandler.ServeHTTP(rr, req) require.Equal(http.StatusUnauthorized, rr.Code) @@ -250,8 +251,8 @@ func TestWrapHandlerUnauthorizedEndpoint(t *testing.T) { wrappedHandler := auth.WrapHandler(dummyHandler) for _, endpoint := range unauthorizedEndpoints { - req := httptest.NewRequest(http.MethodPost, "http://127.0.0.1:9650"+endpoint, strings.NewReader("")) - req.Header.Add("Authorization", "Bearer "+tokenStr) + req := httptest.NewRequest(http.MethodPost, hostName+endpoint, strings.NewReader("")) + req.Header.Add("Authorization", headerValStart+tokenStr) rr := httptest.NewRecorder() wrappedHandler.ServeHTTP(rr, req) require.Equal(http.StatusUnauthorized, rr.Code) @@ -272,7 +273,7 @@ func TestWrapHandlerAuthEndpoint(t *testing.T) { wrappedHandler := auth.WrapHandler(dummyHandler) req := httptest.NewRequest(http.MethodPost, "http://127.0.0.1:9650/ext/auth", strings.NewReader("")) - req.Header.Add("Authorization", "Bearer "+tokenStr) + req.Header.Add("Authorization", headerValStart+tokenStr) rr := httptest.NewRecorder() wrappedHandler.ServeHTTP(rr, req) require.Equal(http.StatusOK, rr.Code) @@ -290,8 +291,8 @@ func TestWrapHandlerAccessAll(t *testing.T) { wrappedHandler := auth.WrapHandler(dummyHandler) for _, endpoint := range endpoints { - req := httptest.NewRequest(http.MethodPost, "http://127.0.0.1:9650"+endpoint, strings.NewReader("")) - req.Header.Add("Authorization", "Bearer "+tokenStr) + req := httptest.NewRequest(http.MethodPost, hostName+endpoint, strings.NewReader("")) + req.Header.Add("Authorization", headerValStart+tokenStr) rr := httptest.NewRecorder() wrappedHandler.ServeHTTP(rr, req) require.Equal(http.StatusOK, rr.Code) @@ -322,7 +323,7 @@ func TestWrapHandlerMutatedRevokedToken(t *testing.T) { wrappedHandler := auth.WrapHandler(dummyHandler) for _, endpoint := range endpoints { - req := httptest.NewRequest(http.MethodPost, "http://127.0.0.1:9650"+endpoint, strings.NewReader("")) + req := httptest.NewRequest(http.MethodPost, hostName+endpoint, strings.NewReader("")) req.Header.Add("Authorization", fmt.Sprintf("Bearer %s=", tokenStr)) // The appended = at the end looks like padding rr := httptest.NewRecorder() wrappedHandler.ServeHTTP(rr, req) @@ -356,8 +357,8 @@ func TestWrapHandlerInvalidSigningMethod(t *testing.T) { wrappedHandler := auth.WrapHandler(dummyHandler) for _, endpoint := range endpoints { - req := httptest.NewRequest(http.MethodPost, "http://127.0.0.1:9650"+endpoint, strings.NewReader("")) - req.Header.Add("Authorization", "Bearer "+tokenStr) + req := httptest.NewRequest(http.MethodPost, hostName+endpoint, strings.NewReader("")) + req.Header.Add("Authorization", headerValStart+tokenStr) rr := httptest.NewRecorder() wrappedHandler.ServeHTTP(rr, req) require.Equal(http.StatusUnauthorized, rr.Code) diff --git a/config/config_test.go b/config/config_test.go index 8c2498d02c75..037b8ac450cc 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -73,7 +73,7 @@ func TestGetChainConfigsFromFiles(t *testing.T) { // Create custom configs for key, value := range test.configs { chainDir := filepath.Join(chainsDir, key) - setupFile(t, chainDir, chainConfigFileName+".ex", value) + setupFile(t, chainDir, chainConfigFileName+".ex", value) //nolint:goconst } for key, value := range test.upgrades { chainDir := filepath.Join(chainsDir, key) diff --git a/ids/id_test.go b/ids/id_test.go index 0a85cead49c2..3424b17633e6 100644 --- a/ids/id_test.go +++ b/ids/id_test.go @@ -149,7 +149,7 @@ func TestIDUnmarshalJSON(t *testing.T) { func TestIDHex(t *testing.T) { id := ID{'a', 'v', 'a', ' ', 'l', 'a', 'b', 's'} - expected := "617661206c616273000000000000000000000000000000000000000000000000" //nolint:gosec + expected := "617661206c616273000000000000000000000000000000000000000000000000" require.Equal(t, expected, id.Hex()) } diff --git a/scripts/lint.sh b/scripts/lint.sh index c6417b7f51f6..a34dee76a9e8 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -32,7 +32,7 @@ fi TESTS=${TESTS:-"golangci_lint license_header require_error_is_no_funcs_as_params single_import interface_compliance_nil require_equal_zero require_len_zero require_equal_len require_nil require_no_error_inline_func"} function test_golangci_lint { - go install -v github.com/golangci/golangci-lint/cmd/golangci-lint@v1.54.2 + go install -v github.com/golangci/golangci-lint/cmd/golangci-lint@v1.55.1 golangci-lint run --config .golangci.yml } diff --git a/snow/consensus/snowball/tree_test.go b/snow/consensus/snowball/tree_test.go index 4aff386174ed..8b0f6159df72 100644 --- a/snow/consensus/snowball/tree_test.go +++ b/snow/consensus/snowball/tree_test.go @@ -1,6 +1,7 @@ // Copyright (C) 2019-2023, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//nolint:goconst package snowball import ( diff --git a/utils/timer/adaptive_timeout_manager_test.go b/utils/timer/adaptive_timeout_manager_test.go index 781686261b52..ec9964bd5a7f 100644 --- a/utils/timer/adaptive_timeout_manager_test.go +++ b/utils/timer/adaptive_timeout_manager_test.go @@ -84,7 +84,7 @@ func TestAdaptiveTimeoutManagerInit(t *testing.T) { } for _, test := range tests { - _, err := NewAdaptiveTimeoutManager(&test.config, "", prometheus.NewRegistry()) //nolint:gosec + _, err := NewAdaptiveTimeoutManager(&test.config, "", prometheus.NewRegistry()) require.ErrorIs(t, err, test.expectedErr) } } diff --git a/vms/avm/txs/import_tx.go b/vms/avm/txs/import_tx.go index 94a12442f4a8..c3066ccc5c40 100644 --- a/vms/avm/txs/import_tx.go +++ b/vms/avm/txs/import_tx.go @@ -31,7 +31,7 @@ func (t *ImportTx) InputUTXOs() []*avax.UTXOID { utxos := t.BaseTx.InputUTXOs() for _, in := range t.ImportedIns { in.Symbol = true - utxos = append(utxos, &in.UTXOID) //nolint:gosec + utxos = append(utxos, &in.UTXOID) } return utxos } diff --git a/vms/avm/vm.go b/vms/avm/vm.go index 869f62e7e39c..50bc646580a0 100644 --- a/vms/avm/vm.go +++ b/vms/avm/vm.go @@ -536,7 +536,7 @@ func (vm *VM) initGenesis(genesisBytes []byte) error { } tx := &txs.Tx{ - Unsigned: &genesisTx.CreateAssetTx, //nolint:gosec + Unsigned: &genesisTx.CreateAssetTx, } if err := vm.parser.InitializeGenesisTx(tx); err != nil { return err diff --git a/vms/components/avax/base_tx.go b/vms/components/avax/base_tx.go index a57793a48213..2bcafa24e497 100644 --- a/vms/components/avax/base_tx.go +++ b/vms/components/avax/base_tx.go @@ -35,7 +35,7 @@ type BaseTx struct { func (t *BaseTx) InputUTXOs() []*UTXOID { utxos := make([]*UTXOID, len(t.Ins)) for i, in := range t.Ins { - utxos[i] = &in.UTXOID //nolint:gosec + utxos[i] = &in.UTXOID } return utxos } diff --git a/vms/components/avax/utxo_id_test.go b/vms/components/avax/utxo_id_test.go index 5e86dfde4801..5652fa1afa69 100644 --- a/vms/components/avax/utxo_id_test.go +++ b/vms/components/avax/utxo_id_test.go @@ -99,7 +99,7 @@ func TestUTXOIDLess(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - require.Equal(t, tt.expected, tt.id1.Less(&tt.id2)) //nolint:gosec + require.Equal(t, tt.expected, tt.id1.Less(&tt.id2)) }) } } diff --git a/vms/platformvm/service.go b/vms/platformvm/service.go index 7eb0f98a2f8f..a2871faf0682 100644 --- a/vms/platformvm/service.go +++ b/vms/platformvm/service.go @@ -303,7 +303,7 @@ utxoFor: continue utxoFor } - response.UTXOIDs = append(response.UTXOIDs, &utxo.UTXOID) //nolint:gosec + response.UTXOIDs = append(response.UTXOIDs, &utxo.UTXOID) } balances := maps.Clone(lockedStakeables) diff --git a/vms/platformvm/txs/executor/standard_tx_executor.go b/vms/platformvm/txs/executor/standard_tx_executor.go index 92a4af6cc09e..2aa9e9c4a400 100644 --- a/vms/platformvm/txs/executor/standard_tx_executor.go +++ b/vms/platformvm/txs/executor/standard_tx_executor.go @@ -155,7 +155,7 @@ func (e *StandardTxExecutor) ImportTx(tx *txs.ImportTx) error { for index, input := range tx.Ins { utxo, err := e.State.GetUTXO(input.InputID()) if err != nil { - return fmt.Errorf("failed to get UTXO %s: %w", &input.UTXOID, err) //nolint:gosec + return fmt.Errorf("failed to get UTXO %s: %w", &input.UTXOID, err) } utxos[index] = utxo } diff --git a/vms/platformvm/utxo/handler.go b/vms/platformvm/utxo/handler.go index b617783bca0b..2d652103fee2 100644 --- a/vms/platformvm/utxo/handler.go +++ b/vms/platformvm/utxo/handler.go @@ -443,7 +443,7 @@ func (h *handler) VerifySpend( if err != nil { return fmt.Errorf( "failed to read consumed UTXO %s due to: %w", - &input.UTXOID, //nolint:gosec + &input.UTXOID, err, ) } diff --git a/wallet/chain/x/builder.go b/wallet/chain/x/builder.go index ba88db984833..0b639a7776ad 100644 --- a/wallet/chain/x/builder.go +++ b/wallet/chain/x/builder.go @@ -655,7 +655,7 @@ func (b *builder) mintFTs( // add the operation to the array operations = append(operations, &txs.Operation{ Asset: utxo.Asset, - UTXOIDs: []*avax.UTXOID{&utxo.UTXOID}, //nolint:gosec + UTXOIDs: []*avax.UTXOID{&utxo.UTXOID}, Op: &secp256k1fx.MintOperation{ MintInput: secp256k1fx.Input{ SigIndices: inputSigIndices, @@ -717,7 +717,7 @@ func (b *builder) mintNFTs( operations = append(operations, &txs.Operation{ Asset: avax.Asset{ID: assetID}, UTXOIDs: []*avax.UTXOID{ - &utxo.UTXOID, //nolint:gosec + &utxo.UTXOID, }, Op: &nftfx.MintOperation{ MintInput: secp256k1fx.Input{ @@ -773,7 +773,7 @@ func (b *builder) mintProperty( operations = append(operations, &txs.Operation{ Asset: avax.Asset{ID: assetID}, UTXOIDs: []*avax.UTXOID{ - &utxo.UTXOID, //nolint:gosec + &utxo.UTXOID, }, Op: &propertyfx.MintOperation{ MintInput: secp256k1fx.Input{ @@ -829,7 +829,7 @@ func (b *builder) burnProperty( operations = append(operations, &txs.Operation{ Asset: avax.Asset{ID: assetID}, UTXOIDs: []*avax.UTXOID{ - &utxo.UTXOID, //nolint:gosec + &utxo.UTXOID, }, Op: &propertyfx.BurnOperation{ Input: secp256k1fx.Input{