Skip to content

Commit

Permalink
Fix linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
UnitylChaos committed Sep 3, 2018
1 parent 3ac55b5 commit 2378e34
Show file tree
Hide file tree
Showing 36 changed files with 71 additions and 18 deletions.
1 change: 1 addition & 0 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ func handleQueryStore(app *BaseApp, path []string, req abci.RequestQuery) (res a
return queryable.Query(req)
}

// nolint: unparam
func handleQueryP2P(app *BaseApp, path []string, req abci.RequestQuery) (res abci.ResponseQuery) {
// "/p2p" prefix for p2p queries
if len(path) >= 4 {
Expand Down
4 changes: 2 additions & 2 deletions baseapp/baseapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -626,12 +626,12 @@ func TestSimulateTx(t *testing.T) {
// simulate a message, check gas reported
result := app.Simulate(tx)
require.True(t, result.IsOK(), result.Log)
require.Equal(t, int64(gasConsumed), result.GasUsed)
require.Equal(t, gasConsumed, result.GasUsed)

// simulate again, same result
result = app.Simulate(tx)
require.True(t, result.IsOK(), result.Log)
require.Equal(t, int64(gasConsumed), result.GasUsed)
require.Equal(t, gasConsumed, result.GasUsed)

// simulate by calling Query with encoded tx
txBytes, err := codec.MarshalBinary(tx)
Expand Down
4 changes: 3 additions & 1 deletion client/context/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ import (

"github.com/pkg/errors"

"strings"

"github.com/cosmos/cosmos-sdk/store"
"github.com/cosmos/cosmos-sdk/wire"
abci "github.com/tendermint/tendermint/abci/types"
cmn "github.com/tendermint/tendermint/libs/common"
tmliteProxy "github.com/tendermint/tendermint/lite/proxy"
rpcclient "github.com/tendermint/tendermint/rpc/client"
ctypes "github.com/tendermint/tendermint/rpc/core/types"
"strings"
)

// GetNode returns an RPC client. If the context's client is not defined, an
Expand Down Expand Up @@ -323,6 +324,7 @@ func (ctx CLIContext) query(path string, key cmn.HexBytes) (res []byte, err erro
}

// verifyProof perform response proof verification
// nolint: unparam
func (ctx CLIContext) verifyProof(path string, resp abci.ResponseQuery) error {

if ctx.Certifier == nil {
Expand Down
3 changes: 3 additions & 0 deletions cmd/cosmos-sdk-cli/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func resolveProjectPath(remoteProjectPath string) string {
return gopath + string(os.PathSeparator) + "src" + string(os.PathSeparator) + remoteProjectPath
}

// nolint: unparam, errcheck
func copyBasecoinTemplate(projectName string, projectPath string, remoteProjectPath string) {
basecoinProjectPath := resolveProjectPath(remoteBasecoinPath)
filepath.Walk(basecoinProjectPath, func(path string, f os.FileInfo, err error) error {
Expand Down Expand Up @@ -88,6 +89,7 @@ func copyBasecoinTemplate(projectName string, projectPath string, remoteProjectP
})
}

// nolint: errcheck
func createGopkg(projectPath string) {
// Create gopkg.toml file
dependencies := map[string]string{
Expand All @@ -111,6 +113,7 @@ func createGopkg(projectPath string) {
ioutil.WriteFile(projectPath+"/Gopkg.toml", []byte(contents), os.ModePerm)
}

// nolint: errcheck
func createMakefile(projectPath string) {
// Create makefile
// TODO: Should we use tools/ directory as in Cosmos-SDK to get tools for linting etc.
Expand Down
3 changes: 3 additions & 0 deletions examples/democoin/x/assoc/validator_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func GetAssocKey(base sdk.ValAddress, assoc sdk.ValAddress) []byte {
}

// Associate associates new address with validator address
// nolint: unparam
func (valset ValidatorSet) Associate(ctx sdk.Context, base sdk.ValAddress, assoc sdk.ValAddress) bool {
if len(base) != valset.addrLen || len(assoc) != valset.addrLen {
return false
Expand All @@ -76,6 +77,7 @@ func (valset ValidatorSet) Associate(ctx sdk.Context, base sdk.ValAddress, assoc
}

// Dissociate removes association between addresses
// nolint: unparam
func (valset ValidatorSet) Dissociate(ctx sdk.Context, base sdk.ValAddress, assoc sdk.ValAddress) bool {
if len(base) != valset.addrLen || len(assoc) != valset.addrLen {
return false
Expand All @@ -90,6 +92,7 @@ func (valset ValidatorSet) Dissociate(ctx sdk.Context, base sdk.ValAddress, asso
}

// Associations returns all associated addresses with a validator
// nolint: unparam
func (valset ValidatorSet) Associations(ctx sdk.Context, base sdk.ValAddress) (res []sdk.ValAddress) {
res = make([]sdk.ValAddress, valset.maxAssoc)
iter := sdk.KVStorePrefixIterator(valset.store, GetAssocPrefix(base))
Expand Down
1 change: 1 addition & 0 deletions server/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ func readOrCreatePrivValidator(tmConfig *cfg.Config) crypto.PubKey {

// writeGenesisFile creates and writes the genesis configuration to disk. An
// error is returned if building or writing the configuration to file fails.
// nolint: unparam
func writeGenesisFile(cdc *wire.Codec, genesisFile, chainID string, validators []tmtypes.GenesisValidator, appState json.RawMessage) error {
genDoc := tmtypes.GenesisDoc{
ChainID: chainID,
Expand Down
1 change: 1 addition & 0 deletions server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ func startStandAlone(ctx *Context, appCreator AppCreator) error {
return nil
}

// nolint: unparam
func startInProcess(ctx *Context, appCreator AppCreator) (*node.Node, error) {
cfg := ctx.Config
home := cfg.RootDir
Expand Down
1 change: 1 addition & 0 deletions store/iavlstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ type iavlStore struct {
}

// CONTRACT: tree should be fully loaded.
// nolint: unparam
func newIAVLStore(tree *iavl.MutableTree, numRecent int64, storeEvery int64) *iavlStore {
st := &iavlStore{
tree: tree,
Expand Down
8 changes: 5 additions & 3 deletions store/multistoreproof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ package store

import (
"encoding/hex"
"testing"

"github.com/stretchr/testify/assert"
"github.com/tendermint/iavl"
cmn "github.com/tendermint/tendermint/libs/common"
"testing"
"github.com/tendermint/tendermint/libs/db"
)

func TestVerifyMultiStoreCommitInfo(t *testing.T) {
Expand Down Expand Up @@ -91,7 +93,7 @@ func TestVerifyMultiStoreCommitInfo(t *testing.T) {
}

func TestVerifyRangeProof(t *testing.T) {
tree := iavl.NewTree(nil, 0)
tree := iavl.NewMutableTree(db.NewMemDB(), 0)

rand := cmn.NewRand()
rand.Seed(0) // for determinism
Expand All @@ -100,7 +102,7 @@ func TestVerifyRangeProof(t *testing.T) {
tree.Set(key, []byte(rand.Str(8)))
}

root := tree.Hash()
root := tree.WorkingHash()

key := []byte{0x32}
val, proof, err := tree.GetWithProof(key)
Expand Down
1 change: 1 addition & 0 deletions store/tracekvstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ func (tkv *TraceKVStore) CacheWrapWithTrace(_ io.Writer, _ TraceContext) CacheWr

// writeOperation writes a KVStore operation to the underlying io.Writer as
// JSON-encoded data where the key/value pair is base64 encoded.
// nolint: errcheck
func writeOperation(w io.Writer, op operation, tc TraceContext, key, value []byte) {
traceOp := traceOperation{
Operation: op,
Expand Down
8 changes: 4 additions & 4 deletions store/tracekvstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ func TestTestTraceKVStoreIterator(t *testing.T) {
iterator := store.Iterator(nil, nil)

s, e := iterator.Domain()
require.Equal(t, []uint8([]byte(nil)), s)
require.Equal(t, []uint8([]byte(nil)), e)
require.Equal(t, []byte(nil), s)
require.Equal(t, []byte(nil), e)

testCases := []struct {
expectedKey []byte
Expand Down Expand Up @@ -212,8 +212,8 @@ func TestTestTraceKVStoreReverseIterator(t *testing.T) {
iterator := store.ReverseIterator(nil, nil)

s, e := iterator.Domain()
require.Equal(t, []uint8([]byte(nil)), s)
require.Equal(t, []uint8([]byte(nil)), e)
require.Equal(t, []byte(nil), s)
require.Equal(t, []byte(nil), e)

testCases := []struct {
expectedKey []byte
Expand Down
1 change: 1 addition & 0 deletions tests/gobash.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

// ExecuteT executes the command, pipes any input to STDIN and return STDOUT,
// logging STDOUT/STDERR to t.
// nolint: errcheck
func ExecuteT(t *testing.T, cmd, input string) (out string) {
t.Log("Running", cmn.Cyan(cmd))

Expand Down
3 changes: 3 additions & 0 deletions types/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ func (aa AccAddress) String() string {
}

// Format implements the fmt.Formatter interface.
// nolint: errcheck
func (aa AccAddress) Format(s fmt.State, verb rune) {
switch verb {
case 's':
Expand Down Expand Up @@ -247,6 +248,7 @@ func (va ValAddress) String() string {
}

// Format implements the fmt.Formatter interface.
// nolint: errcheck
func (va ValAddress) Format(s fmt.State, verb rune) {
switch verb {
case 's':
Expand Down Expand Up @@ -361,6 +363,7 @@ func (ca ConsAddress) String() string {
}

// Format implements the fmt.Formatter interface.
// nolint: errcheck
func (ca ConsAddress) Format(s fmt.State, verb rune) {
switch verb {
case 's':
Expand Down
1 change: 1 addition & 0 deletions types/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type Context struct {
}

// create a new context
// nolint: unparam
func NewContext(ms MultiStore, header abci.Header, isCheckTx bool, logger log.Logger) Context {
c := Context{
Context: context.Background(),
Expand Down
1 change: 1 addition & 0 deletions types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ func (err *sdkError) WithDefaultCodespace(cs CodespaceType) Error {
}

// Implements ABCIError.
// nolint: errcheck
func (err *sdkError) TraceSDK(format string, args ...interface{}) Error {
err.Trace(1, format, args...)
return err
Expand Down
1 change: 1 addition & 0 deletions x/auth/client/cli/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func GetAccountDecoder(cdc *wire.Codec) auth.AccountDecoder {

// GetAccountCmd returns a query account that will display the state of the
// account at a given address.
// nolint: unparam
func GetAccountCmd(storeName string, cdc *wire.Codec, decoder auth.AccountDecoder) *cobra.Command {
return &cobra.Command{
Use: "account [address]",
Expand Down
1 change: 1 addition & 0 deletions x/gov/depositsvotes.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ func (vo VoteOption) String() string {
}

// For Printf / Sprintf, returns bech32 when using %s
// nolint: errcheck
func (vo VoteOption) Format(s fmt.State, verb rune) {
switch verb {
case 's':
Expand Down
6 changes: 6 additions & 0 deletions x/gov/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,34 +210,40 @@ func (keeper Keeper) activateVotingPeriod(ctx sdk.Context, proposal Proposal) {
// Procedures

// Returns the current Deposit Procedure from the global param store
// nolint: errcheck
func (keeper Keeper) GetDepositProcedure(ctx sdk.Context) DepositProcedure {
var depositProcedure DepositProcedure
keeper.ps.Get(ctx, ParamStoreKeyDepositProcedure, &depositProcedure)
return depositProcedure
}

// Returns the current Voting Procedure from the global param store
// nolint: errcheck
func (keeper Keeper) GetVotingProcedure(ctx sdk.Context) VotingProcedure {
var votingProcedure VotingProcedure
keeper.ps.Get(ctx, ParamStoreKeyVotingProcedure, &votingProcedure)
return votingProcedure
}

// Returns the current Tallying Procedure from the global param store
// nolint: errcheck
func (keeper Keeper) GetTallyingProcedure(ctx sdk.Context) TallyingProcedure {
var tallyingProcedure TallyingProcedure
keeper.ps.Get(ctx, ParamStoreKeyTallyingProcedure, &tallyingProcedure)
return tallyingProcedure
}

// nolint: errcheck
func (keeper Keeper) setDepositProcedure(ctx sdk.Context, depositProcedure DepositProcedure) {
keeper.ps.Set(ctx, ParamStoreKeyDepositProcedure, &depositProcedure)
}

// nolint: errcheck
func (keeper Keeper) setVotingProcedure(ctx sdk.Context, votingProcedure VotingProcedure) {
keeper.ps.Set(ctx, ParamStoreKeyVotingProcedure, &votingProcedure)
}

// nolint: errcheck
func (keeper Keeper) setTallyingProcedure(ctx sdk.Context, tallyingProcedure TallyingProcedure) {
keeper.ps.Set(ctx, ParamStoreKeyTallyingProcedure, &tallyingProcedure)
}
Expand Down
2 changes: 2 additions & 0 deletions x/gov/proposals.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ func (pt ProposalKind) String() string {
}

// For Printf / Sprintf, returns bech32 when using %s
// nolint: errcheck
func (pt ProposalKind) Format(s fmt.State, verb rune) {
switch verb {
case 's':
Expand Down Expand Up @@ -289,6 +290,7 @@ func (status ProposalStatus) String() string {
}

// For Printf / Sprintf, returns bech32 when using %s
// nolint: errcheck
func (status ProposalStatus) Format(s fmt.State, verb rune) {
switch verb {
case 's':
Expand Down
7 changes: 7 additions & 0 deletions x/gov/queryable.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type QueryProposalParams struct {
ProposalID int64
}

// nolint: unparam
func queryProposal(ctx sdk.Context, path []string, req abci.RequestQuery, keeper Keeper) (res []byte, err sdk.Error) {
var params QueryProposalParams
err2 := keeper.cdc.UnmarshalJSON(req.Data, &params)
Expand All @@ -61,6 +62,7 @@ type QueryDepositParams struct {
Depositer sdk.AccAddress
}

// nolint: unparam
func queryDeposit(ctx sdk.Context, path []string, req abci.RequestQuery, keeper Keeper) (res []byte, err sdk.Error) {
var params QueryDepositParams
err2 := keeper.cdc.UnmarshalJSON(req.Data, &params)
Expand All @@ -82,6 +84,7 @@ type QueryVoteParams struct {
Voter sdk.AccAddress
}

// nolint: unparam
func queryVote(ctx sdk.Context, path []string, req abci.RequestQuery, keeper Keeper) (res []byte, err sdk.Error) {
var params QueryVoteParams
err2 := keeper.cdc.UnmarshalJSON(req.Data, &params)
Expand All @@ -102,6 +105,7 @@ type QueryDepositsParams struct {
ProposalID int64
}

// nolint: unparam
func queryDeposits(ctx sdk.Context, path []string, req abci.RequestQuery, keeper Keeper) (res []byte, err sdk.Error) {
var params QueryDepositParams
err2 := keeper.cdc.UnmarshalJSON(req.Data, &params)
Expand Down Expand Up @@ -129,6 +133,7 @@ type QueryVotesParams struct {
ProposalID int64
}

// nolint: unparam
func queryVotes(ctx sdk.Context, path []string, req abci.RequestQuery, keeper Keeper) (res []byte, err sdk.Error) {
var params QueryVotesParams
err2 := keeper.cdc.UnmarshalJSON(req.Data, &params)
Expand Down Expand Up @@ -160,6 +165,7 @@ type QueryProposalsParams struct {
NumLatestProposals int64
}

// nolint: unparam
func queryProposals(ctx sdk.Context, path []string, req abci.RequestQuery, keeper Keeper) (res []byte, err sdk.Error) {
var params QueryProposalsParams
err2 := keeper.cdc.UnmarshalJSON(req.Data, &params)
Expand All @@ -181,6 +187,7 @@ type QueryTallyParams struct {
ProposalID int64
}

// nolint: unparam
func queryTally(ctx sdk.Context, path []string, req abci.RequestQuery, keeper Keeper) (res []byte, err sdk.Error) {
// TODO: Dependant on #1914

Expand Down
1 change: 1 addition & 0 deletions x/gov/simulation/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ func SimulateMsgDeposit(k gov.Keeper, sk stake.Keeper) simulation.Operation {
}

// SimulateMsgVote
// nolint: unparam
func SimulateMsgVote(k gov.Keeper, sk stake.Keeper) simulation.Operation {
return func(tb testing.TB, r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, keys []crypto.PrivKey, log string, event func(string)) (action string, fOp []simulation.FutureOperation, err sdk.Error) {
key := simulation.RandomKey(r, keys)
Expand Down
1 change: 1 addition & 0 deletions x/ibc/client/cli/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ func query(node string, key []byte, storeName string) (res []byte, err error) {
return context.NewCLIContext().WithNodeURI(node).QueryStore(key, storeName)
}

// nolint: unparam
func (c relayCommander) broadcastTx(seq int64, node string, tx []byte) error {
_, err := context.NewCLIContext().WithNodeURI(node).BroadcastTx(tx)
return err
Expand Down
2 changes: 2 additions & 0 deletions x/mock/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ func (app *App) CompleteSetup(newKeys []*sdk.KVStoreKey) error {
}

// InitChainer performs custom logic for initialization.
// nolint: errcheck
func (app *App) InitChainer(ctx sdk.Context, _ abci.RequestInitChain) abci.ResponseInitChain {
// Load the genesis accounts
for _, genacc := range app.GenesisAccounts {
Expand Down Expand Up @@ -207,6 +208,7 @@ func GeneratePrivKeyAddressPairsFromRand(rand *rand.Rand, n int) (keys []crypto.

// RandomSetGenesis set genesis accounts with random coin values using the
// provided addresses and coin denominations.
// nolint: errcheck
func RandomSetGenesis(r *rand.Rand, app *App, addrs []sdk.AccAddress, denoms []string) {
accts := make([]auth.Account, len(addrs), len(addrs))
randCoinIntervals := []BigInterval{
Expand Down
1 change: 1 addition & 0 deletions x/mock/simulation/random_simulate_blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ func getKeys(validators map[string]mockValidator) []string {
}

// RandomRequestBeginBlock generates a list of signing validators according to the provided list of validators, signing fraction, and evidence fraction
// nolint: unparam
func RandomRequestBeginBlock(r *rand.Rand, validators map[string]mockValidator, livenessTransitions TransitionMatrix, evidenceFraction float64,
pastTimes []time.Time, pastSigningValidators [][]abci.SigningValidator, event func(string), header abci.Header, log string) abci.RequestBeginBlock {
if len(validators) == 0 {
Expand Down
Loading

0 comments on commit 2378e34

Please sign in to comment.