snowplow/snowplow-javascript-tracker

View on GitHub
libraries/browser-tracker-core/src/tracker/out_queue.ts

Summary

Maintainability
F
1 wk
Test Coverage

Function OutQueueManager has a Cognitive Complexity of 193 (exceeds 5 allowed). Consider refactoring.
Open

export function OutQueueManager(
  id: string,
  sharedSate: SharedState,
  useLocalStorage: boolean,
  eventMethod: string | boolean,
Severity: Minor
Found in libraries/browser-tracker-core/src/tracker/out_queue.ts - About 3 days 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 OutQueueManager has 408 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function OutQueueManager(
  id: string,
  sharedSate: SharedState,
  useLocalStorage: boolean,
  eventMethod: string | boolean,
Severity: Major
Found in libraries/browser-tracker-core/src/tracker/out_queue.ts - About 2 days to fix

    File out_queue.ts has 445 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { attemptWriteLocalStorage, isString } from '../helpers';
    import { SharedState } from '../state';
    import { localStorageAccessible } from '../detectors';
    import { LOG, Payload } from '@snowplow/tracker-core';
    import { PAYLOAD_DATA_SCHEMA } from './schemata';
    Severity: Minor
    Found in libraries/browser-tracker-core/src/tracker/out_queue.ts - About 6 hrs to fix

      Function executeQueue has 105 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        function executeQueue(sync: boolean = false) {
          // Failsafe in case there is some way for a bad value like "null" to end up in the outQueue
          while (outQueue.length && typeof outQueue[0] !== 'string' && typeof outQueue[0] !== 'object') {
            outQueue.shift();
          }
      Severity: Major
      Found in libraries/browser-tracker-core/src/tracker/out_queue.ts - About 4 hrs to fix

        Function OutQueueManager has 20 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          id: string,
          sharedSate: SharedState,
          useLocalStorage: boolean,
          eventMethod: string | boolean,
          postPath: string,
        Severity: Major
        Found in libraries/browser-tracker-core/src/tracker/out_queue.ts - About 2 hrs to fix

          Function enqueueRequest has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            function enqueueRequest(request: Payload, url: string) {
              configCollectorUrl = url + path;
              const eventTooBigWarning = (bytes: number, maxBytes: number) =>
                LOG.warn('Event (' + bytes + 'B) too big, max is ' + maxBytes);
          
          
          Severity: Minor
          Found in libraries/browser-tracker-core/src/tracker/out_queue.ts - About 1 hr to fix

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

              function setXhrCallbacks(xhr: XMLHttpRequest, numberToSend: number, batch: EventBatch) {
                xhr.onreadystatechange = function () {
                  if (xhr.readyState === 4) {
                    clearTimeout(xhrTimeout);
                    if (isSuccessfulRequest(xhr.status)) {
            Severity: Minor
            Found in libraries/browser-tracker-core/src/tracker/out_queue.ts - About 1 hr to fix

              There are no issues that match your filters.

              Category
              Status