grommet/grommet

View on GitHub

Showing 545 of 2,098 total issues

Consider simplifying this complex logical expression.
Open

    } else if (
      focus &&
      formFieldTheme.focus &&
      formFieldTheme.focus.border &&
      formFieldTheme.focus.border.color
Severity: Major
Found in src/js/components/FormField/FormField.js - About 40 mins to fix

    Consider simplifying this complex logical expression.
    Open

              if (
                responsive &&
                ((align.top === 'top' && targetRect.top < 0) ||
                  (align.bottom === 'top' &&
                    targetRect.top - containerRect.height <= 0 &&
    Severity: Major
    Found in src/js/components/Drop/DropContainer.js - About 40 mins to fix

      Consider simplifying this complex logical expression.
      Open

        if (replace || renderPageBounds[1] < lastPage || onMore) {
          let marker = (
            <Box
              key="below"
              ref={(!renderMarker && belowMarkerRef) || undefined}
      Severity: Major
      Found in src/js/components/InfiniteScroll/InfiniteScroll.js - About 40 mins to fix

        Consider simplifying this complex logical expression.
        Open

            } else if (
              // backward compatibility check
              (error && themeBorder && themeBorder.error.color) ||
              (error && formFieldTheme.error && formFieldTheme.error.border)
            ) {
        Severity: Major
        Found in src/js/components/FormField/FormField.js - About 40 mins to fix

          Consider simplifying this complex logical expression.
          Open

              if (
                (border === 'between' ||
                  (border && border.side === 'between') ||
                  (Array.isArray(border) && border.find((b) => b.side === 'between'))) &&
                !gap
          Severity: Major
          Found in src/js/components/Box/Box.js - About 40 mins to fix

            Consider simplifying this complex logical expression.
            Open

                      } else if (
                        responsive &&
                        ((align.bottom === 'bottom' && targetRect.bottom > windowHeight) ||
                          (align.top === 'bottom' &&
                            targetRect.bottom + containerRect.height >= windowHeight &&
            Severity: Major
            Found in src/js/components/Drop/DropContainer.js - About 40 mins to fix

              Consider simplifying this complex logical expression.
              Open

                      if (fromElement && toElement) {
                        const fromRect = fromElement.getBoundingClientRect();
                        const toRect = toElement.getBoundingClientRect();
                        // There is no x and y when unit testing.
                        const fromPoint = [
              Severity: Major
              Found in src/js/components/Diagram/Diagram.js - About 40 mins to fix

                Consider simplifying this complex logical expression.
                Open

                  if (
                    props.active &&
                    props.primary &&
                    props.theme.button.primary &&
                    props.theme.button.primary.active &&
                Severity: Major
                Found in src/js/components/Button/StyledButton.js - About 40 mins to fix

                  Consider simplifying this complex logical expression.
                  Open

                        if (sortSelectedOnClose && value && !open) {
                          const selectedOptions = optionsProp.filter((option) =>
                            arrayIncludes(
                              value,
                              valueKey && valueKey.reduce ? applyKey(option, valueKey) : option,
                  Severity: Major
                  Found in src/js/components/SelectMultiple/SelectMultiple.js - About 40 mins to fix

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

                    const normalizeBackgroundImage = (background, theme) => {
                      let result;
                      if (background.image) {
                        result =
                          normalizeBackground(
                    Severity: Minor
                    Found in src/js/utils/background.js - 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 getHoverIndicatorStyle has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export const getHoverIndicatorStyle = (hoverIndicator, theme) => {
                      let background;
                      let elevation;
                      if (hoverIndicator === true || hoverIndicator === 'background') {
                        ({ background } = theme.global.hover);
                    Severity: Minor
                    Found in src/js/utils/background.js - 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 sortCompare has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                    const sortCompare = (a, b, sort) => {
                      const v1 = a[sort.property] || '';
                      const v2 = b[sort.property] || '';
                      const dir = sort.direction || 'asc';
                      let result = 0;
                    Severity: Minor
                    Found in src/js/components/DataTable/stories/OnUpdate.js - 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 Indeterminate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export const Indeterminate = () => {
                      const [checked, setChecked] = useState([]);
                      const checkboxes = ['fruits', 'vegetables', 'olive oil'];
                    
                      const onCheckAll = (event) => {
                    Severity: Minor
                    Found in src/js/components/CheckBox/stories/Indeterminate.js - 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 defaultColor has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export const defaultColor = (index, theme, valuesLength) => {
                      if (index === valuesLength - 1 && theme.meter.color) {
                        return theme.meter.color;
                      }
                      // We want the last value to have the first color
                    Severity: Minor
                    Found in src/js/components/Meter/utils.js - 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 normalizeValues has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export const normalizeValues = (values) =>
                      (values || []).map((value, index) => {
                        if (value === undefined) return { value: [index, undefined] };
                        if (Array.isArray(value)) return { value };
                        if (typeof value === 'object') return value;
                    Severity: Minor
                    Found in src/js/components/Chart/utils.js - 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 kindStyle has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                    const kindStyle = ({
                      busy,
                      colorValue,
                      hasIcon,
                      hasLabel,
                    Severity: Minor
                    Found in src/js/components/Button/StyledButtonKind.js - 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 TagInput has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                    const TagInput = ({ value = [], onAdd, onChange, onRemove, ...rest }) => {
                      const [currentTag, setCurrentTag] = React.useState('');
                      const boxRef = React.useRef();
                    
                      const updateCurrentTag = (event) => {
                    Severity: Minor
                    Found in src/js/components/TextInput/stories/WithTags.js - 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 validateBounds has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export const validateBounds = (dateBounds, selectedDate) => {
                      if (!dateBounds || !selectedDate) return selectedDate;
                    
                      const [startDate, endDate] = dateBounds.map((date) =>
                        setHoursWithOffset(date).toISOString(),
                    Severity: Minor
                    Found in src/js/components/DateInput/utils.js - 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 ''; // defensive
                    Severity: Major
                    Found in src/js/utils/styles.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                        return 'forwards';
                      Severity: Major
                      Found in src/js/utils/animation.js - About 30 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language