Showing 299 of 400 total issues
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")
}
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 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)
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 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)
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)
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.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 TestWakuStoreProtocolNext
has 59 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func TestWakuStoreProtocolNext(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"))
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"))
Method MissingMessageVerifier.fetchMessagesBatch
has 14 return statements (exceeds 4 allowed). Open
Open
func (m *MissingMessageVerifier) fetchMessagesBatch(c chan<- *protocol.Envelope, interest criteriaInterest, batchFrom int, batchTo int, now time.Time) error {
contentTopics := interest.contentFilter.ContentTopics.ToList()
logger := m.logger.With(
zap.Stringer("peerID", interest.peerID),