keymetrics/pm2-io-apm

View on GitHub
src/profilers/addonProfiler.ts

Summary

Maintainability
B
5 hrs
Test Coverage

Function init has 33 lines of code (exceeds 25 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 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 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 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 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 onCPUProfileStart has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

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

          There are no issues that match your filters.

          Category
          Status