trufflesuite/truffle

View on GitHub
packages/dashboard-message-bus-client/lib/connection/index.ts

Summary

Maintainability
C
1 day
Test Coverage

Function connect has 120 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  async connect(): Promise<void> {
    if (this._socket) {
      switch (this._socket.readyState) {
        case WebSocket.CONNECTING:
          debug(
Severity: Major
Found in packages/dashboard-message-bus-client/lib/connection/index.ts - About 4 hrs to fix

    File index.ts has 277 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import WebSocket from "isomorphic-ws";
    
    // must polyfill AbortController to use axios >=0.20.0, <=0.27.2 on node <= v14.x
    import "../polyfill";
    import axios from "axios";
    Severity: Minor
    Found in packages/dashboard-message-bus-client/lib/connection/index.ts - About 2 hrs to fix

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

              (resolve, reject) => {
                return {
                  open: () => {
                    debug(
                      "connect: %s connection succeeded to url %s",
      Severity: Minor
      Found in packages/dashboard-message-bus-client/lib/connection/index.ts - About 1 hr to fix

        Function _getMessageBusPort has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          private async _getMessageBusPort(): Promise<number> {
            if (this._connectionType === "subscribe" && this._subscribePort) {
              return this._subscribePort;
            }
        
        
        Severity: Minor
        Found in packages/dashboard-message-bus-client/lib/connection/index.ts - About 1 hr to fix

          Function connect has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

            async connect(): Promise<void> {
              if (this._socket) {
                switch (this._socket.readyState) {
                  case WebSocket.CONNECTING:
                    debug(
          Severity: Minor
          Found in packages/dashboard-message-bus-client/lib/connection/index.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

          There are no issues that match your filters.

          Category
          Status