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

Commit

Permalink
Fix metalinter warnings and add to CI (#298)
Browse files Browse the repository at this point in the history
* linting: address some checks

* add nolint warnings; remove duplicate megacheck from Makefile

* add metalinter to CI, closes #196

* Run metalinter on travis

* metalinter: don't run on CI yet
  • Loading branch information
Adrian Brink committed Oct 22, 2017
1 parent 33220ff commit 7bbbac8
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ os:

install: make get_vendor_deps

script: make test_coverage
script: make test_coverage # && make metalinter (enable when CI can handle the memory)

after_success:
- bash <(curl -s https://codecov.io/bash)
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 @@ -69,9 +68,6 @@ test_race:
test_integrations:
@bash ./tests/test.sh

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
5 changes: 3 additions & 2 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ test:
- cd "$REPO" && make install
- cd "$REPO" && make test_coverage
- cd "$REPO" && set -o pipefail && make test_integrations 2>&1 | tee test_integrations.log

# should be uncommented when CI is more robust
#- cd "$REPO" && make metalinter

post:
- cd "$PROJECT_PATH" && mv test_integrations.log "${CIRCLE_ARTIFACTS}"
- cd "$PROJECT_PATH" && bash <(curl -s https://codecov.io/bash)
- 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

0 comments on commit 7bbbac8

Please sign in to comment.