Showing 299 of 400 total issues
Function getLegacyStoreParams
has 9 return statements (exceeds 4 allowed). Open
Open
func getLegacyStoreParams(r *http.Request) (*legacy_store.Query, []legacy_store.HistoryRequestOption, error) {
query := &legacy_store.Query{}
var options []legacy_store.HistoryRequestOption
var err error
peerAddrStr := r.URL.Query().Get("peerAddr")
Method WakuStore.Query
has 9 return statements (exceeds 4 allowed). Open
Open
func (store *WakuStore) Query(ctx context.Context, query Query, opts ...HistoryRequestOption) (*Result, error) {
params := new(HistoryRequestParameters)
params.s = store
optList := DefaultOptions()
Method Pairing.responderHandshake
has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring. Open
Open
func (p *Pairing) responderHandshake(ctx context.Context, msgCh <-chan *pb.WakuMessage) (doneCh chan error) {
doneCh = make(chan error, 1)
func() {
defer close(doneCh)
- 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
Method WakuFilterLightNode.onRequest
has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring. Open
Open
func (wf *WakuFilterLightNode) onRequest(ctx context.Context) func(network.Stream) {
return func(stream network.Stream) {
peerID := stream.Conn().RemotePeer()
logger := wf.log.With(logging.HostID("peerID", peerID))
- 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 DecodePayload
has 9 return statements (exceeds 4 allowed). Open
Open
func DecodePayload(message *pb.WakuMessage, keyInfo *KeyInfo) (*DecodedPayload, error) {
switch message.GetVersion() {
case uint32(0):
return &DecodedPayload{Data: message.Payload}, nil
case uint32(1):
Function NewMessageSentCheck
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func NewMessageSentCheck(ctx context.Context, messageVerifier StorenodeMessageVerifier, cycle *history.StorenodeCycle, timesource timesource.Timesource, msgStoredChan chan common.Hash, msgExpiredChan chan common.Hash, logger *zap.Logger) *MessageSentCheck {
Function WithDynamicRLNRelay
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func WithDynamicRLNRelay(keystorePath string, keystorePassword string, treePath string, membershipContract common.Address, membershipIndex *uint, spamHandler rln.SpamHandler, ethClientAddress string) WakuNodeOption {
Function updateLocalNode
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func updateLocalNode(localnode *enode.LocalNode, multiaddrs []ma.Multiaddr, ipAddr *net.TCPAddr, udpPort uint, wakuFlags WakuEnrBitfield, advertiseAddr *net.IP, shouldAutoUpdate bool) error {
Method WakuNode.updateLocalNode
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func (w *WakuNode) updateLocalNode(localnode *enode.LocalNode, multiaddrs []ma.Multiaddr, ipAddr *net.TCPAddr, udpPort uint, wakuFlags wenr.WakuEnrBitfield, advertiseAddr []ma.Multiaddr, shouldAutoUpdate bool) error {
Function waku_lightpush_publish
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func waku_lightpush_publish(ctx unsafe.Pointer, messageJSON *C.char, topic *C.char, peerID *C.char, ms C.int, cb C.WakuCallBack, userData unsafe.Pointer) C.int {
Function NewWakuPeerExchange
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func NewWakuPeerExchange(disc *discv5.DiscoveryV5, clusterID uint16, peerConnector PeerConnector, pm *peermanager.PeerManager, reg prometheus.Registerer, log *zap.Logger, opts ...Option) (*WakuPeerExchange, error) {
Function save
has 8 return statements (exceeds 4 allowed). Open
Open
func save(keystore *AppKeystore, path string) error {
// We first backup the current keystore
_, err := os.Stat(path)
if err == nil {
err := os.Rename(path, path+".bkp")
Method WakuNode.setupRLNRelay
has 8 return statements (exceeds 4 allowed). Open
Open
func (w *WakuNode) setupRLNRelay() error {
var err error
if !w.opts.enableRLN {
return nil
Function BuildConfig
has 8 return statements (exceeds 4 allowed). Open
Open
func BuildConfig(ctx context.Context, ethClientAddress string, registryAddress common.Address) (*Config, error) {
ethClient, err := ethclient.DialContext(ctx, ethClientAddress)
if err != nil {
return nil, err
}
Function execute
has 8 return statements (exceeds 4 allowed). Open
Open
func execute(options Options) {
var err error
hostAddr, _ := net.ResolveTCPAddr("tcp", fmt.Sprintf("0.0.0.0:%d", options.Port))
if options.NodeKey == nil {
Function extractIPAddressForENR
has 8 return statements (exceeds 4 allowed). Open
Open
func extractIPAddressForENR(addr ma.Multiaddr) (*net.TCPAddr, error) {
// It's a p2p-circuit address. We shouldnt use these
// for building the ENR record default keys
_, err := addr.ValueForProtocol(ma.P_CIRCUIT)
if err == nil {
Method WakuStore.Request
has 8 return statements (exceeds 4 allowed). Open
Open
func (s *WakuStore) Request(ctx context.Context, criteria Criteria, opts ...RequestOption) (Result, error) {
params := new(Parameters)
optList := DefaultOptions()
optList = append(optList, opts...)
Function EncodeAsymmetric
has 8 return statements (exceeds 4 allowed). Open
Open
func EncodeAsymmetric(messageJSON string, publicKey string, optionalSigningKey string) (string, error) {
msg, err := wakuMessage(messageJSON)
if err != nil {
return "", err
}
Function Multiaddress
has 8 return statements (exceeds 4 allowed). Open
Open
func Multiaddress(node *enode.Node) (peer.ID, []multiaddr.Multiaddr, error) {
pubKey := utils.EcdsaPubKeyToSecp256k1PublicKey(node.Pubkey())
peerID, err := peer.IDFromPublicKey(pubKey)
if err != nil {
return "", nil, err
Method StoreQueryRequest.Validate
has 8 return statements (exceeds 4 allowed). Open
Open
func (x *StoreQueryRequest) Validate() error {
if x.RequestId == "" {
return errMissingRequestID
}