snowplow/snowplow-javascript-tracker

View on GitHub

Showing 145 of 325 total issues

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

export function newEmitterEvent(eventStorePayload: EventStorePayload): EmitterEvent {
  let querystring: string | null = null;
  let postBody: Record<string, unknown> | null = null;
  let byteCountGET: number | null = null;
  let byteCountPOST: number | null = null;
Severity: Minor
Found in libraries/tracker-core/src/emitter/emitter_event.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 addVideoEventListeners has 48 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function addVideoEventListeners(video: HTMLMediaElement, id: string) {
          let isWaiting = false;
        
          video.addEventListener('play', () => trackMediaPlay({ id, player: updatePlayer(video) }));
        
        
        Severity: Minor
        Found in plugins/browser-plugin-media-tracking/src/player.ts - About 1 hr to fix

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

          export function newTracker(
            trackerConfiguration: TrackerConfiguration,
            emitterConfiguration: NodeEmitterConfiguration | NodeEmitterConfiguration[]
          ): Tracker {
            const { namespace, appId, encodeBase64 = true } = trackerConfiguration;
          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 newCookie has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

            function newCookie(name: string): Cookie {
              let flushTimer: ReturnType<typeof setTimeout> | undefined;
              let lastSetValueArgs: Parameters<typeof setValue> | undefined;
              let cacheExpireAt: Date | undefined;
              let flushed = true;
            Severity: Minor
            Found in libraries/browser-tracker-core/src/tracker/cookie_storage.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 _trimNpmrcFile has 47 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function _trimNpmrcFile(options) {
                const { sourceNpmrcPath, linesToPrepend, linesToAppend } = options;
                const combinedNpmrcFromCache = _combinedNpmrcMap.get(sourceNpmrcPath);
                if (combinedNpmrcFromCache !== undefined) {
                    return combinedNpmrcFromCache;
            Severity: Minor
            Found in common/scripts/install-run.js - 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 installAndRun has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function installAndRun(logger, packageName, packageVersion, packageBinName, packageBinArgs, lockFilePath = process.env[INSTALL_RUN_LOCKFILE_PATH_VARIABLE]) {
                    const rushJsonFolder = findRushJsonFolder();
                    const rushCommonFolder = path__WEBPACK_IMPORTED_MODULE_3__.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 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 track has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        function track<C = Record<string, unknown>>(
                          pb: PayloadBuilder,
                          context?: Array<SelfDescribingJson<C>> | null,
                          timestamp?: Timestamp | null
                        ): Payload | undefined {
                    Severity: Minor
                    Found in libraries/tracker-core/src/core.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 OptimizelyXPlugin has 43 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 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 _run has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              function _run() {
                                  const [nodePath /* Ex: /bin/node */, scriptPath /* /repo/common/scripts/install-run-rush.js */, ...packageBinArgs /* [build, --to, myproject] */] = process.argv;
                                  // Detect if this script was directly invoked, or if the install-run-rushx script was invokved to select the
                                  // appropriate binary inside the rush package to run
                                  const scriptName = path__WEBPACK_IMPORTED_MODULE_0__.basename(scriptPath);
                              Severity: Minor
                              Found in common/scripts/install-run-rush.js - About 1 hr to fix

                                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