coast-team/netflux

View on GitHub

Showing 48 of 75 total issues

Function setLogLevel has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
Confirmed

export function setLogLevel(...levels: LogLevel[]) {
  logLevels = levels
  if (logLevels.includes(LogLevel.WEB_GROUP)) {
    log.webgroup = (msg: string, ...rest: any[]): void => {
      if (rest.length === 0) {
Severity: Minor
Found in src/misc/util.log.ts - About 6 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

File WebChannel.ts has 404 lines of code (exceeds 250 allowed). Consider refactoring.
Confirmed

import { Observable, Subject } from 'rxjs'

import { Channel } from './Channel'
import {
  extractHostnameAndPort,
Severity: Minor
Found in src/WebChannel.ts - About 5 hrs to fix

    Function constructor has 114 lines of code (exceeds 25 allowed). Consider refactoring.
    Confirmed

      constructor(options: WebGroupOptions = {}) {
        const wc = new WebChannel(options)
        wcs.set(this, wc)
    
        /**
    Severity: Major
    Found in src/WebChannelFacade.ts - About 4 hrs to fix

      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 setLogLevel has 105 lines of code (exceeds 25 allowed). Consider refactoring.
        Confirmed

        export function setLogLevel(...levels: LogLevel[]) {
          logLevels = levels
          if (logLevels.includes(LogLevel.WEB_GROUP)) {
            log.webgroup = (msg: string, ...rest: any[]): void => {
              if (rest.length === 0) {
        Severity: Major
        Found in src/misc/util.log.ts - About 4 hrs to fix

          File ChannelBuilder.ts has 322 lines of code (exceeds 250 allowed). Consider refactoring.
          Confirmed

          import { merge, Observable, Subject } from 'rxjs'
          
          import { Channel } from '../../Channel'
          import { isWebRTCSupported, isWebSocketSupported, log } from '../../misc/util'
          import { channelBuilder as proto } from '../../proto/index'
          Severity: Minor
          Found in src/service/channelBuilder/ChannelBuilder.ts - About 3 hrs to fix

            Function handleMessage has 91 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              private handleMessage(
                streamId: number,
                senderId: number,
                recipientId: number,
                msg: proto.Message
            Severity: Major
            Found in src/service/channelBuilder/ChannelBuilder.ts - About 3 hrs to fix

              Function handleMessage has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
              Open

                private handleMessage(
                  streamId: number,
                  senderId: number,
                  recipientId: number,
                  msg: proto.Message
              Severity: Minor
              Found in src/service/channelBuilder/ChannelBuilder.ts - About 3 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 constructor has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
              Confirmed

                constructor(options: WebGroupOptions = {}) {
                  const wc = new WebChannel(options)
                  wcs.set(this, wc)
              
                  /**
              Severity: Minor
              Found in src/WebChannelFacade.ts - About 3 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 initHandlers has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
              Open

                private initHandlers() {
                  // Configure handlers
                  this.wsOrDc.onmessage = ({ data }: { data: ArrayBuffer }) => {
                    try {
                      const msg = Message.decode(new Uint8Array(data))
              Severity: Minor
              Found in src/Channel.ts - About 3 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

              WebChannel has 27 functions (exceeds 20 allowed). Consider refactoring.
              Confirmed

              export class WebChannel implements IStream<OutWcMessage, InWcMsg> {
                public readonly STREAM_ID = 2
                public members: number[]
                public topologyEnum: TopologyEnum
                public myId: number
              Severity: Minor
              Found in src/WebChannel.ts - About 3 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 constructor has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                  Confirmed

                    constructor(options: BotOptions) {
                      botServer = new BotServer(options)
                  
                      /**
                       * Read-only NodeJS http server instance.
                  Severity: Major
                  Found in src/BotFacade.ts - About 2 hrs to fix

                    Function reconnectToSignaling has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                    Open

                      private reconnectToSignaling() {
                        if (this.members.length === 1 && (!isVisible() || !isOnline())) {
                          this.internalLeave()
                        } else {
                          log.webgroup(`reconnect to Signaling server in ${REJOIN_TIMEOUT}ms`)
                    Severity: Minor
                    Found in src/WebChannel.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 handleMessage has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                    Confirmed

                      handleMessage(msg: proto.Message) {
                        if (msg.type) {
                          switch (msg.type) {
                            case 'offer':
                              log.webrtc('REMOTE OFFER', { offer: msg.offer })
                    Severity: Major
                    Found in src/service/dataChannelBuilder/Remote.ts - About 2 hrs to fix

                      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 setTopology has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          private setTopology(topologyEnum: TopologyEnum): void {
                            this.topologyEnum = topologyEnum
                            this.topology = new FullMesh(this)
                            this.topology.onState.subscribe((state: TopologyState) => {
                              log.webgroup('Topology state: ', TopologyState[state])
                        Severity: Minor
                        Found in src/WebChannel.ts - About 1 hr to fix

                          Function decodeUserMessage has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            decodeUserMessage(bytes: Uint8Array, senderId: number): UserDataType | undefined {
                              try {
                                const { length, type, contentType, full, chunk } = super.decode(bytes) as {
                                  length: number
                                  type: proto.Message.Type
                          Severity: Minor
                          Found in src/service/UserMessage.ts - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language