Skip to content

Commit

Permalink
Update golangci-lint to v1.55.1 (#2228)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhrubabasu authored Oct 26, 2023
1 parent fe74ed1 commit a6448ac
Show file tree
Hide file tree
Showing 15 changed files with 32 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ linters:
- revive
- staticcheck
- stylecheck
- typecheck
- tagalign
- typecheck
- unconvert
- unparam
- unused
Expand Down
29 changes: 15 additions & 14 deletions api/auth/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion ids/id_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}

Expand Down
2 changes: 1 addition & 1 deletion scripts/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
1 change: 1 addition & 0 deletions snow/consensus/snowball/tree_test.go
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion utils/timer/adaptive_timeout_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
2 changes: 1 addition & 1 deletion vms/avm/txs/import_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion vms/avm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion vms/components/avax/base_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion vms/components/avax/utxo_id_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion vms/platformvm/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion vms/platformvm/txs/executor/standard_tx_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion vms/platformvm/utxo/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
}
Expand Down
8 changes: 4 additions & 4 deletions wallet/chain/x/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down

0 comments on commit a6448ac

Please sign in to comment.