chartjs/Chart.js

View on GitHub
src/helpers/helpers.canvas.ts

Summary

Maintainability
D
2 days
Test Coverage

Function drawPointLegend has a Cognitive Complexity of 42 (exceeds 7 allowed). Consider refactoring.
Open

export function drawPointLegend(
  ctx: CanvasRenderingContext2D,
  options: DrawPointOptions,
  x: number,
  y: number,
Severity: Minor
Found in src/helpers/helpers.canvas.ts - About 6 hrs 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

File helpers.canvas.ts has 389 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import type {
  Chart,
  Point,
  FontSpec,
  CanvasFontSpec,
Severity: Minor
Found in src/helpers/helpers.canvas.ts - About 5 hrs to fix

    Function drawPointLegend has 119 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function drawPointLegend(
      ctx: CanvasRenderingContext2D,
      options: DrawPointOptions,
      x: number,
      y: number,
    Severity: Major
    Found in src/helpers/helpers.canvas.ts - About 4 hrs to fix

      Function _longestText has a Cognitive Complexity of 17 (exceeds 7 allowed). Consider refactoring.
      Open

      export function _longestText(
        ctx: CanvasRenderingContext2D,
        font: string,
        arrayOfThings: Things,
        cache?: {data?: Record<string, number>, garbageCollect?: string[], font?: string}
      Severity: Minor
      Found in src/helpers/helpers.canvas.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 _longestText has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function _longestText(
        ctx: CanvasRenderingContext2D,
        font: string,
        arrayOfThings: Things,
        cache?: {data?: Record<string, number>, garbageCollect?: string[], font?: string}
      Severity: Minor
      Found in src/helpers/helpers.canvas.ts - About 1 hr to fix

        Function renderText has a Cognitive Complexity of 13 (exceeds 7 allowed). Consider refactoring.
        Open

        export function renderText(
          ctx: CanvasRenderingContext2D,
          text: string | string[],
          x: number,
          y: number,
        Severity: Minor
        Found in src/helpers/helpers.canvas.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 renderText has 6 arguments (exceeds 5 allowed). Consider refactoring.
        Open

          ctx: CanvasRenderingContext2D,
          text: string | string[],
          x: number,
          y: number,
          font: CanvasFontSpec,
        Severity: Minor
        Found in src/helpers/helpers.canvas.ts - About 35 mins to fix

          There are no issues that match your filters.

          Category
          Status