keymetrics/pm2-io-apm

View on GitHub

Showing 121 of 129 total issues

Function registerHttpsMetric has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  private registerHttpsMetric () {
    if (this.metricService === undefined) return this.logger(`Failed to load metric service`)
    const histogram = new Histogram()
    const p50: InternalMetric = {
      name: `HTTPS Mean Latency`,
Severity: Minor
Found in src/metrics/httpMetrics.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 internalSendCommandWrap has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          return function internalSendCommandWrap (original: Function) {
            return function internal_send_command_trace (command: IORedisCommand) {
              if (!plugin.tracer.currentRootSpan) {
                return original.apply(this, arguments)
              }
      Severity: Minor
      Found in src/census/plugins/ioredis.ts - About 1 hr to fix

        Function registerHttpMetric has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          private registerHttpMetric () {
            if (this.metricService === undefined) return this.logger(`Failed to load metric service`)
            const histogram = new Histogram()
            const p50: InternalMetric = {
              name: `HTTP Mean Latency`,
        Severity: Minor
        Found in src/metrics/httpMetrics.ts - About 1 hr to fix

          Function init has 35 lines of code (exceeds 25 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 1 hr to fix

            Function internal_send_command_trace has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  return function internal_send_command_trace (command: IORedisCommand) {
                    if (!plugin.tracer.currentRootSpan) {
                      return original.apply(this, arguments)
                    }
            
            
            Severity: Minor
            Found in src/census/plugins/ioredis.ts - About 1 hr to fix

              Function koaErrorHandler has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                koaErrorHandler () {
                  const self = this
                  Configuration.configureModule({
                    error : true
                  })
              Severity: Minor
              Found in src/features/notify.ts - About 1 hr to fix

                Function loadPlugins has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  loadPlugins (pluginList: PluginNames) {
                    if (this.hookState === HookState.UNINITIALIZED) {
                      hook(Object.keys(pluginList), (exports, name, basedir) => {
                        if (this.hookState !== HookState.ENABLED) {
                          return exports
                Severity: Minor
                Found in src/census/instrumentation/plugin-loader.ts - About 1 hr to fix

                  Function getPatchCommand has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    private getPatchCommand (label: string) {
                      const plugin = this
                      return (original: Function) => {
                        return function (ns: string, command: any, options: any, callback: Function) {
                          const resultHandler = typeof options === 'function' ? options : callback
                  Severity: Minor
                  Found in src/census/plugins/mongodb.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 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 patchSubmittable has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          private patchSubmittable (pgQuery, span) {
                            const plugin = this
                            let spanEnded = false
                            if (pgQuery.handleError) {
                              shimmer.wrap(pgQuery, 'handleError', (origCallback) => {
                        Severity: Minor
                        Found in src/census/plugins/pg.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 mergeTrace has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                            Open

                              mergeTrace (aggregated, trace) {
                                if (!aggregated || !trace) return
                            
                                // if the trace doesn't any spans stop aggregation here
                                if (trace.spans.length === 0) return
                            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 init has a Cognitive Complexity of 11 (exceeds 5 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

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

                              private getPatchSendCommand () {
                                const plugin = this
                                const addArguments = typeof this.options === 'object'
                                  && this.options.detailedCommands === true
                                return function internalSendCommandWrap (original: Function) {
                            Severity: Minor
                            Found in src/census/plugins/redis.ts - About 1 hr to fix

                              Function catchDownload has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                private catchDownload () {
                                  if (this.metricService === undefined) return this.logger(`Failed to load metric service`)
                                  const downloadMeter = new Meter({})
                              
                                  this.metricService.registerMetric({
                              Severity: Minor
                              Found in src/metrics/network.ts - About 1 hr to fix

                                Function expressErrorHandler has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  expressErrorHandler () {
                                    const self = this
                                    Configuration.configureModule({
                                      error : true
                                    })
                                Severity: Minor
                                Found in src/features/notify.ts - About 1 hr to fix

                                  Function init has 30 lines of code (exceeds 25 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 1 hr to fix

                                    Function findPackageJson has 30 lines of code (exceeds 25 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 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language