snowplow/snowplow-javascript-tracker

View on GitHub

Showing 353 of 353 total issues

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

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

              export interface MediaAd extends Record<string, unknown> {
                /** Friendly name of the ad */
                name?: string;
                /** Unique identifier for the ad */
                adId: string;
              Severity: Major
              Found in plugins/browser-plugin-media/src/types.ts and 1 other location - About 1 hr to fix
              plugins/browser-plugin-media/src/types.ts on lines 331..344

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 67.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

              export interface MediaAdUpdate {
                /** Friendly name of the ad */
                name?: string;
                /** Unique identifier for the ad */
                adId: string;
              Severity: Major
              Found in plugins/browser-plugin-media/src/types.ts and 1 other location - About 1 hr to fix
              plugins/browser-plugin-media/src/types.ts on lines 347..360

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 67.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              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 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 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

              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 WebVitalsPlugin has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export function WebVitalsPlugin(pluginOptions: WebVitalsPluginOptions = defaultPluginOptions): BrowserPlugin {
                  const webVitalsObject: Record<string, unknown> = {};
                  const options = { ...defaultPluginOptions, ...pluginOptions };
                  let trackerId: string;
                  let webVitalsScript: HTMLScriptElement | undefined;
                Severity: Minor
                Found in plugins/browser-plugin-web-vitals/src/index.ts - About 1 hr to fix

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                  export interface EnhancedEcommercePromoContext {
                    /** The promotion ID */
                    id?: string;
                    /** The name of the promotion */
                    name?: string;
                  Severity: Major
                  Found in plugins/browser-plugin-enhanced-ecommerce/src/index.ts and 1 other location - About 1 hr to fix
                  libraries/tracker-core/src/core.ts on lines 1322..1333

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 66.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                  export interface ConsentGrantedEvent {
                    /** Identifier for the document granting consent */
                    id: string;
                    /** Version of the document granting consent */
                    version: string;
                  Severity: Major
                  Found in libraries/tracker-core/src/core.ts and 1 other location - About 1 hr to fix
                  plugins/browser-plugin-enhanced-ecommerce/src/index.ts on lines 273..284

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 66.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Function logger has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function logger(logLevel: LOG_LEVEL = LOG_LEVEL.warn): Logger {
                    function setLogLevel(level: LOG_LEVEL) {
                      if (LOG_LEVEL[level]) {
                        logLevel = level;
                      } else {
                  Severity: Minor
                  Found in libraries/tracker-core/src/logger.ts - About 1 hr to fix

                    Function jsonInterceptor has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      function jsonInterceptor(encodeBase64: boolean): JsonProcessor {
                        const log = (jsonType: string, data: SelfDescribingJson) => {
                          const schemaParts = getSchemaParts(data['schema']);
                          debug(colours.event(), 'Event', [
                            '%c%s%c%s%c%s\n%o',
                    Severity: Minor
                    Found in plugins/browser-plugin-debugger/src/index.ts - About 1 hr to fix

                      Function flush has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        const flush = (): void => {
                          const bufferCopy = buffer;
                          buffer = [];
                          if (bufferCopy.length === 0) {
                            return;
                      Severity: Minor
                      Found in trackers/node-tracker/src/got_emitter.ts - About 1 hr to fix

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

                        export function trackingOptionsParser(id: string, trackingOptions?: MediaTrackingOptions): TrackingOptions {
                          const defaults: TrackingOptions = {
                            id: id,
                            captureEvents: DefaultEvents,
                            progress: {
                        Severity: Minor
                        Found in plugins/browser-plugin-media-tracking/src/helperFunctions.ts - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language