Showing 390 of 2,206 total issues

Function j has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

            j = function() {
                function e(e) {
                    this.plugins = new Map,
                    this.context = e
                }
Severity: Minor
Found in public/vendor/cwr.js - About 1 hr to fix

    Function writeCsvFile has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const writeCsvFile = data => {
      let csvContents =
        'Dependency,Type,Most Recent Version,Most Recent Version Date,Our Version,Our Version Date,Our Version Freshness in Days';
    
      data
    Severity: Minor
    Found in scripts/esmDependencyCheck.js - About 1 hr to fix

      Function Image has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const Image = props => {
        const { children = null, src, useLargeImages = false, ...rest } = props;
        const isProgrammeImage = src.startsWith(
          'https://ichef.bbci.co.uk/images/ic/',
        );
      Severity: Minor
      Found in src/app/legacy/components/Promo/image.jsx - About 1 hr to fix

        Function animationStory has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const animationStory = (dir, script, service) => {
          const isOpen = boolean('Open', false);
          return (
            <Navigation script={script} service={service} dir={dir}>
              <CanonicalDropdown isOpen={isOpen}>
        Severity: Minor
        Found in src/app/legacy/psammead/psammead-navigation/src/index.stories.jsx - About 1 hr to fix

          Function inputs has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const inputs = () => {
            // capitalization is only for presentation purpose on the knob
            const options = Object.keys(svgs)
              .filter(key => key !== 'BBC_BLOCKS')
              .map(key => key.charAt(0).toUpperCase() + key.slice(1));
          Severity: Minor
          Found in src/app/legacy/psammead/psammead-navigation/src/index.stories.jsx - About 1 hr to fix

            Function inputs has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const inputs = (service = 'news') => {
              const options = Object.keys(svgs).filter(key => key !== 'BBC_BLOCKS');
              const svgChoice = select('Service SVG', options, service).toLowerCase();
              const productInput = text('Product', 'BBC News');
              const serviceLocalisedNameInput = text('Localised service name', 'Yoruba');
            Severity: Minor
            Found in src/app/legacy/psammead/psammead-brand/src/index.stories.jsx - About 1 hr to fix

              Function getCampaignID has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const getCampaignID = (pageType: CampaignPageTypes) => {
                const campaignID = {
                  [ARTICLE_PAGE]: 'article',
                  [MEDIA_ARTICLE_PAGE]: 'article-sfv',
                  [FRONT_PAGE]: 'index-home',
              Severity: Minor
              Found in src/app/contexts/EventTrackingContext/index.tsx - About 1 hr to fix

                Function extractHeaders has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                const extractHeaders = (headers: IncomingHttpHeaders) => {
                  let isUK = null;
                  let showCookieBannerBasedOnCountry = true;
                  if (headers['x-bbc-edge-isuk']) {
                    isUK = headers['x-bbc-edge-isuk'] === 'yes';
                Severity: Minor
                Found in src/server/utilities/extractHeaders/index.ts - About 1 hr to fix

                  Consider simplifying this complex logical expression.
                  Open

                      if (Array.isArray(group.items)) {
                        newGroup.items = group.items.filter(item => {
                          const itemType = item.assetTypeCode || item.cpsType;
                          const isValidItemType = whitelist.includes(itemType);
                          const isValidContentType =

                    Consider simplifying this complex logical expression.
                    Open

                                if (!F && !(F = "undefined" != typeof crypto && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || "undefined" != typeof msCrypto && "function" == typeof msCrypto.getRandomValues && msCrypto.getRandomValues.bind(msCrypto)))
                                    throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
                    Severity: Major
                    Found in public/vendor/cwr.js - About 1 hr to fix

                      Function isSupportedClickModifier has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                      const isSupportedClickModifier = (event, functionKey) =>
                        (functionKey && !event.shiftKey && !event.altKey) || // functionKey
                        (event.shiftKey && functionKey && !event.altKey) || // shift + functionKey
                        (event.shiftKey && functionKey && event.altKey) || // shift + functionKey + option/alt
                        (event.shiftKey && event.altKey && !functionKey) || // shift + option/alt
                      Severity: Minor
                      Found in src/app/hooks/useClickTrackerHandler/clickTypes.js - About 55 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 extractBundlesForPageType has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                        extractBundlesForPageType: pageType => {
                          if (pageType === 'ArticlePage') {
                            return [
                              'modern.ArticlePage-31ecd969.31473c35.js',
                              'modern.commons-1111.js',
                      Severity: Minor
                      Found in scripts/bundleSize/__mocks__/pageTypeBundleExtractor.js - About 55 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 validate has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                      const validate = ({
                        output,
                        expectedOutput,
                        device,
                        currentPage,
                      Severity: Minor
                      Found in src/app/components/Pagination/buildBlocks.test.tsx - About 55 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 MetadataContainer has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                      const MetadataContainer = ({
                        title,
                        socialHeadline,
                        lang,
                        twitterHandle,
                      Severity: Minor
                      Found in src/app/components/Metadata/index.tsx - About 55 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 findNthIndex has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                      const findNthIndex = (n, predicate, inputArray) => {
                        if (!validateInputs(n, predicate, inputArray)) return -1;
                        let count = 0;
                        for (let i = 0; i < inputArray.length; i += 1) {
                          if (n - count > inputArray.length - i) break;
                      Severity: Minor
                      Found in src/app/lib/utilities/findNthIndex/index.js - About 55 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 isValidFiles has a Cognitive Complexity of 9 (exceeds 5 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)

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

                      const MediaLoader = ({ blocks, className, embedded }: Props) => {
                        const { lang, translations } = useContext(ServiceContext);
                        const { pageIdentifier } = useContext(EventTrackingContext);
                        const { enabled: adsEnabled } = useToggle('ads');
                      
                      
                      Severity: Minor
                      Found in src/app/components/MediaLoader/index.tsx - About 55 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 OnDemandAudioPage has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                      const OnDemandAudioPage = ({
                        pageData,
                        mediaIsAvailable,
                        MediaError,
                      }: OnDemandAudioProps) => {
                      Severity: Minor
                      Found in src/app/pages/OnDemandAudioPage/OnDemandAudioPage.tsx - About 55 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 RelatedContentSection has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                      const RelatedContentSection = ({ content }: { content: OptimoBlock[] }) => {
                        const { translations, script, service } = useContext(ServiceContext);
                      
                        const {
                          palette: { GREY_2 },
                      Severity: Minor
                      Found in src/app/components/RelatedContentSection/index.tsx - About 55 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 u has 7 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          function u(t, r, n, o, e, i, u) {
                      Severity: Major
                      Found in src/app/hooks/useImageColour/colorthief.js - About 50 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language