mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-06 21:36:26 +00:00
cleanup: remove redundant error plumbing (#6778)
This is a mostly-automated fixup using Comby (https://comby.dev) to remove lexically-obvious redundant error checks. No functional changes are intended. To reproduce the core change: # Collapse redundant error check conditionals % comby -in-place 'if err != nil { return err } return nil' 'return err' .go # Fold out unnecessary error temporaries % comby -in-place ':[spc~^\s*]err :[~:?]= :[any] return err' ':[spc]return :[any]' .go Fixes #6479 and related cases.
This commit is contained in:
@@ -15,11 +15,7 @@ const (
|
||||
func WriteMessage(msg proto.Message, w io.Writer) error {
|
||||
protoWriter := protoio.NewDelimitedWriter(w)
|
||||
_, err := protoWriter.WriteMsg(msg)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
|
||||
// ReadMessage reads a varint length-delimited protobuf message.
|
||||
|
||||
@@ -142,12 +142,7 @@ func (sl *SignerListenerEndpoint) ensureConnection(maxWait time.Duration) error
|
||||
// block until connected or timeout
|
||||
sl.Logger.Info("SignerListener: Blocking for connection")
|
||||
sl.triggerConnect()
|
||||
err := sl.WaitConnection(sl.connectionAvailableCh, maxWait)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return sl.WaitConnection(sl.connectionAvailableCh, maxWait)
|
||||
}
|
||||
|
||||
func (sl *SignerListenerEndpoint) acceptNewConnection() (net.Conn, error) {
|
||||
|
||||
@@ -255,12 +255,7 @@ func verifyTimeStamp(tb string) error {
|
||||
|
||||
if rows.Next() {
|
||||
var ts string
|
||||
err = rows.Scan(&ts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return rows.Scan(&ts)
|
||||
}
|
||||
|
||||
return errors.New("no result")
|
||||
|
||||
@@ -661,10 +661,5 @@ func (store dbStore) saveConsensusParamsInfo(
|
||||
return err
|
||||
}
|
||||
|
||||
err = batch.Set(consensusParamsKey(nextHeight), bz)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return batch.Set(consensusParamsKey(nextHeight), bz)
|
||||
}
|
||||
|
||||
@@ -15,11 +15,7 @@ func Cleanup(testnet *e2e.Testnet) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = cleanupDir(testnet.Dir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return cleanupDir(testnet.Dir)
|
||||
}
|
||||
|
||||
// cleanupDocker removes all E2E resources (with label e2e=True), regardless
|
||||
@@ -37,13 +33,8 @@ func cleanupDocker() error {
|
||||
return err
|
||||
}
|
||||
|
||||
err = exec("bash", "-c", fmt.Sprintf(
|
||||
return exec("bash", "-c", fmt.Sprintf(
|
||||
"docker network ls -q --filter label=e2e | xargs %v docker network rm", xargsR))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// cleanupDir cleans up a testnet directory
|
||||
@@ -74,10 +65,5 @@ func cleanupDir(dir string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
err = os.RemoveAll(dir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return os.RemoveAll(dir)
|
||||
}
|
||||
|
||||
@@ -21,10 +21,7 @@ func Wait(testnet *e2e.Testnet, blocks int64) error {
|
||||
func WaitUntil(testnet *e2e.Testnet, height int64) error {
|
||||
logger.Info(fmt.Sprintf("Waiting for all nodes to reach height %v...", height))
|
||||
_, err := waitForAllNodes(testnet, height, waitingTime(len(testnet.Nodes)))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
|
||||
// waitingTime estimates how long it should take for a node to reach the height.
|
||||
|
||||
@@ -59,6 +59,5 @@ func Fuzz(data []byte) int {
|
||||
|
||||
func outputJSONIsSlice(input []byte) bool {
|
||||
slice := []interface{}{}
|
||||
err := json.Unmarshal(input, &slice)
|
||||
return err == nil
|
||||
return json.Unmarshal(input, &slice) == nil
|
||||
}
|
||||
|
||||
@@ -33,11 +33,7 @@ func (nodeKey NodeKey) SaveAs(filePath string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = ioutil.WriteFile(filePath, jsonBytes, 0600)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return ioutil.WriteFile(filePath, jsonBytes, 0600)
|
||||
}
|
||||
|
||||
// LoadOrGenNodeKey attempts to load the NodeKey from the given filePath. If
|
||||
|
||||
Reference in New Issue
Block a user