coast-team/netflux

View on GitHub

Showing 73 of 75 total issues

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

    if (me.wss && !theOther.wsTried) {
      log.channelBuilder(`Prompt the other to connect over WebSocket`)
      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 248..257

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

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

      protected useAllStreams(
        wc: IStream<OutWcMessage, InWcMsg> & WebChannel,
        sig: IStream<OutSigMsg, InSigMsg>
      ): IAllStreams<OutMsg, InMsg> {
        const wcStream = this.useWebChannelStream(wc)
    Severity: Minor
    Found in src/service/Service.ts - About 1 hr to fix

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

              sigStream.message.pipe(
                map(({ senderId, recipientId, msg }) => ({
                  streamId: sigStream.id,
                  senderId,
                  recipientId,
      Severity: Major
      Found in src/service/Service.ts and 1 other location - About 1 hr to fix
      src/service/Service.ts on lines 122..129

      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 62.

      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

              wcStream.message.pipe(
                map(({ senderId, recipientId, msg }) => ({
                  streamId: wcStream.id,
                  senderId,
                  recipientId,
      Severity: Major
      Found in src/service/Service.ts and 1 other location - About 1 hr to fix
      src/service/Service.ts on lines 130..137

      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 62.

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

          connection.promise = new Promise((resolveResponse, rejectResponse) => {
            const responseTimer = setTimeout(
              () => connection.reject(new Error(ConnectionError.RESPONSE_TIMEOUT)),
              responseTimeout
            )
      Severity: Minor
      Found in src/service/channelBuilder/ConnectionsInProgress.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

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

            join(key?: string): void {
              const wc = wcs.get(this)
              if (wc) {
                return wc.join(key)
              }
          Severity: Major
          Found in src/WebChannelFacade.ts and 1 other location - About 1 hr to fix
          src/WebChannelFacade.ts on lines 290..296

          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 61.

          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.
          Confirmed

            invite(url: string): void {
              const wc = wcs.get(this)
              if (wc) {
                return wc.invite(url)
              }
          Severity: Major
          Found in src/WebChannelFacade.ts and 1 other location - About 1 hr to fix
          src/WebChannelFacade.ts on lines 278..284

          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 61.

          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 a Cognitive Complexity of 11 (exceeds 5 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

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

            private handleInitMessage(msg: proto.Message) {
              switch (msg.type) {
                case 'initPing': {
                  log.channel(`${this.wc.myId} received InitPing`)
                  const { topology, wcId, senderId, members, key } = msg.initPing as proto.Data
          Severity: Minor
          Found in src/Channel.ts - About 1 hr to fix

            Function proceedNegotiation has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              private async proceedNegotiation(
                streamId: number,
                initiator: proto.Info,
                passive: proto.Info,
                amIInitiator: boolean
            Severity: Minor
            Found in src/service/channelBuilder/ChannelBuilder.ts - About 1 hr to fix

              Function readURLQuery has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                private readURLQuery(
                  url: string
                ): {
                  type: number
                  wcId: number
              Severity: Minor
              Found in src/Bot.ts - About 1 hr to fix

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

                    log.signalingState = (msg: string, id: number): void => {
                      console.info(
                        `%cNETFLUX ${id} WebGroup%c: Signaling: %c${msg}%c`,
                        netfluxCSS,
                        '',
                Severity: Major
                Found in src/misc/util.log.ts and 1 other location - About 1 hr to fix
                src/misc/util.log.ts on lines 69..77

                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 58.

                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

                    log.webGroupState = (msg: string, id: number): void => {
                      console.info(
                        `%cNETFLUX ${id} WebGroup%c: WebGroup: %c${msg}%c`,
                        netfluxCSS,
                        '',
                Severity: Major
                Found in src/misc/util.log.ts and 1 other location - About 1 hr to fix
                src/misc/util.log.ts on lines 60..68

                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 58.

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

                  connect(key: string): void {
                    if (isWebSocketSupported()) {
                      this.setState(SignalingState.CONNECTING)
                      this.ws = new env.WebSocket(this.fullUrl(key))
                      this.ws.binaryType = 'arraybuffer'
                Severity: Minor
                Found in src/Signaling.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,
                      wsOrDc: WebSocket | RTCDataChannel,
                      type: number,
                      id: number,
                  Severity: Minor
                  Found in src/Channel.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 constructor has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                    constructor(options: BotOptions) {
                      botServer = new BotServer(options)
                  
                      /**
                       * Read-only NodeJS http server instance.
                  Severity: Minor
                  Found in src/BotFacade.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

                  Severity
                  Category
                  Status
                  Source
                  Language