Showing 300 of 401 total issues
Function getConfig
has 66 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func getConfig(configJSON string) (WakuConfig, error) {
var config WakuConfig
if configJSON != "" {
err := json.Unmarshal([]byte(configJSON), &config)
if err != nil {
Function TestBackwardPagination
has 65 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func TestBackwardPagination(t *testing.T) {
msgList := createSampleList(10)
db := MemoryDB(t)
for _, m := range msgList {
err := db.Put(m)
Function TestQueryOptions
has 65 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func TestQueryOptions(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
pubSubTopic := "/waku/2/go/store/test"
Function getGossipSubParams
has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring. Open
Open
func getGossipSubParams(cfg *GossipSubParams) pubsub.GossipSubParams {
params := pubsub.DefaultGossipSubParams()
if cfg.D != nil {
params.D = *cfg.D
- 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 TestWakuLightPush
has 64 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func TestWakuLightPush(t *testing.T) {
testTopic := "/waku/2/go/lightpush/test"
node1, sub1, host1 := makeWakuRelay(t, testTopic)
defer node1.Stop()
defer sub1.Unsubscribe()
Method mockStore.Populate
has 63 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (t *mockStore) Populate(topics []string, responses int, includeRandomError bool) error {
if responses <= 0 || len(topics) == 0 {
return errors.New("invalid input parameters")
}
Function TestRetrieveFilteredPeerExchangePeers
has 63 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func TestRetrieveFilteredPeerExchangePeers(t *testing.T) {
// H1
host1, _, prvKey1 := tests.CreateHost(t)
udpPort1, err := tests.FindFreePort(t, "127.0.0.1", 3)
require.NoError(t, err)
Method WakuFilterLightNode.unsubscribeAll
has 63 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (wf *WakuFilterLightNode) unsubscribeAll(ctx context.Context, opts ...FilterSubscribeOption) (*WakuFilterPushResult, error) {
params, err := wf.getUnsubscribeParameters(opts...)
if err != nil {
return nil, err
}
Function TestDiscV5
has 62 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func TestDiscV5(t *testing.T) {
// Host1 <-> Host2 <-> Host3
// Host4(No waku capabilities) <-> Host2
// H1
Function TestForwardPagination
has 62 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func TestForwardPagination(t *testing.T) {
msgList := createSampleList(10)
db := MemoryDB(t)
for _, m := range msgList {
err := db.Put(m)
Function TestStaticShardingMultipleTopics
has 61 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func TestStaticShardingMultipleTopics(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
testClusterID := uint16(20)
Function TestHandler
has 61 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func TestHandler(t *testing.T) {
// Create a RLN instance
rlnInstance, err := rln.NewRLN()
require.NoError(t, err)
Method FastestPeerSelector.FastestPeer
has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring. Open
Open
func (r *FastestPeerSelector) FastestPeer(ctx context.Context, peers peer.IDSlice) (peer.ID, error) {
var peerRTT []pingResult
var peerRTTMutex sync.Mutex
wg := sync.WaitGroup{}
- 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 testQuery
has 60 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func testQuery(t *testing.T, db *sql.DB, migrationFn func(*sql.DB, *zap.Logger) error) {
store, err := persistence.NewDBStore(prometheus.DefaultRegisterer, utils.Logger(), persistence.WithDB(db), persistence.WithMigrations(migrationFn), persistence.WithRetentionPolicy(5, 20*time.Second))
require.NoError(t, err)
insertTime := time.Now()
Method WakuPeerExchange.handleResponse
has 60 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (wakuPX *WakuPeerExchange) handleResponse(ctx context.Context, response *pb.PeerExchangeResponse, params *PeerExchangeRequestParameters) error {
var discoveredPeers []struct {
addrInfo peer.AddrInfo
enr *enode.Node
}
Method FilterApiTestSuite.TestFilterManager
has 59 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (s *FilterApiTestSuite) TestFilterManager() {
ctx, cancel := context.WithCancel(context.Background())
testPubsubTopic := s.TestTopic
contentTopicBytes := make([]byte, 4)
Function TestNetworkPartition
has 59 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func TestNetworkPartition(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute)
defer cancel()
t.Log("Starting TestMessageRecovery")
Method WakuFilterLightNode.onRequest
has 59 lines of code (exceeds 50 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))
Method WakuFilterLightNode.request
has 59 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (wf *WakuFilterLightNode) request(ctx context.Context, requestID []byte,
reqType pb.FilterSubscribeRequest_FilterSubscribeType, contentFilter protocol.ContentFilter, peerID peer.ID) error {
request := &pb.FilterSubscribeRequest{
RequestId: hex.EncodeToString(requestID),
FilterSubscribeType: reqType,
Function TestWakuStoreProtocolFind
has 59 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func TestWakuStoreProtocolFind(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
host1, err := libp2p.New(libp2p.DefaultTransports, libp2p.ListenAddrStrings("/ip4/0.0.0.0/tcp/0"))