Fantom-foundation/go-lachesis

View on GitHub
gossip/packsdownloader/peer_downloader.go

Summary

Maintainability
B
4 hrs
Test Coverage

Method PeerPacksDownloader.loop has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring.
Open

func (d *PeerPacksDownloader) loop() {
    // Iterate the event fetching until a quit is requested
    syncTicker := time.NewTicker(recheckInterval)
    defer syncTicker.Stop()

Severity: Minor
Found in gossip/packsdownloader/peer_downloader.go - About 2 hrs to fix

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 PeerPacksDownloader.binarySearchReq has 6 return statements (exceeds 4 allowed).
Open

func (d *PeerPacksDownloader) binarySearchReq() (requestIndex idx.Pack, requestFull bool, syncedUp bool) {
    it := d.packInfos.Iterator()
    var prevIdx *idx.Pack

    for it.End(); it.Prev(); {
Severity: Major
Found in gossip/packsdownloader/peer_downloader.go - About 40 mins to fix

    Method PeerPacksDownloader.NotifyPack has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    func (d *PeerPacksDownloader) NotifyPack(epoch idx.Epoch, index idx.Pack, ids hash.Events, time time.Time, fetchEvents fetcher.EventsRequesterFn) error {
    Severity: Minor
    Found in gossip/packsdownloader/peer_downloader.go - About 35 mins to fix

      Function newPeer has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      func newPeer(peer Peer, myEpoch idx.Epoch, fetcher *fetcher.Fetcher, onlyNotConnected onlyNotConnectedFn, dropPeer dropPeerFn) *PeerPacksDownloader {
      Severity: Minor
      Found in gossip/packsdownloader/peer_downloader.go - About 35 mins to fix

        There are no issues that match your filters.

        Category
        Status