Skip to content

Commit 730c96e

Browse files
committed
src: lint: bump golangci-lint to 1.59, address unchecked fmt.Fprint*
1 parent 5993841 commit 730c96e

File tree

25 files changed

+211
-142
lines changed

25 files changed

+211
-142
lines changed

.github/workflows/check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
submodules: 'recursive'
5858
- uses: ./.github/actions/install-system-dependencies
5959
- uses: ./.github/actions/install-go
60-
- run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.58.2
60+
- run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.0
6161
- run: make deps
6262
- run: golangci-lint run -v --timeout 10m --concurrency 4
6363
check-fmt:

chain/types/fil.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func (f FIL) Nano() string {
6868
func (f FIL) Format(s fmt.State, ch rune) {
6969
switch ch {
7070
case 's', 'v':
71-
fmt.Fprint(s, f.String())
71+
_, _ = fmt.Fprint(s, f.String())
7272
default:
7373
f.Int.Format(s, ch)
7474
}

cli/helper.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,15 @@ func NewAppFmt(a *ufcli.App) *AppFmt {
7676
}
7777

7878
func (a *AppFmt) Print(args ...interface{}) {
79-
fmt.Fprint(a.app.Writer, args...)
79+
_, _ = fmt.Fprint(a.app.Writer, args...)
8080
}
8181

8282
func (a *AppFmt) Println(args ...interface{}) {
83-
fmt.Fprintln(a.app.Writer, args...)
83+
_, _ = fmt.Fprintln(a.app.Writer, args...)
8484
}
8585

8686
func (a *AppFmt) Printf(fmtstr string, args ...interface{}) {
87-
fmt.Fprintf(a.app.Writer, fmtstr, args...)
87+
_, _ = fmt.Fprintf(a.app.Writer, fmtstr, args...)
8888
}
8989

9090
func (a *AppFmt) Scan(args ...interface{}) (int, error) {

cli/info.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,18 @@ func infoCmdAct(cctx *cli.Context) error {
160160
}
161161

162162
fmt.Printf("Bandwidth:\n")
163-
fmt.Fprintf(tw, "\tTotalIn\tTotalOut\tRateIn\tRateOut\n")
164-
fmt.Fprintf(tw, "\t%s\t%s\t%s/s\t%s/s\n", humanize.Bytes(uint64(s.TotalIn)), humanize.Bytes(uint64(s.TotalOut)), humanize.Bytes(uint64(s.RateIn)), humanize.Bytes(uint64(s.RateOut)))
163+
if _, err := fmt.Fprintf(tw, "\tTotalIn\tTotalOut\tRateIn\tRateOut\n"); err != nil {
164+
return err
165+
}
166+
if _, err := fmt.Fprintf(
167+
tw,
168+
"\t%s\t%s\t%s/s\t%s/s\n",
169+
humanize.Bytes(uint64(s.TotalIn)),
170+
humanize.Bytes(uint64(s.TotalOut)),
171+
humanize.Bytes(uint64(s.RateIn)),
172+
humanize.Bytes(uint64(s.RateOut))); err != nil {
173+
return err
174+
}
165175
return tw.Flush()
166176

167177
}

cli/multisig.go

Lines changed: 51 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ var msigCreateCmd = &cli.Command{
168168

169169
// check it executed successfully
170170
if wait.Receipt.ExitCode.IsError() {
171-
fmt.Fprintln(cctx.App.Writer, "actor creation failed!")
171+
_, _ = fmt.Fprintln(cctx.App.Writer, "actor creation failed!")
172172
return err
173173
}
174174

@@ -178,7 +178,7 @@ var msigCreateCmd = &cli.Command{
178178
if err := execreturn.UnmarshalCBOR(bytes.NewReader(wait.Receipt.Return)); err != nil {
179179
return err
180180
}
181-
fmt.Fprintln(cctx.App.Writer, "Created new multisig: ", execreturn.IDAddress, execreturn.RobustAddress)
181+
_, _ = fmt.Fprintln(cctx.App.Writer, "Created new multisig: ", execreturn.IDAddress, execreturn.RobustAddress)
182182

183183
// TODO: maybe register this somewhere
184184
return nil
@@ -242,25 +242,25 @@ var msigInspectCmd = &cli.Command{
242242
return err
243243
}
244244

245-
fmt.Fprintf(cctx.App.Writer, "Balance: %s\n", types.FIL(act.Balance))
246-
fmt.Fprintf(cctx.App.Writer, "Spendable: %s\n", types.FIL(types.BigSub(act.Balance, locked)))
245+
_, _ = fmt.Fprintf(cctx.App.Writer, "Balance: %s\n", types.FIL(act.Balance))
246+
_, _ = fmt.Fprintf(cctx.App.Writer, "Spendable: %s\n", types.FIL(types.BigSub(act.Balance, locked)))
247247

248248
if cctx.Bool("vesting") {
249249
ib, err := mstate.InitialBalance()
250250
if err != nil {
251251
return err
252252
}
253-
fmt.Fprintf(cctx.App.Writer, "InitialBalance: %s\n", types.FIL(ib))
253+
_, _ = fmt.Fprintf(cctx.App.Writer, "InitialBalance: %s\n", types.FIL(ib))
254254
se, err := mstate.StartEpoch()
255255
if err != nil {
256256
return err
257257
}
258-
fmt.Fprintf(cctx.App.Writer, "StartEpoch: %d\n", se)
258+
_, _ = fmt.Fprintf(cctx.App.Writer, "StartEpoch: %d\n", se)
259259
ud, err := mstate.UnlockDuration()
260260
if err != nil {
261261
return err
262262
}
263-
fmt.Fprintf(cctx.App.Writer, "UnlockDuration: %d\n", ud)
263+
_, _ = fmt.Fprintf(cctx.App.Writer, "UnlockDuration: %d\n", ud)
264264
}
265265

266266
signers, err := mstate.Signers()
@@ -271,17 +271,17 @@ var msigInspectCmd = &cli.Command{
271271
if err != nil {
272272
return err
273273
}
274-
fmt.Fprintf(cctx.App.Writer, "Threshold: %d / %d\n", threshold, len(signers))
275-
fmt.Fprintln(cctx.App.Writer, "Signers:")
274+
_, _ = fmt.Fprintf(cctx.App.Writer, "Threshold: %d / %d\n", threshold, len(signers))
275+
_, _ = fmt.Fprintln(cctx.App.Writer, "Signers:")
276276

277277
signerTable := tabwriter.NewWriter(cctx.App.Writer, 8, 4, 2, ' ', 0)
278-
fmt.Fprintf(signerTable, "ID\tAddress\n")
278+
_, _ = fmt.Fprintf(signerTable, "ID\tAddress\n")
279279
for _, s := range signers {
280280
signerActor, err := api.StateAccountKey(ctx, s, types.EmptyTSK)
281281
if err != nil {
282-
fmt.Fprintf(signerTable, "%s\t%s\n", s, "N/A")
282+
_, _ = fmt.Fprintf(signerTable, "%s\t%s\n", s, "N/A")
283283
} else {
284-
fmt.Fprintf(signerTable, "%s\t%s\n", s, signerActor)
284+
_, _ = fmt.Fprintf(signerTable, "%s\t%s\n", s, signerActor)
285285
}
286286
}
287287
if err := signerTable.Flush(); err != nil {
@@ -297,7 +297,7 @@ var msigInspectCmd = &cli.Command{
297297
}
298298

299299
decParams := cctx.Bool("decode-params")
300-
fmt.Fprintln(cctx.App.Writer, "Transactions: ", len(pending))
300+
_, _ = fmt.Fprintln(cctx.App.Writer, "Transactions: ", len(pending))
301301
if len(pending) > 0 {
302302
var txids []int64
303303
for txid := range pending {
@@ -308,7 +308,7 @@ var msigInspectCmd = &cli.Command{
308308
})
309309

310310
w := tabwriter.NewWriter(cctx.App.Writer, 8, 4, 2, ' ', 0)
311-
fmt.Fprintf(w, "ID\tState\tApprovals\tTo\tValue\tMethod\tParams\n")
311+
_, _ = fmt.Fprintf(w, "ID\tState\tApprovals\tTo\tValue\tMethod\tParams\n")
312312
for _, txid := range txids {
313313
tx := pending[txid]
314314
target := tx.To.String()
@@ -320,9 +320,31 @@ var msigInspectCmd = &cli.Command{
320320

321321
if err != nil {
322322
if tx.Method == 0 {
323-
fmt.Fprintf(w, "%d\t%s\t%d\t%s\t%s\t%s(%d)\t%s\n", txid, "pending", len(tx.Approved), target, types.FIL(tx.Value), "Send", tx.Method, paramStr)
323+
_, _ = fmt.Fprintf(
324+
w,
325+
"%d\t%s\t%d\t%s\t%s\t%s(%d)\t%s\n",
326+
txid,
327+
"pending",
328+
len(tx.Approved),
329+
target,
330+
types.FIL(tx.Value),
331+
"Send",
332+
tx.Method,
333+
paramStr,
334+
)
324335
} else {
325-
fmt.Fprintf(w, "%d\t%s\t%d\t%s\t%s\t%s(%d)\t%s\n", txid, "pending", len(tx.Approved), target, types.FIL(tx.Value), "new account, unknown method", tx.Method, paramStr)
336+
_, _ = fmt.Fprintf(
337+
w,
338+
"%d\t%s\t%d\t%s\t%s\t%s(%d)\t%s\n",
339+
txid,
340+
"pending",
341+
len(tx.Approved),
342+
target,
343+
types.FIL(tx.Value),
344+
"new account, unknown method",
345+
tx.Method,
346+
paramStr,
347+
)
326348
}
327349
} else {
328350
method := consensus.NewActorRegistry().Methods[targAct.Code][tx.Method] // TODO: use remote map
@@ -341,7 +363,18 @@ var msigInspectCmd = &cli.Command{
341363
paramStr = string(b)
342364
}
343365

344-
fmt.Fprintf(w, "%d\t%s\t%d\t%s\t%s\t%s(%d)\t%s\n", txid, "pending", len(tx.Approved), target, types.FIL(tx.Value), method.Name, tx.Method, paramStr)
366+
_, _ = fmt.Fprintf(
367+
w,
368+
"%d\t%s\t%d\t%s\t%s\t%s(%d)\t%s\n",
369+
txid,
370+
"pending",
371+
len(tx.Approved),
372+
target,
373+
types.FIL(tx.Value),
374+
method.Name,
375+
tx.Method,
376+
paramStr,
377+
)
345378
}
346379
}
347380
if err := w.Flush(); err != nil {
@@ -923,7 +956,7 @@ var msigAddProposeCmd = &cli.Command{
923956

924957
msgCid := sm.Cid()
925958

926-
fmt.Fprintln(cctx.App.Writer, "sent add proposal in message: ", msgCid)
959+
_, _ = fmt.Fprintln(cctx.App.Writer, "sent add proposal in message: ", msgCid)
927960

928961
wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence")), build.Finality, true)
929962
if err != nil {

cli/net.go

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ var NetBandwidthCmd = &cli.Command{
479479

480480
tw := tabwriter.NewWriter(os.Stdout, 4, 4, 2, ' ', 0)
481481

482-
fmt.Fprintf(tw, "Segment\tTotalIn\tTotalOut\tRateIn\tRateOut\n")
482+
_, _ = fmt.Fprintf(tw, "Segment\tTotalIn\tTotalOut\tRateIn\tRateOut\n")
483483

484484
if bypeer {
485485
bw, err := api.NetBandwidthStatsByPeer(ctx)
@@ -498,7 +498,15 @@ var NetBandwidthCmd = &cli.Command{
498498

499499
for _, p := range peers {
500500
s := bw[p]
501-
fmt.Fprintf(tw, "%s\t%s\t%s\t%s/s\t%s/s\n", p, humanize.Bytes(uint64(s.TotalIn)), humanize.Bytes(uint64(s.TotalOut)), humanize.Bytes(uint64(s.RateIn)), humanize.Bytes(uint64(s.RateOut)))
501+
_, _ = fmt.Fprintf(
502+
tw,
503+
"%s\t%s\t%s\t%s/s\t%s/s\n",
504+
p,
505+
humanize.Bytes(uint64(s.TotalIn)),
506+
humanize.Bytes(uint64(s.TotalOut)),
507+
humanize.Bytes(uint64(s.RateIn)),
508+
humanize.Bytes(uint64(s.RateOut)),
509+
)
502510
}
503511
} else if byproto {
504512
bw, err := api.NetBandwidthStatsByProtocol(ctx)
@@ -520,7 +528,15 @@ var NetBandwidthCmd = &cli.Command{
520528
if p == "" {
521529
p = "<unknown>"
522530
}
523-
fmt.Fprintf(tw, "%s\t%s\t%s\t%s/s\t%s/s\n", p, humanize.Bytes(uint64(s.TotalIn)), humanize.Bytes(uint64(s.TotalOut)), humanize.Bytes(uint64(s.RateIn)), humanize.Bytes(uint64(s.RateOut)))
531+
_, _ = fmt.Fprintf(
532+
tw,
533+
"%s\t%s\t%s\t%s/s\t%s/s\n",
534+
p,
535+
humanize.Bytes(uint64(s.TotalIn)),
536+
humanize.Bytes(uint64(s.TotalOut)),
537+
humanize.Bytes(uint64(s.RateIn)),
538+
humanize.Bytes(uint64(s.RateOut)),
539+
)
524540
}
525541
} else {
526542

@@ -529,7 +545,14 @@ var NetBandwidthCmd = &cli.Command{
529545
return err
530546
}
531547

532-
fmt.Fprintf(tw, "Total\t%s\t%s\t%s/s\t%s/s\n", humanize.Bytes(uint64(s.TotalIn)), humanize.Bytes(uint64(s.TotalOut)), humanize.Bytes(uint64(s.RateIn)), humanize.Bytes(uint64(s.RateOut)))
548+
_, _ = fmt.Fprintf(
549+
tw,
550+
"Total\t%s\t%s\t%s/s\t%s/s\n",
551+
humanize.Bytes(uint64(s.TotalIn)),
552+
humanize.Bytes(uint64(s.TotalOut)),
553+
humanize.Bytes(uint64(s.RateIn)),
554+
humanize.Bytes(uint64(s.RateOut)),
555+
)
533556
}
534557

535558
return tw.Flush()

0 commit comments

Comments
 (0)