Showing 2,206 of 2,206 total issues

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

        if (u == o)
          for (a = n.r1; a <= n.r2; a++) {
            for (c = 0, s = n.g1; s <= n.g2; s++)
              for (h = n.b1; h <= n.b2; h++) c += r[e(a, s, h)] || 0;
            v[a] = f += c;
Severity: Major
Found in src/app/hooks/useImageColour/colorthief.js and 1 other location - About 4 hrs to fix
src/app/hooks/useImageColour/colorthief.js on lines 113..124

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

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

    {
      headlines: {
        shortHeadline:
          "Críticas sobre suposta 'censura' e 'falta de transparência' do Facebook unem petistas e bolsonaristas",
        headline:
Severity: Major
Found in src/app/components/OptimizelyRecommendations/fixtureData.js and 2 other locations - About 4 hrs to fix
src/app/components/OptimizelyRecommendations/fixtureData.js on lines 422..455
src/app/components/OptimizelyRecommendations/fixtureData.js on lines 490..523

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

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

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

import React from 'react';
import { RequestContextProvider } from '#contexts/RequestContext';
import { ToggleContextProvider } from '#contexts/ToggleContext';
import * as clickTracking from '#hooks/useClickTrackerHandler';
import * as viewTracking from '#hooks/useViewTracker';

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

    import React from 'react';
    import assocPath from 'ramda/src/assocPath';
    import pashtoPageData from '#data/pashto/bbc_pashto_radio/w3ct0lz1.json';
    import koreanPageData from '#data/korean/bbc_korean_radio/w3ct0kn5.json';
    import zhongwenPageData from '#data/zhongwen/bbc_cantonese_radio/w172xf3r5x8hw4v.json';
    Severity: Minor
    Found in src/app/pages/OnDemandAudioPage/index.test.tsx - About 4 hrs to fix

      File dataStructures.js has 351 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import {
        DesktopBigPromo,
        BigPromo,
        VerticalPromo,
        TallPromo,
      Severity: Minor
      Found in src/app/components/Curation/HierarchicalGrid/dataStructures.js - About 4 hrs to fix

        Function Tt has 110 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                    }(), Ct = "navigation", xt = "load", Tt = function() {
                        function e() {
                            var e = this;
                            this.eventListener = function() {
                                0 === performance.getEntriesByType(Ct).length ? e.performanceNavigationEventHandlerTimingLevel1() : new PerformanceObserver((function(t) {
        Severity: Major
        Found in public/vendor/cwr.js - About 4 hrs to fix

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

            it('should render the title of the article as a link', () => {
              const { getByText, container } = render(
                <Component promo={cpsRecommendation} />,
              );
          
          
          src/app/legacy/containers/CpsRecommendations/RecommendationsPromo/index.test.jsx on lines 55..71

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

          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('it should render recommendation correctly for optimo promos', () => {
              const { getByText, container } = render(
                <Component promo={optimoRecommendation} />,
              );
          
          
          src/app/legacy/containers/CpsRecommendations/RecommendationsPromo/index.test.jsx on lines 41..53

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

          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

            describe('Most Read', () => {
              it('should construct correct data file path', () => {
                expect(
                  constructDataFilePath({ pageType: 'mostRead', service: 'igbo' }),
                ).toEqual(`${DATA_PATH}/data/igbo/mostRead/index.json`);
          Severity: Major
          Found in src/server/local/constructDataFilePath/index.test.js and 3 other locations - About 4 hrs to fix
          src/server/local/constructDataFilePath/index.test.js on lines 8..24
          src/server/local/constructDataFilePath/index.test.js on lines 52..68
          src/server/local/constructDataFilePath/index.test.js on lines 70..86

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

          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

            describe('Secondary Column', () => {
              it('should construct correct data file path', () => {
                expect(
                  constructDataFilePath({ pageType: 'secondaryColumn', service: 'igbo' }),
                ).toEqual(`${DATA_PATH}/data/igbo/secondaryColumn/index.json`);
          Severity: Major
          Found in src/server/local/constructDataFilePath/index.test.js and 3 other locations - About 4 hrs to fix
          src/server/local/constructDataFilePath/index.test.js on lines 8..24
          src/server/local/constructDataFilePath/index.test.js on lines 34..50
          src/server/local/constructDataFilePath/index.test.js on lines 70..86

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

          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

            describe('Recommendations', () => {
              it('should construct correct data file path', () => {
                expect(
                  constructDataFilePath({ pageType: 'recommendations', service: 'igbo' }),
                ).toEqual(`${DATA_PATH}/data/igbo/recommendations/index.json`);
          Severity: Major
          Found in src/server/local/constructDataFilePath/index.test.js and 3 other locations - About 4 hrs to fix
          src/server/local/constructDataFilePath/index.test.js on lines 8..24
          src/server/local/constructDataFilePath/index.test.js on lines 34..50
          src/server/local/constructDataFilePath/index.test.js on lines 52..68

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

          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

            describe('Front Page', () => {
              it('should construct correct data file path', () => {
                expect(
                  constructDataFilePath({ pageType: 'frontpage', service: 'igbo' }),
                ).toEqual(`${DATA_PATH}/data/igbo/frontpage/index.json`);
          Severity: Major
          Found in src/server/local/constructDataFilePath/index.test.js and 3 other locations - About 4 hrs to fix
          src/server/local/constructDataFilePath/index.test.js on lines 34..50
          src/server/local/constructDataFilePath/index.test.js on lines 52..68
          src/server/local/constructDataFilePath/index.test.js on lines 70..86

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

          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

          describe('detokenise', () => {
            it('detokenises the given text correctly', () => {
              expect(detokenise('Foo %token%', { '%token%': 'Bar' })).toEqual('Foo Bar');
              expect(detokenise('Foo %token%', {})).toEqual('Foo %token%');
            });
          src/app/legacy/psammead/psammead-detokeniser/src/index.test.js on lines 3..13

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

          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

          describe('detokenise', () => {
            it('detokenises the given text correctly', () => {
              expect(detokenise('Foo %token%', { '%token%': 'Bar' })).toEqual('Foo Bar');
              expect(detokenise('Foo %token%', {})).toEqual('Foo %token%');
            });
          src/app/legacy/psammead/psammead-social-embed/src/utilities/index.test.js on lines 21..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 121.

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

                  var _n = function() {
                          function e(e, t, n, r) {
                              void 0 === r && (r = {}),
                              void 0 === n && (n = "us-west-2");
                              var o = An(An({}, {
          Severity: Major
          Found in public/vendor/cwr.js - About 4 hrs to fix

            Function testsThatNeverRunDuringSmokeTestingForCanonicalOnly has 107 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export const testsThatNeverRunDuringSmokeTestingForCanonicalOnly = () => {
              // TODO: Re-enable these and check for consent banner
              describe.skip('Social Embed', () => {
                // This test specifically covers an edge case where more than one tweet is
                // included in a Story and twitter needs to be prompted to render the tweet
            Severity: Major
            Found in cypress/e2e/pages/storyPage/testsForCanonicalOnly.js - About 4 hrs to fix

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

              import React from 'react';
              import { storiesOf } from '@storybook/react';
              import styled from '@emotion/styled';
              import {
                color,
              Severity: Minor
              Found in src/app/legacy/psammead/psammead-navigation/src/index.stories.jsx - About 4 hrs to fix

                Function Image has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
                Open

                const Image = ({
                  alt,
                  aspectRatio,
                  attribution,
                  className,
                Severity: Minor
                Found in src/app/components/Image/index.tsx - About 4 hrs 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 test has 106 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        it('should be displayed if the toggle is on, and shows the expected number of items', function test() {
                          let toggleName;
                
                          if (Cypress.env('currentPath').includes('podcasts')) {
                            toggleName = 'recentPodcastEpisodes';
                Severity: Major
                Found in cypress/e2e/pages/onDemandAudio/tests.js - About 4 hrs to fix

                  File directives.js has 343 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import { bbcDomains, advertisingServiceCountryDomains } from './domainLists';
                  
                  const advertisingDirectives = {
                    frameSrc: [
                      'https://*.doubleclick.net',
                  Severity: Minor
                  Found in src/server/utilities/cspHeader/directives.js - About 4 hrs to fix
                    Severity
                    Category
                    Status
                    Source
                    Language