grommet/grommet

View on GitHub

Showing 545 of 2,098 total issues

Function parseValue has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
Open

const parseValue = (mask, value) => {
  // break the value up into mask parts
  const valueParts = []; // { part, beginIndex, endIndex }
  let valueIndex = 0;
  let maskIndex = 0;
Severity: Minor
Found in src/js/components/MaskedInput/MaskedInput.js - About 7 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 Select has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
Open

  (
    {
      a11yTitle,
      'aria-label': ariaLabel,
      alignSelf,
Severity: Minor
Found in src/js/components/Select/Select.js - About 6 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

File SelectMultiple-test.tsx has 447 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import React, { useState } from 'react';
import { act, render, screen, fireEvent } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { axe } from 'jest-axe';
import 'jest-axe/extend-expect';
Severity: Minor
Found in src/js/components/SelectMultiple/__tests__/SelectMultiple-test.tsx - About 6 hrs to fix

    Function getIconColor has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
    Open

    const getIconColor = (paths = [], theme, colorProp, kind) => {
      let result = [];
      let index = paths.length - 1;
      // caller has specified a themeObj to use for styling
      // relevant for cases like pagination which looks to theme.pagination.button
    Severity: Minor
    Found in src/js/components/Button/Button.js - About 6 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

    File ToggleGroup-test.tsx has 437 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import React from 'react';
    import { fireEvent, render, screen } from '@testing-library/react';
    import { axe } from 'jest-axe';
    import userEvent from '@testing-library/user-event';
    
    
    Severity: Minor
    Found in src/js/components/ToggleGroup/__tests__/ToggleGroup-test.tsx - About 6 hrs to fix

      Function Bar has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
      Open

      const Bar = forwardRef((props, ref) => {
        const {
          background,
          max,
          round,
      Severity: Minor
      Found in src/js/components/Meter/Bar.js - About 6 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

      File StyledBox.js has 426 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import styled, { css } from 'styled-components';
      
      import { defaultProps } from '../../default-props';
      import {
        alignContentStyle,
      Severity: Minor
      Found in src/js/components/Box/StyledBox.js - About 6 hrs to fix

        Function formContextValue has 148 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            const formContextValue = useMemo(() => {
              const useFormInput = ({
                name,
                value: componentValue,
                initialValue,
        Severity: Major
        Found in src/js/components/Form/Form.js - About 5 hrs to fix

          Function edgeStyle has 146 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const edgeStyle = (
            kind,
            data,
            responsive,
            responsiveBreakpoint,
          Severity: Major
          Found in src/js/utils/styles.js - About 5 hrs to fix

            File MaskedInput.js has 410 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import React, {
              forwardRef,
              useCallback,
              useContext,
              useEffect,
            Severity: Minor
            Found in src/js/components/MaskedInput/MaskedInput.js - About 5 hrs to fix

              File Header.js has 409 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              /* eslint-disable no-underscore-dangle */
              import React, {
                forwardRef,
                useCallback,
                useContext,
              Severity: Minor
              Found in src/js/components/DataTable/Header.js - About 5 hrs to fix

                File DataChart-test.tsx has 409 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import React, { Fragment } from 'react';
                import { render } from '@testing-library/react';
                import 'jest-styled-components';
                
                import { Grommet } from '../../Grommet';
                Severity: Minor
                Found in src/js/components/DataChart/__tests__/DataChart-test.tsx - About 5 hrs to fix

                  Function List has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
                  Open

                    (
                      {
                        a11yTitle,
                        'aria-label': ariaLabel,
                        action,
                  Severity: Minor
                  Found in src/js/components/List/List.js - About 5 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 RichAccordion has 143 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const RichAccordion = () => {
                    const [highlightLoaded, setHighlightLoaded] = React.useState(false);
                  
                    return (
                      <Grommet full theme={grommet}>
                  Severity: Major
                  Found in src/js/components/Accordion/stories/CustomThemed/Rich.tsx - About 5 hrs to fix

                    Function Diagram has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
                    Open

                    const Diagram = forwardRef(({ connections, ...rest }, ref) => {
                      const theme = useContext(ThemeContext) || defaultProps.theme;
                      const [dimensions, setDimensions] = useState({ width: 0, height: 0 });
                      const [connectionPoints, setConnectionPoints] = useState();
                      const svgRef = useForwardedRef(ref);
                    Severity: Minor
                    Found in src/js/components/Diagram/Diagram.js - About 5 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 Circle has 139 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    const Circle = forwardRef((props, ref) => {
                      const { background, max, round, size, thickness, type, values, ...rest } =
                        props;
                      const theme = useContext(ThemeContext);
                      const width =
                    Severity: Major
                    Found in src/js/components/Meter/Circle.js - About 5 hrs to fix

                      Function backgroundAndTextColors has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
                      Open

                      export const backgroundAndTextColors = (backgroundArg, textArg, theme) => {
                        if (!backgroundArg) return [undefined, textArg];
                      
                        const { global } = theme;
                        const background = normalizeBackground(backgroundArg, theme);
                      Severity: Minor
                      Found in src/js/utils/background.js - About 5 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 roundStyle has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
                      Open

                      export const roundStyle = (data, responsive, theme) => {
                        const breakpoint = getBreakpointStyle(theme, theme.box.responsiveBreakpoint);
                        const styles = [];
                        if (typeof data === 'object') {
                          const size =
                      Severity: Minor
                      Found in src/js/utils/styles.js - About 5 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 Swatch has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
                      Open

                      const Swatch = ({
                        aspect,
                        color,
                        dash,
                        opacity: opacityProp,
                      Severity: Minor
                      Found in src/js/components/DataChart/Swatch.js - About 5 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 MaskedInput has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
                      Open

                        (
                          {
                            a11yTitle,
                            dropHeight,
                            dropProps,
                      Severity: Minor
                      Found in src/js/components/MaskedInput/MaskedInput.js - About 5 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

                      Severity
                      Category
                      Status
                      Source
                      Language