Showing 2,206 of 2,206 total issues

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

  it('should resolve the twitter handle to a single @ prefix where there are multiple @ symbols in the fragment text', () => {
    const contentBlocks = pathOr(
      [],
      ['content', 'model', 'blocks'],
      contentBlockWithMultipleHandlePrefixes,
src/app/components/Byline/utilities/getAuthorTwitterHandle/index.test.js on lines 15..24
src/app/components/Byline/utilities/getAuthorTwitterHandle/index.test.js on lines 92..101

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

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('asset origins should include fonts origins for Live environment', async () => {
    process.env.SIMORGH_APP_ENV = 'live';

    expect(getAssetOrigins('news')).toEqual([
      'https://ichef.bbci.co.uk',
Severity: Major
Found in src/server/utilities/getAssetOrigins/index.test.js and 1 other location - About 1 hr to fix
src/server/utilities/getAssetOrigins/index.test.js on lines 49..59

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

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('snapshots', () => {
    it('should correctly render Canonical navigation', () => {
      const { container } = render(navigation);
      expect(container).toMatchSnapshot();
    });
src/app/legacy/containers/Navigation/index.amp.test.jsx on lines 24..29

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

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

jest.mock('uuid', () => {
  let x = 1;
  return {
    v4: () => {
      x += 1;
Severity: Major
Found in src/app/pages/FrontPage/index.test.jsx and 1 other location - About 1 hr to fix
src/app/pages/FeatureIdxPage/index.test.jsx on lines 56..64

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

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

  it('should resolve the twitter handle to a single @ prefix where the @ symbol is missing in the fragment text', () => {
    const contentBlocks = pathOr(
      [],
      ['content', 'model', 'blocks'],
      contentBlockWithNoHandlePrefixes,
src/app/components/Byline/utilities/getAuthorTwitterHandle/index.test.js on lines 15..24
src/app/components/Byline/utilities/getAuthorTwitterHandle/index.test.js on lines 81..90

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

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

jest.mock('uuid', () => {
  let x = 1;
  return {
    v4: () => {
      x += 1;
Severity: Major
Found in src/app/pages/FeatureIdxPage/index.test.jsx and 1 other location - About 1 hr to fix
src/app/pages/FrontPage/index.test.jsx on lines 56..64

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

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('asset origins should include fonts origins for Test environment', async () => {
    process.env.SIMORGH_APP_ENV = 'test';

    expect(getAssetOrigins('news')).toEqual([
      'https://ichef.bbci.co.uk',
Severity: Major
Found in src/server/utilities/getAssetOrigins/index.test.js and 1 other location - About 1 hr to fix
src/server/utilities/getAssetOrigins/index.test.js on lines 61..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 57.

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

                    this.page = {
                        pageId: e,
                        parentPageId: this.page.pageId,
                        interaction: this.page.interaction + 1,
                        start: Date.now()
Severity: Major
Found in public/vendor/cwr.js and 1 other location - About 1 hr to fix
public/vendor/cwr.js on lines 2363..2368

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

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

const generateLinks = (service, env, domain) => {
  const output = [];

  const {
    frontPage,
Severity: Minor
Found in scripts/releaseInfo/index.js - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function ordinal has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  ordinal: function (number) {
    var b = number % 10,
      output =
        ~~((number % 100) / 10) === 1
          ? 'th'
Severity: Minor
Found in src/app/legacy/psammead/psammead-locales/moment/pcm.js - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function withOptimizelyProvider has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

const withOptimizelyProvider = Component => {
  return props => {
    const { service } = useContext(ServiceContext);
    const isStoryBook = process.env.STORYBOOK;
    const disableOptimizely = isStoryBook;

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

        avg: function (t) {
          var n = this.histo;
          if (!this._avg || t) {
            var o,
              i,
Severity: Minor
Found in src/app/hooks/useImageColour/colorthief.js - About 1 hr to fix

    Function getCredentialsForIdentity has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

                    this.getCredentialsForIdentity = function(e) {
                        return i(t, void 0, void 0, (function() {
                            var t,
                                n;
                            return s(this, (function(r) {
    Severity: Minor
    Found in public/vendor/cwr.js - About 1 hr to fix

      Function getRouteProps has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const getRouteProps = url => {
        const matchedRoutes = matchRoutes(routes, url);
      
        const route = path([0, 'route'], matchedRoutes);
        const match = path([0, 'match'], matchedRoutes);
      Severity: Minor
      Found in src/app/routes/utils/fetchPageData/utils/getRouteProps/index.js - About 1 hr to fix

        Function NielsenAnalytics has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const NielsenAnalytics = () => {
          const { service, isAmp, pathname } = useContext(RequestContext);
        
          // nielsenAnalytics toggle only set up as local toggle at the moment...
          const { enabled } = useToggle('nielsenAnalytics');
        Severity: Minor
        Found in src/app/legacy/containers/NielsenAnalytics/index.jsx - About 1 hr to fix

          Function buildRSSMarketingString has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const buildRSSMarketingString = href => {
            const { query, hash } = new Url(href, true);
          
            const queryWithParams = hash ? parameteriseHash(hash) : query;
          
          
          Severity: Minor
          Found in src/app/lib/analyticsUtils/index.js - About 1 hr to fix

            Function getType has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export const getType = (pageType: PageTypes | 'index', shorthand = false) => {
              switch (pageType) {
                case FRONT_PAGE:
                case 'index':
                  return shorthand ? 'IDX' : 'Index';
            Severity: Minor
            Found in src/app/components/ChartbeatAnalytics/utils/index.ts - About 1 hr to fix

              Function getArticleTopStoryItem has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const getArticleTopStoryItem = (item: TopStoryItem) => {
                const overtypedHeadline = item?.headlines?.overtyped ?? '';
                const mainHeadline = item?.headlines?.headline ?? '';
                const headlineBlockText =
                  // @ts-expect-error - nested block structure

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

                const teluguStyles = {
                  sansRegular: `
                    ${teluguFontFamily}
                    ${getFontStyleAndWeight('normal', 400)}
                  `,
                src/app/legacy/psammead/psammead-styles/src/font-families.js on lines 86..95
                src/app/legacy/psammead/psammead-styles/src/font-families.js on lines 102..111
                src/app/legacy/psammead/psammead-styles/src/font-families.js on lines 118..127
                src/app/legacy/psammead/psammead-styles/src/font-families.js on lines 134..143
                src/app/legacy/psammead/psammead-styles/src/font-families.js on lines 150..159
                src/app/legacy/psammead/psammead-styles/src/font-families.js on lines 166..175
                src/app/legacy/psammead/psammead-styles/src/font-families.js on lines 182..191
                src/app/legacy/psammead/psammead-styles/src/font-families.js on lines 198..207
                src/app/legacy/psammead/psammead-styles/src/font-families.js on lines 214..223
                src/app/legacy/psammead/psammead-styles/src/font-families.js on lines 230..239
                src/app/legacy/psammead/psammead-styles/src/font-families.js on lines 246..255
                src/app/legacy/psammead/psammead-styles/src/font-families.js on lines 263..272
                src/app/legacy/psammead/psammead-styles/src/font-families.js on lines 279..288
                src/app/legacy/psammead/psammead-styles/src/font-families.js on lines 295..304
                src/app/legacy/psammead/psammead-styles/src/font-families.js on lines 327..336
                src/app/legacy/psammead/psammead-styles/src/font-families.js on lines 343..352

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

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

                  pashto: {
                    articles: 'Sept 2019',
                    frontPage: '23rd April 2020',
                    liveRadio: '14th Jan 2020',
                    mediaAssetPage: '5th March 2020',
                Severity: Major
                Found in scripts/releaseInfo/launchDates.js and 10 other locations - About 1 hr to fix
                scripts/releaseInfo/launchDates.js on lines 13..24
                scripts/releaseInfo/launchDates.js on lines 68..79
                scripts/releaseInfo/launchDates.js on lines 105..116
                scripts/releaseInfo/launchDates.js on lines 168..179
                scripts/releaseInfo/launchDates.js on lines 230..241
                scripts/releaseInfo/launchDates.js on lines 311..322
                scripts/releaseInfo/launchDates.js on lines 327..338
                scripts/releaseInfo/launchDates.js on lines 339..350
                scripts/releaseInfo/launchDates.js on lines 421..432
                scripts/releaseInfo/launchDates.js on lines 433..444

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

                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