keymetrics/pm2-io-apm

View on GitHub

Showing 121 of 129 total issues

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 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 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 assertSpanAttributes has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    span: Span, httpStatusCode: number, httpMethod: string, hostName: string,
    path: string, userAgent?: string) {
Severity: Minor
Found in src/census/plugins/__tests__/http2.spec.ts - About 45 mins 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 assertSpanAttributes has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        span: Span, httpStatusCode: number, httpMethod: string, hostName: string,
        path: string, userAgent?: string) {
    Severity: Minor
    Found in src/census/plugins/__tests__/https.spec.ts - About 45 mins 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 assertSpanAttributes has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          span: Span, httpStatusCode: number, httpMethod: string, hostName: string,
          path: string, userAgent?: string) {
      Severity: Minor
      Found in src/census/plugins/__tests__/http.spec.ts - About 45 mins to fix

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

        Consider simplifying this complex logical expression.
        Open

                if (typeof (options) === 'string') {
                  const parsedUrl = url.parse(options)
                  options = parsedUrl
                  pathname = parsedUrl.pathname || '/'
                  origin = `${parsedUrl.protocol || 'http:'}//${parsedUrl.host}`
        Severity: Major
        Found in src/census/plugins/http.ts - About 40 mins to fix

          Function doNock has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              url: string, path: string, httpCode: number, respBody: string,
              times?: number) {
          Severity: Minor
          Found in src/census/plugins/__tests__/http.spec.ts - About 35 mins to fix

            Function doNock has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                url: string, path: string, httpCode: number, respBody: string,
                times?: number) {
            Severity: Minor
            Found in src/census/plugins/__tests__/https.spec.ts - About 35 mins to fix

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

                patchEnd (span: Span, resultHandler: Function): Function {
                  const plugin = this
                  const patchedEnd = function (err, res) {
                    if (plugin.options.detailedCommands === true && err instanceof Error) {
                      span.addAttribute('error', err.message)
              Severity: Minor
              Found in src/census/plugins/mysql2.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

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

                patchEnd (span: Span, resultHandler: Function): Function {
                  const plugin = this
                  const patchedEnd = function (err, res) {
                    if (plugin.options.detailedCommands === true && err instanceof Error) {
                      span.addAttribute('error', err.message)
              Severity: Minor
              Found in src/census/plugins/mysql.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

              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 (one[i].labels.length !== two[i].labels.length) return false
              Severity: Major
              Found in src/utils/transactionAggregator.ts - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                          return plugin.tracer.startRootSpan(
                              traceOptions,
                              plugin.getMakeRequestTraceFunction(request, options, plugin))
                Severity: Major
                Found in src/census/plugins/http.ts - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                            return original.apply(this, arguments)
                  Severity: Major
                  Found in src/census/plugins/redis.ts - About 30 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language