Skip to content

Commit

Permalink
Add goimports lint (ethereum#54)
Browse files Browse the repository at this point in the history
* Add `goimports` lint.

* Fix `goimports` issue.

* Fix group to `github.com/scroll-tech/go-thereum`.
  • Loading branch information
silathdiir authored Mar 24, 2022
1 parent f853248 commit b6cc89f
Show file tree
Hide file tree
Showing 196 changed files with 329 additions and 115 deletions.
23 changes: 22 additions & 1 deletion .github/workflows/l2geth_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,32 @@ jobs:
uses: actions/checkout@v2
- name: Lint
run: |
rm -rf $HOME/.cache/golangci-lint
rm -rf $HOME/.cache/golangci-lint
make lint
- name: Test
run: |
go get ./...
make test
- name: Upload coverage report
run: bash <(curl -s https://codecov.io/bash)
goimports-lint:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.17.x
- name: Install goimports
run: go get golang.org/x/tools/cmd/goimports
- name: Checkout code
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.ref }}
- run: goimports -local github.com/scroll-tech/go-ethereum/ -w .
- run: go mod tidy
# If there are any diffs from goimports or go mod tidy, fail.
- name: Verify no changes from goimports and go mod tidy
run: |
if [ -n "$(git status --porcelain)" ]; then
exit 1
fi
3 changes: 2 additions & 1 deletion accounts/abi/bind/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
"strings"
"testing"

"github.com/stretchr/testify/assert"

"github.com/scroll-tech/go-ethereum"
"github.com/scroll-tech/go-ethereum/accounts/abi"
"github.com/scroll-tech/go-ethereum/accounts/abi/bind"
Expand All @@ -31,7 +33,6 @@ import (
"github.com/scroll-tech/go-ethereum/core/types"
"github.com/scroll-tech/go-ethereum/crypto"
"github.com/scroll-tech/go-ethereum/rlp"
"github.com/stretchr/testify/assert"
)

func mockSign(addr common.Address, tx *types.Transaction) (*types.Transaction, error) { return tx, nil }
Expand Down
5 changes: 3 additions & 2 deletions accounts/abi/event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ import (
"strings"
"testing"

"github.com/scroll-tech/go-ethereum/common"
"github.com/scroll-tech/go-ethereum/crypto"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/scroll-tech/go-ethereum/common"
"github.com/scroll-tech/go-ethereum/crypto"
)

var jsonEventTransfer = []byte(`{
Expand Down
1 change: 1 addition & 0 deletions accounts/abi/type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"testing"

"github.com/davecgh/go-spew/spew"

"github.com/scroll-tech/go-ethereum/common"
)

Expand Down
3 changes: 2 additions & 1 deletion accounts/abi/unpack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ import (
"strings"
"testing"

"github.com/scroll-tech/go-ethereum/common"
"github.com/stretchr/testify/require"

"github.com/scroll-tech/go-ethereum/common"
)

// TestUnpack tests the general pack/unpack tests in packing_test.go
Expand Down
3 changes: 2 additions & 1 deletion accounts/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ import (
"fmt"
"math/big"

"golang.org/x/crypto/sha3"

"github.com/scroll-tech/go-ethereum"
"github.com/scroll-tech/go-ethereum/common"
"github.com/scroll-tech/go-ethereum/core/types"
"github.com/scroll-tech/go-ethereum/event"
"golang.org/x/crypto/sha3"
)

// Account represents an Ethereum account located at a specific location defined
Expand Down
1 change: 1 addition & 0 deletions accounts/keystore/account_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"time"

mapset "github.com/deckarep/golang-set"

"github.com/scroll-tech/go-ethereum/accounts"
"github.com/scroll-tech/go-ethereum/common"
"github.com/scroll-tech/go-ethereum/log"
Expand Down
1 change: 1 addition & 0 deletions accounts/keystore/account_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (

"github.com/cespare/cp"
"github.com/davecgh/go-spew/spew"

"github.com/scroll-tech/go-ethereum/accounts"
"github.com/scroll-tech/go-ethereum/common"
)
Expand Down
1 change: 1 addition & 0 deletions accounts/keystore/file_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"time"

mapset "github.com/deckarep/golang-set"

"github.com/scroll-tech/go-ethereum/log"
)

Expand Down
1 change: 1 addition & 0 deletions accounts/keystore/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"time"

"github.com/google/uuid"

"github.com/scroll-tech/go-ethereum/accounts"
"github.com/scroll-tech/go-ethereum/common"
"github.com/scroll-tech/go-ethereum/crypto"
Expand Down
5 changes: 3 additions & 2 deletions accounts/keystore/passphrase.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@ import (
"path/filepath"

"github.com/google/uuid"
"golang.org/x/crypto/pbkdf2"
"golang.org/x/crypto/scrypt"

"github.com/scroll-tech/go-ethereum/accounts"
"github.com/scroll-tech/go-ethereum/common"
"github.com/scroll-tech/go-ethereum/common/math"
"github.com/scroll-tech/go-ethereum/crypto"
"golang.org/x/crypto/pbkdf2"
"golang.org/x/crypto/scrypt"
)

const (
Expand Down
3 changes: 2 additions & 1 deletion accounts/keystore/presale.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ import (
"fmt"

"github.com/google/uuid"
"golang.org/x/crypto/pbkdf2"

"github.com/scroll-tech/go-ethereum/accounts"
"github.com/scroll-tech/go-ethereum/crypto"
"golang.org/x/crypto/pbkdf2"
)

// creates a Key and stores that in the given KeyStore by decrypting a presale key JSON
Expand Down
1 change: 1 addition & 0 deletions accounts/keystore/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"time"

"github.com/rjeczalik/notify"

"github.com/scroll-tech/go-ethereum/log"
)

Expand Down
1 change: 1 addition & 0 deletions accounts/scwallet/hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import (
"time"

pcsc "github.com/gballet/go-libpcsclite"

"github.com/scroll-tech/go-ethereum/accounts"
"github.com/scroll-tech/go-ethereum/common"
"github.com/scroll-tech/go-ethereum/event"
Expand Down
3 changes: 2 additions & 1 deletion accounts/scwallet/securechannel.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ import (
"fmt"

pcsc "github.com/gballet/go-libpcsclite"
"github.com/scroll-tech/go-ethereum/crypto"
"golang.org/x/crypto/pbkdf2"
"golang.org/x/text/unicode/norm"

"github.com/scroll-tech/go-ethereum/crypto"
)

const (
Expand Down
3 changes: 2 additions & 1 deletion accounts/scwallet/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ import (
"time"

pcsc "github.com/gballet/go-libpcsclite"
"github.com/status-im/keycard-go/derivationpath"

"github.com/scroll-tech/go-ethereum"
"github.com/scroll-tech/go-ethereum/accounts"
"github.com/scroll-tech/go-ethereum/common"
"github.com/scroll-tech/go-ethereum/core/types"
"github.com/scroll-tech/go-ethereum/crypto"
"github.com/scroll-tech/go-ethereum/log"
"github.com/status-im/keycard-go/derivationpath"
)

// ErrPairingPasswordNeeded is returned if opening the smart card requires pairing with a pairing
Expand Down
1 change: 1 addition & 0 deletions accounts/usbwallet/hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"time"

"github.com/karalabe/usb"

"github.com/scroll-tech/go-ethereum/accounts"
"github.com/scroll-tech/go-ethereum/event"
"github.com/scroll-tech/go-ethereum/log"
Expand Down
1 change: 1 addition & 0 deletions accounts/usbwallet/trezor.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"math/big"

"github.com/golang/protobuf/proto"

"github.com/scroll-tech/go-ethereum/accounts"
"github.com/scroll-tech/go-ethereum/accounts/usbwallet/trezor"
"github.com/scroll-tech/go-ethereum/common"
Expand Down
1 change: 1 addition & 0 deletions accounts/usbwallet/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"time"

"github.com/karalabe/usb"

"github.com/scroll-tech/go-ethereum"
"github.com/scroll-tech/go-ethereum/accounts"
"github.com/scroll-tech/go-ethereum/common"
Expand Down
1 change: 1 addition & 0 deletions build/ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import (
"time"

"github.com/cespare/cp"

"github.com/scroll-tech/go-ethereum/crypto/signify"
"github.com/scroll-tech/go-ethereum/internal/build"
"github.com/scroll-tech/go-ethereum/params"
Expand Down
3 changes: 2 additions & 1 deletion cmd/abigen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ import (
"regexp"
"strings"

"gopkg.in/urfave/cli.v1"

"github.com/scroll-tech/go-ethereum/accounts/abi"
"github.com/scroll-tech/go-ethereum/accounts/abi/bind"
"github.com/scroll-tech/go-ethereum/cmd/utils"
"github.com/scroll-tech/go-ethereum/common/compiler"
"github.com/scroll-tech/go-ethereum/crypto"
"github.com/scroll-tech/go-ethereum/internal/flags"
"github.com/scroll-tech/go-ethereum/log"
"gopkg.in/urfave/cli.v1"
)

var (
Expand Down
3 changes: 2 additions & 1 deletion cmd/checkpoint-admin/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ package main
import (
"strconv"

"gopkg.in/urfave/cli.v1"

"github.com/scroll-tech/go-ethereum/accounts"
"github.com/scroll-tech/go-ethereum/accounts/abi/bind"
"github.com/scroll-tech/go-ethereum/accounts/external"
Expand All @@ -28,7 +30,6 @@ import (
"github.com/scroll-tech/go-ethereum/ethclient"
"github.com/scroll-tech/go-ethereum/params"
"github.com/scroll-tech/go-ethereum/rpc"
"gopkg.in/urfave/cli.v1"
)

// newClient creates a client with specified remote URL.
Expand Down
3 changes: 2 additions & 1 deletion cmd/checkpoint-admin/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import (
"strings"
"time"

"gopkg.in/urfave/cli.v1"

"github.com/scroll-tech/go-ethereum/accounts"
"github.com/scroll-tech/go-ethereum/cmd/utils"
"github.com/scroll-tech/go-ethereum/common"
Expand All @@ -36,7 +38,6 @@ import (
"github.com/scroll-tech/go-ethereum/log"
"github.com/scroll-tech/go-ethereum/params"
"github.com/scroll-tech/go-ethereum/rpc"
"gopkg.in/urfave/cli.v1"
)

var commandDeploy = cli.Command{
Expand Down
3 changes: 2 additions & 1 deletion cmd/checkpoint-admin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ import (
"fmt"
"os"

"gopkg.in/urfave/cli.v1"

"github.com/scroll-tech/go-ethereum/common/fdlimit"
"github.com/scroll-tech/go-ethereum/internal/flags"
"github.com/scroll-tech/go-ethereum/log"
"gopkg.in/urfave/cli.v1"
)

var (
Expand Down
3 changes: 2 additions & 1 deletion cmd/checkpoint-admin/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ package main
import (
"fmt"

"gopkg.in/urfave/cli.v1"

"github.com/scroll-tech/go-ethereum/cmd/utils"
"github.com/scroll-tech/go-ethereum/common"
"gopkg.in/urfave/cli.v1"
)

var commandStatus = cli.Command{
Expand Down
3 changes: 2 additions & 1 deletion cmd/clef/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ import (

"github.com/mattn/go-colorable"
"github.com/mattn/go-isatty"
"gopkg.in/urfave/cli.v1"

"github.com/scroll-tech/go-ethereum/accounts"
"github.com/scroll-tech/go-ethereum/accounts/keystore"
"github.com/scroll-tech/go-ethereum/cmd/utils"
Expand All @@ -56,7 +58,6 @@ import (
"github.com/scroll-tech/go-ethereum/signer/fourbyte"
"github.com/scroll-tech/go-ethereum/signer/rules"
"github.com/scroll-tech/go-ethereum/signer/storage"
"gopkg.in/urfave/cli.v1"
)

const legalWarning = `
Expand Down
3 changes: 2 additions & 1 deletion cmd/devp2p/discv4cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ import (
"strings"
"time"

"gopkg.in/urfave/cli.v1"

"github.com/scroll-tech/go-ethereum/cmd/devp2p/internal/v4test"
"github.com/scroll-tech/go-ethereum/common"
"github.com/scroll-tech/go-ethereum/crypto"
"github.com/scroll-tech/go-ethereum/p2p/discover"
"github.com/scroll-tech/go-ethereum/p2p/enode"
"github.com/scroll-tech/go-ethereum/params"
"gopkg.in/urfave/cli.v1"
)

var (
Expand Down
3 changes: 2 additions & 1 deletion cmd/devp2p/discv5cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ import (
"fmt"
"time"

"gopkg.in/urfave/cli.v1"

"github.com/scroll-tech/go-ethereum/cmd/devp2p/internal/v5test"
"github.com/scroll-tech/go-ethereum/common"
"github.com/scroll-tech/go-ethereum/p2p/discover"
"gopkg.in/urfave/cli.v1"
)

var (
Expand Down
3 changes: 2 additions & 1 deletion cmd/devp2p/dns_cloudflare.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ import (
"strings"

"github.com/cloudflare/cloudflare-go"
"gopkg.in/urfave/cli.v1"

"github.com/scroll-tech/go-ethereum/log"
"github.com/scroll-tech/go-ethereum/p2p/dnsdisc"
"gopkg.in/urfave/cli.v1"
)

var (
Expand Down
3 changes: 2 additions & 1 deletion cmd/devp2p/dns_route53.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ import (
"github.com/aws/aws-sdk-go-v2/credentials"
"github.com/aws/aws-sdk-go-v2/service/route53"
"github.com/aws/aws-sdk-go-v2/service/route53/types"
"gopkg.in/urfave/cli.v1"

"github.com/scroll-tech/go-ethereum/log"
"github.com/scroll-tech/go-ethereum/p2p/dnsdisc"
"gopkg.in/urfave/cli.v1"
)

const (
Expand Down
3 changes: 2 additions & 1 deletion cmd/devp2p/dnscmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ import (
"path/filepath"
"time"

"gopkg.in/urfave/cli.v1"

"github.com/scroll-tech/go-ethereum/accounts/keystore"
"github.com/scroll-tech/go-ethereum/common"
"github.com/scroll-tech/go-ethereum/console/prompt"
"github.com/scroll-tech/go-ethereum/p2p/dnsdisc"
"github.com/scroll-tech/go-ethereum/p2p/enode"
"gopkg.in/urfave/cli.v1"
)

var (
Expand Down
Loading

0 comments on commit b6cc89f

Please sign in to comment.