snowplow/snowplow-javascript-tracker

View on GitHub

Showing 352 of 352 total issues

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

    case InternalVimeoEvent.CHAPTERCHANGE:
      trackMediaSelfDescribingEvent({
        id,
        player,
        event: {
plugins/browser-plugin-vimeo-tracking/src/mediaPluginBinding.ts on lines 131..140
plugins/browser-plugin-vimeo-tracking/src/mediaPluginBinding.ts on lines 142..151

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

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

  const { pageUrl, pageTitle, referrer, minXOffset, maxXOffset, minYOffset, maxYOffset } = event,
    pb = payloadBuilder();
Severity: Minor
Found in libraries/tracker-core/src/core.ts and 1 other location - About 50 mins to fix
libraries/tracker-core/src/core.ts on lines 774..775

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

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

  const { orderId, sku, price, name, category, quantity, currency } = event,
    pb = payloadBuilder();
Severity: Minor
Found in libraries/tracker-core/src/core.ts and 1 other location - About 50 mins to fix
libraries/tracker-core/src/core.ts on lines 642..643

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

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 update has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  update(
    trackEvent: (event: EventWithContext) => void,
    mediaEvent?: MediaEvent,
    customEvent?: SelfDescribingJson,
    player?: MediaPlayerUpdate,
Severity: Minor
Found in plugins/browser-plugin-media/src/mediaTracking.ts - About 45 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 __importStar has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
Severity: Minor
Found in common/scripts/install-run.js - About 45 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 addTracker has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

  trackerId: string,
  namespace: string,
  version: string,
  endpoint: string,
  sharedState: SharedState,
Severity: Minor
Found in libraries/browser-tracker-core/src/snowplow.ts - About 45 mins to fix

    Function Tracker has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      trackerId: string,
      namespace: string,
      version: string,
      endpoint: string,
      sharedState: SharedState,
    Severity: Minor
    Found in libraries/browser-tracker-core/src/tracker/index.ts - About 45 mins to fix

      Function eventHandler has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      function eventHandler(event: MouseEvent, trackerId: string, filter: FilterFunction, context?: DynamicContext) {
        let elem = event.target as HTMLElement | null;
        while (elem) {
          if (elem instanceof HTMLButtonElement || (elem instanceof HTMLInputElement && elem.type === 'button')) {
            if (filter(elem)) {
      Severity: Minor
      Found in plugins/browser-plugin-button-click-tracking/src/api.ts - About 45 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 evaluateProvider has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      function evaluateProvider(
        provider: ConditionalContextProvider,
        event: PayloadBuilder,
        eventType: string,
        eventSchema: string
      Severity: Minor
      Found in libraries/tracker-core/src/contexts.ts - About 45 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 __importStar has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      var __importStar = (this && this.__importStar) || function (mod) {
          if (mod && mod.__esModule) return mod;
          var result = {};
          if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
          __setModuleDefault(result, mod);
      Severity: Minor
      Found in common/scripts/install-run-rush.js - About 45 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 getNpmPath has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      function getNpmPath() {
          if (!_npmPath) {
              try {
                  if (os.platform() === 'win32') {
                      // We're on Windows
      Severity: Minor
      Found in common/scripts/install-run.js - About 45 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 deeply nested control flow statements.
      Open

                          if (!process.env[environmentVariableName]) {
                              // No, so trim this line
                              lineShouldBeTrimmed = true;
                              break;
                          }
      Severity: Major
      Found in common/scripts/install-run.js - About 45 mins to fix

        Function constructor has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          constructor(pingIntervalSeconds: number | undefined, maxPausedPings: number | undefined, trackPing: () => void) {
            if (maxPausedPings !== undefined) {
              this.maxPausedPings = maxPausedPings;
            }
        
        
        Severity: Minor
        Found in plugins/browser-plugin-media/src/pingInterval.ts - About 45 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 updateBufferingStats has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          private updateBufferingStats(log: Log) {
            if (log.eventType == MediaEventType.BufferStart) {
              this.bufferingStartedAt = log.time;
              this.bufferingStartTime = log.contentTime;
            } else if (this.bufferingStartedAt !== undefined) {
        Severity: Minor
        Found in plugins/browser-plugin-media/src/sessionStats.ts - About 45 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 matchVendor has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        function matchVendor(rule: string, vendor: string): boolean {
          // rule and vendor must have same number of elements
          const vendorParts = vendor.split('.');
          const ruleParts = rule.split('.');
          if (vendorParts && ruleParts) {
        Severity: Minor
        Found in libraries/tracker-core/src/contexts.ts - About 45 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

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

        export function newSession(trackers?: Array<string>) {
          dispatchToTrackers(trackers, (t) => {
            t.newSession();
          });
        }
        Severity: Major
        Found in trackers/browser-tracker/src/api.ts and 4 other locations - About 45 mins to fix
        trackers/browser-tracker/src/api.ts on lines 238..242
        trackers/browser-tracker/src/api.ts on lines 249..253
        trackers/browser-tracker/src/api.ts on lines 260..264
        trackers/browser-tracker/src/api.ts on lines 453..457

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

        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 5 locations. Consider refactoring.
        Open

        export function disableActivityTrackingCallback(trackers?: Array<string>) {
          dispatchToTrackers(trackers, (t) => {
            t.disableActivityTrackingCallback();
          });
        }
        Severity: Major
        Found in trackers/browser-tracker/src/api.ts and 4 other locations - About 45 mins to fix
        trackers/browser-tracker/src/api.ts on lines 101..105
        trackers/browser-tracker/src/api.ts on lines 238..242
        trackers/browser-tracker/src/api.ts on lines 260..264
        trackers/browser-tracker/src/api.ts on lines 453..457

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

        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 5 locations. Consider refactoring.
        Open

        export function disableActivityTracking(trackers?: Array<string>) {
          dispatchToTrackers(trackers, (t) => {
            t.disableActivityTracking();
          });
        }
        Severity: Major
        Found in trackers/browser-tracker/src/api.ts and 4 other locations - About 45 mins to fix
        trackers/browser-tracker/src/api.ts on lines 101..105
        trackers/browser-tracker/src/api.ts on lines 249..253
        trackers/browser-tracker/src/api.ts on lines 260..264
        trackers/browser-tracker/src/api.ts on lines 453..457

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

        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 5 locations. Consider refactoring.
        Open

        export function updatePageActivity(trackers?: Array<string>) {
          dispatchToTrackers(trackers, (t) => {
            t.updatePageActivity();
          });
        }
        Severity: Major
        Found in trackers/browser-tracker/src/api.ts and 4 other locations - About 45 mins to fix
        trackers/browser-tracker/src/api.ts on lines 101..105
        trackers/browser-tracker/src/api.ts on lines 238..242
        trackers/browser-tracker/src/api.ts on lines 249..253
        trackers/browser-tracker/src/api.ts on lines 453..457

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

        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 5 locations. Consider refactoring.
        Open

        export function preservePageViewId(trackers?: Array<string>) {
          dispatchToTrackers(trackers, (t) => {
            t.preservePageViewId();
          });
        }
        Severity: Major
        Found in trackers/browser-tracker/src/api.ts and 4 other locations - About 45 mins to fix
        trackers/browser-tracker/src/api.ts on lines 101..105
        trackers/browser-tracker/src/api.ts on lines 238..242
        trackers/browser-tracker/src/api.ts on lines 249..253
        trackers/browser-tracker/src/api.ts on lines 260..264

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

        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

        Severity
        Category
        Status
        Source
        Language