status-im/status-go

View on GitHub
protocol/communities/manager_archive.go

Summary

Maintainability
C
1 day
Test Coverage
F
39%

ArchiveManager has 23 methods (exceeds 21 allowed). Consider refactoring.
Open

type ArchiveManager struct {
    torrentConfig                *params.TorrentConfig
    torrentClient                *torrent.Client
    torrentTasks                 map[string]metainfo.Hash
    historyArchiveDownloadTasks  map[string]*HistoryArchiveDownloadTask
Severity: Minor
Found in protocol/communities/manager_archive.go - About 2 hrs to fix

    Avoid deeply nested control flow statements.
    Open

                            if hasArchive {
                                continue
                            }
    Severity: Major
    Found in protocol/communities/manager_archive.go - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if err != nil {
                              return nil, err
                          }
      Severity: Major
      Found in protocol/communities/manager_archive.go - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if len(existingArchiveIDs) == len(index.Archives) {
                                m.logger.Debug("download cancelled, no new archives")
                                return downloadTaskInfo, nil
                            }
        Severity: Major
        Found in protocol/communities/manager_archive.go - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  for {
                                      select {
                                      case <-downloadTicker.C:
                                          done := true
                                          for i = startIndex; i < endIndex; i++ {
          Severity: Major
          Found in protocol/communities/manager_archive.go - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if err != nil {
                                    return nil, err
                                }
            Severity: Major
            Found in protocol/communities/manager_archive.go - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if err != nil {
                                          m.logger.Error("couldn't save message archive ID", zap.Error(err))
                                          continue
                                      }
              Severity: Major
              Found in protocol/communities/manager_archive.go - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                            if existingHash == hash {
                                                hasArchive = true
                                                break
                                            }
                Severity: Major
                Found in protocol/communities/manager_archive.go - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          for i = startIndex; i < endIndex; i++ {
                                              piecesCompleted[i] = false
                                          }
                  Severity: Major
                  Found in protocol/communities/manager_archive.go - About 45 mins to fix

                    There are no issues that match your filters.

                    Category
                    Status