nnnick/Chart.js

View on GitHub

Showing 245 of 245 total issues

File index.d.ts has 1611 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 976 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 743 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

            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

            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

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

            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

                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

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

            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

            Scale has 68 functions (exceeds 20 allowed). Consider refactoring.
            Open

            export default class Scale extends Element {
            
              // eslint-disable-next-line max-statements
              constructor(cfg) {
                super();
            Severity: Major
            Found in src/core/core.scale.js - About 1 day to fix

              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

                      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 1388..1416

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

                      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

                      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 1362..1416

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

                      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

                      File controller.bar.js has 470 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

                        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

                          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

                          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

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

                          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

                          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

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

                          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

                          Severity
                          Category
                          Status
                          Source
                          Language