teableio/teable

View on GitHub
packages/sdk/src/components/cell-value/CellValue.tsx

Summary

Maintainability
B
6 hrs
Test Coverage

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

export const CellValue = (props: ICellValueContainer) => {
  const { field, value, maxWidth, maxLine, className, itemClassName, formatImageUrl } = props;
  const { type, options, cellValueType } = field;

  switch (type) {
Severity: Minor
Found in packages/sdk/src/components/cell-value/CellValue.tsx - 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 (
        <CellSelect
          value={value as ISingleSelectCellValue | IMultipleSelectCellValue}
          options={transformSelectOptions(options.choices)}
          className={className}
Severity: Major
Found in packages/sdk/src/components/cell-value/CellValue.tsx - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

          return <CellCheckbox value={value as boolean | boolean[]} className={className} />;
    Severity: Major
    Found in packages/sdk/src/components/cell-value/CellValue.tsx - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return <CellCheckbox value={value as boolean | boolean[]} className={className} />;
      Severity: Major
      Found in packages/sdk/src/components/cell-value/CellValue.tsx - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return (
                  <CellNumber
                    value={value as number}
                    formatting={options.formatting as INumberFormatting}
                    className={className}
        Severity: Major
        Found in packages/sdk/src/components/cell-value/CellValue.tsx - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                return <CellText value={value as string} className={className} />;
          Severity: Major
          Found in packages/sdk/src/components/cell-value/CellValue.tsx - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return (
                      <CellDate
                        value={value as string}
                        formatting={options.formatting as IDatetimeFormatting}
                        className={className}
            Severity: Major
            Found in packages/sdk/src/components/cell-value/CellValue.tsx - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                    return (
                      <CellDate value={value as string} formatting={options.formatting} className={className} />
                    );
              Severity: Major
              Found in packages/sdk/src/components/cell-value/CellValue.tsx - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                      return (
                        <CellRating
                          value={value as number}
                          options={options as IRatingFieldOptions}
                          className={className}
                Severity: Major
                Found in packages/sdk/src/components/cell-value/CellValue.tsx - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                        return (
                          <CellUser
                            value={value as IUserCellValue | IUserCellValue[]}
                            className={className}
                            itemClassName={itemClassName}
                  Severity: Major
                  Found in packages/sdk/src/components/cell-value/CellValue.tsx - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                          return (
                            <CellAttachment
                              value={value as IAttachmentCellValue}
                              className={className}
                              itemClassName={itemClassName}
                    Severity: Major
                    Found in packages/sdk/src/components/cell-value/CellValue.tsx - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                            return (
                              <CellLink
                                value={value as ILinkCellValue | ILinkCellValue[]}
                                className={className}
                                itemClassName={itemClassName}
                      Severity: Major
                      Found in packages/sdk/src/components/cell-value/CellValue.tsx - About 30 mins to fix

                        There are no issues that match your filters.

                        Category
                        Status