keymetrics/pm2-io-agent-node

View on GitHub

Showing 10 of 12 total issues

Function listenForLogs has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  listenForLogs () {
    const send = this.send.bind(this, 'logs')
    let isTemporalyLogging = false // used for startLogging and stopLogging

    // Listen actions
Severity: Minor
Found in src/index.js - About 1 hr to fix

    Function listenForLogs has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

      listenForLogs () {
        const send = this.send.bind(this, 'logs')
        let isTemporalyLogging = false // used for startLogging and stopLogging
    
        // Listen actions
    Severity: Minor
    Found in src/index.js - 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 connect has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      connect (cb) {
        debug('Connect transporter to websocket server')
    
        try {
          this.ws = new WebSocket(this.endpoint, {
    Severity: Minor
    Found in src/transport.js - About 1 hr to fix

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

        static open (opts, cb) {
          const http = this.getModule(opts.url)
          const parsedUrl = url.parse(opts.url)
          let data = null
          const options = {
      Severity: Minor
      Found in src/utils/http.js - About 1 hr to fix

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

          start () {
            return new Promise((resolve, reject) => {
              if (this.isStopping) return reject(new Error('Agent is stopping'))
        
              // Trying to check infos
        Severity: Minor
        Found in src/index.js - About 1 hr to fix

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

            constructor (config, proc) {
              // Valid config
              if (!config ||
                typeof config.publicKey !== 'string' ||
                typeof config.secretKey !== 'string' ||
          Severity: Minor
          Found in src/index.js - About 1 hr to fix

            Consider simplifying this complex logical expression.
            Open

                if (!config ||
                  typeof config.publicKey !== 'string' ||
                  typeof config.secretKey !== 'string' ||
                  typeof config.appName !== 'string' ||
                  (typeof config.proxy !== 'undefined' && typeof config.proxy !== 'string') ||
            Severity: Major
            Found in src/index.js - About 1 hr to fix

              Function constructor has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                constructor (config, proc) {
                  // Valid config
                  if (!config ||
                    typeof config.publicKey !== 'string' ||
                    typeof config.secretKey !== 'string' ||
              Severity: Minor
              Found in src/index.js - About 55 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

              Avoid too many return statements within this function.
              Open

                    return cb(null, data.endpoints)
              Severity: Major
              Found in src/index.js - About 30 mins to fix

                Function send has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  send (packet) {
                    if (!packet.channel || !packet.payload) return false
                    if (!this.isConnected()) {
                      this.bufferPacket(packet)
                      return false
                Severity: Minor
                Found in src/transport.js - About 25 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

                Severity
                Category
                Status
                Source
                Language