senecajs/seneca-telemetry-newrelic

View on GitHub

Showing 8 of 16 total issues

Function newrelic has 63 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function newrelic(this: any, options: NewRelicOptions) {
    const isPluginEnabled = options && options.enabled

    if(!isPluginEnabled) {
      return
Severity: Major
Found in src/newrelic.ts - About 2 hrs to fix

    Function MetricsCollector has 52 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function MetricsCollector(metricApiKey: string) {
      const metricsClient = new MetricClient({
        apiKey: metricApiKey,
      });
    
    
    Severity: Major
    Found in src/metrics-collector.ts - About 2 hrs to fix

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

      function preload(this: any, opts: any) {
        const seneca = this;
        const { options }: { options: NewRelicOptions } = opts;
        const isPluginEnabled = options && options.enabled
      
      
      Severity: Minor
      Found in src/newrelic.ts - About 1 hr to fix

        Function sendTracing has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          sendTracing(spec: TelemetrySpecMetadata): Promise<string|void|boolean> {
            return new Promise((resolve, reject) => {
              const spanBatch = new SpanBatch();
        
              const span = new Span(
        Severity: Minor
        Found in src/tracing-collector.ts - About 1 hr to fix

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

          function addSegment(spec: Spec) {
            if (spec.ctx.actdef?.func) {
              const { ctx, data } = spec
              const pattern = ctx.actdef.pattern
              const origfunc = ctx.actdef.func
          Severity: Minor
          Found in src/newrelic.ts - About 1 hr to fix

            Function _updateSpecList has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              async _updateSpecList(specMetadata: TelemetrySpecMetadata) {
                const spec = this.specList.find((s) => s.mi_id === specMetadata.mi_id);
                if (spec) {
                  Object.assign(spec, specMetadata);
                  if (spec.manualEndTime && spec.manualStartTime && !spec.dispatched) {
            Severity: Minor
            Found in src/tracing-collector.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 preload has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            function preload(this: any, opts: any) {
              const seneca = this;
              const { options }: { options: NewRelicOptions } = opts;
              const isPluginEnabled = options && options.enabled
            
            
            Severity: Minor
            Found in src/newrelic.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 MetricsCollector has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            export function MetricsCollector(metricApiKey: string) {
              const metricsClient = new MetricClient({
                apiKey: metricApiKey,
              });
            
            
            Severity: Minor
            Found in src/metrics-collector.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

            Severity
            Category
            Status
            Source
            Language