keymetrics/pm2-io-apm

View on GitHub
src/profilers/inspectorProfiler.ts

Summary

Maintainability
C
1 day
Test Coverage

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

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

      Function onCPUProfileStart has 36 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/inspectorProfiler.ts - About 1 hr to fix

        Function onCPUProfileStop has 33 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/inspectorProfiler.ts - About 1 hr to fix

          Function onHeapdump has 32 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/inspectorProfiler.ts - About 1 hr to fix

            Function onHeapProfileStop has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

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

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

                init () {
                  this.profiler = ServiceManager.get('inspector')
                  if (this.profiler === undefined) {
                    Configuration.configureModule({
                      heapdump: false,
              Severity: Minor
              Found in src/profilers/inspectorProfiler.ts - About 1 hr to fix

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

                There are no issues that match your filters.

                Category
                Status