coast-team/netflux

View on GitHub

Showing 73 of 75 total issues

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

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

                  constructor(
                    wc: WebChannel,
                    wsOrDc: WebSocket | RTCDataChannel,
                    type: number,
                    id: number,
                Severity: Minor
                Found in src/Channel.ts - About 1 hr to fix

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                            connection.reject = (err) => {
                              // This is necessary for some scenarios in order to rid of UnhandledPromiseRejectionWarning errors in NodeJS and similar errors/warnings in browsers
                              connection.promise.catch(() => {})
                              clearTimeout(connectionTimer)
                              this.connections.delete(id)
                  Severity: Major
                  Found in src/service/channelBuilder/ConnectionsInProgress.ts and 1 other location - About 1 hr to fix
                  src/service/channelBuilder/ConnectionsInProgress.ts on lines 54..60

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 68.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                        connection.reject = (err) => {
                          // This is necessary for some scenarios in order to rid of UnhandledPromiseRejectionWarning errors in NodeJS and similar errors/warnings in browsers
                          connection.promise.catch(() => {})
                          clearTimeout(responseTimer)
                          this.connections.delete(id)
                  Severity: Major
                  Found in src/service/channelBuilder/ConnectionsInProgress.ts and 1 other location - About 1 hr to fix
                  src/service/channelBuilder/ConnectionsInProgress.ts on lines 45..51

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 68.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

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

                    constructor(
                      id: number,
                      pc: RTCPeerConnection,
                      send: (msg: proto.IMessage) => void,
                      remotes: Map<number, Remote>,
                  Severity: Minor
                  Found in src/service/dataChannelBuilder/Remote.ts - About 1 hr to fix

                    Function initHandlers has 38 lines of code (exceeds 25 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 1 hr to fix

                      Function create has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        create(
                          id: number,
                          connectionTimeout: number,
                          responseTimeout: number,
                          onConnectionTimeoutCallback: () => void
                      Severity: Minor
                      Found in src/service/channelBuilder/ConnectionsInProgress.ts - About 1 hr to fix

                        Function init has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                        Confirmed

                          private init(): void {
                            this.webSocketServer = new Server({
                              perMessageDeflate: this.perMessageDeflate,
                              verifyClient: (info: any) => this.validateURLQuery(info),
                              server: this.server,
                        Severity: Minor
                        Found in src/Bot.ts - About 1 hr to fix

                          Similar blocks of code found in 2 locations. Consider refactoring.
                          Open

                                if (!theOther.dcTried) {
                                  log.channelBuilder(`Prompt the other to connect over RTCDataChannel`)
                                  this.allStreams.sendOver(
                                    streamId,
                                    { negotiation: { initiator, passive } },
                          Severity: Major
                          Found in src/service/channelBuilder/ChannelBuilder.ts and 1 other location - About 1 hr to fix
                          src/service/channelBuilder/ChannelBuilder.ts on lines 230..239

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 64.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Severity
                          Category
                          Status
                          Source
                          Language