teableio/teable

View on GitHub
packages/sdk/src/components/grid/renderers/layout-renderer/layoutRenderer.ts

Summary

Maintainability
F
1 wk
Test Coverage

File layoutRenderer.ts has 1594 lines of code (exceeds 300 allowed). Consider refactoring.
Open

import { contractColorForTheme } from '@teable/core';
import { isEqual, groupBy, cloneDeep } from 'lodash';
import type { IGridTheme } from '../../configs';
import { GRID_DEFAULT, ROW_RELATED_REGIONS } from '../../configs';
import type { IVisibleRegion } from '../../hooks';

    Function calcCells has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
    Open

    export const calcCells = (props: ILayoutDrawerProps, renderRegion: RenderRegion) => {
      const {
        coordInstance,
        visibleRegion,
        activeCell,

    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 drawColumnStatistics has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
    Open

    export const drawColumnStatistics = (
      ctx: CanvasRenderingContext2D,
      props: ILayoutDrawerProps,
      renderRegion: RenderRegion
      // eslint-disable-next-line sonarjs/cognitive-complexity

    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 drawRowHeader has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

    export const drawRowHeader = (ctx: CanvasRenderingContext2D, props: IRowHeaderDrawerProps) => {
      const {
        x,
        y,
        width,

    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 drawStatisticCell has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    export const drawStatisticCell = (
      ctx: CanvasRenderingContext2D,
      props: IGroupStatisticDrawerProps
    ) => {
      const {

    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 drawColumnHeaders has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    export const drawColumnHeaders = (
      ctx: CanvasRenderingContext2D,
      props: ILayoutDrawerProps,
      renderRegion: RenderRegion
      // eslint-disable-next-line sonarjs/cognitive-complexity

    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 drawCollaborators has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    export const drawCollaborators = (ctx: CanvasRenderingContext2D, props: ILayoutDrawerProps) => {
      const {
        collaborators,
        scrollState,
        coordInstance,

    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

            if (linearRowType === LinearRowType.Group) {
              const { id, depth } = linearRow;
              const text = columnStatistics[columnId ?? name]?.[id];
    
              const labelWidth = isFirstColumn

      Function getVisibleCollaborators has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      const getVisibleCollaborators = (
        collaborators: ICollaborator,
        visibleRegion: IVisibleRegion,
        freezeColumnCount: number,
        getCellContent: (cell: ICellItem) => ICell

      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 drawCacheContent has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      export const drawCacheContent = (
        cacheCanvas: HTMLCanvasElement | undefined,
        props: ICacheDrawerProps
      ) => {
        if (!cacheCanvas) return;

      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 drawActiveCell has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      export const drawActiveCell = (ctx: CanvasRenderingContext2D, props: ILayoutDrawerProps) => {
        const {
          theme,
          mouseState,
          scrollState,

      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 drawColumnHeader has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      export const drawColumnHeader = (ctx: CanvasRenderingContext2D, props: IFieldHeadDrawerProps) => {
        const { x, y, width, height, theme, fill, column, hasMenu, spriteManager } = props;
        const { name, icon, description, hasMenu: hasColumnMenu, isPrimary } = column;
        const {
          cellLineColor,

      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 drawGrid has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      export const drawGrid = (
        mainCanvas: HTMLCanvasElement,
        cacheCanvas: HTMLCanvasElement,
        props: ILayoutDrawerProps,
        lastProps?: ILayoutDrawerProps

      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 drawGridHeader has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      export const drawGridHeader = (ctx: CanvasRenderingContext2D, props: IGridHeaderDrawerProps) => {
        const { x, y, width, height, theme, rowControls, isChecked, isMultiSelectionEnable } = props;
        const {
          iconSizeXS,
          staticWhite,

      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

      There are no issues that match your filters.

      Category
      Status