Showing 390 of 2,206 total issues

Function e has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

                function e(e, t, n, r) {
                    var o = this;
                    this.dispatchFetch = function() {
                        return wt(o, void 0, void 0, (function() {
                            return bt(this, (function(e) {
Severity: Major
Found in public/vendor/cwr.js - About 2 hrs to fix

    Function getSigningKey has 54 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

                    }, e.prototype.getSigningKey = function(e, t, n, r) {
                        return function(e, t, n, r, o) {
                            return be(void 0, void 0, void 0, (function() {
                                var i,
                                    s,
    Severity: Major
    Found in public/vendor/cwr.js - About 2 hrs to fix

      Function generateLinks has 54 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const generateLinks = (service, env, domain) => {
        const output = [];
      
        const {
          frontPage,
      Severity: Major
      Found in scripts/releaseInfo/index.js - About 2 hrs to fix

        Function getDestination has 54 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export const getDestination = (platform, statsDestination) => {
          const destinationIDs = {
            DEFAULT: 596068,
            DEFAULT_TEST: 596068,
            NEWS_PS: 598285,
        Severity: Major
        Found in src/app/lib/analyticsUtils/index.js - About 2 hrs to fix

          Function 430 has 53 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                      430: function(e, t, n) {
                          "use strict";
                          Object.defineProperty(t, "__esModule", {
                              value: !0
                          }),
          Severity: Major
          Found in public/vendor/cwr.js - About 2 hrs to fix

            Function useOptimizelyScrollDepth has 53 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const useOptimizelyScrollDepth = () => {
              const { isAmp } = useContext(RequestContext);
              const { optimizely } = useContext(OptimizelyContext);
              const [scrollDepth, setScrollDepth] = useState(0);
              const [scrollTwentyFive, setScrollTwentyFive] = useState(false);
            Severity: Major
            Found in src/app/hooks/useOptimizelyScrollDepth/index.jsx - About 2 hrs to fix

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

              /** @jsx jsx */
              /* @jsxFrag React.Fragment */
              
              import { jsx } from '@emotion/react';
              import React, { useContext, useEffect, useRef, useState } from 'react';
              Severity: Minor
              Found in src/app/components/MediaLoader/index.tsx - About 2 hrs to fix

                Function listItems has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  const listItems = files.map((fileData: FileData, index: number) => {
                    const { file } = fileData;
                    const key = `${index}-${file.name}`;
                    const thumbnailSrc = thumbnailState[index];
                    const isThumbnailSvg = thumbnailSrc?.startsWith('data:image/svg');

                  Function webpackFinal has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    webpackFinal: async (config, options) => {
                      const babelOptions = await options.presets.apply('babel', {}, options);
                      const typescriptOptions = await options.presets.apply(
                        'typescript',
                        {},
                  Severity: Major
                  Found in .storybook/main.ts - About 2 hrs to fix

                    Function fetchPageData has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                    Open

                    const fetchPageData = async ({
                      path,
                      timeout,
                      shouldLogFetchTime = !onClient(),
                      agent,
                    Severity: Minor
                    Found in src/app/routes/utils/fetchPageData/index.js - About 2 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 exports has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                    Open

                    module.exports = ({
                      resolvePath,
                      IS_PROD,
                      START_DEV_SERVER,
                      IS_PROD_PROFILE,
                    Severity: Minor
                    Found in webpack.config.client.js - About 2 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 useConsentBanner has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    const useConsentBanner = (
                      isUK = false,
                      showCookieBannerBasedOnCountry = true,
                    ) => {
                      const [{ showPrivacyBanner, showCookieBanner }, dispatch] = useReducer(
                    Severity: Major
                    Found in src/app/legacy/containers/ConsentBanner/useConsentBanners/index.js - About 2 hrs to fix

                      Function isValidFiles has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      const isValidFiles: (data: FieldData) => FieldData = (data: FieldData) => {
                        const { value: files, required, wasInvalid, fileTypes, min, max } = data;
                        const MAX_PAYLOAD_SIZE = 1288490189;
                        const RESERVED_FORM_DATA_SIZE = 10000;
                        // we're making the assumption that each file chooser field is only allowed the max payload size less some for data (estimated maximum size ever needed)

                        Function 668 has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                                    668: function(e, t, n) {
                                        "use strict";
                                        n.r(t),
                                        n.d(t, {
                                            fromUtf8: function() {
                        Severity: Minor
                        Found in public/vendor/cwr.js - About 2 hrs to fix

                          Function render has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            render() {
                              const { clientSideEnvVariables, css, helmet, ids, isApp, isLite } =
                                this.props;
                          
                              const htmlAttrs = helmet.htmlAttributes.toComponent();
                          Severity: Minor
                          Found in ws-nextjs-app/pages/_document.page.tsx - About 2 hrs to fix

                            Function customRender has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            const customRender = (
                              ui: ReactElement,
                              options?: Omit<RenderOptions, 'wrapper'> & Omit<Props, 'children'>,
                            ) => {
                              const {
                            Severity: Minor
                            Found in src/app/components/react-testing-library-with-providers.tsx - About 1 hr to fix

                              Function getServerSideProps has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              export const getServerSideProps: GetServerSideProps = async context => {
                                context.res.setHeader(
                                  'Cache-Control',
                                  'public, stale-if-error=300, stale-while-revalidate=120, max-age=30',
                                );
                              Severity: Minor
                              Found in ws-nextjs-app/pages/[service]/send/[id]/[[...variant]].page.tsx - About 1 hr to fix

                                Function A has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                                        A = function(e, t) {
                                                            if ("object" == typeof e && (t = e, e = i), !(this instanceof A))
                                                                return new A(e, t).getResult();
                                                            var n = e || (void 0 !== o && o.navigator && o.navigator.userAgent ? o.navigator.userAgent : ""),
                                                                r = t ? E.extend(T, t) : T;
                                Severity: Minor
                                Found in public/vendor/cwr.js - About 1 hr to fix

                                  Function collectResults has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  const collectResults = async (link, service, type) => {
                                    await fetchWithCert(link).then(response => {
                                      if (response.ok) {
                                        response.json().then(json => {
                                          const jsondata = 'data' in json ? json.data : json;
                                  Severity: Minor
                                  Found in scripts/mostReadAndWatchedCollectionData.js - About 1 hr to fix

                                    Function LiteSiteCta has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                    const LiteSiteCta = () => {
                                      const { dir, translations } = useContext(ServiceContext);
                                      const { canonicalLink } = useContext(RequestContext);
                                      const isRtl = dir === 'rtl';
                                      const { liteSite = defaultTranslations } = translations;
                                    Severity: Minor
                                    Found in src/app/components/LiteSiteCta/index.tsx - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language