chartjs/Chart.js

View on GitHub

Showing 190 of 245 total issues

File index.d.ts has 1611 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* eslint-disable @typescript-eslint/ban-types */
import {DeepPartial, DistributiveArray, UnionToIntersection} from './utils.js';

import {TimeUnit} from '../core/core.adapters.js';
import PointElement from '../elements/element.point.js';
Severity: Major
Found in src/types/index.d.ts - About 4 days to fix

    File core.scale.js has 1223 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import Element from './core.element.js';
    import {_alignPixel, _measureText, renderText, clipArea, unclipArea} from '../helpers/helpers.canvas.js';
    import {callback as call, each, finiteOrDefault, isArray, isFinite, isNullOrUndef, isObject, valueOrDefault} from '../helpers/helpers.core.js';
    import {toDegrees, toRadians, _int16Range, _limitValue, HALF_PI} from '../helpers/helpers.math.js';
    import {_alignStartEnd, _toLeftRightCenter} from '../helpers/helpers.extras.js';
    Severity: Major
    Found in src/core/core.scale.js - About 3 days to fix

      File plugin.tooltip.js has 976 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import Animations from '../core/core.animations.js';
      import Element from '../core/core.element.js';
      import {addRoundedRectPath} from '../helpers/helpers.canvas.js';
      import {each, noop, isNullOrUndef, isArray, _elementsEqual, isObject} from '../helpers/helpers.core.js';
      import {toFont, toPadding, toTRBLCorners} from '../helpers/helpers.options.js';
      Severity: Major
      Found in src/plugins/plugin.tooltip.js - About 2 days to fix

        File core.controller.js has 878 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import animator from './core.animator.js';
        import defaults, {overrides} from './core.defaults.js';
        import Interaction from './core.interaction.js';
        import layouts from './core.layouts.js';
        import {_detectPlatform} from '../platform/index.js';
        Severity: Major
        Found in src/core/core.controller.js - About 2 days to fix

          File core.datasetController.js has 747 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import Animations from './core.animations.js';
          import defaults from './core.defaults.js';
          import {isArray, isFinite, isObject, valueOrDefault, resolveObjectKey, defined} from '../helpers/helpers.core.js';
          import {listenArrayEvents, unlistenArrayEvents} from '../helpers/helpers.collection.js';
          import {createContext, sign} from '../helpers/index.js';
          Severity: Major
          Found in src/core/core.datasetController.js - About 1 day to fix

            Function _computeLabelItems has a Cognitive Complexity of 78 (exceeds 7 allowed). Consider refactoring.
            Open

              _computeLabelItems(chartArea) {
                const axis = this.axis;
                const options = this.options;
                const {position, ticks: optionTicks} = options;
                const isHorizontal = this.isHorizontal();
            Severity: Minor
            Found in src/core/core.scale.js - About 1 day 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

            Chart has 64 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class Chart {
            
              static defaults = defaults;
              static instances = instances;
              static overrides = overrides;
            Severity: Major
            Found in src/core/core.controller.js - About 1 day to fix

              File plugin.legend.js has 525 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import defaults from '../core/core.defaults.js';
              import Element from '../core/core.element.js';
              import layouts from '../core/core.layouts.js';
              import {addRoundedRectPath, drawPointLegend, renderText} from '../helpers/helpers.canvas.js';
              import {
              Severity: Major
              Found in src/plugins/plugin.legend.js - About 1 day to fix

                File scale.radialLinear.js has 500 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import defaults from '../core/core.defaults.js';
                import {_longestText, addRoundedRectPath, renderText, _isPointInArea} from '../helpers/helpers.canvas.js';
                import {HALF_PI, TAU, toDegrees, toRadians, _normalizeAngle, PI} from '../helpers/helpers.math.js';
                import LinearScaleBase from './scale.linearbase.js';
                import Ticks from '../core/core.ticks.js';
                Severity: Minor
                Found in src/scales/scale.radialLinear.js - About 1 day to fix

                  DatasetController has 55 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  export default class DatasetController {
                  
                    /**
                     * @type {any}
                     */
                  Severity: Major
                  Found in src/core/core.datasetController.js - About 7 hrs to fix

                    File controller.bar.js has 470 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import DatasetController from '../core/core.datasetController.js';
                    import {
                      _arrayUnique, isArray, isNullOrUndef,
                      valueOrDefault, resolveObjectKey, sign, defined
                    } from '../helpers/index.js';
                    Severity: Minor
                    Found in src/controllers/controller.bar.js - About 7 hrs to fix

                      Function _computeLabelItems has 164 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        _computeLabelItems(chartArea) {
                          const axis = this.axis;
                          const options = this.options;
                          const {position, ticks: optionTicks} = options;
                          const isHorizontal = this.isHorizontal();
                      Severity: Major
                      Found in src/core/core.scale.js - About 6 hrs to fix

                        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

                        Function generateTicks has a Cognitive Complexity of 38 (exceeds 7 allowed). Consider refactoring.
                        Open

                        function generateTicks(generationOptions, dataRange) {
                          const ticks = [];
                          // To get a "nice" value for the tick spacing, we will use the appropriately named
                          // "nice number" algorithm. See https://stackoverflow.com/questions/8506881/nice-label-algorithm-for-charts-with-minimum-ticks
                          // for details.
                        Severity: Minor
                        Found in src/scales/scale.linearbase.js - About 5 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

                          File scale.time.js has 384 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          import adapters from '../core/core.adapters.js';
                          import {callback as call, isFinite, isNullOrUndef, mergeIf, valueOrDefault} from '../helpers/helpers.core.js';
                          import {toRadians, isNumber, _limitValue} from '../helpers/helpers.math.js';
                          import Scale from '../core/core.scale.js';
                          import {_arrayUnique, _filterBetween, _lookup} from '../helpers/helpers.collection.js';
                          Severity: Minor
                          Found in src/scales/scale.time.js - 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 _draw has 118 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                _draw() {
                                  const {options: opts, columnSizes, lineWidths, ctx} = this;
                                  const {align, labels: labelOpts} = opts;
                                  const defaultColor = defaults.color;
                                  const rtlHelper = getRtlAdapter(opts.rtl, this.left, this.width);
                              Severity: Major
                              Found in src/plugins/plugin.legend.js - About 4 hrs to fix

                                Function _computeGridLineItems has 113 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  _computeGridLineItems(chartArea) {
                                    const axis = this.axis;
                                    const chart = this.chart;
                                    const options = this.options;
                                    const {grid, position, border} = options;
                                Severity: Major
                                Found in src/core/core.scale.js - About 4 hrs to fix

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

                                  /* eslint-disable @typescript-eslint/no-use-before-define */
                                  import type {AnyObject} from '../types/basic.js';
                                  import type {ChartMeta} from '../types/index.js';
                                  import type {
                                    ResolverObjectKey,
                                  Severity: Minor
                                  Found in src/helpers/helpers.config.ts - About 4 hrs to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language