chartjs/Chart.js

View on GitHub

Showing 242 of 247 total issues

File index.d.ts has 1618 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 979 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 753 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

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

            plugins: {
            legend: {
            labels: {
            generateLabels(chart) {
            const data = chart.data;
            Severity: Major
            Found in src/controllers/controller.polarArea.js and 1 other location - About 1 day to fix
            src/controllers/controller.doughnut.js on lines 89..124

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

            plugins: {
            legend: {
            labels: {
            generateLabels(chart) {
            const data = chart.data;
            Severity: Major
            Found in src/controllers/controller.doughnut.js and 1 other location - About 1 day to fix
            src/controllers/controller.polarArea.js on lines 33..68

            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 472 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

                      Similar blocks of code found in 2 locations. Consider refactoring.
                      Open

                      } else if (position === 'right') {
                      if (mirror) {
                      x = this.left + padding;
                       
                      if (crossAlign === 'near') {
                      Severity: Major
                      Found in src/core/core.scale.js and 1 other location - About 7 hrs to fix
                      src/core/core.scale.js on lines 1361..1415

                      Similar blocks of code found in 2 locations. Consider refactoring.
                      Open

                      if (position === 'left') {
                      if (mirror) {
                      x = this.right + padding;
                       
                      if (crossAlign === 'near') {
                      Severity: Major
                      Found in src/core/core.scale.js and 1 other location - About 7 hrs to fix
                      src/core/core.scale.js on lines 1387..1415

                      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

                        Similar blocks of code found in 2 locations. Consider refactoring.
                        Open

                        if (hLimits.start < orig.l) {
                        x = (orig.l - hLimits.start) / sin;
                        limits.l = Math.min(limits.l, orig.l - x);
                        } else if (hLimits.end > orig.r) {
                        x = (hLimits.end - orig.r) / sin;
                        Severity: Major
                        Found in src/scales/scale.radialLinear.js and 1 other location - About 5 hrs to fix
                        src/scales/scale.radialLinear.js on lines 130..136

                        Similar blocks of code found in 2 locations. Consider refactoring.
                        Open

                        if (vLimits.start < orig.t) {
                        y = (orig.t - vLimits.start) / cos;
                        limits.t = Math.min(limits.t, orig.t - y);
                        } else if (vLimits.end > orig.b) {
                        y = (vLimits.end - orig.b) / cos;
                        Severity: Major
                        Found in src/scales/scale.radialLinear.js and 1 other location - About 5 hrs to fix
                        src/scales/scale.radialLinear.js on lines 123..129

                        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
                        Severity
                        Category
                        Status
                        Source
                        Language