coast-team/netflux

View on GitHub
src/WebChannel.ts

Summary

Maintainability
D
2 days
Test Coverage

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

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

          private subscribeToSignalingState() {
            this.signaling.onState.subscribe((state: SignalingState) => {
              log.signalingState(SignalingState[state], this.myId)
              this.onSignalingStateChange(state)
              switch (state) {
        Severity: Minor
        Found in src/WebChannel.ts - About 1 hr to fix

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

            constructor(options: IWebChannelOptions) {
              const { topology, autoRejoin, rtcConfiguration, signalingServer } = {
                ...webChannelDefaultOptions,
                ...options,
              }
          Severity: Minor
          Found in src/WebChannel.ts - About 1 hr to fix

            Function rejoin has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              private rejoin() {
                this.setState(WebChannelState.JOINING)
                if (!isVisible() || !isOnline()) {
                  this.internalLeave()
                } else {
            Severity: Minor
            Found in src/WebChannel.ts - About 1 hr to fix

              Function onBrowserBack has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                private onBrowserBack() {
                  if (isVisible() && isOnline()) {
                    log.webgroup('onBrowserBack', { isVisible: isVisible(), isOnline: isOnline() })
                    this.rejoinEnabled = this.autoRejoin
                    if (this.rejoinEnabled) {
              Severity: Minor
              Found in src/WebChannel.ts - About 45 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

              Function rejoin has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                private rejoin() {
                  this.setState(WebChannelState.JOINING)
                  if (!isVisible() || !isOnline()) {
                    this.internalLeave()
                  } else {
              Severity: Minor
              Found in src/WebChannel.ts - About 45 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