jiskattema/spot

View on GitHub
src/widgets/views/chartjs2d.js

Summary

Maintainability
F
5 days
Test Coverage

Function updateBubbles has 114 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function updateBubbles (view) {
  var filter = view.model.filter;
  var chartData = view._config.data;

  var partitionA = filter.partitions.get(1, 'rank');
Severity: Major
Found in src/widgets/views/chartjs2d.js - About 4 hrs to fix

    Function initChart has 69 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function initChart (view) {
      // Configure plot
      view._config = view.model.chartjsConfig();
      var options = view._config.options;
    
    
    Severity: Major
    Found in src/widgets/views/chartjs2d.js - About 2 hrs to fix

      Function updateBubbles has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

      function updateBubbles (view) {
        var filter = view.model.filter;
        var chartData = view._config.data;
      
        var partitionA = filter.partitions.get(1, 'rank');
      Severity: Minor
      Found in src/widgets/views/chartjs2d.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 initChart has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

      function initChart (view) {
        // Configure plot
        view._config = view.model.chartjsConfig();
        var options = view._config.options;
      
      
      Severity: Minor
      Found in src/widgets/views/chartjs2d.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

      File chartjs2d.js has 258 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      var app = require('ampersand-app');
      var Spot = require('spot-framework');
      var BaseWidget = require('./base-widget');
      var Chart = require('chart.js');
      var colors = require('../../colors');
      Severity: Minor
      Found in src/widgets/views/chartjs2d.js - About 2 hrs to fix

        Consider simplifying this complex logical expression.
        Open

            if (i >= 0 && j >= 0 && group.aa !== misval && group.bb !== misval && group.count !== 0) {
              // initialize if necessary
              chartData.datasets[0].data[d] = chartData.datasets[0].data[d] || {};
              chartData.datasets[0].error[d] = chartData.datasets[0].error[d] || {};
        
        
        Severity: Critical
        Found in src/widgets/views/chartjs2d.js - About 1 hr to fix

          Function normalizeGroup has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function normalizeGroup (data, key) {
            var norm;
            var min = Number.MAX_VALUE;
            var max = -min;
            data.forEach(function (group) {
          Severity: Minor
          Found in src/widgets/views/chartjs2d.js - About 1 hr to fix

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

            function normalizeGroup (data, key) {
              var norm;
              var min = Number.MAX_VALUE;
              var max = -min;
              data.forEach(function (group) {
            Severity: Minor
            Found in src/widgets/views/chartjs2d.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 (
                (partitionA.isDatetime || partitionA.isDuration || partitionA.isContinuous) &&
                (partitionB.isDatetime || partitionB.isDuration || partitionB.isContinuous)) {
                if (partitionA.selected && partitionA.selected.length > 0) {
                  chartData.datasets[1] = chartData.datasets[1] || {
            Severity: Major
            Found in src/widgets/views/chartjs2d.js - About 40 mins to fix

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

                if (partition.isDatetime) {
                  options.scales.xAxes[0].type = 'time';
                } else if (partition.isDuration) {
                  options.scales.xAxes[0].type = 'spot-duration';
                } else if (partition.isContinuous) {
              Severity: Major
              Found in src/widgets/views/chartjs2d.js and 1 other location - About 5 hrs to fix
              src/widgets/views/chartjs2d.js on lines 98..110

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

              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 (partition.isDatetime) {
                  options.scales.yAxes[0].type = 'time';
                } else if (partition.isDuration) {
                  options.scales.yAxes[0].type = 'spot-duration';
                } else if (partition.isContinuous) {
              Severity: Major
              Found in src/widgets/views/chartjs2d.js and 1 other location - About 5 hrs to fix
              src/widgets/views/chartjs2d.js on lines 77..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 153.

              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

                if (aggregate) {
                  errorYFn = function (group) { return group['dd']; };
                } else {
                  errorYFn = function (group) { return null; };
                  if (view._config.options.errorDir === 'vertical') {
              Severity: Major
              Found in src/widgets/views/chartjs2d.js and 1 other location - About 3 hrs to fix
              src/widgets/views/chartjs1d.js on lines 145..160

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

              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

              function deinitChart (view) {
                if (view._chartjs) {
                  view._chartjs.destroy();
                  delete view._chartjs;
                }
              Severity: Major
              Found in src/widgets/views/chartjs2d.js and 2 other locations - About 3 hrs to fix
              src/widgets/views/chartjs.js on lines 69..81
              src/widgets/views/chartjs1d.js on lines 21..33

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

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

              module.exports = BaseWidget.extend({
                template: '<div class="widgetInner mdl-card__media"></div>',
              
                update: function () {
                  update(this);
              Severity: Major
              Found in src/widgets/views/chartjs2d.js and 4 other locations - About 2 hrs to fix
              src/widgets/views/chartjs.js on lines 234..248
              src/widgets/views/chartjs1d.js on lines 230..244
              src/widgets/views/scatter.js on lines 192..206
              src/widgets/views/sigma.js on lines 149..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 76.

              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 (aggregate) {
                  bubbleRadiusFn = normalizeGroup(filter.data, 'bb');
                  chartData.datasets[0].spotAxes.r = aggregate.operation + ' ' + aggregate.label;
                }
              Severity: Major
              Found in src/widgets/views/chartjs2d.js and 1 other location - About 1 hr to fix
              src/widgets/views/chartjs2d.js on lines 200..203

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

              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 (aggregate) {
                  bubbleColorFn = normalizeGroup(filter.data, 'aa');
                  chartData.datasets[0].spotAxes.c = aggregate.operation + ' ' + aggregate.label;
                }
              Severity: Major
              Found in src/widgets/views/chartjs2d.js and 1 other location - About 1 hr to fix
              src/widgets/views/chartjs2d.js on lines 206..209

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

              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 (partitionB.isDatetime || partitionB.isDuration || partitionB.isContinuous) {
                      chartData.datasets[0].data[d].y = partitionB.groups.models[j].value;
                    } else {
                      chartData.datasets[0].data[d].y = j;
                    }
              Severity: Minor
              Found in src/widgets/views/chartjs2d.js and 1 other location - About 35 mins to fix
              src/widgets/views/chartjs2d.js on lines 246..250

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

              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 (partitionA.isDatetime || partitionA.isDuration || partitionA.isContinuous) {
                      chartData.datasets[0].data[d].x = partitionA.groups.models[i].value;
                    } else {
                      chartData.datasets[0].data[d].x = i;
                    }
              Severity: Minor
              Found in src/widgets/views/chartjs2d.js and 1 other location - About 35 mins to fix
              src/widgets/views/chartjs2d.js on lines 252..256

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

              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

              There are no issues that match your filters.

              Category
              Status