Showing 299 of 400 total issues
Method WakuPeerExchange.onRequest
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
Open
func (wakuPX *WakuPeerExchange) onRequest() func(network.Stream) {
return func(stream network.Stream) {
logger := wakuPX.log.With(logging.HostID("peer", stream.Conn().RemotePeer()))
if wakuPX.limiter != nil && !wakuPX.limiter.Allow() {
- 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_filter_subscribe
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func waku_filter_subscribe(ctx unsafe.Pointer, filterJSON *C.char, peerID *C.char, ms C.int, cb C.WakuCallBack, userData unsafe.Pointer) C.int {
Function waku_filter_unsubscribe
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func waku_filter_unsubscribe(ctx unsafe.Pointer, filterJSON *C.char, peerID *C.char, ms C.int, cb C.WakuCallBack, userData unsafe.Pointer) C.int {
Function main
has 6 return statements (exceeds 4 allowed). Open
Open
func main() {
// Removing noisy logs
lvl, err := logging.LevelFromString("error")
if err != nil {
panic(err)
Function Execute
has 6 return statements (exceeds 4 allowed). Open
Open
func Execute() error {
var cTopic, err = protocol.NewContentTopic("basic-light-client", "1", "test", "proto")
if err != nil {
return errors.New("invalid contentTopic")
Function Execute
has 6 return statements (exceeds 4 allowed). Open
Open
func Execute() error {
var cTopic, err = protocol.NewContentTopic("basic-relay", "1", "test", "proto")
if err != nil {
fmt.Println("Invalid contentTopic")
Method DynamicGroupManager.loadCredential
has 6 return statements (exceeds 4 allowed). Open
Open
func (gm *DynamicGroupManager) loadCredential(ctx context.Context) error {
if gm.appKeystore == nil {
gm.log.Warn("no credentials were loaded. Node will only validate messages, but wont be able to generate proofs and attach them to messages")
return nil
}
Method DynamicGroupManager.Start
has 6 return statements (exceeds 4 allowed). Open
Open
func (gm *DynamicGroupManager) Start(ctx context.Context) error {
if gm.cancel != nil {
return errors.New("already started")
}
Method AppKeystore.AddMembershipCredentials
has 6 return statements (exceeds 4 allowed). Open
Open
func (k *AppKeystore) AddMembershipCredentials(newCredential MembershipCredentials, password string) error {
credentials, err := k.GetMembershipCredentials(password, &newCredential.TreeIndex, newCredential.MembershipContractInfo)
if err != nil {
return err
}
Function StringToContentTopic
has 6 return statements (exceeds 4 allowed). Open
Open
func StringToContentTopic(s string) (ContentTopic, error) {
p := strings.Split(s, "/")
switch len(p) {
case 5:
if len(p[1]) == 0 || len(p[2]) == 0 || len(p[3]) == 0 || len(p[4]) == 0 {
Method WakuStore.Find
has 6 return statements (exceeds 4 allowed). Open
Open
func (store *WakuStore) Find(ctx context.Context, query Query, cb CriteriaFN, opts ...HistoryRequestOption) (*wpb.WakuMessage, error) {
if cb == nil {
return nil, errors.New("callback can't be null")
}
Method WakuStore.queryFrom
has 6 return statements (exceeds 4 allowed). Open
Open
func (store *WakuStore) queryFrom(ctx context.Context, historyRequest *pb.HistoryRPC, selectedPeer peer.ID) (*pb.HistoryResponse, error) {
logger := store.log.With(logging.HostID("peer", selectedPeer))
logger.Info("querying message history")
stream, err := store.h.NewStream(ctx, selectedPeer, StoreID_v20beta4)
Function validateAndParse
has 6 return statements (exceeds 4 allowed). Open
Open
func validateAndParse(input []byte) (*DecodedPayload, error) {
end := len(input)
if end < 1 {
return nil, errors.New("invalid message length")
}
Method WakuFilterLightNode.incorrectSubscribeRequest
has 6 return statements (exceeds 4 allowed). Open
Open
func (wf *WakuFilterLightNode) incorrectSubscribeRequest(ctx context.Context, params *FilterSubscribeParameters,
reqType pb.FilterSubscribeRequest_FilterSubscribeType, contentFilter protocol.ContentFilter) error {
const FilterSubscribeID_Incorrect1 = libp2pProtocol.ID("/vac/waku/filter-subscribe/abcd")
Function SetBootnodes
has 6 return statements (exceeds 4 allowed). Open
Open
func SetBootnodes(instance *WakuInstance, bootnodes string) error {
if err := validateInstance(instance, MustBeStarted); err != nil {
return err
}
Method FilterSubscribeRequest.Validate
has 6 return statements (exceeds 4 allowed). Open
Open
func (x *FilterSubscribeRequest) Validate() error {
if x.RequestId == "" {
return errMissingRequestID
}
Function generateSecureRandomData
has 6 return statements (exceeds 4 allowed). Open
Open
func generateSecureRandomData(length int) ([]byte, error) {
x := make([]byte, length)
y := make([]byte, length)
res := make([]byte, length)
Function DecodeSymmetric
has 6 return statements (exceeds 4 allowed). Open
Open
func DecodeSymmetric(messageJSON string, symmetricKey string) (string, error) {
var msg pb.WakuMessage
err := json.Unmarshal([]byte(messageJSON), &msg)
if err != nil {
return "", err
Function buildTransactor
has 6 return statements (exceeds 4 allowed). Open
Open
func buildTransactor(ctx context.Context, membershipFee *big.Int, chainID *big.Int) (*bind.TransactOpts, error) {
auth, err := bind.NewKeyedTransactorWithChainID(options.ETHPrivateKey, chainID)
if err != nil {
return nil, err
}
Method WakuLightPush.request
has 6 return statements (exceeds 4 allowed). Open
Open
func (wakuLP *WakuLightPush) request(ctx context.Context, req *pb.PushRequest, params *lightPushRequestParameters, peerID peer.ID) (*pb.PushResponse, error) {
logger := wakuLP.log.With(logging.HostID("peer", peerID))
stream, err := wakuLP.h.NewStream(ctx, peerID, LightPushID_v20beta1)