nnnick/Chart.js

View on GitHub

Showing 322 of 322 total issues

Function exports has a Cognitive Complexity of 224 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = function() {

    // -- Basic js utility methods

    helpers.where = function(collection, filterCallback) {
Severity: Minor
Found in src/core/core.helpers.js - About 4 days 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 exports has 478 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function() {

    // -- Basic js utility methods

    helpers.where = function(collection, filterCallback) {
Severity: Major
Found in src/core/core.helpers.js - About 2 days to fix

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

    'use strict';
    
    var defaults = require('./core.defaults');
    var Element = require('./core.element');
    var helpers = require('../helpers/index');
    Severity: Major
    Found in src/core/core.scale.js - About 2 days to fix

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

      'use strict';
      
      var defaults = require('./core.defaults');
      var Element = require('./core.element');
      var helpers = require('../helpers/index');
      Severity: Major
      Found in src/core/core.tooltip.js - About 1 day to fix

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

        'use strict';
        
        var Animation = require('./core.animation');
        var animations = require('./core.animations');
        var controllers = require('../controllers/index');
        Severity: Major
        Found in src/core/core.controller.js - About 1 day to fix

          Function determineDataLimits has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring.
          Open

              determineDataLimits: function() {
                  var me = this;
                  var opts = me.options;
                  var chart = me.chart;
                  var datasets = chart.data.datasets;
          Severity: Minor
          Found in src/scales/scale.linear.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

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

          'use strict';
          
          var adapters = require('../core/core.adapters');
          var defaults = require('../core/core.defaults');
          var helpers = require('../helpers/index');
          Severity: Major
          Found in src/scales/scale.time.js - About 1 day to fix

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

                legendCallback: function(chart) {
                    var text = [];
                    text.push('<ul class="' + chart.id + '-legend">');
            
                    var 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 34..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 211.

            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

                legendCallback: function(chart) {
                    var text = [];
                    text.push('<ul class="' + chart.id + '-legend">');
            
                    var 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 24..44

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

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

                determineDataLimits: function() {
                    var me = this;
                    var opts = me.options;
                    var chart = me.chart;
                    var datasets = chart.data.datasets;
            Severity: Minor
            Found in src/scales/scale.logarithmic.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

                setDimensions: function() {
                    var me = this;
                    // Set the unconstrained dimension before label rotation
                    if (me.isHorizontal()) {
                        // Reset position before calculating rotation
            Severity: Major
            Found in src/plugins/plugin.legend.js and 1 other location - About 1 day to fix
            src/plugins/plugin.title.js on lines 72..99

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

            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

                setDimensions: function() {
                    var me = this;
                    // Set the unconstrained dimension before label rotation
                    if (me.isHorizontal()) {
                        // Reset position before calculating rotation
            Severity: Major
            Found in src/plugins/plugin.title.js and 1 other location - About 1 day to fix
            src/plugins/plugin.legend.js on lines 167..194

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

            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

                    labels: {
                        generateLabels: function(chart) {
                            var data = chart.data;
                            if (data.labels.length && data.datasets.length) {
                                return data.labels.map(function(label, i) {
            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 46..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 199.

            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

                    labels: {
                        generateLabels: function(chart) {
                            var data = chart.data;
                            if (data.labels.length && data.datasets.length) {
                                return data.labels.map(function(label, i) {
            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 56..78

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

            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: function(maxWidth, maxHeight, margins) {
                    var 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 37..66

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

            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: function(maxWidth, maxHeight, margins) {
                    var 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 133..161

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

            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

                setHoverStyle: function(point) {
                    var model = point._model;
                    var options = point._options;
                    var getHoverColor = helpers.getHoverColor;
            
            
            Severity: Major
            Found in src/controllers/controller.radar.js and 1 other location - About 7 hrs to fix
            src/controllers/controller.line.js on lines 301..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 193.

            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

                setHoverStyle: function(point) {
                    var model = point._model;
                    var options = point._options;
                    var getHoverColor = helpers.getHoverColor;
            
            
            Severity: Major
            Found in src/controllers/controller.line.js and 1 other location - About 7 hrs to fix
            src/controllers/controller.radar.js on lines 191..207

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

            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 core.helpers.js has 484 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            /* global window: false */
            /* global document: false */
            'use strict';
            
            var color = require('chartjs-color');
            Severity: Minor
            Found in src/core/core.helpers.js - About 7 hrs to fix

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

              'use strict';
              
              var defaults = require('../core/core.defaults');
              var Element = require('../core/core.element');
              var helpers = require('../helpers/index');
              Severity: Minor
              Found in src/plugins/plugin.legend.js - About 6 hrs to fix
                Severity
                Category
                Status
                Source
                Language