From 36f5cf8c469ba09afc6d47f194adf6a8ebe10b47 Mon Sep 17 00:00:00 2001
From: zramsay <zach@monax.io>
Date: Tue, 30 May 2017 23:34:53 -0400
Subject: [PATCH] core: apply megacheck vetting tool

---
 blockchain/filter.go                          | 14 +------------
 client/cmd/burrow-client.go                   |  9 --------
 client/mock/client_mock.go                    |  6 +++---
 client/rpc/client_test.go                     |  2 +-
 client/websocket_client.go                    |  1 -
 cmd/burrow.go                                 |  9 --------
 event/filters.go                              |  2 +-
 files/files.go                                |  2 --
 files/log.go                                  | 21 -------------------
 genesis/maker.go                              |  8 ++-----
 logging/config/sinks.go                       |  1 -
 manager/burrow-mint/accounts.go               |  5 -----
 manager/burrow-mint/evm/sha3/keccakf.go       |  2 +-
 manager/burrow-mint/evm/snative.go            |  5 +----
 manager/burrow-mint/evm/stack.go              |  2 --
 manager/burrow-mint/evm/vm_test.go            |  3 +--
 manager/burrow-mint/state/block_cache_test.go |  8 +++----
 manager/burrow-mint/state/execution.go        | 19 ++++++++---------
 manager/burrow-mint/state/genesis_test.go     |  4 ++--
 manager/burrow-mint/state/permissions_test.go |  4 ++--
 manager/burrow-mint/state/state_test.go       |  2 +-
 manager/burrow-mint/transactor.go             |  5 -----
 rpc/tendermint/client/client_test.go          |  1 +
 rpc/v0/rest_server.go                         |  9 --------
 rpc/v0/rest_server_pipe_test.go               |  2 +-
 rpc/v0/rest_server_test.go                    |  1 -
 server/websocket.go                           |  6 ++----
 test/filters/filter_test.go                   |  2 +-
 test/fixtures/file_fixtures.go                |  3 +++
 test/server/ws_burst_test.go                  |  2 +-
 txs/tx.go                                     |  4 ++--
 txs/tx_test.go                                |  1 +
 32 files changed, 41 insertions(+), 124 deletions(-)
 delete mode 100644 files/log.go

diff --git a/blockchain/filter.go b/blockchain/filter.go
index c61f77fb..d0780f90 100644
--- a/blockchain/filter.go
+++ b/blockchain/filter.go
@@ -70,7 +70,7 @@ func FilterBlocks(blockchain blockchain_types.Blockchain,
 	// Optimization. Break any height filters out. Messy but makes sure we don't
 	// fetch more blocks then necessary. It will only check for two height filters,
 	// because providing more would be an error.
-	if filterData == nil || len(filterData) == 0 {
+	if len(filterData) == 0 {
 		minHeight = 0
 		maxHeight = height
 	} else {
@@ -178,29 +178,24 @@ func getHeightMinMax(fda []*event.FilterData, height int) (int, int, []*event.Fi
 				}
 				min = val
 				max = val
-				break
 			case "<":
 				mx := val - 1
 				if mx > min && mx < max {
 					max = mx
 				}
-				break
 			case "<=":
 				if val > min && val < max {
 					max = val
 				}
-				break
 			case ">":
 				mn := val + 1
 				if mn < max && mn > min {
 					min = mn
 				}
-				break
 			case ">=":
 				if val < max && val > min {
 					min = val
 				}
-				break
 			default:
 				return 0, 0, nil, fmt.Errorf("Operator not supported")
 			}
@@ -214,10 +209,3 @@ func getHeightMinMax(fda []*event.FilterData, height int) (int, int, []*event.Fi
 	}
 	return min, max, fda, nil
 }
-
-func min(x, y int) int {
-	if x > y {
-		return y
-	}
-	return x
-}
diff --git a/client/cmd/burrow-client.go b/client/cmd/burrow-client.go
index 788d7fd1..77f746a3 100644
--- a/client/cmd/burrow-client.go
+++ b/client/cmd/burrow-client.go
@@ -17,7 +17,6 @@ package commands
 import (
 	"os"
 	"strconv"
-	"strings"
 
 	"github.com/spf13/cobra"
 
@@ -100,11 +99,3 @@ func setDefaultString(envVar, def string) string {
 	}
 	return def
 }
-
-func setDefaultStringSlice(envVar string, def []string) []string {
-	env := os.Getenv(envVar)
-	if env != "" {
-		return strings.Split(env, ",")
-	}
-	return def
-}
diff --git a/client/mock/client_mock.go b/client/mock/client_mock.go
index 0460d638..c6a0d12b 100644
--- a/client/mock/client_mock.go
+++ b/client/mock/client_mock.go
@@ -41,9 +41,9 @@ func NewMockNodeClient() *MockNodeClient {
 func (mock *MockNodeClient) Broadcast(transaction txs.Tx) (*txs.Receipt, error) {
 	// make zero transaction receipt
 	txReceipt := &txs.Receipt{
-		TxHash:          make([]byte, 20, 20),
+		TxHash:          make([]byte, 20),
 		CreatesContract: 0,
-		ContractAddr:    make([]byte, 20, 20),
+		ContractAddr:    make([]byte, 20),
 	}
 	return txReceipt, nil
 }
@@ -55,7 +55,7 @@ func (mock *MockNodeClient) DeriveWebsocketClient() (nodeWsClient NodeWebsocketC
 func (mock *MockNodeClient) GetAccount(address []byte) (*acc.Account, error) {
 	// make zero account
 	var zero [32]byte
-	copyAddressBytes := make([]byte, len(address), len(address))
+	copyAddressBytes := make([]byte, len(address))
 	copy(copyAddressBytes, address)
 	account := &acc.Account{
 		Address:     copyAddressBytes,
diff --git a/client/rpc/client_test.go b/client/rpc/client_test.go
index a805b99b..603fe793 100644
--- a/client/rpc/client_test.go
+++ b/client/rpc/client_test.go
@@ -117,7 +117,7 @@ func testName(t *testing.T,
 	// set data
 	dataString := fmt.Sprintf("%X", "We are DOUG.")
 	// set name
-	nameString := fmt.Sprintf("%s", "DOUG")
+	nameString := "DOUG"
 
 	_, err := Name(nodeClient, keyClient, publicKeyString, addressString,
 		amountString, nonceString, feeString, nameString, dataString)
diff --git a/client/websocket_client.go b/client/websocket_client.go
index e3da5e9f..428f78fd 100644
--- a/client/websocket_client.go
+++ b/client/websocket_client.go
@@ -195,7 +195,6 @@ func (burrowNodeWebsocketClient *burrowNodeWebsocketClient) WaitForConfirmation(
 			Exception: nil,
 			Error:     fmt.Errorf("timed out waiting for event"),
 		}
-		return
 	}()
 	return confirmationChannel, nil
 }
diff --git a/cmd/burrow.go b/cmd/burrow.go
index bfa3b264..a29f3e1f 100644
--- a/cmd/burrow.go
+++ b/cmd/burrow.go
@@ -17,7 +17,6 @@ package commands
 import (
 	"os"
 	"strconv"
-	"strings"
 
 	"github.com/spf13/cobra"
 
@@ -92,11 +91,3 @@ func setDefaultString(envVar, def string) string {
 	}
 	return def
 }
-
-func setDefaultStringSlice(envVar string, def []string) []string {
-	env := os.Getenv(envVar)
-	if env != "" {
-		return strings.Split(env, ",")
-	}
-	return def
-}
diff --git a/event/filters.go b/event/filters.go
index ea04e989..0a1c7324 100644
--- a/event/filters.go
+++ b/event/filters.go
@@ -107,7 +107,7 @@ func (this *FilterFactory) RegisterFilterPool(fieldName string, pool *sync.Pool)
 // only if all the sub-filters matches.
 func (this *FilterFactory) NewFilter(fdArr []*FilterData) (Filter, error) {
 
-	if fdArr == nil || len(fdArr) == 0 {
+	if len(fdArr) == 0 {
 		return &MatchAllFilter{}, nil
 	}
 	if len(fdArr) == 1 {
diff --git a/files/files.go b/files/files.go
index a11c8a62..2ab8b515 100644
--- a/files/files.go
+++ b/files/files.go
@@ -17,7 +17,6 @@ package files
 
 import (
 	"fmt"
-	"io"
 	"io/ioutil"
 	"os"
 )
@@ -62,7 +61,6 @@ func WriteFile(fileName string, data []byte, perm os.FileMode) error {
 		return err
 	}
 	if err2 == nil && n < len(data) {
-		err2 = io.ErrShortWrite
 		return err
 	}
 
diff --git a/files/log.go b/files/log.go
deleted file mode 100644
index b07f421f..00000000
--- a/files/log.go
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2017 Monax Industries Limited
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//    http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package files
-
-import (
-	"github.com/tendermint/log15"
-)
-
-var log = log15.New("module", "server/files")
diff --git a/genesis/maker.go b/genesis/maker.go
index bfabb4fb..48f09c56 100644
--- a/genesis/maker.go
+++ b/genesis/maker.go
@@ -43,23 +43,19 @@ func NewGenesisValidator(amount int64, name string, unbondToAddress []byte,
 	// convert the key bytes into a typed fixed size byte array
 	var typedPublicKeyBytes []byte
 	switch keyType {
-	case "ed25519":
+	case "ed25519": // ed25519 has type byte 0x01
 		// TODO: [ben] functionality and checks need to be inherit in the type
 		if len(publicKeyBytes) != PublicKeyEd25519ByteLength {
 			return nil, fmt.Errorf("Invalid length provided for ed25519 public key (%v bytes provided but expected %v bytes)",
 				len(publicKeyBytes), PublicKeyEd25519ByteLength)
 		}
-		// ed25519 has type byte 0x01
-		typedPublicKeyBytes = make([]byte, PublicKeyEd25519ByteLength+1)
 		// prepend type byte to public key
 		typedPublicKeyBytes = append([]byte{crypto.TypeEd25519}, publicKeyBytes...)
-	case "secp256k1":
+	case "secp256k1": // secp256k1 has type byte 0x02
 		if len(publicKeyBytes) != PublicKeySecp256k1ByteLength {
 			return nil, fmt.Errorf("Invalid length provided for secp256k1 public key (%v bytes provided but expected %v bytes)",
 				len(publicKeyBytes), PublicKeySecp256k1ByteLength)
 		}
-		// secp256k1 has type byte 0x02
-		typedPublicKeyBytes = make([]byte, PublicKeySecp256k1ByteLength+1)
 		// prepend type byte to public key
 		typedPublicKeyBytes = append([]byte{crypto.TypeSecp256k1}, publicKeyBytes...)
 	default:
diff --git a/logging/config/sinks.go b/logging/config/sinks.go
index 7eaea511..daf88c30 100644
--- a/logging/config/sinks.go
+++ b/logging/config/sinks.go
@@ -15,7 +15,6 @@ import (
 // This file contains definitions for a configurable output graph for the
 // logging system.
 
-type source string
 type outputType string
 type transformType string
 type filterMode string
diff --git a/manager/burrow-mint/accounts.go b/manager/burrow-mint/accounts.go
index 1443a653..b0e58c35 100644
--- a/manager/burrow-mint/accounts.go
+++ b/manager/burrow-mint/accounts.go
@@ -226,8 +226,3 @@ func (this *AccountBalanceFilter) Match(v interface{}) bool {
 	}
 	return this.match(int64(acc.Balance), this.value)
 }
-
-// Function for matching accounts against filter data.
-func (this *accounts) matchBlock(block, fda []*event.FilterData) bool {
-	return false
-}
diff --git a/manager/burrow-mint/evm/sha3/keccakf.go b/manager/burrow-mint/evm/sha3/keccakf.go
index 107156cc..e12792fd 100644
--- a/manager/burrow-mint/evm/sha3/keccakf.go
+++ b/manager/burrow-mint/evm/sha3/keccakf.go
@@ -40,7 +40,7 @@ var rc = [...]uint64{
 // ro_xx represent the rotation offsets for use in the χ step.
 // Defining them as const instead of in an array allows the compiler to insert constant shifts.
 const (
-	ro_00 = 0
+	ro_00 = 0 // not used
 	ro_01 = 36
 	ro_02 = 3
 	ro_03 = 41
diff --git a/manager/burrow-mint/evm/snative.go b/manager/burrow-mint/evm/snative.go
index d256ddf2..3f628e99 100644
--- a/manager/burrow-mint/evm/snative.go
+++ b/manager/burrow-mint/evm/snative.go
@@ -464,10 +464,7 @@ func (e ErrInvalidPermission) Error() string {
 
 // Checks if a permission flag is valid (a known base chain or snative permission)
 func ValidPermN(n ptypes.PermFlag) bool {
-	if n > ptypes.TopPermFlag {
-		return false
-	}
-	return true
+	return n <= ptypes.TopPermFlag
 }
 
 // Get the global BasePermissions
diff --git a/manager/burrow-mint/evm/stack.go b/manager/burrow-mint/evm/stack.go
index e383be25..f9d48986 100644
--- a/manager/burrow-mint/evm/stack.go
+++ b/manager/burrow-mint/evm/stack.go
@@ -106,7 +106,6 @@ func (st *Stack) Swap(n int) {
 		return
 	}
 	st.data[st.ptr-n], st.data[st.ptr-1] = st.data[st.ptr-1], st.data[st.ptr-n]
-	return
 }
 
 func (st *Stack) Dup(n int) {
@@ -116,7 +115,6 @@ func (st *Stack) Dup(n int) {
 		return
 	}
 	st.Push(st.data[st.ptr-n])
-	return
 }
 
 // Not an opcode, costs no gas.
diff --git a/manager/burrow-mint/evm/vm_test.go b/manager/burrow-mint/evm/vm_test.go
index a7e36a70..0dd35682 100644
--- a/manager/burrow-mint/evm/vm_test.go
+++ b/manager/burrow-mint/evm/vm_test.go
@@ -103,11 +103,10 @@ func TestJumpErr(t *testing.T) {
 
 	var gas int64 = 100000
 	code := []byte{0x60, 0x10, 0x56} // jump to position 16, a clear failure
-	var output []byte
 	var err error
 	ch := make(chan struct{})
 	go func() {
-		output, err = ourVm.Call(account1, account2, code, []byte{}, 0, &gas)
+		_, err = ourVm.Call(account1, account2, code, []byte{}, 0, &gas)
 		ch <- struct{}{}
 	}()
 	tick := time.NewTicker(time.Second * 2)
diff --git a/manager/burrow-mint/state/block_cache_test.go b/manager/burrow-mint/state/block_cache_test.go
index f3bef027..03f99b49 100644
--- a/manager/burrow-mint/state/block_cache_test.go
+++ b/manager/burrow-mint/state/block_cache_test.go
@@ -21,8 +21,8 @@ func TestBlockCache_Sync_Accounts(t *testing.T) {
 	// to remove them twice from merkle tree
 	defer func() {
 		if r := recover(); r != nil {
-			t.Fatalf("Consecutive calls to BlockCache.Sync() failed. " +
-					"Is cache dirty?\n Error: %s", r)
+			t.Fatalf("Consecutive calls to BlockCache.Sync() failed. "+
+				"Is cache dirty?\n Error: %s", r)
 		}
 	}()
 	blockCache.Sync()
@@ -46,8 +46,8 @@ func TestBlockCache_Sync_NameReg(t *testing.T) {
 	blockCache.Sync()
 	defer func() {
 		if r := recover(); r != nil {
-			t.Fatalf("Consecutive calls to BlockCache.Sync() failed. " +
-					"Is cache dirty?\n Error: %s", r)
+			t.Fatalf("Consecutive calls to BlockCache.Sync() failed. "+
+				"Is cache dirty?\n Error: %s", r)
 		}
 	}()
 	blockCache.Sync()
diff --git a/manager/burrow-mint/state/execution.go b/manager/burrow-mint/state/execution.go
index 50745e1a..4c765ec7 100644
--- a/manager/burrow-mint/state/execution.go
+++ b/manager/burrow-mint/state/execution.go
@@ -16,7 +16,6 @@ package state
 
 import (
 	"bytes"
-	"errors"
 	"fmt"
 
 	acm "github.com/hyperledger/burrow/account"
@@ -627,7 +626,7 @@ func ExecTx(blockCache *BlockCache, tx txs.Tx, runCall bool, evc events.Fireable
 			// if the entry already exists, and hasn't expired, we must be owner
 			if entry.Expires > lastBlockHeight {
 				// ensure we are owner
-				if bytes.Compare(entry.Owner, tx.Input.Address) != 0 {
+				if !bytes.Equal(entry.Owner, tx.Input.Address) {
 					logging.InfoMsg(logger, "Sender is trying to update a name for which they are not an owner",
 						"sender_address", tx.Input.Address,
 						"name", tx.Name)
@@ -649,7 +648,7 @@ func ExecTx(blockCache *BlockCache, tx txs.Tx, runCall bool, evc events.Fireable
 				// and changing the data
 				if expired {
 					if expiresIn < txs.MinNameRegistrationPeriod {
-						return errors.New(fmt.Sprintf("Names must be registered for at least %d blocks", txs.MinNameRegistrationPeriod))
+						return fmt.Errorf("Names must be registered for at least %d blocks", txs.MinNameRegistrationPeriod)
 					}
 					entry.Expires = lastBlockHeight + expiresIn
 					entry.Owner = tx.Input.Address
@@ -664,7 +663,7 @@ func ExecTx(blockCache *BlockCache, tx txs.Tx, runCall bool, evc events.Fireable
 					credit := oldCredit + value
 					expiresIn = int(credit / costPerBlock)
 					if expiresIn < txs.MinNameRegistrationPeriod {
-						return errors.New(fmt.Sprintf("Names must be registered for at least %d blocks", txs.MinNameRegistrationPeriod))
+						return fmt.Errorf("Names must be registered for at least %d blocks", txs.MinNameRegistrationPeriod)
 					}
 					entry.Expires = lastBlockHeight + expiresIn
 					logging.TraceMsg(logger, "Updated NameReg entry",
@@ -679,7 +678,7 @@ func ExecTx(blockCache *BlockCache, tx txs.Tx, runCall bool, evc events.Fireable
 			}
 		} else {
 			if expiresIn < txs.MinNameRegistrationPeriod {
-				return errors.New(fmt.Sprintf("Names must be registered for at least %d blocks", txs.MinNameRegistrationPeriod))
+				return fmt.Errorf("Names must be registered for at least %d blocks", txs.MinNameRegistrationPeriod)
 			}
 			// entry does not exist, so create it
 			entry = &core_types.NameRegEntry{
@@ -1001,11 +1000,11 @@ func HasPermission(state AccountGetter, acc *acm.Account, perm ptypes.PermFlag,
 		sanity.PanicSanity("Checking an unknown permission in state should never happen")
 	}
 
-	if acc == nil {
-		// TODO
-		// this needs to fall back to global or do some other specific things
-		// eg. a bondAcc may be nil and so can only bond if global bonding is true
-	}
+	//if acc == nil {
+	// TODO
+	// this needs to fall back to global or do some other specific things
+	// eg. a bondAcc may be nil and so can only bond if global bonding is true
+	//}
 	permString := ptypes.PermFlagToString(perm)
 
 	v, err := acc.Permissions.Base.Get(perm)
diff --git a/manager/burrow-mint/state/genesis_test.go b/manager/burrow-mint/state/genesis_test.go
index d699bc62..983b5cb5 100644
--- a/manager/burrow-mint/state/genesis_test.go
+++ b/manager/burrow-mint/state/genesis_test.go
@@ -33,7 +33,7 @@ import (
 
 var chain_id = "lone_ranger"
 var addr1, _ = hex.DecodeString("964B1493BBE3312278B7DEB94C39149F7899A345")
-var send1, name1, call1 = 1, 1, 0
+var send1 = 1
 var perms, setbit = 66, 70
 var accName = "me"
 var roles1 = []string{"master", "universal-ruler"}
@@ -79,7 +79,7 @@ func TestGenesisReadable(t *testing.T) {
 		t.Fatalf("Incorrect chain id. Got %d, expected %d\n", genDoc.ChainID, chain_id)
 	}
 	acc := genDoc.Accounts[0]
-	if bytes.Compare(acc.Address, addr1) != 0 {
+	if !bytes.Equal(acc.Address, addr1) {
 		t.Fatalf("Incorrect address for account. Got %X, expected %X\n", acc.Address, addr1)
 	}
 	if acc.Amount != amt1 {
diff --git a/manager/burrow-mint/state/permissions_test.go b/manager/burrow-mint/state/permissions_test.go
index dd812410..a02f7406 100644
--- a/manager/burrow-mint/state/permissions_test.go
+++ b/manager/burrow-mint/state/permissions_test.go
@@ -515,7 +515,7 @@ func TestCreatePermission(t *testing.T) {
 	if contractAcc == nil {
 		t.Fatalf("failed to create contract %X", contractAddr)
 	}
-	if bytes.Compare(contractAcc.Code, contractCode) != 0 {
+	if !bytes.Equal(contractAcc.Code, contractCode) {
 		t.Fatalf("contract does not have correct code. Got %X, expected %X", contractAcc.Code, contractCode)
 	}
 
@@ -540,7 +540,7 @@ func TestCreatePermission(t *testing.T) {
 	if contractAcc == nil {
 		t.Fatalf("failed to create contract %X", contractAddr)
 	}
-	if bytes.Compare(contractAcc.Code, factoryCode) != 0 {
+	if !bytes.Equal(contractAcc.Code, factoryCode) {
 		t.Fatalf("contract does not have correct code. Got %X, expected %X", contractAcc.Code, factoryCode)
 	}
 
diff --git a/manager/burrow-mint/state/state_test.go b/manager/burrow-mint/state/state_test.go
index 2ecd60ff..f9f91d9b 100644
--- a/manager/burrow-mint/state/state_test.go
+++ b/manager/burrow-mint/state/state_test.go
@@ -275,7 +275,7 @@ func TestNameTxs(t *testing.T) {
 		if entry == nil {
 			t.Fatalf("Could not find name %s", name)
 		}
-		if bytes.Compare(entry.Owner, addr) != 0 {
+		if !bytes.Equal(entry.Owner, addr) {
 			t.Fatalf("Wrong owner. Got %X expected %X", entry.Owner, addr)
 		}
 		if data != entry.Data {
diff --git a/manager/burrow-mint/transactor.go b/manager/burrow-mint/transactor.go
index 3f73737b..f0cab8b6 100644
--- a/manager/burrow-mint/transactor.go
+++ b/manager/burrow-mint/transactor.go
@@ -391,12 +391,10 @@ func (this *transactor) SignTx(tx txs.Tx, privAccounts []*account.PrivAccount) (
 			input.PubKey = privAccounts[i].PubKey
 			input.Signature = privAccounts[i].Sign(this.chainID, sendTx)
 		}
-		break
 	case *txs.CallTx:
 		callTx := tx.(*txs.CallTx)
 		callTx.Input.PubKey = privAccounts[0].PubKey
 		callTx.Input.Signature = privAccounts[0].Sign(this.chainID, callTx)
-		break
 	case *txs.BondTx:
 		bondTx := tx.(*txs.BondTx)
 		// the first privaccount corresponds to the BondTx pub key.
@@ -406,15 +404,12 @@ func (this *transactor) SignTx(tx txs.Tx, privAccounts []*account.PrivAccount) (
 			input.PubKey = privAccounts[i+1].PubKey
 			input.Signature = privAccounts[i+1].Sign(this.chainID, bondTx)
 		}
-		break
 	case *txs.UnbondTx:
 		unbondTx := tx.(*txs.UnbondTx)
 		unbondTx.Signature = privAccounts[0].Sign(this.chainID, unbondTx).(crypto.SignatureEd25519)
-		break
 	case *txs.RebondTx:
 		rebondTx := tx.(*txs.RebondTx)
 		rebondTx.Signature = privAccounts[0].Sign(this.chainID, rebondTx).(crypto.SignatureEd25519)
-		break
 	default:
 		return nil, fmt.Errorf("Object is not a proper transaction: %v\n", tx)
 	}
diff --git a/rpc/tendermint/client/client_test.go b/rpc/tendermint/client/client_test.go
index 673be6c1..13a5c98e 100644
--- a/rpc/tendermint/client/client_test.go
+++ b/rpc/tendermint/client/client_test.go
@@ -26,6 +26,7 @@ func TestParamsMap(t *testing.T) {
 	}
 	dict, err := paramsMap("Foo", aStruct{5},
 		"Bar", "Nibbles")
+	assert.NoError(t, err, "Should not be a paramsMaperror")
 	assert.Equal(t, map[string]interface{}{
 		"Foo": aStruct{5},
 		"Bar": "Nibbles",
diff --git a/rpc/v0/rest_server.go b/rpc/v0/rest_server.go
index 3f76af20..03c70c5a 100644
--- a/rpc/v0/rest_server.go
+++ b/rpc/v0/rest_server.go
@@ -500,15 +500,6 @@ func heightParam(c *gin.Context) {
 	c.Next()
 }
 
-func subIdParam(c *gin.Context) {
-	subId := c.Param("id")
-	if len(subId) != 64 || !util.IsHex(subId) {
-		c.AbortWithError(400, fmt.Errorf("Malformed event id"))
-	}
-	c.Set("id", subId)
-	c.Next()
-}
-
 // TODO
 func peerAddressParam(c *gin.Context) {
 	subId := c.Param("address")
diff --git a/rpc/v0/rest_server_pipe_test.go b/rpc/v0/rest_server_pipe_test.go
index eea240ba..1cd82822 100644
--- a/rpc/v0/rest_server_pipe_test.go
+++ b/rpc/v0/rest_server_pipe_test.go
@@ -286,7 +286,7 @@ func (trans *transactor) BroadcastTx(tx txs.Tx) (*txs.Receipt, error) {
 }
 
 func (trans *transactor) Transact(privKey, address, data []byte, gasLimit, fee int64) (*txs.Receipt, error) {
-	if address == nil || len(address) == 0 {
+	if len(address) == 0 {
 		return trans.testData.TransactCreate.Output, nil
 	}
 	return trans.testData.Transact.Output, nil
diff --git a/rpc/v0/rest_server_test.go b/rpc/v0/rest_server_test.go
index 75799320..fa4b27dc 100644
--- a/rpc/v0/rest_server_test.go
+++ b/rpc/v0/rest_server_test.go
@@ -52,7 +52,6 @@ func init() {
 
 type MockSuite struct {
 	suite.Suite
-	baseDir      string
 	serveProcess *server.ServeProcess
 	codec        rpc.Codec
 	sUrl         string
diff --git a/server/websocket.go b/server/websocket.go
index 265ac3a4..b7c8a111 100644
--- a/server/websocket.go
+++ b/server/websocket.go
@@ -358,9 +358,8 @@ func (sessionManager *SessionManager) RemoveSessionOpenEventChannel(lChan chan *
 	if len(ec) == 0 {
 		return false
 	}
-	for i, c := range ec {
+	for _, c := range ec {
 		if lChan == c {
-			ec[i], ec = ec[len(ec)-1], ec[:len(ec)-1]
 			return true
 		}
 	}
@@ -380,9 +379,8 @@ func (sessionManager *SessionManager) RemoveSessionCloseEventChannel(lChan chan
 	if len(ec) == 0 {
 		return false
 	}
-	for i, c := range ec {
+	for _, c := range ec {
 		if lChan == c {
-			ec[i], ec = ec[len(ec)-1], ec[:len(ec)-1]
 			return true
 		}
 	}
diff --git a/test/filters/filter_test.go b/test/filters/filter_test.go
index e3cf1052..35601f46 100644
--- a/test/filters/filter_test.go
+++ b/test/filters/filter_test.go
@@ -96,7 +96,7 @@ type FilterSuite struct {
 }
 
 func (this *FilterSuite) SetupSuite() {
-	objects := make([]FilterableObject, OBJECTS, OBJECTS)
+	objects := make([]FilterableObject, OBJECTS)
 
 	for i := 0; i < 100; i++ {
 		objects[i] = FilterableObject{i, fmt.Sprintf("string%d", i)}
diff --git a/test/fixtures/file_fixtures.go b/test/fixtures/file_fixtures.go
index d6926c09..d751f55f 100644
--- a/test/fixtures/file_fixtures.go
+++ b/test/fixtures/file_fixtures.go
@@ -84,6 +84,9 @@ func (ffs *FileFixtures) RemoveAll() {
 func createWriteClose(filename, content string) error {
 	// We'll create any parent dirs, with permissive permissions
 	err := os.MkdirAll(path.Dir(filename), 0777)
+	if err != nil {
+		return err
+	}
 	f, err := os.Create(filename)
 	if err != nil {
 		return err
diff --git a/test/server/ws_burst_test.go b/test/server/ws_burst_test.go
index 820e173a..1721fa9a 100644
--- a/test/server/ws_burst_test.go
+++ b/test/server/ws_burst_test.go
@@ -94,7 +94,7 @@ func runWs() error {
 	runners := uint16(0)
 	for runners < CONNS {
 		select {
-		case _ = <-doneChan:
+		case <-doneChan:
 			runners++
 		case err := <-errChan:
 			return err
diff --git a/txs/tx.go b/txs/tx.go
index d7b1c50a..44cd1b10 100644
--- a/txs/tx.go
+++ b/txs/tx.go
@@ -360,9 +360,9 @@ type DupeoutTx struct {
 }
 
 func (tx *DupeoutTx) WriteSignBytes(chainID string, w io.Writer, n *int, err *error) {
-	//PanicSanity("DupeoutTx has no sign bytes")
+	// PanicSanity("DupeoutTx has no sign bytes")
 	// TODO
-	return
+	// return
 }
 
 func (tx *DupeoutTx) String() string {
diff --git a/txs/tx_test.go b/txs/tx_test.go
index 1ccef655..ca4b2ff0 100644
--- a/txs/tx_test.go
+++ b/txs/tx_test.go
@@ -212,6 +212,7 @@ func TestEncodeTxDecodeTx(t *testing.T) {
 		t.Fatal(err)
 	}
 	txOut, err := DecodeTx(txBytes)
+	assert.NoError(t, err, "DecodeTx error")
 	assert.Equal(t, tx, txOut)
 }
 
-- 
GitLab