File baseRenderer.ts
has 569 lines of code (exceeds 300 allowed). Consider refactoring. Open
import { LRUCache } from 'lru-cache';
import { parseToRGB } from '../../utils';
import type {
ILineProps,
IMultiLineTextProps,
Function drawMultiLineText
has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring. Open
export const drawMultiLineText = (ctx: CanvasRenderingContext2D, props: IMultiLineTextProps) => {
const {
x = 0,
y = 0,
text,
- 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 drawRoundPoly
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
export const drawRoundPoly = (ctx: CanvasRenderingContext2D, props: IRoundPolyProps) => {
const { points, radiusAll, fill, stroke } = props;
const asVec = function (p: IPoint, pp: IPoint): IVector {
const vx = pp.x - p.x;
const vy = pp.y - p.y;
- 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 drawSingleLineText
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
export const drawSingleLineText = (ctx: CanvasRenderingContext2D, props: ISingleLineTextProps) => {
const {
x = 0,
y = 0,
text,
- 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 drawChartBar
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
export const drawChartBar = (ctx: CanvasRenderingContext2D, props: IChartBarProps) => {
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 drawChartLine
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
export const drawChartLine = (ctx: CanvasRenderingContext2D, props: IChartLineProps) => {
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 drawAvatar
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
export const drawAvatar = (ctx: CanvasRenderingContext2D, props: IAvatarProps) => {
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 drawRect
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export const drawRect = (ctx: CanvasRenderingContext2D, props: IRectProps) => {
const { x, y, width, height, fill, stroke, radius: _radius } = props;
ctx.beginPath();
if (fill) ctx.fillStyle = fill;
- 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
Avoid deeply nested control flow statements. Open
if (currentLineWidth + ellipsisWidth > maxWidth) {
let tempLine = currentLine;
let tempLineWidth = currentLineWidth;
while (tempLineWidth + ellipsisWidth > maxWidth) {
tempLine = tempLine.substring(0, tempLine.length - 1);