nagix/chartjs-plugin-style

View on GitHub

Showing 14 of 22 total issues

File helpers.style.js has 329 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

import Chart from 'chart.js';
import optionsHelpers from './helpers.options';

Severity: Minor
Found in src/helpers/helpers.style.js - About 3 hrs to fix

    Function parseBorderWidth has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    function parseBorderWidth(vm) {
        var value = vm.borderWidth;
        var skip = parseBorderSkipped(vm);
        var maxW, maxH, t, r, b, l;
    
    
    Severity: Minor
    Found in src/controllers/controller.styleBar.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 drawBevel has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        drawBevel: function(chart, options, drawCallback) {
            var ctx = chart.ctx;
            var pixelRatio = chart.currentDevicePixelRatio;
            var shadowWidthFactor = pixelRatio * 5 / 6;
            var width = options.bevelWidth * shadowWidthFactor;
    Severity: Minor
    Found in src/helpers/helpers.style.js - About 1 hr to fix

      Function draw has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          draw: function() {
              var me = this;
              var chart = me.chart;
              var globalDefaults = defaults.global;
              var each = helpers.each;
      Severity: Minor
      Found in src/plugins/plugin.styleLegend.js - About 1 hr to fix

        Function resolvePointStyle has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            resolvePointStyle: function(controller, element, index, options) {
                var me = this;
                var chart = controller.chart;
                var dataset = chart.data.datasets[controller.index];
                var custom = element.custom || {};
        Severity: Minor
        Found in src/helpers/helpers.style.js - About 1 hr to fix

          Function generateLabels has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          defaults.global.legend.labels.generateLabels = function(chart) {
              var data = chart.data;
              var options = chart.options.legend || {};
              var usePointStyle = options.labels && options.labels.usePointStyle;
          
          
          Severity: Minor
          Found in src/plugins/plugin.styleLegend.js - About 1 hr to fix

            Function resolveStyle has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                resolveStyle: function(controller, element, index, options) {
                    var me = this;
                    var chart = controller.chart;
                    var dataset = chart.data.datasets[controller.index];
                    var custom = element.custom || {};
            Severity: Minor
            Found in src/helpers/helpers.style.js - About 1 hr to fix

              Function drawGlow has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  drawGlow: function(chart, options, drawCallback, isOuter) {
                      var ctx = chart.ctx;
                      var width = isOuter ? options.outerGlowWidth : options.innerGlowWidth;
                      var borderWidth = options.borderWidth;
                      var pixelRatio = chart.currentDevicePixelRatio;
              Severity: Minor
              Found in src/helpers/helpers.style.js - About 1 hr to fix

                Function resolve has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                    resolve: optionsHelpers.resolve || function(inputs, context, index) {
                        var i, ilen, value;
                
                        for (i = 0, ilen = inputs.length; i < ilen; ++i) {
                            value = inputs[i];
                Severity: Minor
                Found in src/helpers/helpers.options.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

                Consider simplifying this complex logical expression.
                Open

                    if (value !== null && Object.prototype.toString.call(value) === '[object Object]') {
                        t = +value.top || 0;
                        r = +value.right || 0;
                        b = +value.bottom || 0;
                        l = +value.left || 0;
                Severity: Major
                Found in src/controllers/controller.styleBar.js - About 1 hr to fix

                  Function descriptors has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  plugins.descriptors = function(chart) {
                      var style = chart._style;
                  
                      // Replace legend plugin with style legend plugin
                      if (style) {
                  Severity: Minor
                  Found in src/plugins/plugin.style.js - About 45 mins 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 drawBevel has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      drawBevel: function(chart, options, drawCallback) {
                          var ctx = chart.ctx;
                          var pixelRatio = chart.currentDevicePixelRatio;
                          var shadowWidthFactor = pixelRatio * 5 / 6;
                          var width = options.bevelWidth * shadowWidthFactor;
                  Severity: Minor
                  Found in src/helpers/helpers.style.js - About 45 mins 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 drawBackground has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      drawBackground: function(pt, vm, ctx, tooltipSize, opacity) {
                  Severity: Minor
                  Found in src/core/core.styleTooltip.js - About 35 mins to fix

                    Function drawGlow has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        drawGlow: function(chart, options, drawCallback, isOuter) {
                            var ctx = chart.ctx;
                            var width = isOuter ? options.outerGlowWidth : options.innerGlowWidth;
                            var borderWidth = options.borderWidth;
                            var pixelRatio = chart.currentDevicePixelRatio;
                    Severity: Minor
                    Found in src/helpers/helpers.style.js - About 25 mins 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