ethanhann/Diagrammatica

View on GitHub
src/js/heat-map.js

Summary

Maintainability
D
2 days
Test Coverage

File heat-map.js has 294 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';
/* global d3: false, check: false, ChartBase, isD3Selection: false, moment: false */
/* exported heatMap */
var HeatMapBase = function (selection, data) {
    this.data = data;
Severity: Minor
Found in src/js/heat-map.js - About 3 hrs to fix

    Function renderRectangles has 70 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    HeatMapBase.prototype.renderRectangles = function () {
        var chart = this.chart;
        var cellHeight = this.cellHeight;
        var cellWidth = this.cellWidth;
        var categories = this.categories;
    Severity: Major
    Found in src/js/heat-map.js - About 2 hrs to fix

      Function heatMap has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      var heatMap = function (selection, data) {
          var heatMapBase = new HeatMapBase(selection, data).render();
          var chart = heatMapBase.chart;
          var update = heatMapBase.chart.update = function (newData) {
              data = heatMapBase.data = !check.undefined(newData) ? newData : heatMapBase.data;
      Severity: Major
      Found in src/js/heat-map.js - About 2 hrs to fix

        Function preRender has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        HeatMapBase.prototype.preRender = function () {
            var displayData = this.displayData;
            var chart = this.chart;
            var config = this.chart.config;
            this.updateCellPrimitives = function (data) {
        Severity: Minor
        Found in src/js/heat-map.js - About 1 hr to fix

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

          HeatMapBase.prototype.renderLegend = function () {
              var chart = this.chart;
              var config = this.config;
              var buckets = this.buckets;
              var colors = this.colors;
          Severity: Minor
          Found in src/js/heat-map.js - About 1 hr to fix

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

            HeatMapBase.prototype.prepareDisplayData = function () {
            
                this.displayData = {
                    data: this.filterDataByDateRange(this.data, 'month'),
                    dateFormat: d3.time.format('%b %Y'),
            Severity: Minor
            Found in src/js/heat-map.js - About 1 hr to fix

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

              var heatMap = function (selection, data) {
                  var heatMapBase = new HeatMapBase(selection, data).render();
                  var chart = heatMapBase.chart;
                  var update = heatMapBase.chart.update = function (newData) {
                      data = heatMapBase.data = !check.undefined(newData) ? newData : heatMapBase.data;
              Severity: Minor
              Found in src/js/heat-map.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

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

                      return (m.isAfter(self.fromX, unit) || m.isSame(self.fromX, unit)) &&
                      m.isBefore(self.toX, unit) || m.isSame(self.toX, unit);
              Severity: Major
              Found in src/js/heat-map.js and 1 other location - About 1 hr to fix
              src/js/heat-map.js on lines 39..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 67.

              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

                          return (m.isAfter(self.fromX, unit) || m.isSame(self.fromX, unit)) &&
                          m.isBefore(self.toX, unit) || m.isSame(self.toX, unit);
              Severity: Major
              Found in src/js/heat-map.js and 1 other location - About 1 hr to fix
              src/js/heat-map.js on lines 24..25

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

              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

                  update.fromX = function (value) {
                      if (check.undefined(value)) {
                          return heatMapBase.fromX;
                      }
                      heatMapBase.fromX = value;
              Severity: Minor
              Found in src/js/heat-map.js and 1 other location - About 55 mins to fix
              src/js/heat-map.js on lines 324..330

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

              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

                  update.toX = function (value) {
                      if (check.undefined(value)) {
                          return heatMapBase.toX;
                      }
                      heatMapBase.toX = value;
              Severity: Minor
              Found in src/js/heat-map.js and 1 other location - About 55 mins to fix
              src/js/heat-map.js on lines 316..322

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

              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

                  update.height = function (value) {
                      return chart.height(value, function () {
                          heatMapBase.updateX(heatMapBase.data);
                      });
                  };
              Severity: Minor
              Found in src/js/heat-map.js and 1 other location - About 40 mins to fix
              src/js/heat-map.js on lines 284..288

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

              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

                  update.width = function (value) {
                      return chart.width(value, function () {
                          heatMapBase.updateY(heatMapBase.data);
                      });
                  };
              Severity: Minor
              Found in src/js/heat-map.js and 1 other location - About 40 mins to fix
              src/js/heat-map.js on lines 290..294

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

              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

                      var maxXLabelHeight = d3.max(this.xLabels[0], function (d) {
                          return d.getBoundingClientRect().height;
                      });
              Severity: Minor
              Found in src/js/heat-map.js and 1 other location - About 35 mins to fix
              src/js/heat-map.js on lines 158..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 46.

              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

                      var maxYLabelHeight = d3.max(this.yLabels[0], function (d) {
                          return d.getBoundingClientRect().height;
                      });
              Severity: Minor
              Found in src/js/heat-map.js and 1 other location - About 35 mins to fix
              src/js/heat-map.js on lines 183..185

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

              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

                  this.xLabels = chart.renderArea.selectAll('.xLabel')
                      .data(displayData.dates)
                      .enter().append('text')
                      .text(function (d) {
                          return displayData.dateFormat(new Date(d));
              Severity: Minor
              Found in src/js/heat-map.js and 1 other location - About 30 mins to fix
              src/js/heat-map.js on lines 191..199

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

              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

                  this.rectGroups = chart.renderArea.selectAll('g')
                      .data(displayData.data)
                      .enter()
                      .append('g')
                      .attr('transform', function (d, i) {
              Severity: Minor
              Found in src/js/heat-map.js and 1 other location - About 30 mins to fix
              src/js/heat-map.js on lines 170..175

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

              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