chartjs/Chart.js

View on GitHub

Showing 242 of 247 total issues

Function update has 58 lines of code (exceeds 25 allowed). Consider refactoring.
Open

update(chart, width, height, minPadding) {
if (!chart) {
return;
}
 
 
Severity: Major
Found in src/core/core.layouts.js - About 2 hrs to fix

    Function _getYAxisLabelAlignment has 58 lines of code (exceeds 25 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: Major
    Found in src/core/core.scale.js - About 2 hrs to fix

      Function buildOrUpdateScales has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      buildOrUpdateScales() {
      const options = this.options;
      const scaleOpts = options.scales;
      const scales = this.scales;
      const updated = Object.keys(scales).reduce((obj, id) => {
      Severity: Major
      Found in src/core/core.controller.js - About 2 hrs to fix

        Function beforeElementsUpdate has 55 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        beforeElementsUpdate: (chart, args, options) => {
        if (!options.enabled) {
        // The decimation plugin may have been previously enabled. Need to remove old `dataset._data` handlers
        cleanDecimatedData(chart);
        return;
        Severity: Major
        Found in src/plugins/plugin.decimation.js - About 2 hrs to fix

          Function _calculateBarValuePixels has 55 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          _calculateBarValuePixels(index) {
          const {_cachedMeta: {vScale, _stacked, index: datasetIndex}, options: {base: baseValue, minBarLength}} = this;
          const actualBase = baseValue || 0;
          const parsed = this.getParsed(index);
          const custom = parsed._custom;
          Severity: Major
          Found in src/controllers/controller.bar.js - About 2 hrs to fix

            Function constructor has 54 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            constructor(item, userConfig) {
            const config = this.config = new Config(userConfig);
            const initialCanvas = getCanvas(item);
            const existingChart = getChart(initialCanvas);
            if (existingChart) {
            Severity: Major
            Found in src/core/core.controller.js - About 2 hrs to fix

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

              /**
              * @namespace Chart.helpers
              */
               
              import type {AnyObject} from '../types/basic.js';
              Severity: Minor
              Found in src/helpers/helpers.core.ts - About 2 hrs to fix

                Function placeBoxes has a Cognitive Complexity of 18 (exceeds 7 allowed). Consider refactoring.
                Open

                function placeBoxes(boxes, chartArea, params, stacks) {
                const userPadding = params.padding;
                let {x, y} = chartArea;
                 
                for (const layout of boxes) {
                Severity: Minor
                Found in src/core/core.layouts.js - About 2 hrs to fix

                Function pathArc has a Cognitive Complexity of 18 (exceeds 7 allowed). Consider refactoring.
                Open

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

                Function minMaxDecimation has 51 lines of code (exceeds 25 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: Major
                Found in src/plugins/plugin.decimation.js - About 2 hrs to fix

                  Function getTooltipSize has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function getTooltipSize(tooltip, options) {
                  const ctx = tooltip.chart.ctx;
                  const {body, footer, title} = tooltip;
                  const {boxWidth, boxHeight} = options;
                  const bodyFont = toFont(options.bodyFont);
                  Severity: Major
                  Found in src/plugins/plugin.tooltip.js - About 2 hrs to fix

                    Function doSplitByStyles has 51 lines of code (exceeds 25 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: Major
                    Found in src/helpers/helpers.segment.js - About 2 hrs to fix

                      File helpers.segment.js has 251 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      import {_angleBetween, _angleDiff, _isBetween, _normalizeAngle} from './helpers.math.js';
                      import {createContext} from './helpers.options.js';
                      import {isPatternOrGradient} from './helpers.color.js';
                       
                      /**
                      Severity: Minor
                      Found in src/helpers/helpers.segment.js - About 2 hrs to fix

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

                        } else if (position === 'right') {
                        borderValue = alignBorderValue(this.left);
                        x1 = chartArea.left;
                        x2 = alignBorderValue(chartArea.right) - axisHalfWidth;
                        tx1 = borderValue + axisHalfWidth;
                        Severity: Major
                        Found in src/core/core.scale.js and 1 other location - About 2 hrs to fix
                        src/core/core.scale.js on lines 1040..1084

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

                        } else if (position === 'bottom') {
                        borderValue = alignBorderValue(this.top);
                        y1 = chartArea.top;
                        y2 = alignBorderValue(chartArea.bottom) - axisHalfWidth;
                        ty1 = borderValue + axisHalfWidth;
                        Severity: Major
                        Found in src/core/core.scale.js and 1 other location - About 2 hrs to fix
                        src/core/core.scale.js on lines 1052..1084

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

                        if (position === 'top') {
                        borderValue = alignBorderValue(this.bottom);
                        ty1 = this.bottom - tl;
                        ty2 = borderValue - axisHalfWidth;
                        y1 = alignBorderValue(chartArea.top) + axisHalfWidth;
                        Severity: Major
                        Found in src/core/core.scale.js and 1 other location - About 2 hrs to fix
                        src/core/core.scale.js on lines 1046..1084

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

                        } else if (position === 'left') {
                        borderValue = alignBorderValue(this.right);
                        tx1 = this.right - tl;
                        tx2 = borderValue - axisHalfWidth;
                        x1 = alignBorderValue(chartArea.left) + axisHalfWidth;
                        Severity: Major
                        Found in src/core/core.scale.js and 1 other location - About 2 hrs to fix
                        src/core/core.scale.js on lines 1034..1084

                        Function update has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        update(maxWidth, maxHeight, margins) {
                        const {beginAtZero, grace, ticks: tickOpts} = this.options;
                        const sampleSize = tickOpts.sampleSize;
                         
                        // Update Lifecycle - Probably don't want to ever extend or overwrite this function ;)
                        Severity: Minor
                        Found in src/core/core.scale.js - About 1 hr to fix

                          Function constructor has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          constructor(cfg) {
                          super();
                           
                          /** @type {string} */
                          this.id = cfg.id;
                          Severity: Minor
                          Found in src/core/core.scale.js - About 1 hr to fix

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

                            updateElements(bars, start, count, mode) {
                            const reset = mode === 'reset';
                            const {index, _cachedMeta: {vScale}} = this;
                            const base = vScale.getBasePixel();
                            const horizontal = vScale.isHorizontal();
                            Severity: Minor
                            Found in src/controllers/controller.bar.js - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language