fix linter errors thrown by unconvert, goconst, and nakedret (#3960)

* Remove unnecessary type conversions

* Consolidate repeated strings into consts

* Clothe return statements

* Update blockchain/v1/reactor_fsm_test.go

Co-Authored-By: Anton Kaliaev <anton.kalyaev@gmail.com>

This PR repairs linter errors seen when running the following commands:
golangci-lint run --no-config --disable-all=true --enable=unconvert
golangci-lint run --no-config --disable-all=true --enable=goconst
golangci-lint run --no-config --disable-all=true --enable=nakedret

Contributes to #3262
This commit is contained in:
Phil Salant
2019-09-10 03:31:44 -04:00
committed by Anton Kaliaev
parent 7f0c55f249
commit 04d13d9945
31 changed files with 69 additions and 59 deletions

View File

@@ -246,7 +246,7 @@ func (h *Handshaker) Handshake(proxyApp proxy.AppConns) error {
return fmt.Errorf("Error calling Info: %v", err)
}
blockHeight := int64(res.LastBlockHeight)
blockHeight := res.LastBlockHeight
if blockHeight < 0 {
return fmt.Errorf("Got a negative last block height (%d) from the app", blockHeight)
}

View File

@@ -1458,7 +1458,7 @@ func (cs *ConsensusState) addProposalBlockPart(msg *BlockPartMessage, peerID p2p
_, err = cdc.UnmarshalBinaryLengthPrefixedReader(
cs.ProposalBlockParts.GetReader(),
&cs.ProposalBlock,
int64(cs.state.ConsensusParams.Block.MaxBytes),
cs.state.ConsensusParams.Block.MaxBytes,
)
if err != nil {
return added, err
@@ -1675,7 +1675,7 @@ func (cs *ConsensusState) addVote(vote *types.Vote, peerID p2p.ID) (added bool,
panic(fmt.Sprintf("Unexpected vote type %X", vote.Type)) // go-amino should prevent this.
}
return
return added, err
}
func (cs *ConsensusState) signVote(type_ types.SignedMsgType, hash []byte, header types.PartSetHeader) (*types.Vote, error) {

View File

@@ -189,7 +189,7 @@ func TestStateBadProposal(t *testing.T) {
if len(stateHash) == 0 {
stateHash = make([]byte, 32)
}
stateHash[0] = byte((stateHash[0] + 1) % 255)
stateHash[0] = (stateHash[0] + 1) % 255
propBlock.AppHash = stateHash
propBlockParts := propBlock.MakePartSet(partSize)
blockID := types.BlockID{Hash: propBlock.Hash(), PartsHeader: propBlockParts.Header()}
@@ -364,7 +364,7 @@ func TestStateLockNoPOL(t *testing.T) {
// lets add one for a different block
hash := make([]byte, len(theBlockHash))
copy(hash, theBlockHash)
hash[0] = byte((hash[0] + 1) % 255)
hash[0] = (hash[0] + 1) % 255
signAddVotes(cs1, types.PrecommitType, hash, thePartSetHeader, vs2)
ensurePrecommit(voteCh, height, round) // precommit