chartjs/Chart.js

View on GitHub

Showing 240 of 245 total issues

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

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

                      if (opts.reverse) {
                        ticks.reverse();
                  
                        this.start = this.max;
                        this.end = this.min;
                  Severity: Major
                  Found in src/scales/scale.logarithmic.js and 1 other location - About 2 hrs to fix
                  src/scales/scale.linearbase.js on lines 277..285

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 85.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

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

                      if (opts.reverse) {
                        ticks.reverse();
                  
                        this.start = this.max;
                        this.end = this.min;
                  Severity: Major
                  Found in src/scales/scale.linearbase.js and 1 other location - About 2 hrs to fix
                  src/scales/scale.logarithmic.js on lines 175..183

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 85.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  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

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