snowplow/snowplow-javascript-tracker

View on GitHub

Showing 145 of 325 total issues

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

export function isFilterProvider(input: unknown): boolean {
  if (Array.isArray(input)) {
    if (input.length === 2) {
      if (Array.isArray(input[1])) {
        return isContextCallbackFunction(input[0]) && input[1].every(isContextPrimitive);
Severity: Minor
Found in libraries/tracker-core/src/contexts.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 getQuerystring has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function getQuerystring(request: Payload) {
  let lowPriorityKeys: { [key: string]: boolean } = { co: true, cx: true };

  let args: string[] = [];

Severity: Minor
Found in libraries/tracker-core/src/emitter/emitter_event.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

      return false;
Severity: Major
Found in libraries/browser-tracker-core/src/tracker/index.ts - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

          if (Array.isArray(primitivesB)) return false;
    Severity: Major
    Found in libraries/tracker-core/src/contexts.ts - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return currentUrl.pathname != previousUrl.pathname || currentUrl.search != previousUrl.search;
      Severity: Major
      Found in libraries/browser-tracker-core/src/tracker/index.ts - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

          return false;
        Severity: Major
        Found in libraries/tracker-core/src/contexts.ts - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

            return document.referrer;
          Severity: Major
          Found in libraries/browser-tracker-core/src/helpers/index.ts - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                if (!isContextPrimitive(b)) return false;
            Severity: Major
            Found in libraries/tracker-core/src/contexts.ts - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return currentUrl.pathname != previousUrl.pathname;
              Severity: Major
              Found in libraries/browser-tracker-core/src/tracker/index.ts - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                      return compareProviderPart(primitivesA, primitivesB);
                Severity: Major
                Found in libraries/tracker-core/src/contexts.ts - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                    return false;
                  Severity: Major
                  Found in libraries/tracker-core/src/contexts.ts - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                        return compareProviderPart(a, b);
                    Severity: Major
                    Found in libraries/tracker-core/src/contexts.ts - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                        return findMediaElementChild(el);
                      Severity: Major
                      Found in plugins/browser-plugin-media-tracking/src/findElem.ts - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                          return false;
                        Severity: Major
                        Found in libraries/tracker-core/src/contexts.ts - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                return primitivesA.reduce<boolean>((matches, a, i) => matches && compareProviderPart(a, primitivesB[i]), true);
                          Severity: Major
                          Found in libraries/tracker-core/src/contexts.ts - About 30 mins to fix

                            Function sendError has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                            function sendError(
                              {
                                errorEvent,
                                commonContext,
                                contextAdder,
                            Severity: Minor
                            Found in plugins/browser-plugin-error-tracking/src/index.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

                            Function sendRequest has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                            function sendRequest(url: string, userId: string, LOG: Logger, successCallback: () => void): void {
                              const xhr = new XMLHttpRequest();
                              xhr.open('GET', getKantarURL(url, userId));
                              xhr.timeout = 5000;
                            
                            
                            Severity: Minor
                            Found in plugins/browser-plugin-focalmeter/src/index.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

                            Function getSpecifiedClassesSet has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                            function getSpecifiedClassesSet<T>(criterion: FilterCriterion<T>) {
                              // Convert the array of classes to an object of the form {class1: true, class2: true, ...}
                              var specifiedClassesSet: Record<string, boolean> = {};
                              var specifiedClasses = criterion.allowlist || criterion.denylist;
                            
                            
                            Severity: Minor
                            Found in libraries/browser-tracker-core/src/helpers/index.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

                            Function filterFunctionFromFilter has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                            export function filterFunctionFromFilter(filter?: Filter): FilterFunction {
                              // If a function is provided, return it as-is
                              if (typeof filter === 'function') {
                                return filter;
                              }
                            Severity: Minor
                            Found in plugins/browser-plugin-button-click-tracking/src/util.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

                            Function findRootDomain has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                            export function findRootDomain(sameSite: string, secure: boolean) {
                              const windowLocationHostnameAlias = window.location.hostname,
                                cookiePrefix = '_sp_root_domain_test_',
                                cookieName = cookiePrefix + new Date().getTime(),
                                cookieValue = '_test_value_' + new Date().getTime();
                            Severity: Minor
                            Found in libraries/browser-tracker-core/src/helpers/index.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