nnnick/Chart.js

View on GitHub

Showing 191 of 245 total issues

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

TimeScale has 22 functions (exceeds 20 allowed). Consider refactoring.
Open

export default class TimeScale extends Scale {

  static id = 'time';

  /**
Severity: Minor
Found in src/scales/scale.time.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 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 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 _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 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 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

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

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

                    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

                        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

                          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 _boundSegment has a Cognitive Complexity of 17 (exceeds 7 allowed). Consider refactoring.
                              Open

                              export function _boundSegment(segment, points, bounds) {
                                if (!bounds) {
                                  return [segment];
                                }
                              
                              
                              Severity: Minor
                              Found in src/helpers/helpers.segment.js - 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 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

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

                              Severity
                              Category
                              Status
                              Source
                              Language