Skip to content

Commit

Permalink
Fix linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sequel21 committed Nov 4, 2024
1 parent 85b124d commit d21189b
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 22 deletions.
11 changes: 7 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ linters-settings:
- performance
- style
govet:
check-shadowing: true
enable:
# report about shadowed variables
- shadowing
nolintlint:
require-explanation: true
require-explanation: false
require-specific: true
funlen:
lines: 100
Expand All @@ -30,12 +32,12 @@ linters:
- asciicheck
- bodyclose
- contextcheck
- depguard
- copyloopvar
# - depguard
- dogsled
# - dupl
- errcheck
- errorlint
- exportloopref
- exhaustive
- goconst
# - gocritic
Expand Down Expand Up @@ -65,4 +67,5 @@ linters:

run:
issues-exit-code: 1
go: '1.22'

2 changes: 1 addition & 1 deletion lib/go/iinft/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ require (
github.com/rs/zerolog v1.29.0
github.com/spf13/afero v1.10.0
github.com/stretchr/testify v1.9.0
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a
)

require (
Expand Down Expand Up @@ -212,7 +213,6 @@ require (
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/oauth2 v0.17.0 // indirect
golang.org/x/sync v0.8.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions lib/go/iinft/gwtf/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (e EventFetcherBuilder) End(blockHeight uint64) EventFetcherBuilder {
// Last fetch events from the number last blocks
func (e EventFetcherBuilder) Last(number uint64) EventFetcherBuilder {
e.EndAtCurrentHeight = true
e.FromIndex = -int64(number)
e.FromIndex = -int64(number) //nolint:gosec
return e
}

Expand Down Expand Up @@ -187,7 +187,7 @@ func (e EventFetcherBuilder) Run(ctx context.Context) ([]*FormatedEvent, error)
fromIndex := e.FromIndex
// if we have a negative fromIndex is relative to endIndex
if e.FromIndex <= 0 {
fromIndex = int64(endIndex) + e.FromIndex
fromIndex = int64(endIndex) + e.FromIndex //nolint:gosec
}

if fromIndex < 0 {
Expand Down
2 changes: 1 addition & 1 deletion lib/go/iinft/gwtf/script.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package gwtf
import (
"context"
"fmt"
"github.com/onflow/flowkit/v2"
"log"
"os"

"github.com/onflow/cadence"
"github.com/onflow/flow-go-sdk"
"github.com/onflow/flowkit/v2"
)

// FlowScriptBuilder is a struct to hold information for running a script
Expand Down
4 changes: 2 additions & 2 deletions lib/go/iinft/gwtf/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import (
"context"
"errors"
"fmt"
"github.com/onflow/flowkit/v2"
"github.com/onflow/flowkit/v2/transactions"
"log"
"os"
"time"

"github.com/araddon/dateparse"
"github.com/onflow/cadence"
"github.com/onflow/flow-go-sdk"
"github.com/onflow/flowkit/v2"
"github.com/onflow/flowkit/v2/accounts"
"github.com/onflow/flowkit/v2/transactions"
)

// TransactionFromFile will start a flow transaction builder
Expand Down
10 changes: 5 additions & 5 deletions lib/go/iinft/scripts/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,12 @@ func GetExampleTokenBalance(t *testing.T, se *Engine, address flow.Address) floa
func SetUpRoyaltyReceivers(t *testing.T, se *Engine, signAndProposeAs, payAs string, extraTokenNames ...string) {
t.Helper()

var addresses []cadence.Value
var names []cadence.Value
addresses := make([]cadence.Value, len(extraTokenNames))
names := make([]cadence.Value, len(extraTokenNames))

for _, name := range extraTokenNames {
addresses = append(addresses, cadence.NewAddress(se.ContractAddress(name)))
names = append(names, cadence.String(name))
for i, name := range extraTokenNames {
addresses[i] = cadence.NewAddress(se.ContractAddress(name))
names[i] = cadence.String(name)
}

_ = se.NewTransaction("account_royalty_receiver_setup").
Expand Down
14 changes: 7 additions & 7 deletions lib/go/iinft/test/digitalart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package test
import (
"context"
"os"
"sort"
"slices"
"testing"
"time"

Expand Down Expand Up @@ -768,13 +768,13 @@ access(all) fun main(address:Address, tokenID:UInt64) : [UInt64] {
idArray, ok := viewsVal.(cadence.Array)
require.True(t, ok)
require.Equal(t, 2, len(idArray.Values))
ids := []int{
int(idArray.Values[0].(cadence.UInt64)),
int(idArray.Values[1].(cadence.UInt64)),
ids := []uint64{
uint64(idArray.Values[0].(cadence.UInt64)),
uint64(idArray.Values[1].(cadence.UInt64)),
}
sort.Ints(ids)
assert.Equal(t, 0, ids[0])
assert.Equal(t, 1, ids[1])
slices.Sort(ids)
assert.Equal(t, uint64(0), ids[0])
assert.Equal(t, uint64(1), ids[1])
})

t.Run("borrowNFT(...) should return NonFungibleToken.NFT", func(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions lib/go/iinft/test/marketplace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ func TestMarketplace_payForMintedTokens(t *testing.T) {
}, evergreenAddr)
require.NoError(t, err)

//nolint:gosec
scriptWithExampleToken := `
import FungibleToken from 0xee82856bf20e2aa6
import ExampleToken from 0xf8d6e0586b0a20c7
Expand Down

0 comments on commit d21189b

Please sign in to comment.