Showing 417 of 2,650 total issues

Avoid too many return statements within this function.
Open

  return <EmbedHtml embeddableContent={html} />;
Severity: Major
Found in src/app/components/Embeds/OEmbed/index.tsx - About 30 mins to fix

    Function getCert has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    const getCert = async () => {
      const caPath = process.env.CA_PATH || '/etc/pki/tls/certs/ca-bundle.crt';
      const certChainPath =
        process.env.CERT_CHAIN_PATH || '/etc/pki/tls/certs/client.crt';
      const keyPath = process.env.KEY_PATH || '/etc/pki/tls/private/client.key';
    Severity: Minor
    Found in src/server/utilities/getAgent/certs.js - About 25 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 getRouteProps has a Cognitive Complexity of 6 (exceeds 5 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 25 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 processBlock has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    export const processBlock = _block => {
      const block = { ..._block };
    
      if (path(['text'], block)) {
        // catch plain_text ARES response for legacy MAPs with <link> elements

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

    const convertToBlocks = (node, attributes = []) =>
      pathOr([], ['children'], node).reduce((acc, childNode) => {
        if (isXmlNodeSupported(childNode, attributes)) {
          return handleSupportedNodes(childNode, attributes, acc);
        }
    Severity: Minor
    Found in src/app/legacy/psammead/psammead-rich-text-transforms/src/candy-xml.js - About 25 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 xmlNodeToBlock has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    const xmlNodeToBlock = (node, attributes) => {
      if (!is(Object, node)) return undefined;
    
      if (node.type === 'text') {
        return fragment(node.text, attributes);
    Severity: Minor
    Found in src/app/legacy/psammead/psammead-rich-text-transforms/src/candy-xml.js - About 25 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 RecentAudioEpisodes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    const RecentAudioEpisodes = ({
      masterBrand,
      episodes,
      brandId = '',
      pageType,
    Severity: Minor
    Found in src/app/legacy/containers/EpisodeList/RecentAudioEpisodes/index.jsx - About 25 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 getProviderFromSource has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    export const getProviderFromSource = source => {
      if (source.match(/^https:\/\/twitter\.com/)) {
        return PROVIDERS.TWITTER;
      }
      if (source.match(/^https:\/\/www\.instagram\.com/)) {
    Severity: Minor
    Found in src/app/legacy/containers/SocialEmbed/sourceHelpers.js - About 25 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 IndexPageSection has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    const IndexPageSection = ({
      bar = true,
      group,
      sectionNumber,
      showAllPromos = false,
    Severity: Minor
    Found in src/app/legacy/containers/IndexPageSection/index.jsx - About 25 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 CpsOnwardJourney has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    const CpsOnwardJourney = ({
      className = '',
      LabelComponent = StyledSectionLabel,
      labelId,
      title = '',
    Severity: Minor
    Found in src/app/legacy/containers/CpsOnwardJourney/index.jsx - About 25 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 getImageBlock has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    const getImageBlock = (type, blockData, isAmp) => {
      const supportedImageTypes = ['idt2'];
    
      const imageData = blockData[type];
    
    

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

    const squashTopStories = jsonRaw => {
      const json = jsonRaw;
      let groups = pathOr(null, ['content', 'groups'], json);
      let collectedItems = [];
      let collectedStrapline;
    Severity: Minor
    Found in src/app/routes/utils/sharedDataTransformers/squashTopStories/index.js - About 25 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 NielsenAnalytics has a Cognitive Complexity of 6 (exceeds 5 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 25 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 enrichBlocks has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    const enrichBlocks = (accumulator, block, index, blocks) => {
      const embedUrl = getEmbedUrl(block);
      const embedProvider = getEmbedProvider(block);
      const source = getSource(block);
    
    
    Severity: Minor
    Found in src/app/routes/utils/sharedDataTransformers/addIndexesToEmbeds/index.js - About 25 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 IncludeContainer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    const IncludeContainer = props => {
      const { isAmp, isLite, canonicalLink } = useContext(RequestContext);
      const { translations } = useContext(ServiceContext);
      const { enabled } = useToggle('include');
    
    
    Severity: Minor
    Found in src/app/legacy/containers/Include/index.jsx - About 25 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 CpsRecommendations has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    const CpsRecommendations = ({ items = [] }) => {
      const { recommendations, translations, script, service, dir } =
        useContext(ServiceContext);
      const { pageType } = useContext(RequestContext);
      const { enabled } = useToggle('cpsRecommendations');
    Severity: Minor
    Found in src/app/legacy/containers/CpsRecommendations/index.jsx - About 25 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 getVariantRedirectUrl has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    const getVariantRedirectUrl = ({ path, params, service, variant }) => {
      if (!path) return null;
    
      const cookieVariant = getPreferredVariant(service);
      const defaultVariant = getVariant({

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

    const Header = ({ brandRef, borderBottom, skipLink, scriptLink, linkId }) => {
      const [showConsentBanner, setShowConsentBanner] = useState(true);
    
      const handleBannerBlur = event => {
        const isRejectButton =
    Severity: Minor
    Found in src/app/legacy/containers/Header/index.jsx - About 25 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 convertInclude has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    const convertInclude = async (includeBlock, pageData, ...restParams) => {
      const { href, type } = includeBlock;
    
      if (!href) {
        logger.error(INCLUDE_MISSING_URL, includeBlock);

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

    const ScrollablePromo = ({ blocks, blockGroupIndex = null }) => {
      const { script, service, dir, translations } = useContext(ServiceContext);
    
      const eventTrackingData = {
        componentName: `edoj${blockGroupIndex}`,
    Severity: Minor
    Found in src/app/legacy/components/ScrollablePromo/index.jsx - About 25 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