Merge pull request #1850 from filecoin-project/chore/lint
Cleanup many lint warnings
This commit is contained in:
@@ -2,12 +2,13 @@ package config
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/filecoin-project/sector-storage/stores"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/sector-storage/stores"
|
||||
)
|
||||
|
||||
func StorageFromFile(path string, def *stores.StorageConfig) (*stores.StorageConfig, error) {
|
||||
|
||||
+5
-5
@@ -64,7 +64,7 @@ func (hs *Service) HandleStream(s inet.Stream) {
|
||||
var hmsg HelloMessage
|
||||
if err := cborutil.ReadCborRPC(s, &hmsg); err != nil {
|
||||
log.Infow("failed to read hello message, disconnecting", "error", err)
|
||||
s.Conn().Close()
|
||||
_ = s.Conn().Close()
|
||||
return
|
||||
}
|
||||
arrived := time.Now()
|
||||
@@ -76,11 +76,11 @@ func (hs *Service) HandleStream(s inet.Stream) {
|
||||
|
||||
if hmsg.GenesisHash != hs.syncer.Genesis.Cids()[0] {
|
||||
log.Warnf("other peer has different genesis! (%s)", hmsg.GenesisHash)
|
||||
s.Conn().Close()
|
||||
_ = s.Conn().Close()
|
||||
return
|
||||
}
|
||||
go func() {
|
||||
defer s.Close()
|
||||
defer s.Close() //nolint:errcheck
|
||||
|
||||
sent := time.Now()
|
||||
msg := &LatencyMessage{
|
||||
@@ -152,10 +152,10 @@ func (hs *Service) SayHello(ctx context.Context, pid peer.ID) error {
|
||||
}
|
||||
|
||||
go func() {
|
||||
defer s.Close()
|
||||
defer s.Close() //nolint:errcheck
|
||||
|
||||
lmsg := &LatencyMessage{}
|
||||
s.SetReadDeadline(time.Now().Add(10 * time.Second))
|
||||
_ = s.SetReadDeadline(time.Now().Add(10 * time.Second))
|
||||
err := cborutil.ReadCborRPC(s, lmsg)
|
||||
if err != nil {
|
||||
log.Infow("reading latency message", "error", err)
|
||||
|
||||
@@ -432,7 +432,7 @@ func (a *API) ClientGenCar(ctx context.Context, ref api.FileRef, outputPath stri
|
||||
return err
|
||||
}
|
||||
|
||||
defer bufferedDS.Remove(ctx, c)
|
||||
defer bufferedDS.Remove(ctx, c) //nolint:errcheck
|
||||
ssb := builder.NewSelectorSpecBuilder(basicnode.Style.Any)
|
||||
|
||||
// entire DAG selector
|
||||
@@ -440,7 +440,6 @@ func (a *API) ClientGenCar(ctx context.Context, ref api.FileRef, outputPath stri
|
||||
ssb.ExploreAll(ssb.ExploreRecursiveEdge())).Node()
|
||||
|
||||
f, err := os.Create(outputPath)
|
||||
defer f.Close()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -450,7 +449,7 @@ func (a *API) ClientGenCar(ctx context.Context, ref api.FileRef, outputPath stri
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return f.Close()
|
||||
}
|
||||
|
||||
func (a *API) clientImport(ref api.FileRef, bufferedDS *ipld.BufferedDAG) (cid.Cid, error) {
|
||||
|
||||
@@ -425,7 +425,7 @@ func (a *ChainAPI) ChainExport(ctx context.Context, tsk types.TipSetKey) (<-chan
|
||||
r, w := io.Pipe()
|
||||
out := make(chan []byte)
|
||||
go func() {
|
||||
defer w.Close()
|
||||
defer w.Close() //nolint:errcheck // it is a pipe
|
||||
if err := a.Chain.Export(ctx, ts, w); err != nil {
|
||||
log.Errorf("chain export call failed: %s", err)
|
||||
return
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
)
|
||||
|
||||
type remoteWorker struct {
|
||||
api.WorkerApi
|
||||
api.WorkerAPI
|
||||
closer jsonrpc.ClientCloser
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ func RecordValidator(ps peerstore.Peerstore) record.Validator {
|
||||
}
|
||||
}
|
||||
|
||||
const JWTSecretName = "auth-jwt-private"
|
||||
const JWTSecretName = "auth-jwt-private" //nolint:gosec
|
||||
|
||||
type jwtPayload struct {
|
||||
Allow []auth.Permission
|
||||
|
||||
@@ -18,7 +18,7 @@ func AddrFilters(filters []string) func() (opts Libp2pOpts, err error) {
|
||||
if err != nil {
|
||||
return opts, fmt.Errorf("incorrectly formatted address filter in config: %s", s)
|
||||
}
|
||||
opts.Opts = append(opts.Opts, libp2p.FilterAddresses(f))
|
||||
opts.Opts = append(opts.Opts, libp2p.FilterAddresses(f)) //nolint:staticcheck
|
||||
}
|
||||
return opts, nil
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ func GetParams(sbc *ffiwrapper.Config) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := paramfetch.GetParams(build.ParametersJson(), uint64(ssize)); err != nil {
|
||||
if err := paramfetch.GetParams(build.ParametersJSON(), uint64(ssize)); err != nil {
|
||||
return xerrors.Errorf("fetching proof parameters: %w", err)
|
||||
}
|
||||
|
||||
@@ -167,12 +167,10 @@ func StorageMiner(mctx helpers.MetricsCtx, lc fx.Lifecycle, api lapi.FullNode, h
|
||||
func HandleRetrieval(host host.Host, lc fx.Lifecycle, m retrievalmarket.RetrievalProvider) {
|
||||
lc.Append(fx.Hook{
|
||||
OnStart: func(context.Context) error {
|
||||
m.Start()
|
||||
return nil
|
||||
return m.Start()
|
||||
},
|
||||
OnStop: func(context.Context) error {
|
||||
m.Stop()
|
||||
return nil
|
||||
return m.Stop()
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -182,12 +180,10 @@ func HandleDeals(mctx helpers.MetricsCtx, lc fx.Lifecycle, host host.Host, h sto
|
||||
|
||||
lc.Append(fx.Hook{
|
||||
OnStart: func(context.Context) error {
|
||||
h.Start(ctx)
|
||||
return nil
|
||||
return h.Start(ctx)
|
||||
},
|
||||
OnStop: func(context.Context) error {
|
||||
h.Stop()
|
||||
return nil
|
||||
return h.Stop()
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
+4
-2
@@ -84,9 +84,11 @@ func testStorageNode(ctx context.Context, t *testing.T, waddr address.Address, a
|
||||
|
||||
nic := storedcounter.New(ds, datastore.NewKey(modules.StorageCounterDSPrefix))
|
||||
for i := 0; i < nGenesisPreseals; i++ {
|
||||
nic.Next()
|
||||
_, err := nic.Next()
|
||||
require.NoError(t, err)
|
||||
}
|
||||
nic.Next()
|
||||
_, err = nic.Next()
|
||||
require.NoError(t, err)
|
||||
|
||||
err = lr.Close()
|
||||
require.NoError(t, err)
|
||||
|
||||
Reference in New Issue
Block a user