keymetrics/pm2-io-apm

View on GitHub

Showing 76 of 82 total issues

Function metrics has a Cognitive Complexity of 10 (exceeds 5 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

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

  constructor (opts?) {
    opts = opts || {}

    this._measurement = opts.measurement
    this._callFn = null
Severity: Minor
Found in src/utils/metrics/histogram.ts - About 1 hr to fix

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

      private onCPUProfileStop (cb) {
        if (this.currentProfile === null) {
          return cb({
            err: 'No profiling are already running',
            success: false
    Severity: Minor
    Found in src/profilers/addonProfiler.ts - About 1 hr to fix

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

        private hookHttp (nodule: any, name: string) {
          if (nodule.Server === undefined || nodule.Server.prototype === undefined) return
          if (this.modules[name] !== undefined) return this.logger(`Module ${name} already hooked`)
          this.logger(`Hooking to ${name} module`)
          this.modules[name] = nodule.Server.prototype
      Severity: Minor
      Found in src/metrics/httpMetrics.ts - About 1 hr to fix

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

          private onCPUProfileStart (opts, cb) {
            if (typeof cb !== 'function') {
              cb = opts
              opts = {}
            }
        Severity: Minor
        Found in src/profilers/addonProfiler.ts - About 1 hr to fix

          Function _sink has 26 lines of code (exceeds 25 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

            Function metric has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              metric (opts: Metric): Gauge {
                let metric: InternalMetric
                if (typeof opts.value === 'function') {
                  metric = {
                    name: opts.name,
            Severity: Minor
            Found in src/services/metrics.ts - About 1 hr to fix

              Function onHeapdump has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                private onHeapdump (opts, cb) {
                  if (typeof cb !== 'function') {
                    cb = opts
                    opts = {}
                  }
              Severity: Minor
              Found in src/profilers/addonProfiler.ts - About 1 hr to fix

                Function percentiles has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  percentiles (percentiles) {
                    const values = this._sample
                      .toArray()
                      .sort(function (a, b) {
                        return (a === b)
                Severity: Minor
                Found in src/utils/metrics/histogram.ts - About 1 hr to fix

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

                  export function getObjectAtPath (context: Object, path: string): any {
                    if (path.indexOf('.') === -1 && path.indexOf('[') === -1) {
                      return context[path]
                    }
                  
                  
                  Severity: Minor
                  Found in src/featureManager.ts - 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

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

                    percentiles (percentiles) {
                      const values = this._sample
                        .toArray()
                        .sort(function (a, b) {
                          return (a === b)
                  Severity: Minor
                  Found in src/utils/metrics/histogram.ts - 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

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

                    init (config?: ProfilingConfig | boolean) {
                      if (config === true) {
                        config = defaultProfilingConfig
                      } else if (config === false) {
                        config = disabledProfilingConfig
                  Severity: Minor
                  Found in src/features/profiling.ts - 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

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

                    static findPackageJson () {
                      try {
                        require.main = Configuration.getMain()
                      } catch (_e) {
                        // Ignore error when getter is set on require.main, but no setter
                  Severity: Minor
                  Found in src/configuration.ts - 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

                  Function onHeapProfileStart has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                    private onHeapProfileStart (opts, cb) {
                      if (typeof cb !== 'function') {
                        cb = opts
                        opts = {}
                      }
                  Severity: Minor
                  Found in src/profilers/inspectorProfiler.ts - About 45 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

                  Function onCPUProfileStart has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                    private onCPUProfileStart (opts, cb) {
                      if (typeof cb !== 'function') {
                        cb = opts
                        opts = {}
                      }
                  Severity: Minor
                  Found in src/profilers/inspectorProfiler.ts - About 45 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

                  Function autoExitHook has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                    private autoExitHook () {
                      // clean listener if event loop is empty
                      // important to ensure apm will not prevent application to stop
                      this.autoExitHandle = setInterval(() => {
                        let currentProcess: any = (cluster.isWorker) ? cluster.worker.process : process
                  Severity: Minor
                  Found in src/transports/IPCTransport.ts - About 45 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

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

                    init () {
                      for (const moduleName of this.modules) {
                        let path = utils.detectModule(moduleName)
                        // continue to search if we dont find it
                        if (path === null) continue
                  Severity: Minor
                  Found in src/profilers/addonProfiler.ts - About 45 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

                  Function expressErrorHandler has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                    expressErrorHandler () {
                      const self = this
                      Configuration.configureModule({
                        error : true
                      })
                  Severity: Minor
                  Found in src/features/notify.ts - About 35 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

                          if (j === 0) return segments.join('/')
                  Severity: Major
                  Found in src/utils/transactionAggregator.ts - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                return segments.join('/')
                    Severity: Major
                    Found in src/utils/transactionAggregator.ts - About 30 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language