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,
- Read upRead up
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
- Read upRead up
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,
- Read upRead up
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 {
- Read upRead up
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
- Read upRead up
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,
- Read upRead up
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
- Read upRead up
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;
- Read upRead up
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,
- Read upRead up
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,
- Read upRead up
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
- Read upRead up
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,
- Read upRead up
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"