Showing 390 of 2,206 total issues

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

const didSuppressWarning = (message, ...rest) => {
  const { expectedWarnings } = window;
  if (SUPPRESSED_REGEX.test(message)) {
    return true;
  }
Severity: Minor
Found in src/testHelpers/setupTests.js - About 45 mins to fix

Cognitive Complexity

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

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

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

Further reading

Avoid deeply nested control flow statements.
Open

              for (h = n.b1; h <= n.b2; h++) c += r[e(a, s, h)] || 0;
Severity: Major
Found in src/app/hooks/useImageColour/colorthief.js - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                for (c = 0, s = n.r1; s <= n.r2; s++)
                  for (h = n.g1; h <= n.g2; h++) c += r[e(s, h, a)] || 0;
    Severity: Major
    Found in src/app/hooks/useImageColour/colorthief.js - About 45 mins to fix

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

      const dealWithNonNumericCharacters = (versionString, timeJson) => {
        const patchVersion = versionString.match(/patch/);
        if (patchVersion) {
          const possibleVersionStrings = versionString.match(
            /@npm:([\d.]+)|@([\d.]+)/,
      Severity: Minor
      Found in scripts/esmDependencyCheck.js - About 45 mins to fix

      Cognitive Complexity

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

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

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

      Further reading

      Avoid deeply nested control flow statements.
      Open

                  for (c = 0, s = n.r1; s <= n.r2; s++)
                    for (h = n.b1; h <= n.b2; h++) c += r[e(s, a, h)] || 0;
      Severity: Major
      Found in src/app/hooks/useImageColour/colorthief.js - About 45 mins to fix

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

        const getStatsDestination = ({ isUK = true, env = 'test', service }: Props) => {
          let destination = '';
          switch (service) {
            case 'news':
              // checks if "news" service is in the UK or not and set apprioprate destination
        Severity: Minor
        Found in src/app/contexts/RequestContext/getStatsDestination/index.ts - About 45 mins to fix

        Cognitive Complexity

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

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

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

        Further reading

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

        const ImageWithPlaceholder = ({
          alt,
          children = null,
          copyright = null,
          fade = false,
        Severity: Minor
        Found in src/app/legacy/containers/ImageWithPlaceholder/index.jsx - About 45 mins to fix

        Cognitive Complexity

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

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

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

        Further reading

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

        const getToggles = async (service, cache) => {
          const environment = getEnvConfig().SIMORGH_APP_ENV || 'local';
          const timeout =
            parseInt(getEnvConfig().SIMORGH_CONFIG_TIMEOUT_SECONDS, 10) * 1000;
          const localToggles = defaultToggles[environment];
        Severity: Minor
        Found in src/app/lib/utilities/getToggles/index.js - About 45 mins to fix

        Cognitive Complexity

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

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

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

        Further reading

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

        export const EventTrackingContextProvider = ({
          children,
          data,
          atiData,
        }: PropsWithChildren<EventTrackingProviderProps>) => {
        Severity: Minor
        Found in src/app/contexts/EventTrackingContext/index.tsx - About 45 mins to fix

        Cognitive Complexity

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

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

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

        Further reading

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

        const BulletinContainer = ({ item, lazyLoadImage = true }) => {
          const { script, service, dir, translations } = useContext(ServiceContext);
        
          const headline = pathOr(null, ['name'], item);
          const ctaLink = pathOr(null, ['uri'], item);
        Severity: Minor
        Found in src/app/legacy/containers/Bulletin/index.jsx - About 45 mins to fix

        Cognitive Complexity

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

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

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

        Further reading

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

        const Content = ({
          mediaDuration = '',
          headline,
          isPhotoGallery = false,
          isLive = false,
        Severity: Minor
        Found in src/app/legacy/components/OptimoPromos/Content/index.jsx - About 45 mins to fix

        Cognitive Complexity

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

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

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

        Further reading

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

        const HealthFactors = ({ metadata }: HealthFactorsProps) => {
          const uxAccessibility = path(['uxAccessibilityDoc'], metadata);
          const uxSwarm = path(['swarm'], metadata);
          const acceptanceCriteria = path(['acceptanceCriteria'], metadata);
        
        
        Severity: Minor
        Found in .storybook/DocsDecorator/HealthFactors/index.tsx - About 45 mins to fix

        Cognitive Complexity

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

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

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

        Further reading

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

        const MostRead = ({
          data,
          columnLayout = 'multiColumn',
          size = 'default',
          mobileDivider = false,
        Severity: Minor
        Found in src/app/components/MostRead/index.tsx - About 45 mins to fix

        Cognitive Complexity

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

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

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

        Further reading

        Consider simplifying this complex logical expression.
        Open

                                                if (u = f[n++].exec(e))
                                                    for (o = 0; o < p.length; o++)
                                                        l = u[++r],
                                                        typeof (a = p[o]) === c && a.length > 0 ? 2 == a.length ? typeof a[1] == s ? this[a[0]] = a[1].call(this, l) : this[a[0]] = a[1] : 3 == a.length ? typeof a[1] !== s || a[1].exec && a[1].test ? this[a[0]] = l ? l.replace(a[1], a[2]) : i : this[a[0]] = l ? a[1].call(this, l, a[2]) : i : 4 == a.length && (this[a[0]] = l ? a[3].call(this, l.replace(a[1], a[2])) : i) : this[a] = l || i;
        Severity: Major
        Found in public/vendor/cwr.js - About 40 mins to fix

          Consider simplifying this complex logical expression.
          Open

            if (
              !children ||
              children.length === 0 ||
              isRoot ||
              docsOnly ||
          Severity: Major
          Found in .storybook/SidebarLabel/index.tsx - About 40 mins to fix

            Function J has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                        J = function(e, t, n, r, o) {
            Severity: Minor
            Found in public/vendor/cwr.js - About 35 mins to fix

              Function fetch has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                                  }, n.fetch = function(e, t, r, o, i) {
              Severity: Minor
              Found in public/vendor/cwr.js - About 35 mins to fix

                Function fetchEventHandler has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                const fetchEventHandler = async event => {
                  if (
                    /^https:\/\/ichef(\.test)?\.bbci\.co\.uk\/(news|images|ace\/(standard|ws))\/.+.webp$/.test(
                      event.request.url,
                    )
                Severity: Minor
                Found in public/sw.js - About 35 mins to fix

                Cognitive Complexity

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

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

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

                Further reading

                Function getMvtExperiments has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                const getMvtExperiments = (headers, service, derivedPageType) => {
                  return Object.entries(headers).reduce((result, [header, content]) => {
                    if (header.startsWith('mvt-')) {
                      const noMvtPrefixHeader = header.slice(4);
                
                
                Severity: Minor
                Found in src/server/utilities/mvtHeader/getMvtExperiments/index.js - About 35 mins to fix

                Cognitive Complexity

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

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

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

                Further reading

                Function HeadingsContainer has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                const HeadingsContainer = ({
                  blocks = [
                    {
                      model: {
                        blocks: [
                Severity: Minor
                Found in src/app/legacy/containers/Headings/index.jsx - About 35 mins to fix

                Cognitive Complexity

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

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

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

                Further reading

                Severity
                Category
                Status
                Source
                Language