Browse Source

update gometalinter to 3.0.0 (#3233)

in the attempt to fix https://circleci.com/gh/tendermint/tendermint/43165

also

    code is simplified by running gofmt -s .
    remove unused vars
    enable linters we're currently passing
    remove deprecated linters
pull/3118/head
Anton Kaliaev 6 years ago
committed by GitHub
parent
commit
d470945503
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 50 additions and 59 deletions
  1. +19
    -19
      Makefile
  2. +1
    -1
      abci/types/messages_test.go
  3. +0
    -4
      cmd/tendermint/commands/root_test.go
  4. +2
    -2
      consensus/wal_test.go
  5. +1
    -1
      crypto/merkle/rfc6962_test.go
  6. +0
    -2
      evidence/pool_test.go
  7. +1
    -1
      evidence/reactor.go
  8. +8
    -8
      libs/flowrate/io_test.go
  9. +3
    -3
      libs/pubsub/query/query_test.go
  10. +1
    -1
      p2p/conn/connection_test.go
  11. +4
    -4
      p2p/transport_test.go
  12. +2
    -2
      privval/client_test.go
  13. +2
    -2
      scripts/get_tools.sh
  14. +2
    -2
      state/txindex/kv/kv_test.go
  15. +1
    -1
      tools/tm-monitor/eventmeter/eventmeter.go
  16. +3
    -3
      types/genesis_test.go
  17. +0
    -3
      types/part_set.go

+ 19
- 19
Makefile View File

@ -249,31 +249,31 @@ fmt:
metalinter: metalinter:
@echo "--> Running linter" @echo "--> Running linter"
@gometalinter $(LINT_FLAGS) --disable-all \ @gometalinter $(LINT_FLAGS) --disable-all \
--enable=vet \
--enable=vetshadow \
--enable=deadcode \ --enable=deadcode \
--enable=gosimple \
--enable=varcheck \
--enable=structcheck \
--enable=misspell \ --enable=misspell \
--enable=safesql \ --enable=safesql \
--enable=gosec \
--enable=goimports \
--enable=gofmt \
./... ./...
#--enable=gas \
#--enable=gotype \
#--enable=gotypex \
#--enable=gocyclo \
#--enable=golint \
#--enable=maligned \ #--enable=maligned \
#--enable=dupl \
#--enable=errcheck \ #--enable=errcheck \
#--enable=staticcheck \
#--enable=dupl \
#--enable=ineffassign \
#--enable=interfacer \
#--enable=unconvert \
#--enable=goconst \ #--enable=goconst \
#--enable=gocyclo \
#--enable=goimports \
#--enable=golint \ <== comments on anything exported
#--enable=gotype \
#--enable=ineffassign \
#--enable=interfacer \
#--enable=megacheck \
#--enable=staticcheck \
#--enable=structcheck \
#--enable=unconvert \
#--enable=unparam \
#--enable=unused \
#--enable=varcheck \
#--enable=vet \
#--enable=vetshadow \
#--enable=unparam \
#--enable=nakedret \
metalinter_all: metalinter_all:
@echo "--> Running linter (all)" @echo "--> Running linter (all)"
@ -343,4 +343,4 @@ build-slate:
# To avoid unintended conflicts with file names, always add to .PHONY # To avoid unintended conflicts with file names, always add to .PHONY
# unless there is a reason not to. # unless there is a reason not to.
# https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html # https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
.PHONY: check build build_race build_abci dist install install_abci check_dep check_tools get_tools get_dev_tools update_tools get_vendor_deps draw_deps get_protoc protoc_abci protoc_libs gen_certs clean_certs grpc_dbserver test_cover test_apps test_persistence test_p2p test test_race test_integrations test_release test100 vagrant_test fmt rpc-docs build-linux localnet-start localnet-stop build-docker build-docker-localnode sentry-start sentry-config sentry-stop build-slate protoc_grpc protoc_all build_c install_c test_with_deadlock cleanup_after_test_with_deadlock
.PHONY: check build build_race build_abci dist install install_abci check_dep check_tools get_tools get_dev_tools update_tools get_vendor_deps draw_deps get_protoc protoc_abci protoc_libs gen_certs clean_certs grpc_dbserver test_cover test_apps test_persistence test_p2p test test_race test_integrations test_release test100 vagrant_test fmt rpc-docs build-linux localnet-start localnet-stop build-docker build-docker-localnode sentry-start sentry-config sentry-stop build-slate protoc_grpc protoc_all build_c install_c test_with_deadlock cleanup_after_test_with_deadlock metalinter metalinter_all

+ 1
- 1
abci/types/messages_test.go View File

@ -83,7 +83,7 @@ func TestWriteReadMessage2(t *testing.T) {
Log: phrase, Log: phrase,
GasWanted: 10, GasWanted: 10,
Tags: []cmn.KVPair{ Tags: []cmn.KVPair{
cmn.KVPair{Key: []byte("abc"), Value: []byte("def")},
{Key: []byte("abc"), Value: []byte("def")},
}, },
}, },
// TODO: add the rest // TODO: add the rest


+ 0
- 4
cmd/tendermint/commands/root_test.go View File

@ -22,10 +22,6 @@ var (
defaultRoot = os.ExpandEnv("$HOME/.some/test/dir") defaultRoot = os.ExpandEnv("$HOME/.some/test/dir")
) )
const (
rootName = "root"
)
// clearConfig clears env vars, the given root dir, and resets viper. // clearConfig clears env vars, the given root dir, and resets viper.
func clearConfig(dir string) { func clearConfig(dir string) {
if err := os.Unsetenv("TMHOME"); err != nil { if err := os.Unsetenv("TMHOME"); err != nil {


+ 2
- 2
consensus/wal_test.go View File

@ -68,8 +68,8 @@ func TestWALTruncate(t *testing.T) {
func TestWALEncoderDecoder(t *testing.T) { func TestWALEncoderDecoder(t *testing.T) {
now := tmtime.Now() now := tmtime.Now()
msgs := []TimedWALMessage{ msgs := []TimedWALMessage{
TimedWALMessage{Time: now, Msg: EndHeightMessage{0}},
TimedWALMessage{Time: now, Msg: timeoutInfo{Duration: time.Second, Height: 1, Round: 1, Step: types.RoundStepPropose}},
{Time: now, Msg: EndHeightMessage{0}},
{Time: now, Msg: timeoutInfo{Duration: time.Second, Height: 1, Round: 1, Step: types.RoundStepPropose}},
} }
b := new(bytes.Buffer) b := new(bytes.Buffer)


+ 1
- 1
crypto/merkle/rfc6962_test.go View File

@ -26,7 +26,7 @@ import (
func TestRFC6962Hasher(t *testing.T) { func TestRFC6962Hasher(t *testing.T) {
_, leafHashTrail := trailsFromByteSlices([][]byte{[]byte("L123456")}) _, leafHashTrail := trailsFromByteSlices([][]byte{[]byte("L123456")})
leafHash := leafHashTrail.Hash leafHash := leafHashTrail.Hash
_, leafHashTrail = trailsFromByteSlices([][]byte{[]byte{}})
_, leafHashTrail = trailsFromByteSlices([][]byte{{}})
emptyLeafHash := leafHashTrail.Hash emptyLeafHash := leafHashTrail.Hash
for _, tc := range []struct { for _, tc := range []struct {
desc string desc string


+ 0
- 2
evidence/pool_test.go View File

@ -13,8 +13,6 @@ import (
tmtime "github.com/tendermint/tendermint/types/time" tmtime "github.com/tendermint/tendermint/types/time"
) )
var mockState = sm.State{}
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
types.RegisterMockEvidences(cdc) types.RegisterMockEvidences(cdc)


+ 1
- 1
evidence/reactor.go View File

@ -48,7 +48,7 @@ func (evR *EvidenceReactor) SetLogger(l log.Logger) {
// It returns the list of channels for this reactor. // It returns the list of channels for this reactor.
func (evR *EvidenceReactor) GetChannels() []*p2p.ChannelDescriptor { func (evR *EvidenceReactor) GetChannels() []*p2p.ChannelDescriptor {
return []*p2p.ChannelDescriptor{ return []*p2p.ChannelDescriptor{
&p2p.ChannelDescriptor{
{
ID: EvidenceChannel, ID: EvidenceChannel,
Priority: 5, Priority: 5,
}, },


+ 8
- 8
libs/flowrate/io_test.go View File

@ -81,12 +81,12 @@ func TestReader(t *testing.T) {
// Active, Start, Duration, Idle, Bytes, Samples, InstRate, CurRate, AvgRate, PeakRate, BytesRem, TimeRem, Progress // Active, Start, Duration, Idle, Bytes, Samples, InstRate, CurRate, AvgRate, PeakRate, BytesRem, TimeRem, Progress
want := []Status{ want := []Status{
Status{true, start, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
Status{true, start, _100ms, 0, 10, 1, 100, 100, 100, 100, 0, 0, 0},
Status{true, start, _200ms, _100ms, 20, 2, 100, 100, 100, 100, 0, 0, 0},
Status{true, start, _300ms, _200ms, 20, 3, 0, 90, 67, 100, 0, 0, 0},
Status{false, start, _300ms, 0, 20, 3, 0, 0, 67, 100, 0, 0, 0},
Status{false, start, _300ms, 0, 20, 3, 0, 0, 67, 100, 0, 0, 0},
{true, start, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{true, start, _100ms, 0, 10, 1, 100, 100, 100, 100, 0, 0, 0},
{true, start, _200ms, _100ms, 20, 2, 100, 100, 100, 100, 0, 0, 0},
{true, start, _300ms, _200ms, 20, 3, 0, 90, 67, 100, 0, 0, 0},
{false, start, _300ms, 0, 20, 3, 0, 0, 67, 100, 0, 0, 0},
{false, start, _300ms, 0, 20, 3, 0, 0, 67, 100, 0, 0, 0},
} }
for i, s := range status { for i, s := range status {
if !statusesAreEqual(&s, &want[i]) { if !statusesAreEqual(&s, &want[i]) {
@ -139,8 +139,8 @@ func TestWriter(t *testing.T) {
// Active, Start, Duration, Idle, Bytes, Samples, InstRate, CurRate, AvgRate, PeakRate, BytesRem, TimeRem, Progress // Active, Start, Duration, Idle, Bytes, Samples, InstRate, CurRate, AvgRate, PeakRate, BytesRem, TimeRem, Progress
want := []Status{ want := []Status{
Status{true, start, _400ms, 0, 80, 4, 200, 200, 200, 200, 20, _100ms, 80000},
Status{true, start, _500ms, _100ms, 100, 5, 200, 200, 200, 200, 0, 0, 100000},
{true, start, _400ms, 0, 80, 4, 200, 200, 200, 200, 20, _100ms, 80000},
{true, start, _500ms, _100ms, 100, 5, 200, 200, 200, 200, 0, 0, 100000},
} }
for i, s := range status { for i, s := range status {
if !statusesAreEqual(&s, &want[i]) { if !statusesAreEqual(&s, &want[i]) {


+ 3
- 3
libs/pubsub/query/query_test.go View File

@ -73,9 +73,9 @@ func TestConditions(t *testing.T) {
s string s string
conditions []query.Condition conditions []query.Condition
}{ }{
{s: "tm.events.type='NewBlock'", conditions: []query.Condition{query.Condition{Tag: "tm.events.type", Op: query.OpEqual, Operand: "NewBlock"}}},
{s: "tx.gas > 7 AND tx.gas < 9", conditions: []query.Condition{query.Condition{Tag: "tx.gas", Op: query.OpGreater, Operand: int64(7)}, query.Condition{Tag: "tx.gas", Op: query.OpLess, Operand: int64(9)}}},
{s: "tx.time >= TIME 2013-05-03T14:45:00Z", conditions: []query.Condition{query.Condition{Tag: "tx.time", Op: query.OpGreaterEqual, Operand: txTime}}},
{s: "tm.events.type='NewBlock'", conditions: []query.Condition{{Tag: "tm.events.type", Op: query.OpEqual, Operand: "NewBlock"}}},
{s: "tx.gas > 7 AND tx.gas < 9", conditions: []query.Condition{{Tag: "tx.gas", Op: query.OpGreater, Operand: int64(7)}, {Tag: "tx.gas", Op: query.OpLess, Operand: int64(9)}}},
{s: "tx.time >= TIME 2013-05-03T14:45:00Z", conditions: []query.Condition{{Tag: "tx.time", Op: query.OpGreaterEqual, Operand: txTime}}},
} }
for _, tc := range testCases { for _, tc := range testCases {


+ 1
- 1
p2p/conn/connection_test.go View File

@ -30,7 +30,7 @@ func createMConnectionWithCallbacks(conn net.Conn, onReceive func(chID byte, msg
cfg := DefaultMConnConfig() cfg := DefaultMConnConfig()
cfg.PingInterval = 90 * time.Millisecond cfg.PingInterval = 90 * time.Millisecond
cfg.PongTimeout = 45 * time.Millisecond cfg.PongTimeout = 45 * time.Millisecond
chDescs := []*ChannelDescriptor{&ChannelDescriptor{ID: 0x01, Priority: 1, SendQueueCapacity: 1}}
chDescs := []*ChannelDescriptor{{ID: 0x01, Priority: 1, SendQueueCapacity: 1}}
c := NewMConnectionWithConfig(conn, chDescs, onReceive, onError, cfg) c := NewMConnectionWithConfig(conn, chDescs, onReceive, onError, cfg)
c.SetLogger(log.TestingLogger()) c.SetLogger(log.TestingLogger())
return c return c


+ 4
- 4
p2p/transport_test.go View File

@ -498,13 +498,13 @@ func TestTransportConnDuplicateIPFilter(t *testing.T) {
) )
cs.Set(c, []net.IP{ cs.Set(c, []net.IP{
net.IP{10, 0, 10, 1},
net.IP{10, 0, 10, 2},
net.IP{10, 0, 10, 3},
{10, 0, 10, 1},
{10, 0, 10, 2},
{10, 0, 10, 3},
}) })
if err := filter(cs, c, []net.IP{ if err := filter(cs, c, []net.IP{
net.IP{10, 0, 10, 2},
{10, 0, 10, 2},
}); err == nil { }); err == nil {
t.Errorf("expected Peer to be rejected as duplicate") t.Errorf("expected Peer to be rejected as duplicate")
} }


+ 2
- 2
privval/client_test.go View File

@ -37,11 +37,11 @@ func socketTestCases(t *testing.T) []socketTestCase {
require.NoError(t, err) require.NoError(t, err)
unixAddr := fmt.Sprintf("unix://%s", unixFilePath) unixAddr := fmt.Sprintf("unix://%s", unixFilePath)
return []socketTestCase{ return []socketTestCase{
socketTestCase{
{
addr: tcpAddr, addr: tcpAddr,
dialer: DialTCPFn(tcpAddr, testConnDeadline, ed25519.GenPrivKey()), dialer: DialTCPFn(tcpAddr, testConnDeadline, ed25519.GenPrivKey()),
}, },
socketTestCase{
{
addr: unixAddr, addr: unixAddr,
dialer: DialUnixFn(unixFilePath), dialer: DialUnixFn(unixFilePath),
}, },


+ 2
- 2
scripts/get_tools.sh View File

@ -47,8 +47,8 @@ installFromGithub() {
installFromGithub mitchellh/gox 51ed453898ca5579fea9ad1f08dff6b121d9f2e8 installFromGithub mitchellh/gox 51ed453898ca5579fea9ad1f08dff6b121d9f2e8
installFromGithub golang/dep 22125cfaa6ddc71e145b1535d4b7ee9744fefff2 cmd/dep installFromGithub golang/dep 22125cfaa6ddc71e145b1535d4b7ee9744fefff2 cmd/dep
## gometalinter v2.0.11
installFromGithub alecthomas/gometalinter 17a7ffa42374937bfecabfb8d2efbd4db0c26741
## gometalinter v3.0.0
installFromGithub alecthomas/gometalinter df395bfa67c5d0630d936c0044cf07ff05086655
installFromGithub gogo/protobuf 61dbc136cf5d2f08d68a011382652244990a53a9 protoc-gen-gogo installFromGithub gogo/protobuf 61dbc136cf5d2f08d68a011382652244990a53a9 protoc-gen-gogo
installFromGithub square/certstrap e27060a3643e814151e65b9807b6b06d169580a7 installFromGithub square/certstrap e27060a3643e814151e65b9807b6b06d169580a7


+ 2
- 2
state/txindex/kv/kv_test.go View File

@ -184,8 +184,8 @@ func TestIndexAllTags(t *testing.T) {
indexer := NewTxIndex(db.NewMemDB(), IndexAllTags()) indexer := NewTxIndex(db.NewMemDB(), IndexAllTags())
txResult := txResultWithTags([]cmn.KVPair{ txResult := txResultWithTags([]cmn.KVPair{
cmn.KVPair{Key: []byte("account.owner"), Value: []byte("Ivan")},
cmn.KVPair{Key: []byte("account.number"), Value: []byte("1")},
{Key: []byte("account.owner"), Value: []byte("Ivan")},
{Key: []byte("account.number"), Value: []byte("1")},
}) })
err := indexer.Index(txResult) err := indexer.Index(txResult)


+ 1
- 1
tools/tm-monitor/eventmeter/eventmeter.go View File

@ -196,7 +196,7 @@ func (em *EventMeter) RegisterDisconnectCallback(f DisconnectCallbackFunc) {
// Private // Private
func (em *EventMeter) subscribe() error { func (em *EventMeter) subscribe() error {
for query, _ := range em.queryToMetricMap {
for query := range em.queryToMetricMap {
if err := em.wsc.Subscribe(context.TODO(), query); err != nil { if err := em.wsc.Subscribe(context.TODO(), query); err != nil {
return err return err
} }


+ 3
- 3
types/genesis_test.go View File

@ -15,9 +15,9 @@ import (
func TestGenesisBad(t *testing.T) { func TestGenesisBad(t *testing.T) {
// test some bad ones from raw json // test some bad ones from raw json
testCases := [][]byte{ testCases := [][]byte{
[]byte{}, // empty
[]byte{1, 1, 1, 1, 1}, // junk
[]byte(`{}`), // empty
{}, // empty
{1, 1, 1, 1, 1}, // junk
[]byte(`{}`), // empty
[]byte(`{"chain_id":"mychain","validators":[{}]}`), // invalid validator []byte(`{"chain_id":"mychain","validators":[{}]}`), // invalid validator
// missing pub_key type // missing pub_key type
[]byte(`{"validators":[{"pub_key":{"value":"AT/+aaL1eB0477Mud9JMm8Sh8BIvOYlPGC9KkIUmFaE="},"power":"10","name":""}]}`), []byte(`{"validators":[{"pub_key":{"value":"AT/+aaL1eB0477Mud9JMm8Sh8BIvOYlPGC9KkIUmFaE="},"power":"10","name":""}]}`),


+ 0
- 3
types/part_set.go View File

@ -21,9 +21,6 @@ type Part struct {
Index int `json:"index"` Index int `json:"index"`
Bytes cmn.HexBytes `json:"bytes"` Bytes cmn.HexBytes `json:"bytes"`
Proof merkle.SimpleProof `json:"proof"` Proof merkle.SimpleProof `json:"proof"`
// Cache
hash []byte
} }
// ValidateBasic performs basic validation. // ValidateBasic performs basic validation.


Loading…
Cancel
Save