keymetrics/pm2-io-apm

View on GitHub

Showing 76 of 82 total issues

Function init has 117 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  init (config?: RuntimeMetricsOptions | boolean) {
    if (config === false) return
    if (config === undefined) {
      config = defaultOptions
    }
Severity: Major
Found in src/metrics/runtime.ts - About 4 hrs to fix

    File transactionAggregator.ts has 336 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    'use strict'
    
    import * as Debug from 'debug'
    import { EventEmitter2 } from 'eventemitter2'
    import EWMA from './EWMA'
    Severity: Minor
    Found in src/utils/transactionAggregator.ts - About 4 hrs to fix

      Function matchPath has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

        matchPath (path, routes) {
          // empty route is / without the fist slash
          if (!path || !routes) return false
          if (path === '/') return routes[path] ? path : null
      
      
      Severity: Minor
      Found in src/utils/transactionAggregator.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 init has 83 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        init (config?: EventLoopMetricOption | boolean) {
          if (config === false) return
          if (config === undefined) {
            config = defaultOptions
          }
      Severity: Major
      Found in src/metrics/eventLoopMetrics.ts - About 3 hrs to fix

        Function init has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
        Open

          init (config?: RuntimeMetricsOptions | boolean) {
            if (config === false) return
            if (config === undefined) {
              config = defaultOptions
            }
        Severity: Minor
        Found in src/metrics/runtime.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 init has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

          init (config?: V8MetricsConfig | boolean) {
            if (config === false) return
            if (config === undefined) {
              config = defaultOptions
            }
        Severity: Minor
        Found in src/metrics/v8.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 prepareAggregationforShipping has 66 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          prepareAggregationforShipping () {
            let routes = this.cache.routes
        
            const normalized: Trace = {
              routes: [],
        Severity: Major
        Found in src/utils/transactionAggregator.ts - About 2 hrs to fix

          Function init has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

            init (config?: EventLoopMetricOption | boolean) {
              if (config === false) return
              if (config === undefined) {
                config = defaultOptions
              }
          Severity: Minor
          Found in src/metrics/eventLoopMetrics.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 init has 61 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            static init (conf, doNotTellPm2?) {
              const packageFilepath = Configuration.findPackageJson()
              let packageJson
          
              if (!conf.module_conf) {
          Severity: Major
          Found in src/configuration.ts - About 2 hrs to fix

            Function init has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
            Open

              static init (conf, doNotTellPm2?) {
                const packageFilepath = Configuration.findPackageJson()
                let packageJson
            
                if (!conf.module_conf) {
            Severity: Minor
            Found in src/configuration.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

            File inspectorProfiler.ts has 263 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            
            import { ProfilerType } from '../features/profiling'
            import Configuration from '../configuration'
            import { ServiceManager } from '../serviceManager'
            import { Transport } from '../services/transport'
            Severity: Minor
            Found in src/profilers/inspectorProfiler.ts - About 2 hrs to fix

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

                _sink (sinkIndex) {
                  const sinkElement = this._elements[sinkIndex]
                  const sinkScore = this._score(sinkElement)
                  const length = this._elements.length
              
              
              Severity: Minor
              Found in src/utils/BinaryHeap.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 metrics has 47 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                metrics (metric: MetricBulk | Array<MetricBulk>): any[] {
              
                  const res: any[] = []
                  // tslint:disable-next-line
                  if (metric === undefined || metric === null) {
              Severity: Minor
              Found in src/pmx.ts - About 1 hr to fix

                Function listener has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  private listener (data) {
                    this.logger(`Received new message from reverse`)
                    if (!data) return false
                
                    const actionName = data.msg ? data.msg : data.action_name ? data.action_name : data
                Severity: Minor
                Found in src/services/actions.ts - About 1 hr to fix

                  Function aggregate has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    aggregate (packet) {
                      if (this.validateData(packet) === false) return false
                  
                      // Get http path of current span
                      let path = packet.spans[0].labels['http/path']
                  Severity: Minor
                  Found in src/utils/transactionAggregator.ts - About 1 hr to fix

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

                      init (config?: IOConfig) {
                        const callsite = (new Error().stack || '').split('\n')[2]
                        if (callsite && callsite.length > 0) {
                          this.logger(`init from ${callsite}`)
                        }
                    Severity: Minor
                    Found in src/pmx.ts - About 1 hr to fix

                      Function init has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                      Open

                        init (): void {
                          this.transport = ServiceManager.get('transport')
                          if (this.transport === null) return this.logger('Failed to init metrics service cause no transporter')
                      
                          this.logger('init')
                      Severity: Minor
                      Found in src/services/metrics.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 listener has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                      Open

                        private listener (data) {
                          this.logger(`Received new message from reverse`)
                          if (!data) return false
                      
                          const actionName = data.msg ? data.msg : data.action_name ? data.action_name : data
                      Severity: Minor
                      Found in src/services/actions.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 compareList has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                      Open

                        compareList (one: any[], two: any[]) {
                          if (one.length !== two.length) return false
                      
                          for (let i = 0; i < one.length; i++) {
                            if (one[i].name !== two[i].name) return false
                      Severity: Minor
                      Found in src/utils/transactionAggregator.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 registerAction has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        registerAction (actionName?: string, opts?: Object | undefined | Function, handler?: Function): void {
                          if (typeof opts === 'function') {
                            handler = opts
                            opts = undefined
                          }
                      Severity: Minor
                      Found in src/services/actions.ts - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language