Skip to content

Commit

Permalink
fix: lint error-checks
Browse files Browse the repository at this point in the history
fix: lint error-checks
  • Loading branch information
rjan90 committed May 27, 2024
1 parent 4a2f9e2 commit f2948f2
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 16 deletions.
13 changes: 9 additions & 4 deletions cli/spcli/actor.go
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,9 @@ func ActorProposeChangeWorkerCmd(getActor ActorAddressGetter) *cli.Command {
}

if !cctx.Bool("really-do-it") {
fmt.Fprintln(cctx.App.Writer, "Pass --really-do-it to actually execute this action")
if _, err := fmt.Fprintln(cctx.App.Writer, "Pass --really-do-it to actually execute this action"); err != nil {
return err
}
return nil
}

Expand All @@ -695,8 +697,9 @@ func ActorProposeChangeWorkerCmd(getActor ActorAddressGetter) *cli.Command {
return xerrors.Errorf("mpool push: %w", err)
}

fmt.Fprintln(cctx.App.Writer, "Propose Message CID:", smsg.Cid())

if _, err := fmt.Fprintln(cctx.App.Writer, "Propose Message CID:", smsg.Cid()); err != nil {
return err
}
// wait for it to get mined into a block
wait, err := api.StateWaitMsg(ctx, smsg.Cid(), build.MessageConfidence)
if err != nil {
Expand Down Expand Up @@ -942,7 +945,9 @@ func ActorConfirmChangeWorkerCmd(getActor ActorAddressGetter) *cli.Command {

// check it executed successfully
if wait.Receipt.ExitCode.IsError() {
fmt.Fprintln(cctx.App.Writer, "Worker change failed!")
if _, err := fmt.Fprintln(cctx.App.Writer, "Worker change failed!"); err != nil {
return err
}
return err
}

Expand Down
34 changes: 24 additions & 10 deletions cmd/lotus-shed/actor.go
Original file line number Diff line number Diff line change
Expand Up @@ -719,12 +719,16 @@ var actorControlSet = &cli.Command{
return err
}

fmt.Fprintln(cctx.App.Writer, hex.EncodeToString(msgBytes))
if _, err := fmt.Fprintln(cctx.App.Writer, hex.EncodeToString(msgBytes)); err != nil {
return err
}
return nil
}

if !cctx.Bool("really-do-it") {
fmt.Fprintln(cctx.App.Writer, "Pass --really-do-it to actually execute this action")
if _, err := fmt.Fprintln(cctx.App.Writer, "Pass --really-do-it to actually execute this action"); err != nil {
return err
}
return nil
}

Expand Down Expand Up @@ -760,7 +764,9 @@ var actorProposeChangeWorker = &cli.Command{
}

if !cctx.Bool("really-do-it") {
fmt.Fprintln(cctx.App.Writer, "Pass --really-do-it to actually execute this action")
if _, err := fmt.Fprintln(cctx.App.Writer, "Pass --really-do-it to actually execute this action"); err != nil {
return err
}
return nil
}

Expand Down Expand Up @@ -840,8 +846,9 @@ var actorProposeChangeWorker = &cli.Command{
return xerrors.Errorf("mpool push: %w", err)
}

fmt.Fprintln(cctx.App.Writer, "Propose Message CID:", smsg.Cid())

if _, err := fmt.Fprintln(cctx.App.Writer, "Propose Message CID:", smsg.Cid()); err != nil {
return err
}
// wait for it to get mined into a block
wait, err := nodeAPI.StateWaitMsg(ctx, smsg.Cid(), build.MessageConfidence)
if err != nil {
Expand All @@ -850,7 +857,9 @@ var actorProposeChangeWorker = &cli.Command{

// check it executed successfully
if wait.Receipt.ExitCode.IsError() {
fmt.Fprintln(cctx.App.Writer, "Propose worker change failed!")
if _, err := fmt.Fprintln(cctx.App.Writer, "Propose worker change failed!"); err != nil {
return err
}
return err
}

Expand Down Expand Up @@ -890,7 +899,9 @@ var actorConfirmChangeWorker = &cli.Command{
}

if !cctx.Bool("really-do-it") {
fmt.Fprintln(cctx.App.Writer, "Pass --really-do-it to actually execute this action")
if _, err := fmt.Fprintln(cctx.App.Writer, "Pass --really-do-it to actually execute this action"); err != nil {
return err
}
return nil
}

Expand Down Expand Up @@ -961,8 +972,9 @@ var actorConfirmChangeWorker = &cli.Command{
return xerrors.Errorf("mpool push: %w", err)
}

fmt.Fprintln(cctx.App.Writer, "Confirm Message CID:", smsg.Cid())

if _, err := fmt.Fprintln(cctx.App.Writer, "Confirm Message CID:", smsg.Cid()); err != nil {
return err
}
// wait for it to get mined into a block
wait, err := nodeAPI.StateWaitMsg(ctx, smsg.Cid(), build.MessageConfidence)
if err != nil {
Expand All @@ -971,7 +983,9 @@ var actorConfirmChangeWorker = &cli.Command{

// check it executed successfully
if wait.Receipt.ExitCode.IsError() {
fmt.Fprintln(cctx.App.Writer, "Worker change failed!")
if _, err := fmt.Fprintln(cctx.App.Writer, "Worker change failed!"); err != nil {
return err
}
return err
}

Expand Down
8 changes: 6 additions & 2 deletions cmd/lotus-shed/balances.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,9 @@ every day of chain processed.
for _, bh := range ts.Blocks() {
bms, err := api.ChainGetBlockMessages(ctx, bh.Cid())
if err != nil {
fmt.Fprintln(os.Stderr, "ERROR: ", err)
if _, err := fmt.Fprintln(os.Stderr, "ERROR: ", err); err != nil {
fmt.Fprintln(os.Stderr, "Failed to write error message:", err)
}
return
}

Expand Down Expand Up @@ -295,7 +297,9 @@ every day of chain processed.
printLk.Lock()
err := encoder.Encode(grouped)
if err != nil {
fmt.Fprintln(os.Stderr, "ERROR: ", err)
if _, err := fmt.Fprintln(os.Stderr, "ERROR: ", err); err != nil {
fmt.Fprintln(os.Stderr, "Failed to write error message:", err)
}
}
printLk.Unlock()
}
Expand Down

0 comments on commit f2948f2

Please sign in to comment.