Vizzuality/gfw-climate

View on GitHub
app/assets/javascripts/abstract/timeline/TimelineMonthClass.js

Summary

Maintainability
F
6 days
Test Coverage

File TimelineMonthClass.js has 538 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * The Timeline view module.
 *
 * Timeline for all layers configured by setting layer-specific options.
 *
Severity: Major
Found in app/assets/javascripts/abstract/timeline/TimelineMonthClass.js - About 1 day to fix

    Function render has 159 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          render: function() {
            _.bindAll(this, '_moveHandler');
            var self = this;
            this.$timeline = $('.timeline-container');
            this.$el.html(this.template());
    Severity: Major
    Found in app/assets/javascripts/abstract/timeline/TimelineMonthClass.js - About 6 hrs to fix

      Function toggleDisabled has 54 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            toggleDisabled: function() {
              _.each(this.$selectsYear, function(el) {
                var $options = document.getElementById($(el).attr('id')).options;
                var compare = $($(el).data('compare'))[0].selectedIndex;
                var direction = Boolean(parseInt($(el).data('direction')));
      Severity: Major
      Found in app/assets/javascripts/abstract/timeline/TimelineMonthClass.js - About 2 hrs to fix

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

              initialize: function(layer, currentDate) {
                this.layer = layer;
                this.name = layer.slug;
                this.options = _.extend({}, this.defaults, this.options || {});
                this.dateRangeStart = this.options.dateRange[0];
        Severity: Minor
        Found in app/assets/javascripts/abstract/timeline/TimelineMonthClass.js - About 1 hr to fix

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

                _onBrush: function(event) {
                  var value = this.xscale.invert(d3.mouse(event)[0]);
                  var rounded = Math.round(value);
                  var x = this.xscale(rounded);
                  var date = this._domainToDate(rounded);
          Severity: Minor
          Found in app/assets/javascripts/abstract/timeline/TimelineMonthClass.js - About 1 hr to fix

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

                    _.each(this.$selectsYear, function(el) {
                      var $options = document.getElementById($(el).attr('id')).options;
                      var compare = $($(el).data('compare'))[0].selectedIndex;
                      var direction = Boolean(parseInt($(el).data('direction')));
            
            
            app/assets/javascripts/abstract/timeline/TimelineYearClass.js on lines 151..167

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

            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

                  setSelects: function() {
                    _.each(this.$selects, function(el) {
                      var date = $(el).val();
                      var $dateButton = $('#' + $(el).attr('id') + '-button');
                      $dateButton.text(date);
            app/assets/javascripts/abstract/timeline/TimelineYearClass.js on lines 141..148

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

            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.hiddenBrush = d3.svg
                        .brush()
                        .x(this.xscale)
                        .extent([0, 0])
                        .on('brush', function() {
            app/assets/javascripts/abstract/timeline/TimelineMonthClass.js on lines 344..353

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

            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.brush = d3.svg
                      .brush()
                      .x(this.xscale)
                      .extent([0, 0])
                      .on('brush', function() {
            app/assets/javascripts/abstract/timeline/TimelineMonthClass.js on lines 425..434

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

            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

                    this.trail
                      .call(this.hiddenBrush.event)
                      .transition()
                      .duration(speed)
                      .ease('line')
            app/assets/javascripts/abstract/timeline/TimelineYearClass.js on lines 447..453

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

            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

                    this.trail = this.tipsy
                      .append('svg:line')
                      .attr('class', 'trail')
                      .attr('x1', this.handlers.right.attr('x'))
                      .attr('x2', this.handlers.right.attr('x'))
            app/assets/javascripts/abstract/timeline/TimelineYearClass.js on lines 346..352

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

                    enquire.register(
                      'screen and (min-width:' + window.gfw.config.GFW_MOBILE + 'px)',
                      {
                        match: _.bind(function() {
                          this.render();
            app/assets/javascripts/abstract/timeline/TimelineBtnClass.js on lines 74..81
            app/assets/javascripts/abstract/timeline/TimelineMonthClass.js on lines 99..106
            app/assets/javascripts/abstract/timeline/TimelineYearClass.js on lines 83..90
            app/assets/javascripts/abstract/timeline/TimelineYearClass.js on lines 91..98

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

                    enquire.register(
                      'screen and (max-width:' + window.gfw.config.GFW_MOBILE + 'px)',
                      {
                        match: _.bind(function() {
                          this.renderMobile();
            app/assets/javascripts/abstract/timeline/TimelineBtnClass.js on lines 74..81
            app/assets/javascripts/abstract/timeline/TimelineMonthClass.js on lines 91..98
            app/assets/javascripts/abstract/timeline/TimelineYearClass.js on lines 83..90
            app/assets/javascripts/abstract/timeline/TimelineYearClass.js on lines 91..98

            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

                    this.svg
                      .append('g')
                      .attr('class', 'xaxis')
                      .attr('transform', 'translate(0,{0})'.format(height / 2 - 3))
                      .call(
            Severity: Minor
            Found in app/assets/javascripts/abstract/timeline/TimelineMonthClass.js and 1 other location - About 50 mins to fix
            app/assets/javascripts/abstract/timeline/TimelineMonthClass.js on lines 364..368

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

            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.handlers.left = this.slider
                      .append('svg:image')
                      .attr('class', 'handle')
                      .attr('transform', 'translate(-8,{0})'.format(height / 2 - 11))
                      .attr('width', 16)
            Severity: Minor
            Found in app/assets/javascripts/abstract/timeline/TimelineMonthClass.js and 1 other location - About 50 mins to fix
            app/assets/javascripts/abstract/timeline/TimelineMonthClass.js on lines 287..302

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

            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 (currentDate && currentDate[0]) {
                      this.currentDate = currentDate;
                    } else {
                      this._updateCurrentDate(this.options.dateRange);
                    }
            Severity: Minor
            Found in app/assets/javascripts/abstract/timeline/TimelineMonthClass.js and 1 other location - About 50 mins to fix
            app/assets/javascripts/abstract/timeline/TimelineYearClass.js on lines 53..57

            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

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

                    this.handlers.right = this.handlers.left
                      .select(function() {
                        return this.parentNode.appendChild(this.cloneNode(true));
                      })
                      .attr('x', this.xscale(this._dateToDomain(this.currentDate[1])));
            Severity: Minor
            Found in app/assets/javascripts/abstract/timeline/TimelineMonthClass.js and 1 other location - About 45 mins to fix
            app/assets/javascripts/abstract/timeline/TimelineYearClass.js on lines 329..333

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

                    this.tooltip = d3
                      .select(this.$time[0])
                      .append('div')
                      .attr('class', 'tooltip')
                      .style('visibility', 'hidden')
            Severity: Minor
            Found in app/assets/javascripts/abstract/timeline/TimelineMonthClass.js and 1 other location - About 40 mins to fix
            app/assets/javascripts/abstract/timeline/TimelineYearClass.js on lines 354..359

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

            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 (
                      Math.abs(this.xscale(value) - xr) < Math.abs(this.xscale(value) - xl)
                    ) {
                      if (this.ext.left > x) {
                        return;
            Severity: Minor
            Found in app/assets/javascripts/abstract/timeline/TimelineMonthClass.js and 1 other location - About 35 mins to fix
            app/assets/javascripts/abstract/timeline/TimelineYearClass.js on lines 524..568

            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