Vizzuality/gfw-climate

View on GitHub
app/assets/javascripts/widgets/indicators/stacked/StackedChart.js

Summary

Maintainability
F
6 days
Test Coverage

File StackedChart.js has 330 lines of code (exceeds 250 allowed). Consider refactoring.
Open

define(
  [
    'jquery',
    'd3',
    'underscore',
Severity: Minor
Found in app/assets/javascripts/widgets/indicators/stacked/StackedChart.js - About 3 hrs to fix

    Function _drawData has 48 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        StackedChart.prototype._drawData = function() {
          var self = this;
          this.bars = this.svg
            .selectAll('.layer')
            .data(this.stacked)
    Severity: Minor
    Found in app/assets/javascripts/widgets/indicators/stacked/StackedChart.js - About 1 hr to fix

      Function StackedChart has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          var StackedChart = function(options) {
            this.svg;
            this.options = options;
            this.parent = options.parent;
            this.data = options.data;
      Severity: Minor
      Found in app/assets/javascripts/widgets/indicators/stacked/StackedChart.js - About 1 hr to fix

        Function _drawAxes has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            StackedChart.prototype._drawAxes = function() {
              var self = this;
              var tickSizeX = $(window).width() > 1025 ? 1 : 2;
              var tickFormatY = this.unit != 'percentage' ? '.2s' : '.2f';
              this.xAxis = d3.svg
        Severity: Minor
        Found in app/assets/javascripts/widgets/indicators/stacked/StackedChart.js - About 1 hr to fix

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

              StackedChart.prototype._createStack = function() {
                var self = this;
                this.stacked = d3.layout.stack()(
                  this.data.map(function(d) {
                    return d.map(function(i) {
          Severity: Minor
          Found in app/assets/javascripts/widgets/indicators/stacked/StackedChart.js - About 1 hr to fix

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

                StackedChart.prototype.setListeners = function() {
                  var formatDate = d3.time.format('%Y');
                  var bisectDate = d3.bisector(function(d) {
                    return d.year;
                  }).left;
            Severity: Minor
            Found in app/assets/javascripts/widgets/indicators/stacked/StackedChart.js - About 1 hr to fix

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

                  StackedChart.prototype._createScales = function() {
                    var self = this;
                    this.xKey = this.options.keys.x;
                    this.yKey = this.options.keys.y;
              
              
              Severity: Minor
              Found in app/assets/javascripts/widgets/indicators/stacked/StackedChart.js - About 1 hr to fix

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

                    StackedChart.prototype._drawTooltip = function() {
                      var self = this;
                      var data = data;
                
                      // Tooltip
                Severity: Minor
                Found in app/assets/javascripts/widgets/indicators/stacked/StackedChart.js - About 1 hr to fix

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

                      StackedChart.prototype._drawAxes = function() {
                        var self = this;
                        var tickSizeX = $(window).width() > 1025 ? 1 : 2;
                        var tickFormatY = this.unit != 'percentage' ? '.2s' : '.2f';
                        this.xAxis = d3.svg
                  app/assets/javascripts/widgets/indicators/multiline/MultiLineChart.js on lines 114..149

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

                  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

                      StackedChart.prototype.destroy = function() {
                        if (!!this.tooltip) {
                          this.tooltip.remove();
                        }
                        if (this.subcriptions) {
                  app/assets/javascripts/widgets/indicators/multiline/MultiLineChart.js on lines 379..388

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

                  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

                      StackedChart.prototype._createEl = function() {
                        this.svg = d3
                          .select(this.options.el)
                          .append('svg')
                          .attr('class', 'lineChart')
                  app/assets/javascripts/widgets/indicators/line/LineChart.js on lines 66..73
                  app/assets/javascripts/widgets/indicators/multiline/MultiLineChart.js on lines 62..69

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

                  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

                      StackedChart.prototype.resize = function() {
                        this.offResize();
                        $(this.options.el)
                          .find('svg')
                          .remove();
                  app/assets/javascripts/widgets/indicators/multiline/MultiLineChart.js on lines 53..60

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

                  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

                      StackedChart.prototype._createDefs = function() {
                        this.svg
                          .append('defs')
                          .append('clipPath')
                          .attr('id', 'clip')
                  app/assets/javascripts/widgets/indicators/line/LineChart.js on lines 114..122
                  app/assets/javascripts/widgets/indicators/multiline/MultiLineChart.js on lines 104..112

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

                  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

                        (this.width = this.parentWidth - this.sizing.left - this.sizing.right),
                          (this.height =
                            this.parentHeight - this.sizing.top - this.sizing.bottom);
                  app/assets/javascripts/widgets/indicators/line/LineChart.js on lines 37..39
                  app/assets/javascripts/widgets/indicators/multiline/MultiLineChart.js on lines 32..34

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

                  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

                            mps.subscribe(
                              'StackedChart/mousemove' + this.options.slug + this.options.id,
                              function(x0) {
                                if (!!self.svg) {
                                  self.setTooltip(x0, true);
                  app/assets/javascripts/widgets/indicators/line/LineChart.js on lines 326..333
                  app/assets/javascripts/widgets/indicators/multiline/MultiLineChart.js on lines 343..350

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

                        this.x = d3.scale
                          .ordinal()
                          .rangeRoundBands([
                            this.options.innerPadding.left,
                            this.width - this.options.innerPadding.right
                  app/assets/javascripts/widgets/indicators/line/LineChart.js on lines 80..85
                  app/assets/javascripts/widgets/indicators/multiline/MultiLineChart.js on lines 76..81

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

                  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.bars = this.svg
                          .selectAll('.layer')
                          .data(this.stacked)
                          .enter()
                          .append('g')
                  app/assets/javascripts/widgets/indicators/line/LineChart.js on lines 173..179

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

                  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.rectangles = this.bars
                          .selectAll('rect')
                          .data(function(d) {
                            return d;
                          })
                  app/assets/javascripts/widgets/indicators/stacked/StackedChart.js on lines 224..231

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

                  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.text = this.bars
                          .selectAll('text')
                          .data(function(d) {
                            return d;
                          })
                  app/assets/javascripts/widgets/indicators/stacked/StackedChart.js on lines 210..217

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

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

                        $(window).on(
                          'resize.namespace' + this.namespace,
                          _.debounce(this.resize.bind(this), 100)
                        );
                  app/assets/javascripts/widgets/indicators/line/LineChart.js on lines 48..51
                  app/assets/javascripts/widgets/indicators/multiline/MultiLineChart.js on lines 43..46

                  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

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

                        this.tooltip = d3
                          .select('body')
                          .append('div')
                          .attr('class', 'linegraph-tooltip')
                          .style('visibility', 'hidden');
                  app/assets/javascripts/widgets/indicators/line/LineChart.js on lines 225..229
                  app/assets/javascripts/widgets/indicators/multiline/MultiLineChart.js on lines 239..243

                  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

                          this.data.map(function(d) {
                            return d.map(function(i) {
                              return { x: i.year, y: i.value };
                            });
                          })
                  app/assets/javascripts/data-download/views/DataDownloadIndexView.js on lines 166..173

                  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

                  There are no issues that match your filters.

                  Category
                  Status