diff --git a/.tool-versions b/.tool-versions index 29cb7e0..7850523 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1,2 @@ golang 1.21.8 -golangci-lint 1.50.1 +golangci-lint 1.57.2 diff --git a/accesscontroller/ipfs/accesscontroller_ipfs.go b/accesscontroller/ipfs/accesscontroller_ipfs.go index 9caedcd..7462d02 100644 --- a/accesscontroller/ipfs/accesscontroller_ipfs.go +++ b/accesscontroller/ipfs/accesscontroller_ipfs.go @@ -38,7 +38,7 @@ func (i *ipfsAccessController) Address() address.Address { return nil } -func (i *ipfsAccessController) CanAppend(entry logac.LogEntry, p identityprovider.Interface, additionalContext accesscontroller.CanAppendAdditionalContext) error { +func (i *ipfsAccessController) CanAppend(entry logac.LogEntry, p identityprovider.Interface, _ accesscontroller.CanAppendAdditionalContext) error { i.muWriteAccess.RLock() defer i.muWriteAccess.RUnlock() @@ -63,11 +63,11 @@ func (i *ipfsAccessController) GetAuthorizedByRole(role string) ([]string, error return nil, nil } -func (i *ipfsAccessController) Grant(ctx context.Context, capability string, keyID string) error { +func (i *ipfsAccessController) Grant(ctx context.Context, capability string, keyID string) error { //nolint:all return fmt.Errorf("not implemented - does not exist in JS version") } -func (i *ipfsAccessController) Revoke(ctx context.Context, capability string, keyID string) error { +func (i *ipfsAccessController) Revoke(ctx context.Context, capability string, keyID string) error { //nolint:all return fmt.Errorf("not implemented - does not exist in JS version") } diff --git a/accesscontroller/orbitdb/accesscontroller_orbitdb.go b/accesscontroller/orbitdb/accesscontroller_orbitdb.go index 69b506f..f9e40d2 100644 --- a/accesscontroller/orbitdb/accesscontroller_orbitdb.go +++ b/accesscontroller/orbitdb/accesscontroller_orbitdb.go @@ -112,7 +112,7 @@ func (o *orbitDBAccessController) getAuthorizations() (map[string][]string, erro return authorizationsLists, nil } -func (o *orbitDBAccessController) CanAppend(entry logac.LogEntry, p identityprovider.Interface, additionalContext accesscontroller.CanAppendAdditionalContext) error { +func (o *orbitDBAccessController) CanAppend(entry logac.LogEntry, p identityprovider.Interface, _ accesscontroller.CanAppendAdditionalContext) error { writeAccess, err := o.GetAuthorizedByRole("write") if err != nil { return fmt.Errorf("unable to get keys with write access: %w", err) @@ -249,7 +249,7 @@ func (o *orbitDBAccessController) Load(ctx context.Context, address string) erro return nil } -func (o *orbitDBAccessController) Save(ctx context.Context) (accesscontroller.ManifestParams, error) { +func (o *orbitDBAccessController) Save(_ context.Context) (accesscontroller.ManifestParams, error) { return accesscontroller.NewManifestParams(o.kvStore.Address().GetRoot(), false, "orbitdb"), nil } @@ -261,7 +261,7 @@ func (o *orbitDBAccessController) Close() error { return nil } -func (o *orbitDBAccessController) onUpdate(ctx context.Context) { +func (o *orbitDBAccessController) onUpdate(_ context.Context) { if err := o.emitterEvtUpdated.Emit(&EventUpdated{}); err != nil { o.logger.Warn("unable to emit event updated", zap.Error(err)) } diff --git a/accesscontroller/simple/accesscontroller_simple.go b/accesscontroller/simple/accesscontroller_simple.go index 588aeff..fe8dd06 100644 --- a/accesscontroller/simple/accesscontroller_simple.go +++ b/accesscontroller/simple/accesscontroller_simple.go @@ -38,19 +38,19 @@ func (o *simpleAccessController) Address() address.Address { return nil } -func (o *simpleAccessController) Grant(ctx context.Context, capability string, keyID string) error { +func (o *simpleAccessController) Grant(ctx context.Context, capability string, keyID string) error { //nolint:all return nil } -func (o *simpleAccessController) Revoke(ctx context.Context, capability string, keyID string) error { +func (o *simpleAccessController) Revoke(ctx context.Context, capability string, keyID string) error { //nolint:all return nil } -func (o *simpleAccessController) Load(ctx context.Context, address string) error { +func (o *simpleAccessController) Load(ctx context.Context, address string) error { //nolint:all return nil } -func (o *simpleAccessController) Save(ctx context.Context) (accesscontroller.ManifestParams, error) { +func (o *simpleAccessController) Save(_ context.Context) (accesscontroller.ManifestParams, error) { return accesscontroller.NewManifestParams(cid.Cid{}, true, "simple"), nil } @@ -66,7 +66,7 @@ func (o *simpleAccessController) GetAuthorizedByRole(role string) ([]string, err return o.allowedKeys[role], nil } -func (o *simpleAccessController) CanAppend(e logac.LogEntry, p identityprovider.Interface, additionalContext accesscontroller.CanAppendAdditionalContext) error { +func (o *simpleAccessController) CanAppend(e logac.LogEntry, _ identityprovider.Interface, _ accesscontroller.CanAppendAdditionalContext) error { for _, id := range o.allowedKeys["write"] { if e.GetIdentity().ID == id || id == "*" { return nil diff --git a/baseorbitdb/orbitdb.go b/baseorbitdb/orbitdb.go index a74e15b..0c0ee94 100644 --- a/baseorbitdb/orbitdb.go +++ b/baseorbitdb/orbitdb.go @@ -31,6 +31,7 @@ import ( peer "github.com/libp2p/go-libp2p/core/peer" "github.com/libp2p/go-libp2p/p2p/host/eventbus" "go.opentelemetry.io/otel/trace" + tracenoop "go.opentelemetry.io/otel/trace/noop" "go.uber.org/zap" ) @@ -334,7 +335,7 @@ func newOrbitDB(ctx context.Context, is coreiface.CoreAPI, identity *idp.Identit } if options.Tracer == nil { - options.Tracer = trace.NewNoopTracerProvider().Tracer("") + options.Tracer = tracenoop.NewTracerProvider().Tracer("") } if options.EventBus == nil { diff --git a/events/events.go b/events/events.go index 7828a06..a992c26 100644 --- a/events/events.go +++ b/events/events.go @@ -46,7 +46,7 @@ type eventBox struct { // Deprecated: use event bus directly // Emit Sends an event to the subscribed listeners -func (e *EventEmitter) Emit(ctx context.Context, evt Event) { +func (e *EventEmitter) Emit(_ context.Context, evt Event) { e.muEmitters.Lock() bus := e.getBus() diff --git a/pubsub/directchannel/channel.go b/pubsub/directchannel/channel.go index f4b1d58..f1af096 100644 --- a/pubsub/directchannel/channel.go +++ b/pubsub/directchannel/channel.go @@ -76,7 +76,7 @@ func (d *directChannel) handleNewPeer(s network.Stream) { // @NOTE(gfanton): we dont need this on direct channel // Connect Waits for the other peer to be connected -func (d *directChannel) Connect(ctx context.Context, pid peer.ID) (err error) { +func (d *directChannel) Connect(ctx context.Context, pid peer.ID) (err error) { //nolint:all return nil } @@ -92,7 +92,7 @@ type holderChannels struct { logger *zap.Logger } -func (c *holderChannels) NewChannel(ctx context.Context, emitter iface.DirectChannelEmitter, opts *iface.DirectChannelOptions) (iface.DirectChannel, error) { +func (c *holderChannels) NewChannel(_ context.Context, emitter iface.DirectChannelEmitter, opts *iface.DirectChannelOptions) (iface.DirectChannel, error) { if opts == nil { opts = &iface.DirectChannelOptions{} } diff --git a/pubsub/pubsubcoreapi/pubsub.go b/pubsub/pubsubcoreapi/pubsub.go index 341fcfc..e374176 100644 --- a/pubsub/pubsubcoreapi/pubsub.go +++ b/pubsub/pubsubcoreapi/pubsub.go @@ -9,6 +9,7 @@ import ( "github.com/ipfs/kubo/core/coreiface/options" "github.com/libp2p/go-libp2p/core/peer" "go.opentelemetry.io/otel/trace" + tracenoop "go.opentelemetry.io/otel/trace/noop" "go.uber.org/zap" "berty.tech/go-orbit-db/events" @@ -172,7 +173,7 @@ func NewPubSub(api coreiface.CoreAPI, id peer.ID, pollInterval time.Duration, lo } if tracer == nil { - tracer = trace.NewNoopTracerProvider().Tracer("") + tracer = tracenoop.NewTracerProvider().Tracer("") } return &coreAPIPubSub{ diff --git a/pubsub/pubsubraw/pubsub.go b/pubsub/pubsubraw/pubsub.go index ed39fb3..4e568d0 100644 --- a/pubsub/pubsubraw/pubsub.go +++ b/pubsub/pubsubraw/pubsub.go @@ -7,6 +7,7 @@ import ( p2ppubsub "github.com/libp2p/go-libp2p-pubsub" "github.com/libp2p/go-libp2p/core/peer" "go.opentelemetry.io/otel/trace" + tracernoop "go.opentelemetry.io/otel/trace/noop" "go.uber.org/zap" "berty.tech/go-orbit-db/events" @@ -141,7 +142,7 @@ func NewPubSub(ps *p2ppubsub.PubSub, id peer.ID, logger *zap.Logger, tracer trac } if tracer == nil { - tracer = trace.NewNoopTracerProvider().Tracer("") + tracer = tracernoop.NewTracerProvider().Tracer("") } return &rawPubSub{ diff --git a/stores/basestore/base_index.go b/stores/basestore/base_index.go index a46869b..7abab2a 100644 --- a/stores/basestore/base_index.go +++ b/stores/basestore/base_index.go @@ -20,7 +20,7 @@ func (b *baseIndex) Get(_ string) interface{} { return b.index } -func (b *baseIndex) UpdateIndex(log ipfslog.Log, entries []ipfslog.Entry) error { +func (b *baseIndex) UpdateIndex(log ipfslog.Log, _ []ipfslog.Entry) error { b.mu.Lock() defer b.mu.Unlock() b.index = log.Values().Slice() diff --git a/stores/basestore/base_store.go b/stores/basestore/base_store.go index 419fce6..f338a47 100644 --- a/stores/basestore/base_store.go +++ b/stores/basestore/base_store.go @@ -34,6 +34,7 @@ import ( "github.com/pkg/errors" otkv "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" + tracenoop "go.opentelemetry.io/otel/trace/noop" "go.uber.org/zap" ) @@ -180,7 +181,7 @@ func (b *BaseStore) InitBaseStore(ipfs coreiface.CoreAPI, identity *identityprov b.messageMarshaler = options.MessageMarshaler if options.Tracer == nil { - options.Tracer = trace.NewNoopTracerProvider().Tracer("") + options.Tracer = tracenoop.NewTracerProvider().Tracer("") } if identity == nil { @@ -662,7 +663,7 @@ func (b *BaseStore) Sync(ctx context.Context, heads []ipfslog.Entry) error { return nil } -func (b *BaseStore) LoadMoreFrom(ctx context.Context, amount uint, entries []ipfslog.Entry) { +func (b *BaseStore) LoadMoreFrom(ctx context.Context, amount uint, entries []ipfslog.Entry) { //nolint:all b.Replicator().Load(ctx, entries) // TODO: can this return an error? } diff --git a/stores/documentstore/document.go b/stores/documentstore/document.go index ac9f471..3edb8de 100644 --- a/stores/documentstore/document.go +++ b/stores/documentstore/document.go @@ -20,7 +20,7 @@ type orbitDBDocumentStore struct { docOpts *iface.CreateDocumentDBOptions } -func (o *orbitDBDocumentStore) Get(ctx context.Context, key string, opts *iface.DocumentStoreGetOptions) ([]interface{}, error) { +func (o *orbitDBDocumentStore) Get(_ context.Context, key string, opts *iface.DocumentStoreGetOptions) ([]interface{}, error) { if opts == nil { opts = &iface.DocumentStoreGetOptions{} } @@ -179,7 +179,7 @@ func (o *orbitDBDocumentStore) PutAll(ctx context.Context, values []interface{}) } // Query Finds documents using a filter function -func (o *orbitDBDocumentStore) Query(ctx context.Context, filter func(doc interface{}) (bool, error)) ([]interface{}, error) { +func (o *orbitDBDocumentStore) Query(_ context.Context, filter func(doc interface{}) (bool, error)) ([]interface{}, error) { docIndex, ok := o.Index().(*documentIndex) if !ok { return nil, fmt.Errorf("unable to cast index to documentIndex") diff --git a/stores/eventlogstore/index.go b/stores/eventlogstore/index.go index f3c955d..304612a 100644 --- a/stores/eventlogstore/index.go +++ b/stores/eventlogstore/index.go @@ -12,7 +12,7 @@ type eventIndex struct { lock sync.RWMutex } -func (i *eventIndex) Get(key string) interface{} { +func (i *eventIndex) Get(key string) interface{} { //nolint:all i.lock.RLock() defer i.lock.RUnlock() diff --git a/stores/eventlogstore/log.go b/stores/eventlogstore/log.go index 6522179..22e56a5 100644 --- a/stores/eventlogstore/log.go +++ b/stores/eventlogstore/log.go @@ -80,7 +80,7 @@ func (o *orbitDBEventLogStore) Get(ctx context.Context, cid cid.Cid) (operation. } } -func (o *orbitDBEventLogStore) Stream(ctx context.Context, resultChan chan operation.Operation, options *iface.StreamOptions) error { +func (o *orbitDBEventLogStore) Stream(_ context.Context, resultChan chan operation.Operation, options *iface.StreamOptions) error { defer close(resultChan) messages, err := o.query(options) if err != nil { diff --git a/stores/kvstore/keyvalue.go b/stores/kvstore/keyvalue.go index 4c9ab3c..774f503 100644 --- a/stores/kvstore/keyvalue.go +++ b/stores/kvstore/keyvalue.go @@ -67,7 +67,7 @@ func (o *orbitDBKeyValue) Delete(ctx context.Context, key string) (operation.Ope return op, nil } -func (o *orbitDBKeyValue) Get(ctx context.Context, key string) ([]byte, error) { +func (o *orbitDBKeyValue) Get(_ context.Context, key string) ([]byte, error) { value, ok := o.Index().(*kvIndex).Get(key).([]byte) if value == nil { return nil, nil diff --git a/stores/replicator/replicator.go b/stores/replicator/replicator.go index 8130fcf..1be932f 100644 --- a/stores/replicator/replicator.go +++ b/stores/replicator/replicator.go @@ -14,6 +14,7 @@ import ( "github.com/libp2p/go-libp2p/p2p/host/eventbus" otkv "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" + tracenoop "go.opentelemetry.io/otel/trace/noop" "go.uber.org/zap" "golang.org/x/sync/semaphore" ) @@ -77,7 +78,7 @@ func NewReplicator(store storeInterface, concurrency uint, opts *Options) (Repli } if opts.Tracer == nil { - opts.Tracer = trace.NewNoopTracerProvider().Tracer("") + opts.Tracer = tracenoop.NewTracerProvider().Tracer("") } if concurrency == 0 { @@ -178,7 +179,7 @@ func (r *replicator) Load(ctx context.Context, entries []ipfslog.Entry) { wg.Add(1) // add one process - go func(i int) { + go func(_ int) { if err := r.processOne(ctx, &wg); err != nil { r.logger.Warn("unable to process entry", zap.Error(err)) }