keymetrics/pm2-io-apm

View on GitHub

Showing 121 of 129 total issues

Function getPatchEmitFunction has 58 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  private getPatchEmitFunction () {
    const plugin = this
    return (original: RequestFunction): Func<http2.ClientHttp2Stream> => {
      return function patchedEmit (
                 this: http2.Http2Server, event: string,
Severity: Major
Found in src/census/plugins/http2.ts - About 2 hrs to fix

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

            return function outgoingRequest (
                       options: httpModule.RequestOptions | string,
                       callback): httpModule.ClientRequest {
              if (!options) {
                return original.apply(this, arguments)
      Severity: Major
      Found in src/census/plugins/http.ts - About 2 hrs to fix

        Function patchedEmit has 50 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              return function patchedEmit (
                         this: http2.Http2Server, event: string,
                         stream: http2.ServerHttp2Stream,
                         headers: http2.IncomingHttpHeaders): http2.ClientHttp2Stream {
                if (event !== 'stream') {
        Severity: Minor
        Found in src/census/plugins/http2.ts - About 2 hrs to fix

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

          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 metrics has 47 lines of code (exceeds 25 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

            Function listener has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              private listener (data) {
                this.logger(`Received new message from reverse`)
                if (!data) return false
            
                const actionName = data.msg ? data.msg : data.action_name ? data.action_name : data
            Severity: Minor
            Found in src/services/actions.ts - About 1 hr to fix

              Function aggregate has 45 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                aggregate (packet) {
                  if (this.validateData(packet) === false) return false
              
                  // Get http path of current span
                  let path = packet.spans[0].labels['http/path']
              Severity: Minor
              Found in src/utils/transactionAggregator.ts - About 1 hr to fix

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

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

                    init (): void {
                      this.transport = ServiceManager.get('transport')
                      if (this.transport === null) return this.logger('Failed to init metrics service cause no transporter')
                  
                      this.logger('init')
                  Severity: Minor
                  Found in src/services/metrics.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 getPatchIncomingRequestFunction has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    protected getPatchIncomingRequestFunction () {
                      return (original: (event: string) => boolean) => {
                        const plugin = this
                        // This function's signature is that of an event listener, which can have
                        // any number of variable-type arguments.
                  Severity: Minor
                  Found in src/census/plugins/net.ts - About 1 hr to fix

                    Function getMakeHttp2RequestTraceFunction has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      private getMakeHttp2RequestTraceFunction (
                          request: http2.ClientHttp2Stream, headers: http2.OutgoingHttpHeaders,
                          authority: string, plugin: Http2Plugin): Func<http2.ClientHttp2Stream> {
                        return (span: Span): http2.ClientHttp2Stream => {
                          if (!span) return request
                    Severity: Minor
                    Found in src/census/plugins/http2.ts - About 1 hr to fix

                      Function getPatchSendCommand has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

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

                        Function compareList has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                        Open

                          compareList (one: any[], two: any[]) {
                            if (one.length !== two.length) return false
                        
                            for (let i = 0; i < one.length; i++) {
                              if (one[i].name !== two[i].name) return false
                        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 13 (exceeds 5 allowed). Consider refactoring.
                        Open

                          init (config: IOConfig): void {
                            this.logger('init tracing')
                        
                            if (config.tracing === undefined) {
                              config.tracing = defaultTracingConfig
                        Severity: Minor
                        Found in src/features/tracing.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 listener has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                        Open

                          private listener (data) {
                            this.logger(`Received new message from reverse`)
                            if (!data) return false
                        
                            const actionName = data.msg ? data.msg : data.action_name ? data.action_name : data
                        Severity: Minor
                        Found in src/services/actions.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 incomingRequest has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                              return function incomingRequest (event: string, ...args: any[]): boolean {
                                // Only traces request events
                                if (event !== 'connection') {
                                  return original.apply(this, arguments)
                                }
                        Severity: Minor
                        Found in src/census/plugins/net.ts - About 1 hr to fix

                          Function registerAction has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            registerAction (actionName?: string, opts?: Object | undefined | Function, handler?: Function): void {
                              if (typeof opts === 'function') {
                                handler = opts
                                opts = undefined
                              }
                          Severity: Minor
                          Found in src/services/actions.ts - About 1 hr to fix

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

                              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
                                Severity
                                Category
                                Status
                                Source
                                Language