Skip to content

Commit

Permalink
Fix linting errors (#675)
Browse files Browse the repository at this point in the history
* Add linter guards on problematic error checks

* Resolve linting errors

* Sort imports using goimports

* Remove useless separator
  • Loading branch information
zivkovicmilos committed Aug 9, 2022
1 parent b5462e0 commit d3d4f8a
Show file tree
Hide file tree
Showing 116 changed files with 323 additions and 244 deletions.
1 change: 0 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ jobs:
-E makezero
-E lll
-E importas
-E ifshort
-E gosec
-E gofmt
-E goconst
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ build:
.PHONY: lint
lint:
golangci-lint run -E whitespace -E wsl -E wastedassign -E unconvert -E tparallel -E thelper -E stylecheck -E prealloc \
-E predeclared -E nlreturn -E misspell -E makezero -E lll -E importas -E ifshort -E gosec -E gofmt -E goconst \
-E predeclared -E nlreturn -E misspell -E makezero -E lll -E importas -E gosec -E gofmt -E goconst \
-E forcetypeassert -E dogsled -E dupl -E errname -E errorlint -E nolintlint --timeout 2m

.PHONY: generate-bsd-licenses
Expand Down
5 changes: 2 additions & 3 deletions blockchain/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ type Verifier interface {
PreStateCommit(header *types.Header, txn *state.Transition) error
}

// TODO: this should be part of Verifier (consensus)
type Executor interface {
ProcessBlock(parentRoot types.Hash, block *types.Block, blockCreator types.Address) (*state.Transition, error)
}
Expand All @@ -106,7 +105,7 @@ func (b *Blockchain) updateGasPriceAvg(newValues []*big.Int) {
b.gpAverage.Lock()
defer b.gpAverage.Unlock()

// Sum the values for quick reference
// Sum the values for quick reference
sum := big.NewInt(0)
for _, val := range newValues {
sum = sum.Add(sum, val)
Expand Down Expand Up @@ -897,7 +896,7 @@ func (b *Blockchain) WriteBlock(block *types.Block, source string) error {
return err
}

// update snapshot
// update snapshot
if err := b.consensus.ProcessHeaders([]*types.Header{header}); err != nil {
return err
}
Expand Down
3 changes: 2 additions & 1 deletion blockchain/blockchain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package blockchain
import (
"errors"
"fmt"
"github.com/0xPolygon/polygon-edge/state"
"math/big"
"reflect"
"testing"

"github.com/0xPolygon/polygon-edge/state"

"github.com/0xPolygon/polygon-edge/chain"
"github.com/stretchr/testify/assert"

Expand Down
2 changes: 0 additions & 2 deletions blockchain/subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ func (m *MockSubscription) GetEvent() *Event {
func (m *MockSubscription) Close() {
}

/////////////////////////

// subscription is the Blockchain event subscription object
type subscription struct {
updateCh chan void // Channel for update information
Expand Down
3 changes: 2 additions & 1 deletion blockchain/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package blockchain
import (
"errors"
"fmt"
"github.com/0xPolygon/polygon-edge/blockchain/storage"
"math/big"
"testing"

"github.com/0xPolygon/polygon-edge/blockchain/storage"

"github.com/0xPolygon/polygon-edge/chain"
"github.com/0xPolygon/polygon-edge/state"
itrie "github.com/0xPolygon/polygon-edge/state/immutable-trie"
Expand Down
1 change: 1 addition & 0 deletions command/backup/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package backup

import (
"errors"

"github.com/0xPolygon/polygon-edge/archive"
"github.com/0xPolygon/polygon-edge/command"
"github.com/0xPolygon/polygon-edge/command/helper"
Expand Down
1 change: 1 addition & 0 deletions command/backup/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package backup
import (
"bytes"
"fmt"

"github.com/0xPolygon/polygon-edge/command/helper"
)

Expand Down
1 change: 1 addition & 0 deletions command/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package command

import (
"errors"

"github.com/0xPolygon/polygon-edge/helper/common"
)

Expand Down
1 change: 1 addition & 0 deletions command/genesis/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package genesis

import (
"fmt"

"github.com/0xPolygon/polygon-edge/command"
"github.com/0xPolygon/polygon-edge/command/helper"
"github.com/0xPolygon/polygon-edge/consensus/ibft"
Expand Down
9 changes: 5 additions & 4 deletions command/genesis/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ package genesis

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"

"github.com/0xPolygon/polygon-edge/chain"
"github.com/0xPolygon/polygon-edge/command"
"github.com/0xPolygon/polygon-edge/consensus/ibft"
"github.com/0xPolygon/polygon-edge/crypto"
"github.com/0xPolygon/polygon-edge/types"
"io/ioutil"
"os"
"path/filepath"
"strings"
)

const (
Expand Down
1 change: 1 addition & 0 deletions command/ibft/candidates/ibft_candidates.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package candidates

import (
"context"

"github.com/0xPolygon/polygon-edge/command"
"github.com/0xPolygon/polygon-edge/command/helper"
ibftOp "github.com/0xPolygon/polygon-edge/consensus/ibft/proto"
Expand Down
1 change: 1 addition & 0 deletions command/ibft/candidates/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package candidates
import (
"bytes"
"fmt"

"github.com/0xPolygon/polygon-edge/command/helper"
ibftHelper "github.com/0xPolygon/polygon-edge/command/ibft/helper"
ibftOp "github.com/0xPolygon/polygon-edge/consensus/ibft/proto"
Expand Down
1 change: 1 addition & 0 deletions command/ibft/propose/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package propose
import (
"context"
"errors"

ibftOp "github.com/0xPolygon/polygon-edge/consensus/ibft/proto"

"github.com/0xPolygon/polygon-edge/command"
Expand Down
3 changes: 2 additions & 1 deletion command/ibft/quorum/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package quorum
import (
"errors"
"fmt"
"os"

"github.com/0xPolygon/polygon-edge/chain"
"github.com/0xPolygon/polygon-edge/command"
"github.com/0xPolygon/polygon-edge/command/helper"
"github.com/0xPolygon/polygon-edge/helper/common"
"os"
)

const (
Expand Down
1 change: 1 addition & 0 deletions command/ibft/quorum/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package quorum
import (
"bytes"
"fmt"

"github.com/0xPolygon/polygon-edge/command/helper"
"github.com/0xPolygon/polygon-edge/helper/common"
)
Expand Down
1 change: 1 addition & 0 deletions command/ibft/snapshot/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package snapshot

import (
"context"

"github.com/0xPolygon/polygon-edge/command"
"github.com/0xPolygon/polygon-edge/command/helper"
ibftOp "github.com/0xPolygon/polygon-edge/consensus/ibft/proto"
Expand Down
1 change: 1 addition & 0 deletions command/ibft/snapshot/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package snapshot
import (
"bytes"
"fmt"

"github.com/0xPolygon/polygon-edge/command/helper"
ibftHelper "github.com/0xPolygon/polygon-edge/command/ibft/helper"
ibftOp "github.com/0xPolygon/polygon-edge/consensus/ibft/proto"
Expand Down
1 change: 1 addition & 0 deletions command/ibft/status/ibft_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package status

import (
"context"

"github.com/0xPolygon/polygon-edge/command"
"github.com/0xPolygon/polygon-edge/command/helper"
ibftOp "github.com/0xPolygon/polygon-edge/consensus/ibft/proto"
Expand Down
1 change: 1 addition & 0 deletions command/ibft/status/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package status
import (
"bytes"
"fmt"

"github.com/0xPolygon/polygon-edge/command/helper"
)

Expand Down
3 changes: 2 additions & 1 deletion command/ibft/switch/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ package ibftswitch
import (
"errors"
"fmt"
"os"

"github.com/0xPolygon/polygon-edge/chain"
"github.com/0xPolygon/polygon-edge/command"
"github.com/0xPolygon/polygon-edge/command/helper"
"github.com/0xPolygon/polygon-edge/consensus/ibft"
"github.com/0xPolygon/polygon-edge/helper/common"
"github.com/0xPolygon/polygon-edge/types"
"os"
)

const (
Expand Down
1 change: 1 addition & 0 deletions command/ibft/switch/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ibftswitch
import (
"bytes"
"fmt"

"github.com/0xPolygon/polygon-edge/command/helper"
"github.com/0xPolygon/polygon-edge/consensus/ibft"
"github.com/0xPolygon/polygon-edge/helper/common"
Expand Down
1 change: 1 addition & 0 deletions command/license/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package license
import (
"bytes"
"fmt"

"github.com/0xPolygon/polygon-edge/licenses"
)

Expand Down
3 changes: 2 additions & 1 deletion command/loadbot/duration.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package loadbot

import (
"github.com/umbracle/ethgo"
"sync"
"sync/atomic"
"time"

"github.com/umbracle/ethgo"
)

type ExecDuration struct {
Expand Down
3 changes: 2 additions & 1 deletion command/loadbot/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import (
"context"
"crypto/ecdsa"
"fmt"
"github.com/umbracle/ethgo"
"math/big"
"sync"
"sync/atomic"
"time"

"github.com/umbracle/ethgo"

"github.com/0xPolygon/polygon-edge/command/loadbot/generator"
"github.com/0xPolygon/polygon-edge/helper/tests"
txpoolOp "github.com/0xPolygon/polygon-edge/txpool/proto"
Expand Down
16 changes: 8 additions & 8 deletions command/loadbot/generator/contract_txn_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ type ContractTxnsGenerator struct {
failedContractTxnsLock sync.RWMutex
}

// Returns contract deployment tx if contractAddress is empty, otherwise returns
// a token transfer tx
// Returns contract deployment tx if contractAddress is empty, otherwise returns
// a token transfer tx
func (gen *ContractTxnsGenerator) GetExampleTransaction() (*types.Transaction, error) {
if gen.contractAddress == nil {
// contract not deployed yet
// generate contract deployment tx
// contract not deployed yet
// generate contract deployment tx
return gen.signer.SignTx(&types.Transaction{
From: gen.params.SenderAddress,
Value: big.NewInt(0),
Expand All @@ -34,7 +34,7 @@ func (gen *ContractTxnsGenerator) GetExampleTransaction() (*types.Transaction, e
}, gen.params.SenderKey)
}

// return token transfer tx
// return token transfer tx
return gen.signer.SignTx(&types.Transaction{
From: gen.params.SenderAddress,
To: gen.contractAddress,
Expand All @@ -49,8 +49,8 @@ func (gen *ContractTxnsGenerator) GenerateTransaction() (*types.Transaction, err
newNextNonce := atomic.AddUint64(&gen.params.Nonce, 1)

if gen.contractAddress == nil {
// contract not deployed yet
// generate contract deployment tx
// contract not deployed yet
// generate contract deployment tx
return gen.signer.SignTx(&types.Transaction{
From: gen.params.SenderAddress,
Value: big.NewInt(0),
Expand All @@ -62,7 +62,7 @@ func (gen *ContractTxnsGenerator) GenerateTransaction() (*types.Transaction, err
}, gen.params.SenderKey)
}

// return token transfer tx
// return token transfer tx
return gen.signer.SignTx(&types.Transaction{
From: gen.params.SenderAddress,
To: gen.contractAddress,
Expand Down
3 changes: 2 additions & 1 deletion command/loadbot/generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package generator
import (
"crypto/ecdsa"
"encoding/json"
"github.com/umbracle/ethgo"
"io/ioutil"
"math/big"

"github.com/umbracle/ethgo"

"github.com/0xPolygon/polygon-edge/types"
"github.com/umbracle/ethgo/abi"
)
Expand Down
3 changes: 2 additions & 1 deletion command/loadbot/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package loadbot

import (
"fmt"
"github.com/umbracle/ethgo"
"math/big"
"sync"
"time"

"github.com/umbracle/ethgo"

"github.com/0xPolygon/polygon-edge/types"
"github.com/umbracle/ethgo/jsonrpc"
)
Expand Down
4 changes: 2 additions & 2 deletions command/loadbot/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package loadbot
import (
"bytes"
"fmt"
"github.com/umbracle/ethgo"
"math"
"sort"

"github.com/umbracle/ethgo"

"github.com/0xPolygon/polygon-edge/command/helper"
"github.com/0xPolygon/polygon-edge/command/loadbot/generator"
"github.com/0xPolygon/polygon-edge/helper/common"
Expand Down Expand Up @@ -139,7 +140,6 @@ func (lr *LoadbotResult) initDetailedErrors(gen generator.TransactionGenerator)
}

func (lr *LoadbotResult) writeBlockData(buffer *bytes.Buffer) {
//nolint: ifshort
blockData := &lr.BlockData

buffer.WriteString("\n\n[BLOCK DATA]\n")
Expand Down
3 changes: 2 additions & 1 deletion command/monitor/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"context"
"errors"
"fmt"
"io"

"github.com/0xPolygon/polygon-edge/command"
"github.com/0xPolygon/polygon-edge/helper/common"
"github.com/spf13/cobra"
"io"

"github.com/0xPolygon/polygon-edge/command/helper"
"github.com/0xPolygon/polygon-edge/server/proto"
Expand Down
1 change: 1 addition & 0 deletions command/monitor/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package monitor
import (
"bytes"
"fmt"

"github.com/0xPolygon/polygon-edge/command/helper"
"github.com/0xPolygon/polygon-edge/server/proto"
)
Expand Down
1 change: 1 addition & 0 deletions command/peers/add/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package add
import (
"context"
"errors"

"github.com/0xPolygon/polygon-edge/command"
"github.com/0xPolygon/polygon-edge/command/helper"
"github.com/0xPolygon/polygon-edge/server/proto"
Expand Down

0 comments on commit d3d4f8a

Please sign in to comment.