nnnick/Chart.js

View on GitHub

Showing 276 of 276 total issues

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

import defaults from './core.defaults';
import Element from './core.element';
import {_alignPixel, _measureText} from '../helpers/helpers.canvas';
import {callback as call, each, isArray, isFinite, isNullOrUndef, isObject, valueOrDefault} from '../helpers/helpers.core';
import {_factorize, toDegrees, toRadians} from '../helpers/helpers.math';
Severity: Major
Found in src/core/core.scale.js - About 2 days to fix

    File plugin.tooltip.js has 807 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import Animations from '../core/core.animations';
    import defaults from '../core/core.defaults';
    import Element from '../core/core.element';
    import plugins from '../core/core.plugins';
    import helpers from '../helpers/index';
    Severity: Major
    Found in src/plugins/plugin.tooltip.js - About 1 day to fix

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

      import helpers from '../helpers/index';
      import Animations from './core.animations';
      
      /**
       * @typedef { import("./core.controller").default } Chart
      Severity: Major
      Found in src/core/core.datasetController.js - About 1 day to fix

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

        import Animator from './core.animator';
        import controllers from '../controllers/index';
        import defaults from './core.defaults';
        import helpers from '../helpers/index';
        import Interaction from './core.interaction';
        Severity: Major
        Found in src/core/core.controller.js - About 1 day to fix

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

              legend: {
                  labels: {
                      generateLabels(chart) {
                          const data = chart.data;
                          if (data.labels.length && data.datasets.length) {
          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 25..54

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

          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

              legend: {
                  labels: {
                      generateLabels(chart) {
                          const data = chart.data;
                          if (data.labels.length && data.datasets.length) {
          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..62

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

          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 plugin.legend.js has 527 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import defaults from '../core/core.defaults';
          import Element from '../core/core.element';
          import layouts from '../core/core.layouts';
          import {drawPoint} from '../helpers/helpers.canvas';
          import {callback as call, mergeIf, valueOrDefault} from '../helpers/helpers.core';
          Severity: Major
          Found in src/plugins/plugin.legend.js - About 1 day to fix

            Scale has 58 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

              DatasetController has 58 functions (exceeds 20 allowed). Consider refactoring.
              Open

              export default class DatasetController {
              
                  static extend = helpers.inherits;
              
                  /**
              Severity: Major
              Found in src/core/core.datasetController.js - About 1 day to fix

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

                    update(maxWidth, maxHeight, margins) {
                        const me = this;
                
                        // Update Lifecycle - Probably don't want to ever extend or overwrite this function ;)
                        me.beforeUpdate();
                Severity: Major
                Found in src/plugins/plugin.legend.js and 1 other location - About 7 hrs to fix
                src/plugins/plugin.title.js on lines 47..74

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

                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

                    update(maxWidth, maxHeight, margins) {
                        const me = this;
                
                        // Update Lifecycle - Probably don't want to ever extend or overwrite this function ;)
                        me.beforeUpdate();
                Severity: Major
                Found in src/plugins/plugin.title.js and 1 other location - About 7 hrs to fix
                src/plugins/plugin.legend.js on lines 148..174

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

                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 scale.time.js has 459 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import adapters from '../core/core.adapters';
                import defaults from '../core/core.defaults';
                import {isFinite, isNullOrUndef, mergeIf, valueOrDefault} from '../helpers/helpers.core';
                import {toRadians} from '../helpers/helpers.math';
                import Scale from '../core/core.scale';
                Severity: Minor
                Found in src/scales/scale.time.js - About 7 hrs to fix

                  Function _computeLabelItems has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
                  Open

                      _computeLabelItems(chartArea) {
                          const me = this;
                          const axis = me.axis;
                          const options = me.options;
                          const {position, ticks: optionTicks} = options;
                  Severity: Minor
                  Found in src/core/core.scale.js - 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

                          x(chart, e, options, useFinalPosition) {
                              const position = getRelativePosition(e, chart);
                              const items = [];
                              let intersectsItem = false;
                  
                  
                  Severity: Major
                  Found in src/core/core.interaction.js and 1 other location - About 6 hrs to fix
                  src/core/core.interaction.js on lines 328..349

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

                  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

                          y(chart, e, options, useFinalPosition) {
                              const position = getRelativePosition(e, chart);
                              const items = [];
                              let intersectsItem = false;
                  
                  
                  Severity: Major
                  Found in src/core/core.interaction.js and 1 other location - About 6 hrs to fix
                  src/core/core.interaction.js on lines 296..317

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

                  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

                  Chart has 46 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  export default class Chart {
                  
                      static version = version;
                  
                      /**
                  Severity: Minor
                  Found in src/core/core.controller.js - About 6 hrs to fix

                    Function splineCurveMonotone has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export function splineCurveMonotone(points) {
                        // This function calculates Bézier control points in a similar way than |splineCurve|,
                        // but preserves monotonicity of the provided data and ensures no local extremums are added
                        // between the dataset discrete points due to the interpolation.
                        // See : https://en.wikipedia.org/wiki/Monotone_cubic_interpolation
                    Severity: Minor
                    Found in src/helpers/helpers.curve.js - About 5 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

                    export function getMaximumWidth(domNode) {
                        const container = _getParentNode(domNode);
                        if (!container) {
                            if (typeof domNode.clientWidth === 'number') {
                                return domNode.clientWidth;
                    Severity: Major
                    Found in src/helpers/helpers.dom.js and 1 other location - About 5 hrs to fix
                    src/helpers/helpers.dom.js on lines 147..163

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

                    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

                    export function getMaximumHeight(domNode) {
                        const container = _getParentNode(domNode);
                        if (!container) {
                            if (typeof domNode.clientHeight === 'number') {
                                return domNode.clientHeight;
                    Severity: Major
                    Found in src/helpers/helpers.dom.js and 1 other location - About 5 hrs to fix
                    src/helpers/helpers.dom.js on lines 129..145

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

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

                        drawTitle(chartArea) { // eslint-disable-line no-unused-vars
                            const me = this;
                            const ctx = me.ctx;
                            const options = me.options;
                            const scaleLabel = options.scaleLabel;
                    Severity: Minor
                    Found in src/core/core.scale.js - About 5 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