snowplow/snowplow-javascript-tracker

View on GitHub

Showing 153 of 352 total issues

Function globalContexts has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function globalContexts(): GlobalContexts {
  let globalPrimitives: Array<ContextPrimitive> = [];
  let conditionalProviders: Array<ConditionalContextProvider> = [];

  /**
Severity: Major
Found in libraries/tracker-core/src/contexts.ts - About 2 hrs to fix

    Function createSharedState has 51 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function createSharedState(): SharedState {
      const sharedState = new SharedState(),
        documentAlias = document,
        windowAlias = window;
    
    
    Severity: Major
    Found in libraries/browser-tracker-core/src/state.ts - About 2 hrs to fix

      Function parseIdCookie has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function parseIdCookie(
        id: string | undefined,
        domainUserId: string,
        memorizedSessionId: string,
        memorizedVisitCount: number
      Severity: Major
      Found in libraries/browser-tracker-core/src/tracker/id_cookie.ts - About 2 hrs to fix

        Consider simplifying this complex logical expression.
        Open

          if (isExtendedFormat) {
            /* Index is used by Enrich, so it should not be changed. */
            crossDomainParameterValue = [
              domainUserId,
              timestamp,
        Severity: Critical
        Found in libraries/browser-tracker-core/src/helpers/cross_domain.ts - About 2 hrs to fix

          Function PerformanceTimingPlugin has 49 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function PerformanceTimingPlugin(): BrowserPlugin {
            /**
             * Creates a context from the window.performance.timing object
             *
             * @returns object PerformanceTiming context
          Severity: Minor
          Found in plugins/browser-plugin-performance-timing/src/index.ts - About 1 hr to fix

            Function tracker has 48 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export function tracker(
              emitters: Emitter | Array<Emitter>,
              namespace: string,
              appId: string,
              encodeBase64: boolean
            Severity: Minor
            Found in trackers/node-tracker/src/tracker.ts - About 1 hr to fix

              Function matchSchemaAgainstRuleSet has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

              export function matchSchemaAgainstRuleSet(ruleSet: RuleSet, schema: string): boolean {
                let rejectCount = 0;
                let acceptCount = 0;
                const acceptRules = ruleSet['accept'];
                if (Array.isArray(acceptRules)) {
              Severity: Minor
              Found in libraries/tracker-core/src/contexts.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 OptimizelyXPlugin has 45 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function OptimizelyXPlugin(): BrowserPlugin {
                /**
                 * Check that *both* optimizely and optimizely.get exist
                 *
                 * @param property - optimizely data property
              Severity: Minor
              Found in plugins/browser-plugin-optimizely-x/src/index.ts - About 1 hr to fix

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

                export function base64decode(encodedData: string): string {
                  //  discuss at: http://locutus.io/php/base64_decode/
                  // original by: Tyler Akins (http://rumkin.com)
                  // improved by: Thunder.m
                  // improved by: Kevin van Zonneveld (http://kvz.io)
                Severity: Minor
                Found in libraries/tracker-core/src/base64.ts - About 1 hr to fix

                  Function getPerformanceTimingContext has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    function getPerformanceTimingContext() {
                      var windowAlias = window,
                        performanceAlias =
                          windowAlias.performance ||
                          windowAlias.mozPerformance ||
                  Severity: Minor
                  Found in plugins/browser-plugin-performance-timing/src/index.ts - About 1 hr to fix

                    Function addFormListeners has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export function addFormListeners(tracker: BrowserTracker, configuration: FormTrackingConfiguration) {
                      const { options, context } = configuration,
                        trackingMarker = tracker.id + 'form',
                        config = getConfigurationForOptions(options);
                    
                    
                    Severity: Minor
                    Found in plugins/browser-plugin-form-tracking/src/helpers.ts - About 1 hr to fix

                      Function ClientHintsPlugin has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export function ClientHintsPlugin(includeHighEntropy?: boolean): BrowserPlugin {
                        const populateClientHints = () => {
                          const navigatorAlias = navigator;
                          const uaData = navigatorAlias.userAgentData;
                      
                      
                      Severity: Minor
                      Found in plugins/browser-plugin-client-hints/src/index.ts - About 1 hr to fix

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

                        export function payloadBuilder(): PayloadBuilder {
                          const dict: Payload = {},
                            allJson: EventJson = [],
                            jsonForProcessing: EventJson = [],
                            contextEntitiesForProcessing: SelfDescribingJson[] = [];
                        Severity: Minor
                        Found in libraries/tracker-core/src/payload.ts - About 1 hr to fix

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

                            function applyAsyncFunction(...args: any[]) {
                              // Outer loop in case someone push'es in zarg of arrays
                              for (let i = 0; i < args.length; i += 1) {
                                let parameterArray = args[i],
                                  input = Array.prototype.shift.call(parameterArray);
                          Severity: Minor
                          Found in trackers/javascript-tracker/src/in_queue.ts - About 1 hr to fix

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

                            export function trackingOptionsParser(id: string | YT.Player, conf?: MediaTrackingOptions): TrackingOptions {
                              const player = typeof id === 'string' ? undefined : id;
                              const elementId = typeof id === 'string' ? id : id.getIframe().id;
                              const defaultBoundaries = [10, 25, 50, 75];
                              const defaultUpdateRate = 500;
                            Severity: Minor
                            Found in plugins/browser-plugin-youtube-tracking/src/index.ts - About 1 hr to fix

                              Function installAndRun has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              function installAndRun(logger, packageName, packageVersion, packageBinName, packageBinArgs) {
                                  const rushJsonFolder = findRushJsonFolder();
                                  const rushCommonFolder = path.join(rushJsonFolder, 'common');
                                  const rushTempFolder = _getRushTempFolder(rushCommonFolder);
                                  const packageInstallFolder = _ensureAndJoinPath(rushTempFolder, 'install-run', `${packageName}@${packageVersion}`);
                              Severity: Minor
                              Found in common/scripts/install-run.js - About 1 hr to fix

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

                                export function isRuleSet(input: unknown): input is Record<string, unknown> {
                                  const ruleSet = input as Record<string, unknown>;
                                  let ruleCount = 0;
                                  if (input != null && typeof input === 'object' && !Array.isArray(input)) {
                                    if (Object.prototype.hasOwnProperty.call(ruleSet, 'accept')) {
                                Severity: Minor
                                Found in libraries/tracker-core/src/contexts.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 ClientHintsPlugin has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                                Open

                                export function ClientHintsPlugin(includeHighEntropy?: boolean): BrowserPlugin {
                                  const populateClientHints = () => {
                                    const navigatorAlias = navigator;
                                    const uaData = navigatorAlias.userAgentData;
                                
                                
                                Severity: Minor
                                Found in plugins/browser-plugin-client-hints/src/index.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 cookie has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                                Open

                                export function cookie(
                                  name: string,
                                  value?: string,
                                  ttl?: number,
                                  path?: string,
                                Severity: Minor
                                Found in libraries/browser-tracker-core/src/helpers/index.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 parseIdCookie has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                                Open

                                export function parseIdCookie(
                                  id: string | undefined,
                                  domainUserId: string,
                                  memorizedSessionId: string,
                                  memorizedVisitCount: number
                                Severity: Minor
                                Found in libraries/browser-tracker-core/src/tracker/id_cookie.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

                                Severity
                                Category
                                Status
                                Source
                                Language