coast-team/netflux

View on GitHub
src/service/topology/FullMesh.ts

Summary

Maintainability
D
2 days
Test Coverage

File FullMesh.ts has 348 lines of code (exceeds 250 allowed). Consider refactoring.
Confirmed

import { Channel, IChannelInitData, MAXIMUM_MISSED_HEARTBEAT } from '../../Channel'
import { isBrowser, log } from '../../misc/util'
import { fullMesh as proto } from '../../proto/index'
import { InWcMsg, WebChannel } from '../../WebChannel'
import { ConnectionError } from '../channelBuilder/ConnectionError'
Severity: Minor
Found in src/service/topology/FullMesh.ts - About 4 hrs to fix

    Function constructor has 73 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      constructor(wc: WebChannel) {
        super(wc, FullMesh.SERVICE_ID, proto.Message)
        this.adjacentMembers = new Map()
        this.distantMembers = new Map()
        this.antecedentId = 0
    Severity: Major
    Found in src/service/topology/FullMesh.ts - About 2 hrs to fix

      Function findRoutedChannel has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

        private findRoutedChannel(
          distantMember: IDistantMember | undefined,
          distance: number
        ): Channel | undefined {
          if (distantMember) {
      Severity: Minor
      Found in src/service/topology/FullMesh.ts - 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

      Function updateAntecedentId has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

        private updateAntecedentId() {
          if (this.adjacentMembers.size > 0) {
            let maxId = -1
            let desiredId = -1
            for (const id of this.wc.members) {
      Severity: Minor
      Found in src/service/topology/FullMesh.ts - 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

      Function connectToMembers has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        private connectToMembers(ids: number[], adjacentId: number): Promise<void | void[]> {
          const missingIds = ids.filter((id) => !this.adjacentMembers.has(id) && id !== this.wc.myId)
          if (missingIds.length !== 0) {
            log.topology(`TRY TO CONNECT to members`, missingIds)
            const attempts: Array<Promise<void>> = []
      Severity: Minor
      Found in src/service/topology/FullMesh.ts - About 1 hr to fix

        Function connectToMembers has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

          private connectToMembers(ids: number[], adjacentId: number): Promise<void | void[]> {
            const missingIds = ids.filter((id) => !this.adjacentMembers.has(id) && id !== this.wc.myId)
            if (missingIds.length !== 0) {
              log.topology(`TRY TO CONNECT to members`, missingIds)
              const attempts: Array<Promise<void>> = []
        Severity: Minor
        Found in src/service/topology/FullMesh.ts - About 1 hr 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

        Function constructor has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

          constructor(wc: WebChannel) {
            super(wc, FullMesh.SERVICE_ID, proto.Message)
            this.adjacentMembers = new Map()
            this.distantMembers = new Map()
            this.antecedentId = 0
        Severity: Minor
        Found in src/service/topology/FullMesh.ts - About 1 hr 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

        Function startHeartbeatInterval has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          private startHeartbeatInterval() {
            this.heartbeatInterval = setInterval(() => {
              this.adjacentMembers.forEach((ch) => ch.sendHeartbeat())
              this.distantMembers.forEach((peer, id) => {
                peer.missedHeartbeat++
        Severity: Minor
        Found in src/service/topology/FullMesh.ts - About 35 mins 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

        There are no issues that match your filters.

        Category
        Status