src/app/legacy/components/Promo/index.test.jsx

Summary

Maintainability
F
1 wk
Test Coverage

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

import React from 'react';
import moment from 'moment';
import {
  render,
  screen,
Severity: Minor
Found in src/app/legacy/components/Promo/index.test.jsx - About 2 hrs to fix

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

        describe('Relative time 9 hours ago', () => {
          it('should render timestamp in string format', () => {
            const nineHoursAgoString = calcTimestampHoursAgo(9).toISOString();
            const { getByText } = render(
              <Fixture timestamp={nineHoursAgoString} />,
    Severity: Major
    Found in src/app/legacy/components/Promo/index.test.jsx and 1 other location - About 7 hrs to fix
    src/app/legacy/components/Promo/index.test.jsx on lines 220..242

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

    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

        describe('Relative time 59 minutes ago', () => {
          it('should render timestamp in string format', () => {
            const fiftyNineMinutesAgoString =
              calcTimestampMinutesAgo(59).toISOString();
            const { getByText } = render(
    Severity: Major
    Found in src/app/legacy/components/Promo/index.test.jsx and 1 other location - About 7 hrs to fix
    src/app/legacy/components/Promo/index.test.jsx on lines 243..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 185.

    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 FixtureWithWebp = ({
      useLargeImages = false,
      timestamp = Date.now(),
    }) => (
      <Promo>
    Severity: Major
    Found in src/app/legacy/components/Promo/index.test.jsx and 1 other location - About 6 hrs to fix
    src/app/legacy/components/Promo/index.test.jsx on lines 10..23

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

    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 Fixture = ({ useLargeImages = false, timestamp = Date.now() }) => (
      <Promo>
        <Promo.Image
          useLargeImages={useLargeImages}
          src="https://ichef.test.bbci.co.uk/ace/ws/{width}/cpsdevpb/3502/test/0c533a40-770b-11ed-bd83-8f15ba358e41.jpg"
    Severity: Major
    Found in src/app/legacy/components/Promo/index.test.jsx and 1 other location - About 6 hrs to fix
    src/app/legacy/components/Promo/index.test.jsx on lines 25..41

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

    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 FixtureProgrammes = ({ useLargeImages = false }) => (
      <Promo>
        <Promo.Image
          useLargeImages={useLargeImages}
          src="https://ichef.bbci.co.uk/images/ic/{width}xn/p06vzdgj.jpg"
    Severity: Major
    Found in src/app/legacy/components/Promo/index.test.jsx and 1 other location - About 4 hrs to fix
    src/app/legacy/components/Promo/index.test.jsx on lines 57..69

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

    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 FixtureProgrammesWithWebp = ({ useLargeImages = false }) => (
      <Promo>
        <Promo.Image
          useLargeImages={useLargeImages}
          src="https://ichef.bbci.co.uk/images/ic/{width}xn/p06vzdgj.jpg.webp"
    Severity: Major
    Found in src/app/legacy/components/Promo/index.test.jsx and 1 other location - About 4 hrs to fix
    src/app/legacy/components/Promo/index.test.jsx on lines 43..55

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

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

      it('should append a webp file extension - programmes iChef recipes', () => {
        render(<FixtureProgrammes />);
    
        const image = screen.getByAltText('Test image alt text');
        const srcSet = image.getAttribute('srcSet');
    Severity: Major
    Found in src/app/legacy/components/Promo/index.test.jsx and 3 other locations - About 4 hrs to fix
    src/app/legacy/components/Promo/index.test.jsx on lines 127..139
    src/app/legacy/components/Promo/index.test.jsx on lines 141..153
    src/app/legacy/components/Promo/index.test.jsx on lines 155..167

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

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

      it('should have only one webp file extension when URL has one already - programmes iChef recipes', () => {
        render(<FixtureProgrammesWithWebp />);
    
        const image = screen.getByAltText('Test image alt text');
        const srcSet = image.getAttribute('srcSet');
    Severity: Major
    Found in src/app/legacy/components/Promo/index.test.jsx and 3 other locations - About 4 hrs to fix
    src/app/legacy/components/Promo/index.test.jsx on lines 113..125
    src/app/legacy/components/Promo/index.test.jsx on lines 141..153
    src/app/legacy/components/Promo/index.test.jsx on lines 155..167

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

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

      it('should append a webp file extension - all other iChef Recipes', () => {
        render(<Fixture />);
    
        const image = screen.getByAltText('Test image alt text');
        const srcSet = image.getAttribute('srcSet');
    Severity: Major
    Found in src/app/legacy/components/Promo/index.test.jsx and 3 other locations - About 4 hrs to fix
    src/app/legacy/components/Promo/index.test.jsx on lines 113..125
    src/app/legacy/components/Promo/index.test.jsx on lines 127..139
    src/app/legacy/components/Promo/index.test.jsx on lines 155..167

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

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

      it('should have only one webp file extension when URL has one already - all other iChef Recipes', () => {
        render(<FixtureWithWebp />);
    
        const image = screen.getByAltText('Test image alt text');
        const srcSet = image.getAttribute('srcSet');
    Severity: Major
    Found in src/app/legacy/components/Promo/index.test.jsx and 3 other locations - About 4 hrs to fix
    src/app/legacy/components/Promo/index.test.jsx on lines 113..125
    src/app/legacy/components/Promo/index.test.jsx on lines 127..139
    src/app/legacy/components/Promo/index.test.jsx on lines 141..153

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

    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

      it('should create src set using correct resolutions - programmes iChef recipes ', () => {
        render(<FixtureProgrammes />);
    
        const image = screen.getByAltText('Test image alt text');
        const srcSet = image.getAttribute('srcSet');
    Severity: Major
    Found in src/app/legacy/components/Promo/index.test.jsx and 1 other location - About 3 hrs to fix
    src/app/legacy/components/Promo/index.test.jsx on lines 101..111

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

    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

      it('should create src set using resolutions - all other iChef Recipes', () => {
        render(<Fixture />);
    
        const image = screen.getByAltText('Test image alt text');
        const srcSet = image.getAttribute('srcSet');
    Severity: Major
    Found in src/app/legacy/components/Promo/index.test.jsx and 1 other location - About 3 hrs to fix
    src/app/legacy/components/Promo/index.test.jsx on lines 89..99

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

    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

          it('should render timestamp in ISO string format', () => {
            const overTenHoursString = calcTimestampHoursAgo(10).toISOString();
            const { getByText } = render(
              <Fixture timestamp={overTenHoursString} />,
              {
    Severity: Major
    Found in src/app/legacy/components/Promo/index.test.jsx and 1 other location - About 2 hrs to fix
    src/app/legacy/components/Promo/index.test.jsx on lines 279..288

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

    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

          it('should render timestamp in epoch format', () => {
            const overTenHoursEpoch = calcTimestampHoursAgo(10).getTime();
            const { getByText } = render(
              <Fixture timestamp={overTenHoursEpoch} />,
              {
    Severity: Major
    Found in src/app/legacy/components/Promo/index.test.jsx and 1 other location - About 2 hrs to fix
    src/app/legacy/components/Promo/index.test.jsx on lines 269..278

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

    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