src/app/hooks/useViewTracker/index.test.jsx

Summary

Maintainability
F
3 days
Test Coverage

File index.test.jsx has 601 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* eslint-disable no-console */

import React from 'react';
import {
  renderHook,
Severity: Major
Found in src/app/hooks/useViewTracker/index.test.jsx - About 1 day to fix

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

    const IntersectionObserver = jest.fn(cb => {
      const item = {
        callback: cb,
        elements: new Set(),
      };
    Severity: Major
    Found in src/app/hooks/useViewTracker/index.test.jsx and 1 other location - About 4 hrs to fix
    src/app/legacy/containers/OptimizelyArticleCompleteTracking/index.test.jsx on lines 22..40

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

    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

    const getObserverInstance = element => {
      try {
        const [instance] = Array.from(observers).find(([, item]) =>
          item.elements.has(element),
        );
    Severity: Major
    Found in src/app/hooks/useViewTracker/index.test.jsx and 1 other location - About 2 hrs to fix
    src/app/legacy/containers/OptimizelyArticleCompleteTracking/index.test.jsx on lines 42..52

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

    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

    const urlToObject = url => {
      const { origin, pathname, searchParams } = new URL(url);
    
      return {
        origin,
    Severity: Major
    Found in src/app/hooks/useViewTracker/index.test.jsx and 1 other location - About 1 hr to fix
    src/app/hooks/useClickTrackerHandler/index.test.jsx on lines 23..31

    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

        act(() => {
          triggerIntersection({
            changes: [{ isIntersecting: true }],
            observer: observerInstanceA,
          });
    Severity: Major
    Found in src/app/hooks/useViewTracker/index.test.jsx and 1 other location - About 1 hr to fix
    src/app/hooks/useViewTracker/index.test.jsx on lines 339..348

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

    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

        act(() => {
          triggerIntersection({
            changes: [{ isIntersecting: true }],
            observer: observerInstanceA,
          });
    Severity: Major
    Found in src/app/hooks/useViewTracker/index.test.jsx and 1 other location - About 1 hr to fix
    src/app/hooks/useViewTracker/index.test.jsx on lines 270..279

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

    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

    beforeEach(() => {
      jest.clearAllMocks();
      jest.useFakeTimers();
      console.error = jest.fn();
      global.IntersectionObserver = IntersectionObserver;
    Severity: Major
    Found in src/app/hooks/useViewTracker/index.test.jsx and 1 other location - About 1 hr to fix
    src/app/legacy/containers/OptimizelyArticleCompleteTracking/index.test.jsx on lines 75..80

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

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

        const { result: resultA } = renderHook(() => useViewTracker(trackingData), {
          wrapper: props =>
            wrapper({ ...props, pageData: fixtureData, atiData: atiAnalytics }),
        });
    Severity: Major
    Found in src/app/hooks/useViewTracker/index.test.jsx and 6 other locations - About 55 mins to fix
    src/app/hooks/useViewTracker/index.test.jsx on lines 207..210
    src/app/hooks/useViewTracker/index.test.jsx on lines 257..260
    src/app/hooks/useViewTracker/index.test.jsx on lines 293..296
    src/app/hooks/useViewTracker/index.test.jsx on lines 326..329
    src/app/hooks/useViewTracker/index.test.jsx on lines 362..365
    src/app/hooks/useViewTracker/index.test.jsx on lines 462..465

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

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

        const { result: resultB } = renderHook(() => useViewTracker(trackingData), {
          wrapper: props =>
            wrapper({ ...props, pageData: fixtureData, atiData: atiAnalytics }),
        });
    Severity: Major
    Found in src/app/hooks/useViewTracker/index.test.jsx and 6 other locations - About 55 mins to fix
    src/app/hooks/useViewTracker/index.test.jsx on lines 207..210
    src/app/hooks/useViewTracker/index.test.jsx on lines 257..260
    src/app/hooks/useViewTracker/index.test.jsx on lines 293..296
    src/app/hooks/useViewTracker/index.test.jsx on lines 322..325
    src/app/hooks/useViewTracker/index.test.jsx on lines 362..365
    src/app/hooks/useViewTracker/index.test.jsx on lines 462..465

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

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

        const { result } = renderHook(() => useViewTracker(trackingData), {
          wrapper: props =>
            wrapper({ ...props, pageData: fixtureData, atiData: atiAnalytics }),
        });
    Severity: Major
    Found in src/app/hooks/useViewTracker/index.test.jsx and 6 other locations - About 55 mins to fix
    src/app/hooks/useViewTracker/index.test.jsx on lines 257..260
    src/app/hooks/useViewTracker/index.test.jsx on lines 293..296
    src/app/hooks/useViewTracker/index.test.jsx on lines 322..325
    src/app/hooks/useViewTracker/index.test.jsx on lines 326..329
    src/app/hooks/useViewTracker/index.test.jsx on lines 362..365
    src/app/hooks/useViewTracker/index.test.jsx on lines 462..465

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

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

        const { result } = renderHook(() => useViewTracker(trackingData), {
          wrapper: props =>
            wrapper({ ...props, pageData: fixtureData, atiData: atiAnalytics }),
        });
    Severity: Major
    Found in src/app/hooks/useViewTracker/index.test.jsx and 6 other locations - About 55 mins to fix
    src/app/hooks/useViewTracker/index.test.jsx on lines 207..210
    src/app/hooks/useViewTracker/index.test.jsx on lines 293..296
    src/app/hooks/useViewTracker/index.test.jsx on lines 322..325
    src/app/hooks/useViewTracker/index.test.jsx on lines 326..329
    src/app/hooks/useViewTracker/index.test.jsx on lines 362..365
    src/app/hooks/useViewTracker/index.test.jsx on lines 462..465

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

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

        const { result } = renderHook(() => useViewTracker(trackingData), {
          wrapper: props =>
            wrapper({ ...props, pageData: fixtureData, atiData: atiAnalytics }),
        });
    Severity: Major
    Found in src/app/hooks/useViewTracker/index.test.jsx and 6 other locations - About 55 mins to fix
    src/app/hooks/useViewTracker/index.test.jsx on lines 207..210
    src/app/hooks/useViewTracker/index.test.jsx on lines 257..260
    src/app/hooks/useViewTracker/index.test.jsx on lines 322..325
    src/app/hooks/useViewTracker/index.test.jsx on lines 326..329
    src/app/hooks/useViewTracker/index.test.jsx on lines 362..365
    src/app/hooks/useViewTracker/index.test.jsx on lines 462..465

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

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

        const { result } = renderHook(() => useViewTracker(trackingData), {
          wrapper: props =>
            wrapper({ ...props, pageData: fixtureData, atiData: atiAnalytics }),
        });
    Severity: Major
    Found in src/app/hooks/useViewTracker/index.test.jsx and 6 other locations - About 55 mins to fix
    src/app/hooks/useViewTracker/index.test.jsx on lines 207..210
    src/app/hooks/useViewTracker/index.test.jsx on lines 257..260
    src/app/hooks/useViewTracker/index.test.jsx on lines 293..296
    src/app/hooks/useViewTracker/index.test.jsx on lines 322..325
    src/app/hooks/useViewTracker/index.test.jsx on lines 326..329
    src/app/hooks/useViewTracker/index.test.jsx on lines 462..465

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

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

        const { result } = renderHook(() => useViewTracker(trackingData), {
          wrapper: props =>
            wrapper({ ...props, pageData: fixtureData, atiData: atiAnalytics }),
        });
    Severity: Major
    Found in src/app/hooks/useViewTracker/index.test.jsx and 6 other locations - About 55 mins to fix
    src/app/hooks/useViewTracker/index.test.jsx on lines 207..210
    src/app/hooks/useViewTracker/index.test.jsx on lines 257..260
    src/app/hooks/useViewTracker/index.test.jsx on lines 293..296
    src/app/hooks/useViewTracker/index.test.jsx on lines 322..325
    src/app/hooks/useViewTracker/index.test.jsx on lines 326..329
    src/app/hooks/useViewTracker/index.test.jsx on lines 362..365

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

    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

    afterEach(() => {
      jest.runOnlyPendingTimers();
      jest.useRealTimers();
      console.error = error;
      observers.clear();
    Severity: Minor
    Found in src/app/hooks/useViewTracker/index.test.jsx and 1 other location - About 55 mins to fix
    src/app/legacy/containers/OptimizelyArticleCompleteTracking/index.test.jsx on lines 82..87

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

    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

    const triggerIntersection = ({ changes, observer }) => {
      const item = observers.get(observer);
    
      item.callback(changes);
    };
    Severity: Minor
    Found in src/app/hooks/useViewTracker/index.test.jsx and 1 other location - About 45 mins to fix
    src/app/legacy/containers/OptimizelyArticleCompleteTracking/index.test.jsx on lines 54..58

    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

    There are no issues that match your filters.

    Category
    Status