grommet/grommet

View on GitHub
src/js/components/FormField/FormField.js

Summary

Maintainability
F
3 days
Test Coverage

Function FormField has a Cognitive Complexity of 102 (exceeds 5 allowed). Consider refactoring.
Open

  (
    {
      children,
      className,
      component,
Severity: Minor
Found in src/js/components/FormField/FormField.js - About 2 days 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 FormField.js has 501 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import React, {
  Children,
  cloneElement,
  forwardRef,
  useContext,
Severity: Major
Found in src/js/components/FormField/FormField.js - About 1 day to fix

    Consider simplifying this complex logical expression.
    Open

        if (themeBorder) {
          const innerProps =
            themeBorder.position === 'inner'
              ? {
                  border: {
    Severity: Critical
    Found in src/js/components/FormField/FormField.js - About 3 hrs to fix

      Function Message has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      const Message = ({ error, info, message, type, ...rest }) => {
        const theme = useContext(ThemeContext) || defaultProps.theme;
      
        if (message) {
          let icon;
      Severity: Minor
      Found in src/js/components/FormField/FormField.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 Input has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      const Input = ({ component, disabled, invalid, name, onChange, ...rest }) => {
        const formContext = useContext(FormContext);
        const [value, setValue] = formContext.useFormInput({
          name,
          value: rest.value,
      Severity: Minor
      Found in src/js/components/FormField/FormField.js - About 45 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

      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

            } 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

          There are no issues that match your filters.

          Category
          Status