coast-team/netflux

View on GitHub
src/Channel.ts

Summary

Maintainability
C
1 day
Test Coverage

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

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

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

        TODO found
        Open

                  // TODO: implement when there are more than one topology implementation
        Severity: Minor
        Found in src/Channel.ts by fixme

        TODO found
        Open

                  // TODO: this is a rare case, when the joining peer id equals to the
        Severity: Minor
        Found in src/Channel.ts by fixme

        There are no issues that match your filters.

        Category
        Status