Browse Source

determinisitic linter (#902)

* linter: address gosimple lints

* linter: make deterministic & a rebase fix

* lint/rpc: fix a gosimple lint

* run linter in CI

* fix rebase mistake

* fix makefile

* ugh

* revert Makefile

* add metalinter to CI

* try this

* linter: last little fix

* need glide

* better

* okayy circle, have it your way

* lints: gosimple

* pr comments
pull/897/head
Zach 7 years ago
committed by GitHub
parent
commit
12c5a57415
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 19 additions and 22 deletions
  1. +7
    -7
      Makefile
  2. +1
    -0
      circle.yml
  3. +1
    -6
      node/node.go
  4. +2
    -2
      p2p/trust/store.go
  5. +7
    -6
      rpc/lib/client/ws_client.go
  6. +1
    -1
      state/txindex/kv/kv.go

+ 7
- 7
Makefile View File

@ -1,7 +1,7 @@
GOTOOLS = \
github.com/mitchellh/gox \
github.com/tcnksm/ghr \
github.com/alecthomas/gometalinter
gopkg.in/alecthomas/gometalinter.v2
PACKAGES=$(shell go list ./... | grep -v '/vendor/')
BUILD_TAGS?=tendermint
@ -74,7 +74,7 @@ get_vendor_deps:
@hash glide 2>/dev/null || go get github.com/Masterminds/glide
@rm -rf vendor/
@echo "--> Running glide install"
@glide install
$(GOPATH)/bin/glide install
update_tools:
@echo "--> Updating tools"
@ -83,21 +83,22 @@ update_tools:
tools:
@echo "--> Installing tools"
@go get $(GOTOOLS)
@gometalinter --install
$(GOPATH)/bin/gometalinter.v2 --install
### Formatting, linting, and vetting
metalinter:
@gometalinter --vendor --deadline=600s --enable-all --disable=lll ./...
$(GOPATH)/bin/gometalinter.v2 --vendor --deadline=600s --enable-all --disable=lll ./...
metalinter_test:
@gometalinter --vendor --deadline=600s --disable-all \
$(GOPATH)/bin/gometalinter.v2 --vendor --deadline=600s --disable-all \
--enable=deadcode \
--enable=gosimple \
--enable=misspell \
--enable=safesql \
./...
# --enable=gas \
#--enable=gas \
#--enable=maligned \
#--enable=dupl \
#--enable=errcheck \
@ -105,7 +106,6 @@ metalinter_test:
#--enable=gocyclo \
#--enable=goimports \
#--enable=golint \ <== comments on anything exported
#--enable=gosimple \
#--enable=gotype \
#--enable=ineffassign \
#--enable=interfacer \


+ 1
- 0
circle.yml View File

@ -24,6 +24,7 @@ dependencies:
test:
override:
- cd "$PROJECT_PATH" && make tools && make get_vendor_deps && make metalinter_test
- cd "$PROJECT_PATH" && set -o pipefail && make test_integrations 2>&1 | tee test_integrations.log:
timeout: 1800
post:


+ 1
- 6
node/node.go View File

@ -373,12 +373,7 @@ func (n *Node) OnStart() error {
}
// start tx indexer
err = n.indexerService.Start()
if err != nil {
return err
}
return nil
return n.indexerService.Start()
}
// OnStop stops the Node. It implements cmn.Service.


+ 2
- 2
p2p/trust/store.go View File

@ -138,7 +138,7 @@ func (tms *TrustMetricStore) loadFromDB() bool {
return false
}
peers := make(map[string]MetricHistoryJSON, 0)
peers := make(map[string]MetricHistoryJSON)
err := json.Unmarshal(bytes, &peers)
if err != nil {
cmn.PanicCrisis(cmn.Fmt("Could not unmarshal Trust Metric Store DB data: %v", err))
@ -160,7 +160,7 @@ func (tms *TrustMetricStore) loadFromDB() bool {
func (tms *TrustMetricStore) saveToDB() {
tms.Logger.Debug("Saving TrustHistory to DB", "size", tms.size())
peers := make(map[string]MetricHistoryJSON, 0)
peers := make(map[string]MetricHistoryJSON)
for key, tm := range tms.peerMetrics {
// Add an entry for the peer identified by key


+ 7
- 6
rpc/lib/client/ws_client.go View File

@ -169,13 +169,14 @@ func (c *WSClient) OnStop() {}
// Stop overrides cmn.Service#Stop. There is no other way to wait until Quit
// channel is closed.
func (c *WSClient) Stop() error {
err := c.BaseService.Stop()
if err == nil {
// only close user-facing channels when we can't write to them
c.wg.Wait()
close(c.ResponsesCh)
if err := c.BaseService.Stop(); err != nil {
return err
}
return err
// only close user-facing channels when we can't write to them
c.wg.Wait()
close(c.ResponsesCh)
return nil
}
// IsReconnecting returns true if the client is reconnecting right now.


+ 1
- 1
state/txindex/kv/kv.go View File

@ -342,7 +342,7 @@ func startKey(c query.Condition, height int64) []byte {
func startKeyForRange(r queryRange, height int64) []byte {
if r.lowerBound == nil {
return []byte(fmt.Sprintf("%s", r.key))
return []byte(r.key)
}
var lowerBound interface{}


Loading…
Cancel
Save