Vizzuality/gfw-climate

View on GitHub
app/assets/javascripts/embed/views/pantropical/vis.js

Summary

Maintainability
F
1 mo
Test Coverage

File vis.js has 827 lines of code (exceeds 250 allowed). Consider refactoring.
Open

function CustomTooltip(tooltipId, width) {
  var tooltipId = tooltipId;
  $('#vis').append("<div class='tooltip' id='" + tooltipId + "'></div>");

  if (width) {
Severity: Major
Found in app/assets/javascripts/embed/views/pantropical/vis.js - About 1 day to fix

    Function BubbleChart has 117 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function BubbleChart(data) {
          this.hide_details = __bind(this.hide_details, this);
          this.show_details = __bind(this.show_details, this);
          this.hide_years = __bind(this.hide_years, this);
          this.display_years = __bind(this.display_years, this);
    Severity: Major
    Found in app/assets/javascripts/embed/views/pantropical/vis.js - About 4 hrs to fix

      Function create_vis has 59 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          BubbleChart.prototype.create_vis = function() {
            var that;
            this.vis = d3
              .select('#vis')
              .append('svg')
      Severity: Major
      Found in app/assets/javascripts/embed/views/pantropical/vis.js - About 2 hrs to fix

        Function generateCircles has 55 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            BubbleChart.prototype.generateCircles = function(values_array) {
              var that = this;
              var circles = that.circles;
              var style_string;
        
        
        Severity: Major
        Found in app/assets/javascripts/embed/views/pantropical/vis.js - About 2 hrs to fix

          Function display_by_change has 55 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              BubbleChart.prototype.display_by_change = function(year) {
                this.year_to_compare = year;
                var that = this;
                this.force
                  .gravity(this.layout_gravity)
          Severity: Major
          Found in app/assets/javascripts/embed/views/pantropical/vis.js - About 2 hrs to fix

            Function get_coordinates has 52 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                BubbleChart.prototype.get_coordinates = function(sorted_index) {
                  var dist_x = 85;
                  var dist_y = 55;
                  var offset_x = 75;
                  var offset_y = 50;
            Severity: Major
            Found in app/assets/javascripts/embed/views/pantropical/vis.js - About 2 hrs to fix

              Function CustomTooltip has 46 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function CustomTooltip(tooltipId, width) {
                var tooltipId = tooltipId;
                $('#vis').append("<div class='tooltip' id='" + tooltipId + "'></div>");
              
                if (width) {
              Severity: Minor
              Found in app/assets/javascripts/embed/views/pantropical/vis.js - About 1 hr to fix

                Function create_nodes has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    BubbleChart.prototype.create_nodes = function() {
                      this.data.forEach(
                        (function(_this) {
                          return function(d) {
                            if (parseFloat(d.Average).toFixed(3) > 0.003) {
                Severity: Minor
                Found in app/assets/javascripts/embed/views/pantropical/vis.js - About 1 hr to fix

                  Function get_label_text has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      BubbleChart.prototype.get_label_text = function(
                        order,
                        coordinates,
                        id,
                        country,
                  Severity: Minor
                  Found in app/assets/javascripts/embed/views/pantropical/vis.js - About 1 hr to fix

                    Function display_by_ny has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          (BubbleChart.prototype.display_by_ny = function() {
                            this.force
                              .gravity(this.layout_gravity)
                              .charge(this.charge)
                              .friction(0.9)
                    Severity: Minor
                    Found in app/assets/javascripts/embed/views/pantropical/vis.js - About 1 hr to fix

                      Function display_group_all has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          BubbleChart.prototype.display_group_all = function() {
                            this.force
                              .gravity(this.layout_gravity)
                              .charge(this.charge)
                              .friction(0.9)
                      Severity: Minor
                      Found in app/assets/javascripts/embed/views/pantropical/vis.js - About 1 hr to fix

                        Function CustomTooltip has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                        Open

                        function CustomTooltip(tooltipId, width) {
                          var tooltipId = tooltipId;
                          $('#vis').append("<div class='tooltip' id='" + tooltipId + "'></div>");
                        
                          if (width) {
                        Severity: Minor
                        Found in app/assets/javascripts/embed/views/pantropical/vis.js - About 1 hr to fix

                        Cognitive Complexity

                        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                        A method's cognitive complexity is based on a few simple rules:

                        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                        • Code is considered more complex for each "break in the linear flow of the code"
                        • Code is considered more complex when "flow breaking structures are nested"

                        Further reading

                        Function updatePosition has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          function updatePosition(event) {
                            var ttid = '#' + tooltipId;
                            var xOffset = -120;
                            var yOffset = -70;
                        
                        
                        Severity: Minor
                        Found in app/assets/javascripts/embed/views/pantropical/vis.js - About 1 hr to fix

                          Function get_label_text has 7 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                                order,
                                coordinates,
                                id,
                                country,
                                data,
                          Severity: Major
                          Found in app/assets/javascripts/embed/views/pantropical/vis.js - About 50 mins to fix

                            Consider simplifying this complex logical expression.
                            Open

                                  if (
                                    (order === 1 && radius < 47.5) ||
                                    (order === 2 && radius < 47.5) ||
                                    (order === 3 && radius < 47.5)
                                  ) {
                            Severity: Major
                            Found in app/assets/javascripts/embed/views/pantropical/vis.js - About 40 mins to fix

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

                                  function BubbleChart(data) {
                                    this.hide_details = __bind(this.hide_details, this);
                                    this.show_details = __bind(this.show_details, this);
                                    this.hide_years = __bind(this.hide_years, this);
                                    this.display_years = __bind(this.display_years, this);
                              Severity: Major
                              Found in app/assets/javascripts/embed/views/pantropical/vis.js and 1 other location - About 1 wk to fix
                              app/assets/javascripts/countries/views/pantropical/vis.js on lines 80..198

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

                              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

                                  BubbleChart.prototype.create_vis = function() {
                                    var that;
                                    this.vis = d3
                                      .select('#vis')
                                      .append('svg')
                              Severity: Major
                              Found in app/assets/javascripts/embed/views/pantropical/vis.js and 1 other location - About 3 days to fix
                              app/assets/javascripts/countries/views/pantropical/vis.js on lines 249..310

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

                              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

                                  BubbleChart.prototype.generateCircles = function(values_array) {
                                    var that = this;
                                    var circles = that.circles;
                                    var style_string;
                              
                              
                              Severity: Major
                              Found in app/assets/javascripts/embed/views/pantropical/vis.js and 1 other location - About 3 days to fix
                              app/assets/javascripts/countries/views/pantropical/vis.js on lines 553..624

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

                              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

                              function CustomTooltip(tooltipId, width) {
                                var tooltipId = tooltipId;
                                $('#vis').append("<div class='tooltip' id='" + tooltipId + "'></div>");
                              
                                if (width) {
                              Severity: Major
                              Found in app/assets/javascripts/embed/views/pantropical/vis.js and 1 other location - About 3 days to fix
                              app/assets/javascripts/countries/views/pantropical/vis.js on lines 1..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 540.

                              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

                                $(function() {
                                  var chart, render_vis;
                                  chart = null;
                                  render_vis = function(csv) {
                                    chart = new BubbleChart(csv);
                              Severity: Major
                              Found in app/assets/javascripts/embed/views/pantropical/vis.js and 1 other location - About 2 days to fix
                              app/assets/javascripts/countries/views/pantropical/vis.js on lines 879..940

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

                              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

                                  BubbleChart.prototype.get_label_text = function(
                                    order,
                                    coordinates,
                                    id,
                                    country,
                              Severity: Major
                              Found in app/assets/javascripts/embed/views/pantropical/vis.js and 1 other location - About 2 days to fix
                              app/assets/javascripts/countries/views/pantropical/vis.js on lines 626..685

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

                              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

                                  BubbleChart.prototype.create_nodes = function() {
                                    this.data.forEach(
                                      (function(_this) {
                                        return function(d) {
                                          if (parseFloat(d.Average).toFixed(3) > 0.003) {
                              Severity: Major
                              Found in app/assets/javascripts/embed/views/pantropical/vis.js and 1 other location - About 2 days to fix
                              app/assets/javascripts/countries/views/pantropical/vis.js on lines 200..247

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

                              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

                                  BubbleChart.prototype.display_group_all = function() {
                                    this.force
                                      .gravity(this.layout_gravity)
                                      .charge(this.charge)
                                      .friction(0.9)
                              Severity: Major
                              Found in app/assets/javascripts/embed/views/pantropical/vis.js and 1 other location - About 2 days to fix
                              app/assets/javascripts/countries/views/pantropical/vis.js on lines 323..367

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

                              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 (sorted_index < col_count) {
                                      y_position = 150;
                                    } else if (sorted_index < 2 * col_count) {
                                      y_position = 300;
                                    } else if (sorted_index < 3 * col_count) {
                              Severity: Major
                              Found in app/assets/javascripts/embed/views/pantropical/vis.js and 1 other location - About 1 day to fix
                              app/assets/javascripts/countries/views/pantropical/vis.js on lines 796..826

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

                              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

                                  BubbleChart.prototype.calculate_average = function(d) {
                                    var year_left = this.year_left;
                                    var year_right = this.year_right;
                                    var diff_years = Math.abs(this.year_right - this.year_left);
                                    var years_between = diff_years - 1;
                              Severity: Major
                              Found in app/assets/javascripts/embed/views/pantropical/vis.js and 1 other location - About 1 day to fix
                              app/assets/javascripts/countries/views/pantropical/vis.js on lines 687..718

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

                              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

                                  (BubbleChart.prototype.mandatorySort = function(alpha, filter) {
                                    var that = this;
                                    return function(d) {
                                      // if (! !!filter) {
                                      //   if (d.id == 103 || d.id == 104) return;
                              Severity: Major
                              Found in app/assets/javascripts/embed/views/pantropical/vis.js and 1 other location - About 1 day to fix
                              app/assets/javascripts/countries/views/pantropical/vis.js on lines 393..417

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

                              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.circles
                                              .transition()
                                              .duration(50)
                                              .attr('r', function(d) {
                                                if (!!!that.year_to_compare) {
                              Severity: Major
                              Found in app/assets/javascripts/embed/views/pantropical/vis.js and 1 other location - About 1 day to fix
                              app/assets/javascripts/countries/views/pantropical/vis.js on lines 474..494

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

                              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

                                  BubbleChart.prototype.move_towards_center = function(alpha) {
                                    return (function(_this) {
                                      return function(d) {
                                        if (d.id == 103 || d.id == 104) {
                                          return (d.x = d.y = -2000);
                              Severity: Major
                              Found in app/assets/javascripts/embed/views/pantropical/vis.js and 1 other location - About 1 day to fix
                              app/assets/javascripts/countries/views/pantropical/vis.js on lines 369..381

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

                              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

                                  BubbleChart.prototype.move_towards_year = function(alpha) {
                                    return (function(_this) {
                                      return function(d) {
                                        var target;
                                        target = _this.year_centers[d.year || 2010];
                              Severity: Major
                              Found in app/assets/javascripts/embed/views/pantropical/vis.js and 1 other location - About 6 hrs to fix
                              app/assets/javascripts/countries/views/pantropical/vis.js on lines 522..532

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

                              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

                                  BubbleChart.prototype.get_values_array = function() {
                                    var that = this;
                                    var values_array = [];
                              
                                    this.circles.each(function(d) {
                              Severity: Major
                              Found in app/assets/javascripts/embed/views/pantropical/vis.js and 1 other location - About 6 hrs to fix
                              app/assets/javascripts/countries/views/pantropical/vis.js on lines 749..764

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

                              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

                                  BubbleChart.prototype.display_by_country = function(values_array) {
                                    $('#svg_vis').css({
                                      height: 1100
                                    });
                              
                              
                              Severity: Major
                              Found in app/assets/javascripts/embed/views/pantropical/vis.js and 1 other location - About 5 hrs to fix
                              app/assets/javascripts/countries/views/pantropical/vis.js on lines 534..551

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

                              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

                              function addCommas(nStr) {
                                nStr += '';
                                x = nStr.split('.');
                                x1 = x[0];
                                x2 = x.length > 1 ? '.' + x[1] : '';
                              Severity: Major
                              Found in app/assets/javascripts/embed/views/pantropical/vis.js and 1 other location - About 4 hrs to fix
                              app/assets/javascripts/countries/views/pantropical/vis.js on lines 58..68

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

                              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

                                  BubbleChart.prototype.set_years = function(year) {
                                    this.year = year;
                              
                                    if (!!!this.year) {
                                      this.year_left = 2001;
                              Severity: Major
                              Found in app/assets/javascripts/embed/views/pantropical/vis.js and 1 other location - About 3 hrs to fix
                              app/assets/javascripts/countries/views/pantropical/vis.js on lines 737..747

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

                              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

                                  BubbleChart.prototype.sort_desc = function(array) {
                                    array.sort(function(a, b) {
                                      if (a.value > b.value) {
                                        return 1;
                                      }
                              Severity: Major
                              Found in app/assets/javascripts/embed/views/pantropical/vis.js and 1 other location - About 3 hrs to fix
                              app/assets/javascripts/countries/views/pantropical/vis.js on lines 722..735

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

                              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

                                  BubbleChart.prototype.hide_details = function(data, i, element) {
                                    d3.select(element).attr(
                                      'stroke',
                                      (function(_this) {
                                        return function(d) {
                              Severity: Major
                              Found in app/assets/javascripts/embed/views/pantropical/vis.js and 1 other location - About 3 hrs to fix
                              app/assets/javascripts/countries/views/pantropical/vis.js on lines 862..872

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

                              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

                                  BubbleChart.prototype.buoyancy = function(alpha) {
                                    var that = this;
                                    return function(d) {
                                      var targetY = that.centerY;
                                      d.y =
                              Severity: Major
                              Found in app/assets/javascripts/embed/views/pantropical/vis.js and 1 other location - About 3 hrs to fix
                              app/assets/javascripts/countries/views/pantropical/vis.js on lines 383..391

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

                              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 _this.circles
                                                .each(_this.mandatorySort(e.alpha))
                                                .each(_this.buoyancy(e.alpha))
                                                .attr('cx', function(d) {
                                                  return d.x - 115;
                              Severity: Major
                              Found in app/assets/javascripts/embed/views/pantropical/vis.js and 1 other location - About 2 hrs to fix
                              app/assets/javascripts/embed/views/pantropical/vis.js on lines 494..502

                              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

                                            return _this.circles
                                              .each(_this.mandatorySort(e.alpha))
                                              .each(_this.buoyancy(e.alpha))
                                              .attr('cx', function(d) {
                                                return d.x - 135;
                              Severity: Major
                              Found in app/assets/javascripts/embed/views/pantropical/vis.js and 1 other location - About 2 hrs to fix
                              app/assets/javascripts/embed/views/pantropical/vis.js on lines 433..441

                              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

                                  BubbleChart.prototype.start = function() {
                                    return (this.force = d3.layout
                                      .force()
                                      .nodes(this.nodes)
                                      .size([this.width, this.height]));
                              Severity: Major
                              Found in app/assets/javascripts/embed/views/pantropical/vis.js and 1 other location - About 1 hr to fix
                              app/assets/javascripts/countries/views/pantropical/vis.js on lines 316..321

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

                              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

                                  BubbleChart.prototype.hide_years = function() {
                                    var years;
                                    return (years = this.vis.selectAll('.years').remove());
                                  };
                              Severity: Minor
                              Found in app/assets/javascripts/embed/views/pantropical/vis.js and 1 other location - About 50 mins to fix
                              app/assets/javascripts/countries/views/pantropical/vis.js on lines 836..839

                              Duplicated Code

                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                              Tuning

                              This issue has a mass of 51.

                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                              Refactorings

                              Further Reading

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

                                    if (sorted_index < 4) {
                                      // bubbles at index 0, 1, 2, 3 are in line 1
                                      col_count = 4;
                                      dist_x = 85;
                                      offset_x = 200;
                              Severity: Minor
                              Found in app/assets/javascripts/embed/views/pantropical/vis.js and 1 other location - About 35 mins to fix
                              app/assets/javascripts/countries/views/pantropical/vis.js on lines 775..783

                              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