Skip to content

Commit

Permalink
Update golangci-lint to v1.54.2 (#2082)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhrubabasu authored Sep 22, 2023
1 parent 1d45599 commit d8b845c
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 23 deletions.
15 changes: 9 additions & 6 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,15 @@ linters-settings:
goimports:
local-prefixes: github.com/ava-labs/avalanchego
depguard:
list-type: blacklist
packages-with-error-message:
- io/ioutil: 'io/ioutil is deprecated. Use package io or os instead.'
- github.com/stretchr/testify/assert: 'github.com/stretchr/testify/require should be used instead.'
- github.com/golang/mock/gomock: 'go.uber.org/mock/gomock should be used instead.'
include-go-root: true
rules:
packages:
deny:
- pkg: "io/ioutil"
desc: io/ioutil is deprecated. Use package io or os instead.
- pkg: "github.com/stretchr/testify/assert"
desc: github.com/stretchr/testify/require should be used instead.
- pkg: "github.com/golang/mock/gomock"
desc: go.uber.org/mock/gomock should be used instead.
errorlint:
# Check for plain type assertions and type switches.
asserts: false
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"
expected := "617661206c616273000000000000000000000000000000000000000000000000" //nolint:gosec
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.51.2
go install -v github.com/golangci/golangci-lint/cmd/golangci-lint@v1.54.2
golangci-lint run --config .golangci.yml
}

Expand Down
4 changes: 2 additions & 2 deletions utils/timer/adaptive_timeout_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestAdaptiveTimeoutManagerInit(t *testing.T) {
expectedErr error
}

tests := []test{
tests := []*test{
{
config: AdaptiveTimeoutConfig{
InitialTimeout: time.Second,
Expand Down Expand Up @@ -84,7 +84,7 @@ func TestAdaptiveTimeoutManagerInit(t *testing.T) {
}

for _, test := range tests {
_, err := NewAdaptiveTimeoutManager(&test.config, "", prometheus.NewRegistry())
_, err := NewAdaptiveTimeoutManager(&test.config, "", prometheus.NewRegistry()) //nolint:gosec
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)
utxos = append(utxos, &in.UTXOID) //nolint:gosec
}
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 @@ -535,7 +535,7 @@ func (vm *VM) initGenesis(genesisBytes []byte) error {
}

tx := &txs.Tx{
Unsigned: &genesisTx.CreateAssetTx,
Unsigned: &genesisTx.CreateAssetTx, //nolint:gosec
}
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
utxos[i] = &in.UTXOID //nolint:gosec
}
return utxos
}
Expand Down
4 changes: 2 additions & 2 deletions vms/components/avax/utxo_id_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func TestUTXOIDLess(t *testing.T) {
id2 UTXOID
expected bool
}
tests := []test{
tests := []*test{
{
name: "same",
id1: UTXOID{},
Expand Down 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))
require.Equal(t, tt.expected, tt.id1.Less(&tt.id2)) //nolint:gosec
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion vms/platformvm/genesis/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func ParseState(genesisBytes []byte) (*State, error) {

utxos := make([]*avax.UTXO, 0, len(genesis.UTXOs))
for _, utxo := range genesis.UTXOs {
utxos = append(utxos, &utxo.UTXO)
utxos = append(utxos, &utxo.UTXO) //nolint:gosec
}

return &State{
Expand Down
2 changes: 1 addition & 1 deletion vms/platformvm/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ utxoFor:
continue utxoFor
}

response.UTXOIDs = append(response.UTXOIDs, &utxo.UTXOID)
response.UTXOIDs = append(response.UTXOIDs, &utxo.UTXOID) //nolint:gosec
}

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 @@ -154,7 +154,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)
return fmt.Errorf("failed to get UTXO %s: %w", &input.UTXOID, err) //nolint:gosec
}
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,
&input.UTXOID, //nolint:gosec
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},
UTXOIDs: []*avax.UTXOID{&utxo.UTXOID}, //nolint:gosec
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,
&utxo.UTXOID, //nolint:gosec
},
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,
&utxo.UTXOID, //nolint:gosec
},
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,
&utxo.UTXOID, //nolint:gosec
},
Op: &propertyfx.BurnOperation{
Input: secp256k1fx.Input{
Expand Down

0 comments on commit d8b845c

Please sign in to comment.