chartjs/Chart.js

View on GitHub

Showing 190 of 245 total issues

Function _getYAxisLabelAlignment has a Cognitive Complexity of 29 (exceeds 7 allowed). Consider refactoring.
Open

  _getYAxisLabelAlignment(tl) {
    const {position, ticks: {crossAlign, mirror, padding}} = this.options;
    const labelSizes = this._getLabelSizes();
    const tickAndPadding = tl + padding;
    const widest = labelSizes.widest.width;
Severity: Minor
Found in src/core/core.scale.js - About 3 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

effects has 31 functions (exceeds 20 allowed). Consider refactoring.
Open

const effects = {
  linear: (t: number) => t,

  easeInQuad: (t: number) => t * t,

Severity: Minor
Found in src/helpers/helpers.easing.ts - About 3 hrs to fix

    Function generateTicks has 86 lines of code (exceeds 25 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: Major
    Found in src/scales/scale.linearbase.js - About 3 hrs to fix

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

      import defaults, {overrides, descriptors} from './core.defaults.js';
      import {mergeIf, resolveObjectKey, isArray, isFunction, valueOrDefault, isObject} from '../helpers/helpers.core.js';
      import {_attachContext, _createResolver, _descriptors} from '../helpers/helpers.config.js';
      
      export function getIndexAxis(type, options) {
      Severity: Minor
      Found in src/core/core.config.js - About 3 hrs to fix

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

        import {defined, each, isObject} from '../helpers/helpers.core.js';
        import {toPadding} from '../helpers/helpers.options.js';
        
        /**
         * @typedef { import('./core.controller.js').default } Chart
        Severity: Minor
        Found in src/core/core.layouts.js - About 3 hrs to fix

          Function updateElements has a Cognitive Complexity of 25 (exceeds 7 allowed). Consider refactoring.
          Open

            updateElements(points, start, count, mode) {
              const reset = mode === 'reset';
              const {iScale, vScale, _stacked, _dataset} = this._cachedMeta;
              const {sharedOptions, includeOptions} = this._getSharedOptions(start, mode);
              const iAxis = iScale.axis;
          Severity: Minor
          Found in src/controllers/controller.line.js - About 3 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

          Tooltip has 26 functions (exceeds 20 allowed). Consider refactoring.
          Open

          export class Tooltip extends Element {
          
            /**
             * @namespace Chart.Tooltip.positioners
             */
          Severity: Minor
          Found in src/plugins/plugin.tooltip.js - About 3 hrs to fix

            Function minMaxDecimation has a Cognitive Complexity of 23 (exceeds 7 allowed). Consider refactoring.
            Open

            function minMaxDecimation(data, start, count, availableWidth) {
              let avgX = 0;
              let countX = 0;
              let i, point, x, y, prevX, minIndex, maxIndex, startIndex, minY, maxY;
              const decimated = [];
            Severity: Minor
            Found in src/plugins/plugin.decimation.js - About 2 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 updateElements has a Cognitive Complexity of 23 (exceeds 7 allowed). Consider refactoring.
            Open

              updateElements(points, start, count, mode) {
                const reset = mode === 'reset';
                const {iScale, vScale, _stacked, _dataset} = this._cachedMeta;
                const firstOpts = this.resolveDataElementOptions(start, mode);
                const sharedOptions = this.getSharedOptions(firstOpts);
            Severity: Minor
            Found in src/controllers/controller.scatter.js - About 2 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 controller.doughnut.js has 286 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import DatasetController from '../core/core.datasetController.js';
            import {isObject, resolveObjectKey, toPercentage, toDimension, valueOrDefault} from '../helpers/helpers.core.js';
            import {formatNumber} from '../helpers/helpers.intl.js';
            import {toRadians, PI, TAU, HALF_PI, _angleBetween} from '../helpers/helpers.math.js';
            
            
            Severity: Minor
            Found in src/controllers/controller.doughnut.js - About 2 hrs to fix

              File element.arc.ts has 285 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import Element from '../core/core.element.js';
              import {_angleBetween, getAngleFromPoint, TAU, HALF_PI, valueOrDefault} from '../helpers/index.js';
              import {PI, _isBetween, _limitValue} from '../helpers/helpers.math.js';
              import {_readValueToProps} from '../helpers/helpers.options.js';
              import type {ArcOptions, Point} from '../types/index.js';
              Severity: Minor
              Found in src/elements/element.arc.ts - About 2 hrs to fix

                Function applyScaleDefaults has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export function applyScaleDefaults(defaults) {
                  defaults.set('scale', {
                    display: true,
                    offset: false,
                    reverse: false,
                Severity: Major
                Found in src/core/core.scale.defaults.js - About 2 hrs to fix

                  File element.line.js has 281 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import Element from '../core/core.element.js';
                  import {_bezierInterpolation, _pointInLine, _steppedInterpolation} from '../helpers/helpers.interpolation.js';
                  import {_computeSegments, _boundSegments} from '../helpers/helpers.segment.js';
                  import {_steppedLineTo, _bezierCurveTo} from '../helpers/helpers.canvas.js';
                  import {_updateBezierControlPoints} from '../helpers/helpers.curve.js';
                  Severity: Minor
                  Found in src/elements/element.line.js - About 2 hrs to fix

                    Function fit has a Cognitive Complexity of 21 (exceeds 7 allowed). Consider refactoring.
                    Open

                      fit() {
                        // Reset
                        const minSize = {
                          width: 0,
                          height: 0
                    Severity: Minor
                    Found in src/core/core.scale.js - About 2 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 applyAnimationsDefaults has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export function applyAnimationsDefaults(defaults) {
                      defaults.set('animation', {
                        delay: undefined,
                        duration: 1000,
                        easing: 'easeOutQuart',
                    Severity: Major
                    Found in src/core/core.animations.defaults.js - About 2 hrs to fix

                      Function pathArc has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function pathArc(
                        ctx: CanvasRenderingContext2D,
                        element: ArcElement,
                        offset: number,
                        spacing: number,
                      Severity: Major
                      Found in src/elements/element.arc.ts - About 2 hrs to fix

                        Function _drawColorBox has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          _drawColorBox(ctx, pt, i, rtlHelper, options) {
                            const labelColor = this.labelColors[i];
                            const labelPointStyle = this.labelPointStyles[i];
                            const {boxHeight, boxWidth} = options;
                            const bodyFont = toFont(options.bodyFont);
                        Severity: Major
                        Found in src/plugins/plugin.tooltip.js - About 2 hrs to fix

                          Function doSplitByStyles has a Cognitive Complexity of 20 (exceeds 7 allowed). Consider refactoring.
                          Open

                          function doSplitByStyles(line, segments, points, segmentOptions) {
                            const chartContext = line._chart.getContext();
                            const baseStyle = readStyle(line.options);
                            const {_datasetIndex: datasetIndex, options: {spanGaps}} = line;
                            const count = points.length;
                          Severity: Minor
                          Found in src/helpers/helpers.segment.js - About 2 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 _computeGridLineItems has a Cognitive Complexity of 20 (exceeds 7 allowed). Consider refactoring.
                          Open

                            _computeGridLineItems(chartArea) {
                              const axis = this.axis;
                              const chart = this.chart;
                              const options = this.options;
                              const {grid, position, border} = options;
                          Severity: Minor
                          Found in src/core/core.scale.js - About 2 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 parse has a Cognitive Complexity of 20 (exceeds 7 allowed). Consider refactoring.
                          Open

                            parse(start, count) {
                              const {_cachedMeta: meta, _data: data} = this;
                              const {iScale, _stacked} = meta;
                              const iAxis = iScale.axis;
                          
                          
                          Severity: Minor
                          Found in src/core/core.datasetController.js - About 2 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

                          Severity
                          Category
                          Status
                          Source
                          Language