teableio/teable

View on GitHub
packages/sdk/src/components/grid/utils/region.ts

Summary

Maintainability
C
1 day
Test Coverage

File region.ts has 393 lines of code (exceeds 300 allowed). Consider refactoring.
Open

/* eslint-disable @typescript-eslint/naming-convention */
import { GRID_DEFAULT } from '../configs';
import { LinearRowType, RegionType, RowControlType } from '../interface';
import type {
  IActiveCellBound,
Severity: Minor
Found in packages/sdk/src/components/grid/utils/region.ts - About 4 hrs to fix

    Function checkIsColumnHeader has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    const checkIsColumnHeader = (props: ICheckRegionProps): IRegionData | null => {
      const {
        position,
        scrollState,
        coordInstance,
    Severity: Minor
    Found in packages/sdk/src/components/grid/utils/region.ts - 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 getColumnStatisticData has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    export const getColumnStatisticData = (
      props: Pick<
        IRenderLayerProps,
        'height' | 'scrollState' | 'coordInstance' | 'columnStatistics' | 'getLinearRow'
      > & {
    Severity: Minor
    Found in packages/sdk/src/components/grid/utils/region.ts - 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 checkIsRowHeader has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    const checkIsRowHeader = (props: ICheckRegionProps): IRegionData | null => {
      const { position, theme, rowControls, scrollState, coordInstance } = props;
      const { x, y, rowIndex, columnIndex } = position;
    
      if (rowIndex <= -1 || columnIndex !== -1) return null;
    Severity: Minor
    Found in packages/sdk/src/components/grid/utils/region.ts - 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

    Avoid too many return statements within this function.
    Open

      return { ...BLANK_REGION_DATA, type: RegionType.RowHeader };
    Severity: Major
    Found in packages/sdk/src/components/grid/utils/region.ts - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

        return null;
      Severity: Major
      Found in packages/sdk/src/components/grid/utils/region.ts - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

          return null;
        Severity: Major
        Found in packages/sdk/src/components/grid/utils/region.ts - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

              return {
                type: RegionType.ColumnHeader,
                x: startOffsetX,
                y: 0,
                width,
          Severity: Major
          Found in packages/sdk/src/components/grid/utils/region.ts - About 30 mins to fix

            There are no issues that match your filters.

            Category
            Status