Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: enable goimports and varcheck linters #16446

Merged
merged 17 commits into from
Apr 17, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixing all linting errs
add makefile for goimports -w
run goimports
add lint to travis build
  • Loading branch information
thomasmodeneis committed Apr 5, 2018
commit c41a7cc5fad942091c52565785d9a85eb57912a7
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ matrix:
- sudo chown root:$USER /etc/fuse.conf
- go run build/ci.go install
- go run build/ci.go test -coverage
- make install-linters
- make lint

# These are the latest Go versions.
- os: linux
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ ios:
test: all
build/env.sh go run build/ci.go test

lint: install-linters ## Run linters. Use make install-linters first.
lint: ## Run linters. Use make install-linters first.
vendorcheck ./...
gometalinter --disable-all -E vet -E goimports -E varcheck -E gofmt -E misspell -E goconst -E unconvert -E gosimple --deadline=10m --min-occurrences=6 --tests --vendor ./...

Expand All @@ -46,6 +46,9 @@ install-linters: ## Install linters
go get -u github.com/alecthomas/gometalinter
gometalinter --vendored-linters --install

format: # Formats the code. Must have goimports installed (use make install-linters).
goimports -w -local github.com/ethereum/go-ethereum ./

clean:
rm -fr build/_workspace/pkg/ $(GOBIN)/*

Expand Down
3 changes: 2 additions & 1 deletion accounts/abi/bind/bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ import (
"text/template"
"unicode"

"github.com/ethereum/go-ethereum/accounts/abi"
"golang.org/x/tools/imports"

"github.com/ethereum/go-ethereum/accounts/abi"
)

// Lang is a target programming language selector to generate bindings for.
Expand Down
3 changes: 2 additions & 1 deletion accounts/abi/bind/bind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ import (
"strings"
"testing"

"github.com/ethereum/go-ethereum/common"
"golang.org/x/tools/imports"

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

var bindTests = []struct {
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/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/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/ethereum/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/ethereum/go-ethereum/common"
"github.com/stretchr/testify/require"

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

type unpackTest struct {
Expand Down
3 changes: 2 additions & 1 deletion accounts/keystore/account_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ import (
"sync"
"time"

"gopkg.in/fatih/set.v0"

"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
"gopkg.in/fatih/set.v0"
)

// Minimum amount of time between cache reloads. This limit applies if the platform does
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/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common"
)
Expand Down
3 changes: 2 additions & 1 deletion accounts/keystore/file_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ import (
"sync"
"time"

"github.com/ethereum/go-ethereum/log"
set "gopkg.in/fatih/set.v0"

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

// fileCache is a cache of files seen during scan of keystore.
Expand Down
3 changes: 2 additions & 1 deletion accounts/keystore/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ import (
"strings"
"time"

"github.com/pborman/uuid"

"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/pborman/uuid"
)

const (
Expand Down
7 changes: 4 additions & 3 deletions accounts/keystore/keystore_passphrase.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ import (
"io/ioutil"
"path/filepath"

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

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto/randentropy"
"github.com/pborman/uuid"
"golang.org/x/crypto/pbkdf2"
"golang.org/x/crypto/scrypt"
)

const (
Expand Down
5 changes: 3 additions & 2 deletions accounts/keystore/presale.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ import (
"errors"
"fmt"

"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/crypto"
"github.com/pborman/uuid"
"golang.org/x/crypto/pbkdf2"

"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/crypto"
)

// creates a Key and stores that in the given KeyStore by decrypting a presale key JSON
Expand Down
3 changes: 2 additions & 1 deletion accounts/keystore/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ package keystore
import (
"time"

"github.com/ethereum/go-ethereum/log"
"github.com/rjeczalik/notify"

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

type watcher struct {
Expand Down
3 changes: 2 additions & 1 deletion accounts/usbwallet/hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ import (
"sync"
"time"

"github.com/karalabe/hid"

"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/log"
"github.com/karalabe/hid"
)

// LedgerScheme is the protocol scheme prefixing account and wallet URLs.
Expand Down
6 changes: 3 additions & 3 deletions accounts/usbwallet/ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ const (
ledgerOpSignTransaction ledgerOpcode = 0x04 // Signs an Ethereum transaction after having the user validate the parameters
ledgerOpGetConfiguration ledgerOpcode = 0x06 // Returns specific wallet application configuration

ledgerP1DirectlyFetchAddress ledgerParam1 = 0x00 // Return address directly from the wallet
ledgerP1ConfirmFetchAddress ledgerParam1 = 0x01 // Require a user confirmation before returning the address
ledgerP1DirectlyFetchAddress ledgerParam1 = 0x00 // Return address directly from the wallet
//ledgerP1ConfirmFetchAddress ledgerParam1 = 0x01 // Require a user confirmation before returning the address
ledgerP1InitTransactionData ledgerParam1 = 0x00 // First transaction data block for signing
ledgerP1ContTransactionData ledgerParam1 = 0x80 // Subsequent transaction data block for signing
ledgerP2DiscardAddressChainCode ledgerParam2 = 0x00 // Do not return the chain code along with the address
ledgerP2ReturnAddressChainCode ledgerParam2 = 0x01 // Require a user confirmation before returning the address
//ledgerP2ReturnAddressChainCode ledgerParam2 = 0x01 // Require a user confirmation before returning the address
)

// errLedgerReplyInvalidHeader is the error message returned by a Ledger data exchange
Expand Down
3 changes: 2 additions & 1 deletion accounts/usbwallet/trezor.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ import (
"io"
"math/big"

"github.com/golang/protobuf/proto"

"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/accounts/usbwallet/internal/trezor"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"
"github.com/golang/protobuf/proto"
)

// ErrTrezorPINNeeded is returned if opening the trezor requires a PIN code. In
Expand Down
3 changes: 2 additions & 1 deletion accounts/usbwallet/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ import (
"sync"
"time"

"github.com/karalabe/hid"

ethereum "github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"
"github.com/karalabe/hid"
)

// Maximum time between wallet health checks to detect USB unplugs.
Expand Down
5 changes: 3 additions & 2 deletions cmd/ethkey/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ import (
"os"
"path/filepath"

"github.com/pborman/uuid"
"gopkg.in/urfave/cli.v1"

"github.com/ethereum/go-ethereum/accounts/keystore"
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/crypto"
"github.com/pborman/uuid"
"gopkg.in/urfave/cli.v1"
)

type outputGenerate struct {
Expand Down
3 changes: 2 additions & 1 deletion cmd/ethkey/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ import (
"fmt"
"io/ioutil"

"gopkg.in/urfave/cli.v1"

"github.com/ethereum/go-ethereum/accounts/keystore"
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/crypto"
"gopkg.in/urfave/cli.v1"
)

type outputInspect struct {
Expand Down
11 changes: 6 additions & 5 deletions cmd/ethkey/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ import (
"fmt"
"os"

"github.com/ethereum/go-ethereum/cmd/utils"
"gopkg.in/urfave/cli.v1"

"github.com/ethereum/go-ethereum/cmd/utils"
)

const (
Expand Down Expand Up @@ -53,10 +54,10 @@ var (
Name: "json",
Usage: "output JSON instead of human-readable format",
}
messageFlag = cli.StringFlag{
Name: "message",
Usage: "the file that contains the message to sign/verify",
}
//messageFlag = cli.StringFlag{
// Name: "message",
// Usage: "the file that contains the message to sign/verify",
//}
)

func main() {
Expand Down
3 changes: 2 additions & 1 deletion cmd/ethkey/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ import (
"fmt"
"io/ioutil"

"gopkg.in/urfave/cli.v1"

"github.com/ethereum/go-ethereum/accounts/keystore"
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"gopkg.in/urfave/cli.v1"
)

type outputSign struct {
Expand Down
1 change: 1 addition & 0 deletions cmd/ethkey/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"testing"

"github.com/docker/docker/pkg/reexec"

"github.com/ethereum/go-ethereum/internal/cmdtest"
)

Expand Down
3 changes: 2 additions & 1 deletion cmd/ethkey/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ import (
"io/ioutil"
"strings"

"gopkg.in/urfave/cli.v1"

"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/console"
"github.com/ethereum/go-ethereum/crypto"
"gopkg.in/urfave/cli.v1"
)

// getPassPhrase obtains a passphrase given by the user. It first checks the
Expand Down
3 changes: 2 additions & 1 deletion cmd/evm/disasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ import (
"io/ioutil"
"strings"

"github.com/ethereum/go-ethereum/core/asm"
cli "gopkg.in/urfave/cli.v1"

"github.com/ethereum/go-ethereum/core/asm"
)

var disasmCommand = cli.Command{
Expand Down
3 changes: 2 additions & 1 deletion cmd/evm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ import (
"math/big"
"os"

"github.com/ethereum/go-ethereum/cmd/utils"
"gopkg.in/urfave/cli.v1"

"github.com/ethereum/go-ethereum/cmd/utils"
)

var gitCommit = "" // Git SHA1 commit hash of the release (set via linker flags)
Expand Down
3 changes: 2 additions & 1 deletion cmd/evm/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import (

goruntime "runtime"

cli "gopkg.in/urfave/cli.v1"

"github.com/ethereum/go-ethereum/cmd/evm/internal/compiler"
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/common"
Expand All @@ -37,7 +39,6 @@ import (
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
cli "gopkg.in/urfave/cli.v1"
)

var runCommand = cli.Command{
Expand Down
3 changes: 2 additions & 1 deletion cmd/faucet/faucet.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ import (
"sync"
"time"

"golang.org/x/net/websocket"

"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/accounts/keystore"
"github.com/ethereum/go-ethereum/common"
Expand All @@ -58,7 +60,6 @@ import (
"github.com/ethereum/go-ethereum/p2p/discv5"
"github.com/ethereum/go-ethereum/p2p/nat"
"github.com/ethereum/go-ethereum/params"
"golang.org/x/net/websocket"
)

var (
Expand Down
3 changes: 2 additions & 1 deletion cmd/geth/accountcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ import (
"fmt"
"io/ioutil"

"gopkg.in/urfave/cli.v1"

"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/accounts/keystore"
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/console"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
"gopkg.in/urfave/cli.v1"
)

var (
Expand Down
Loading