Skip to content
This repository has been archived by the owner on Oct 7, 2020. It is now read-only.

fix metalinter warnings and add to CI #297

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 0 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
GOTOOLS = \
github.com/karalabe/xgo \
github.com/Masterminds/glide \
honnef.co/go/tools/cmd/megacheck \
github.com/alecthomas/gometalinter
PACKAGES=$(shell go list ./... | grep -v '/vendor/')
BUILD_TAGS?=ethermint
Expand Down Expand Up @@ -66,9 +65,6 @@ test_race:
@echo "--> Running go test --race"
@go test -race $(PACKAGES)

megacheck: ensure_tools
@for pkg in ${PACKAGES}; do megacheck "$$pkg"; done

metalinter: ensure_tools
@gometalinter --install
gometalinter --vendor --deadline=600s --enable-all --disable=lll ./...
Expand Down
1 change: 1 addition & 0 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ test:
- "echo $REPO && ls $REPO"
- "cd $REPO && make install"
- "cd $REPO && make test_coverage"
- "cd $REPO && make metalinter"

post:
- cd "$PROJECT_PATH" && bash <(curl -s https://codecov.io/bash)
12 changes: 9 additions & 3 deletions cmd/utils/reset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,14 @@ func TestResetAll(t *testing.T) {
defer os.RemoveAll(tempDatadir) // nolint: errcheck

// set EMHOME env variable
os.Setenv(emHome, tempDatadir)
defer os.Unsetenv(emHome)
if err = os.Setenv(emHome, tempDatadir); err != nil {
t.Errorf("could not set env: %v", err)
}
defer func() {
if err = os.Unsetenv(emHome); err != nil {
t.Errorf("could not unset env: %v", err)
}
}()

// context with empty flag set
context := getContextNoFlag()
Expand All @@ -43,7 +49,7 @@ func TestResetAll(t *testing.T) {
}

// check dir exists
if _, err := os.Stat(dataDir); err != nil {
if _, err = os.Stat(dataDir); err != nil {
t.Errorf("database doesn't exist: %v", err)

}
Expand Down
4 changes: 3 additions & 1 deletion cmd/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/tendermint/ethermint/ethereum"
)

// StartNode will start up the node.
func StartNode(stack *ethereum.Node) {
if err := stack.Start(); err != nil {
ethUtils.Fatalf("Error starting protocol stack: %v", err)
Expand All @@ -25,7 +26,7 @@ func StartNode(stack *ethereum.Node) {
defer signal.Stop(sigc)
<-sigc
log.Info("Got interrupt, shutting down...")
go stack.Stop()
go stack.Stop() // nolint: errcheck
for i := 10; i > 0; i-- {
<-sigc
if i > 1 {
Expand Down Expand Up @@ -65,6 +66,7 @@ func DefaultDataDir() string {
return ""
}

// ResetAll will remove the data directory.
func ResetAll(ctx *cli.Context) error {
dbDir := filepath.Join(MakeDataDir(ctx), "ethermint")
if err := os.RemoveAll(dbDir); err != nil {
Expand Down
4 changes: 3 additions & 1 deletion ethereum/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@ import (
"github.com/ethereum/go-ethereum/node"
)

// Node is the main object.
type Node struct {
node.Node
}

// New creates a new node.
func New(conf *node.Config) (*Node, error) {
stack, err := node.New(conf)
if err != nil {
return nil, err
}

return &Node{*stack}, nil
return &Node{*stack}, nil // nolint: vet
}

// Start starts base node and stop p2p server
Expand Down
3 changes: 1 addition & 2 deletions ethereum/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ func TestEnsureDisabledEthereumP2PStack(t *testing.T) {
t.Fatalf("cannot initialise new node from config: %v", err)
}

node.Start()
if err != nil {
if err := node.Start(); err != nil {
t.Fatalf("cannot start node: %v", err)
}
// Make a listener and ensure that ListenAddr can be bound to
Expand Down