nagix/chartjs-plugin-colorschemes

View on GitHub

Showing 13 of 13 total issues

Function exports has 78 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function(karma) {
    const args = karma.args || {};
    const regex = args.watch ? /\.js$/ : /\.min\.js$/;
    const build = builds.filter((v) => v.output.file.match(regex))[0];

Severity: Major
Found in karma.config.js - About 3 hrs to fix

    Function beforeUpdate has 75 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        beforeUpdate: function(chart, args, options) {
            // Please note that in v3, the args argument was added. It was not used before it was added,
            // so we just check if it is not actually our options object
            if (options === undefined) {
                options = args;
    Severity: Major
    Found in src/plugins/plugin.colorschemes.js - About 3 hrs to fix

      File colorschemes.brewer.js has 267 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      'use strict';
      
      // eslint-disable-next-line one-var
      export var
          // Sequential
      Severity: Minor
      Found in src/colorschemes/colorschemes.brewer.js - About 2 hrs to fix

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

                            if (typeof dataset.pointBackgroundColor === 'undefined' || override) {
                                dataset[EXPANDO_KEY].pointBackgroundColor = dataset.pointBackgroundColor;
                                dataset.pointBackgroundColor = helpers.color(color).alpha(fillAlpha).rgbString();
                            }
        Severity: Major
        Found in src/plugins/plugin.colorschemes.js and 2 other locations - About 1 hr to fix
        src/plugins/plugin.colorschemes.js on lines 98..101
        src/plugins/plugin.colorschemes.js on lines 129..132

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

        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 3 locations. Consider refactoring.
        Open

                            if (typeof dataset.backgroundColor === 'undefined' || override) {
                                dataset[EXPANDO_KEY].backgroundColor = dataset.backgroundColor;
                                dataset.backgroundColor = helpers.color(color).alpha(fillAlpha).rgbString();
                            }
        Severity: Major
        Found in src/plugins/plugin.colorschemes.js and 2 other locations - About 1 hr to fix
        src/plugins/plugin.colorschemes.js on lines 106..109
        src/plugins/plugin.colorschemes.js on lines 129..132

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

        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 3 locations. Consider refactoring.
        Open

                            if (typeof dataset.backgroundColor === 'undefined' || override) {
                                dataset[EXPANDO_KEY].backgroundColor = dataset.backgroundColor;
                                dataset.backgroundColor = helpers.color(color).alpha(fillAlpha).rgbString();
                            }
        Severity: Major
        Found in src/plugins/plugin.colorschemes.js and 2 other locations - About 1 hr to fix
        src/plugins/plugin.colorschemes.js on lines 98..101
        src/plugins/plugin.colorschemes.js on lines 106..109

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

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

            afterUpdate: function(chart) {
                // Unset colors
                chart.config.data.datasets.forEach(function(dataset) {
                    if (dataset[EXPANDO_KEY]) {
                        if (dataset[EXPANDO_KEY].hasOwnProperty('backgroundColor')) {
        Severity: Minor
        Found in src/plugins/plugin.colorschemes.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

        Function beforeUpdate has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            beforeUpdate: function(chart, args, options) {
                // Please note that in v3, the args argument was added. It was not used before it was added,
                // so we just check if it is not actually our options object
                if (options === undefined) {
                    options = args;
        Severity: Minor
        Found in src/plugins/plugin.colorschemes.js - About 55 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

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

                            if (typeof dataset.borderColor === 'undefined' || override) {
                                dataset[EXPANDO_KEY].borderColor = dataset.borderColor;
                                dataset.borderColor = color;
                            }
        Severity: Major
        Found in src/plugins/plugin.colorschemes.js and 3 other locations - About 50 mins to fix
        src/plugins/plugin.colorschemes.js on lines 110..113
        src/plugins/plugin.colorschemes.js on lines 133..136
        src/plugins/plugin.colorschemes.js on lines 140..143

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

        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 4 locations. Consider refactoring.
        Open

                            if (typeof dataset.backgroundColor === 'undefined' || override) {
                                dataset[EXPANDO_KEY].backgroundColor = dataset.backgroundColor;
                                dataset.backgroundColor = color;
                            }
        Severity: Major
        Found in src/plugins/plugin.colorschemes.js and 3 other locations - About 50 mins to fix
        src/plugins/plugin.colorschemes.js on lines 102..105
        src/plugins/plugin.colorschemes.js on lines 110..113
        src/plugins/plugin.colorschemes.js on lines 133..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 51.

        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 4 locations. Consider refactoring.
        Open

                            if (typeof dataset.borderColor === 'undefined' || override) {
                                dataset[EXPANDO_KEY].borderColor = dataset.borderColor;
                                dataset.borderColor = color;
                            }
        Severity: Major
        Found in src/plugins/plugin.colorschemes.js and 3 other locations - About 50 mins to fix
        src/plugins/plugin.colorschemes.js on lines 102..105
        src/plugins/plugin.colorschemes.js on lines 110..113
        src/plugins/plugin.colorschemes.js on lines 140..143

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

        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 4 locations. Consider refactoring.
        Open

                            if (typeof dataset.pointBorderColor === 'undefined' || override) {
                                dataset[EXPANDO_KEY].pointBorderColor = dataset.pointBorderColor;
                                dataset.pointBorderColor = color;
                            }
        Severity: Major
        Found in src/plugins/plugin.colorschemes.js and 3 other locations - About 50 mins to fix
        src/plugins/plugin.colorschemes.js on lines 102..105
        src/plugins/plugin.colorschemes.js on lines 133..136
        src/plugins/plugin.colorschemes.js on lines 140..143

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

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

        function getScheme(scheme) {
            var colorschemes, matches, arr, category;
        
            if (helpers.isArray(scheme)) {
                return scheme;
        Severity: Minor
        Found in src/plugins/plugin.colorschemes.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