bbc/psammead

View on GitHub

Showing 33 of 201 total issues

Function inputs has 31 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 packages/components/psammead-navigation/src/index.stories.jsx - About 1 hr to fix

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

    const getBrand = () => {
      const {
        productInput,
        serviceLocalisedNameInput,
        svgHeightInput,
    Severity: Minor
    Found in packages/components/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 packages/components/psammead-brand/src/index.stories.jsx - About 1 hr to fix

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

        const childrenFallback = (
          item,
          dir,
          columnsGroup,
          marginsGroup,
        Severity: Minor
        Found in packages/components/psammead-grid/src/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

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

          (
            {
              children,
              startOffset: gridStartOffset, // alias this prop to prevent it rendering as an element attribute e.g. <div startoffset="[object Object]">
              ...otherProps
        Severity: Minor
        Found in packages/components/psammead-grid/src/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

        Avoid too many return statements within this function.
        Open

            return convertToBlocks(node, [...attributes, styleAttribute]);
        Severity: Major
        Found in packages/utilities/psammead-rich-text-transforms/src/candy-xml.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

            return {
              type: node.name,
              model: {
                text: getTextFromChildBlocks(childBlocks),
                blocks: childBlocks,
          Severity: Major
          Found in packages/utilities/psammead-rich-text-transforms/src/candy-xml.js - About 30 mins to fix

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

            const mockEventListener = mockedEvent => {
              const originalAddEventListener = window.addEventListener;
              const originalRemoveEventListener = window.removeEventListener;
              window.addEventListener = jest.fn((event, cb) => {
                if (event !== mockedEvent) {
            Severity: Minor
            Found in packages/utilities/web-vitals/src/index.test.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 exports has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            module.exports = name => {
              let packageVersions = [];
            
              if (!checkPackage(name)) return '-1';
            
            
            Severity: Minor
            Found in scripts/publish/src/getRegistryVersion.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 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 packages/utilities/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 mockEventListener has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            const mockEventListener = mockedEvent => {
              const originalAddEventListener = window.addEventListener;
              const originalRemoveEventListener = window.removeEventListener;
              window.addEventListener = jest.fn((event, cb) => {
                if (event !== mockedEvent) {
            Severity: Minor
            Found in packages/utilities/web-vitals/src/use-event.test.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

            Severity
            Category
            Status
            Source
            Language