nagix/chartjs-plugin-style

View on GitHub

Showing 22 of 22 total issues

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

export default RadarController.extend({

    datasetElementType: StyleLine,

    dataElementType: StylePoint,
Severity: Major
Found in src/controllers/controller.styleRadar.js and 1 other location - About 2 days to fix
src/controllers/controller.styleLine.js on lines 14..73

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

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 default LineController.extend({

    datasetElementType: StyleLine,

    dataElementType: StylePoint,
Severity: Major
Found in src/controllers/controller.styleLine.js and 1 other location - About 2 days to fix
src/controllers/controller.styleRadar.js on lines 14..73

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

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

Chart.defaults.polarArea.legend.labels.generateLabels = function(chart) {
    var data = chart.data;
    if (data.labels.length && data.datasets.length) {
        return data.labels.map(function(label, i) {
            var meta = chart.getDatasetMeta(0);
Severity: Major
Found in src/controllers/controller.stylePolarArea.js and 1 other location - About 1 day to fix
src/controllers/controller.styleDoughnut.js on lines 15..41

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

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

defaults.doughnut.legend.labels.generateLabels = defaults.pie.legend.labels.generateLabels = function(chart) {
    var data = chart.data;
    if (data.labels.length && data.datasets.length) {
        return data.labels.map(function(label, i) {
            var meta = chart.getDatasetMeta(0);
Severity: Major
Found in src/controllers/controller.styleDoughnut.js and 1 other location - About 1 day to fix
src/controllers/controller.stylePolarArea.js on lines 14..40

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

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 default DoughnutController.extend({

    dataElementType: StyleArc,

    updateElement: function(arc, index) {
Severity: Major
Found in src/controllers/controller.styleDoughnut.js and 1 other location - About 1 day to fix
src/controllers/controller.stylePolarArea.js on lines 44..89

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

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 default PolarAreaController.extend({

    dataElementType: StyleArc,

    updateElement: function(arc, index) {
Severity: Major
Found in src/controllers/controller.stylePolarArea.js and 1 other location - About 1 day to fix
src/controllers/controller.styleDoughnut.js on lines 45..90

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

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

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

                        if (styleHelpers.opaque(vm.backgroundColor)) {
                            styleHelpers.drawBackground(vm, drawCallback);
                            styleHelpers.drawBackgroundOverlay(chart, vm, drawCallback);
                            styleHelpers.drawBevel(chart, vm, drawCallback);
                        }
                Severity: Major
                Found in src/elements/element.stylePoint.js and 1 other location - About 1 hr to fix
                src/elements/element.styleRectangle.js on lines 25..29

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

                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 (styleHelpers.opaque(vm.backgroundColor)) {
                            styleHelpers.drawBackground(vm, drawCallback);
                            styleHelpers.drawBackgroundOverlay(chart, vm, setPathCallback);
                            styleHelpers.drawBevel(chart, vm, setPathCallback);
                        }
                Severity: Major
                Found in src/elements/element.styleRectangle.js and 1 other location - About 1 hr to fix
                src/elements/element.stylePoint.js on lines 36..40

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

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

                  Severity
                  Category
                  Status
                  Source
                  Language