Showing 299 of 400 total issues
Avoid deeply nested control flow statements. Open
Open
if _, ok := meshPeersSet[p]; !ok {
relayPeersSet[p] = struct{}{}
}
Function Subscribe
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func Subscribe(ctx context.Context, wf *filter.WakuFilterLightNode, contentFilter protocol.ContentFilter, config FilterConfig, log *zap.Logger, params *subscribeParameters) (*Sub, error) {
Method AppKeystore.GetMembershipCredentials
has 7 return statements (exceeds 4 allowed). Open
Open
func (k *AppKeystore) GetMembershipCredentials(keystorePassword string, index *rln.MembershipIndex, filterMembershipContract MembershipContractInfo) (*MembershipCredentials, error) {
// If there is only one, and index to laod nil, assume 0,
// if there is more than one, complain if the index to load is nil
var key Key
Function NewStaticGroupManager
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
group []rln.IDCommitment,
identityCredential rln.IdentityCredential,
index rln.MembershipIndex,
rlnInstance *rln.RLN,
rootTracker *group_manager.MerkleRootTracker,
Function waku_store_query
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func waku_store_query(ctx unsafe.Pointer, queryJSON *C.char, peerID *C.char, ms C.int, cb C.WakuCallBack, userData unsafe.Pointer) C.int {
Function DecodeAsymmetric
has 7 return statements (exceeds 4 allowed). Open
Open
func DecodeAsymmetric(messageJSON string, privateKey string) (string, error) {
var msg pb.WakuMessage
err := json.Unmarshal([]byte(messageJSON), &msg)
if err != nil {
return "", err
Function waku_content_topic
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func waku_content_topic(applicationName *C.char, applicationVersion *C.char, contentTopicName *C.char, encoding *C.char, cb C.WakuCallBack, userData unsafe.Pointer) C.int {
Function waku_relay_publish
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func waku_relay_publish(ctx unsafe.Pointer, messageJSON *C.char, topic *C.char, ms C.int, cb C.WakuCallBack, userData unsafe.Pointer) C.int {
Method Payload.Encode
has 7 return statements (exceeds 4 allowed). Open
Open
func (payload Payload) Encode(version uint32) ([]byte, error) {
switch version {
case 0:
return payload.Data, nil
case 1:
Method WakuFilterLightNode.Subscribe
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
Open
func (wf *WakuFilterLightNode) Subscribe(ctx context.Context, contentFilter protocol.ContentFilter, opts ...FilterSubscribeOption) ([]*subscription.SubscriptionDetails, error) {
wf.RLock()
defer wf.RUnlock()
if err := wf.ErrOnNotRunning(); err != nil {
return nil, err
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function waku_dns_discovery
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func waku_dns_discovery(ctx unsafe.Pointer, url *C.char, nameserver *C.char, ms C.int, cb C.WakuCallBack, userData unsafe.Pointer) C.int {
Method WakuPeerExchange.Request
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
Open
func (wakuPX *WakuPeerExchange) Request(ctx context.Context, numPeers int, opts ...RequestOption) error {
params := new(PeerExchangeRequestParameters)
params.host = wakuPX.h
params.log = wakuPX.log
params.pm = wakuPX.pm
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function StringToQR
has 7 return statements (exceeds 4 allowed). Open
Open
func StringToQR(qrString string) (QR, error) {
values := strings.Split(qrString, ":")
if len(values) != 5 {
return QR{}, errors.New("invalid qr string")
}
Function NewWakuRelay
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func NewWakuRelay(bcaster Broadcaster, minPeersToPublish int, timesource timesource.Timesource,
reg prometheus.Registerer, log *zap.Logger, opts ...RelayOption) *WakuRelay {
Method WakuStore.queryFrom
has 7 return statements (exceeds 4 allowed). Open
Open
func (s *WakuStore) queryFrom(ctx context.Context, storeRequest *pb.StoreQueryRequest, params *Parameters) (*pb.StoreQueryResponse, error) {
logger := s.log.With(logging.HostID("peer", params.selectedPeer), zap.String("requestId", storeRequest.RequestId))
logger.Debug("sending store request")
Function FilterUnsubscribe
has 7 return statements (exceeds 4 allowed). Open
Open
func FilterUnsubscribe(instance *WakuInstance, filterJSON string, peerID string, ms int) error {
cf, err := toContentFilter(filterJSON)
if err != nil {
return err
}
Function NewWakuFilterLightNode
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
broadcaster relay.Broadcaster,
pm *peermanager.PeerManager,
timesource timesource.Timesource,
onlineChecker onlinechecker.OnlineChecker,
reg prometheus.Registerer,
Function EncodeSymmetric
has 7 return statements (exceeds 4 allowed). Open
Open
func EncodeSymmetric(messageJSON string, symmetricKey string, optionalSigningKey string) (string, error) {
msg, err := wakuMessage(messageJSON)
if err != nil {
return "", err
}
Method WakuFilterLightNode.Unsubscribe
has 7 return statements (exceeds 4 allowed). Open
Open
func (wf *WakuFilterLightNode) Unsubscribe(ctx context.Context, contentFilter protocol.ContentFilter, opts ...FilterSubscribeOption) (*WakuFilterPushResult, error) {
wf.RLock()
defer wf.RUnlock()
if err := wf.ErrOnNotRunning(); err != nil {
return nil, err
Function validateInstance
has 7 return statements (exceeds 4 allowed). Open
Open
func validateInstance(instance *WakuInstance, validationType ValidationType) error {
if instance == nil {
return errWakuNodeNotReady
}