Vizzuality/gfw-climate

View on GitHub
app/assets/javascripts/map/views/MapView.js

Summary

Maintainability
F
3 days
Test Coverage

File MapView.js has 575 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * The MapView class for the Google Map.
 *
 * @return MapView class (extends Backbone.View)
 */
Severity: Major
Found in app/assets/javascripts/map/views/MapView.js - About 1 day to fix

    Function _addListeners has 57 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          _addListeners: function() {
            google.maps.event.addListener(
              this.map,
              'zoom_changed',
              _.bind(function() {
    Severity: Major
    Found in app/assets/javascripts/map/views/MapView.js - About 2 hrs to fix

      Consider simplifying this complex logical expression.
      Open

                  if (
                    !hoverCarbonLoss &&
                    !hoverMenuLogin &&
                    !hoverCarbonGains &&
                    !hoverCarbonDensity &&
      Severity: Critical
      Found in app/assets/javascripts/map/views/MapView.js - About 2 hrs to fix

        Function _appearMenu has 49 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              _appearMenu() {
                $('body').mousemove(function(event) {
                  if (event.pageY < 100) {
                    $('#headerGfw').addClass('-show');
                    $('.logo-menu').addClass('-show');
        Severity: Minor
        Found in app/assets/javascripts/map/views/MapView.js - About 1 hr to fix

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

                initialize: function() {
                  this.presenter = new Presenter(this);
                  this.layerInst = {};
                  this.$maplngLng = $('.map-container .map-latlng');
                  this.$viewFinder = $('#viewfinder');
          Severity: Minor
          Found in app/assets/javascripts/map/views/MapView.js - About 1 hr to fix

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

                  offsetCenter: function(latlng, offsetx, offsety) {
                    // latlng is the apparent centre-point
                    // offsetx is the distance you want that point to move to the right, in pixels
                    // offsety is the distance you want that point to move upwards, in pixels
                    // offset can be negative
            Severity: Minor
            Found in app/assets/javascripts/map/views/MapView.js - About 1 hr to fix

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

                      enquire.register(
                        'screen and (min-width:' + window.gfw.config.GFW_MOBILE + 'px)',
                        {
                          match: _.bind(function() {
                            this.mobile = false;
              Severity: Major
              Found in app/assets/javascripts/map/views/MapView.js and 1 other location - About 2 hrs to fix
              app/assets/javascripts/map/views/MapView.js on lines 86..95

              Duplicated Code

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

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

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

              Tuning

              This issue has a mass of 88.

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

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

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

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

              Refactorings

              Further Reading

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

                      enquire.register(
                        'screen and (max-width:' + window.gfw.config.GFW_MOBILE + 'px)',
                        {
                          match: _.bind(function() {
                            this.mobile = true;
              Severity: Major
              Found in app/assets/javascripts/map/views/MapView.js and 1 other location - About 2 hrs to fix
              app/assets/javascripts/map/views/MapView.js on lines 76..85

              Duplicated Code

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

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

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

              Tuning

              This issue has a mass of 88.

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

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

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

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

              Refactorings

              Further Reading

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

                        if (event.pageY < 100) {
                          $('#headerGfw').addClass('-show');
                          $('.logo-menu').addClass('-show');
                          $('.nav-sections').addClass('-show');
                          $('.layout-header-bottom').addClass('-show');
              Severity: Major
              Found in app/assets/javascripts/map/views/MapView.js and 1 other location - About 1 hr to fix
              app/assets/javascripts/map/views/MapView.js on lines 657..673

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

              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 (
                            !hoverCarbonLoss &&
                            !hoverMenuLogin &&
                            !hoverCarbonGains &&
                            !hoverCarbonDensity &&
              Severity: Major
              Found in app/assets/javascripts/map/views/MapView.js and 1 other location - About 1 hr to fix
              app/assets/javascripts/map/views/MapView.js on lines 625..630

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

              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

                    updateLatlngAnalysis: function(lat, lng) {
                      var html = 'Lat/long: {0}, {1}'.format(lat.toFixed(6), lng.toFixed(6));
                      this.$analysislatlng.html(html);
                    },
              Severity: Major
              Found in app/assets/javascripts/map/views/MapView.js and 1 other location - About 1 hr to fix
              app/assets/javascripts/map/views/MapView.js on lines 584..587

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

              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

                    updateLatlngInfo: function(lat, lng) {
                      var html = 'Lat/long: {0}, {1}'.format(lat.toFixed(6), lng.toFixed(6));
                      this.$maplngLng.html(html);
                    },
              Severity: Major
              Found in app/assets/javascripts/map/views/MapView.js and 1 other location - About 1 hr to fix
              app/assets/javascripts/map/views/MapView.js on lines 569..572

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

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

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

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

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

              Refactorings

              Further Reading

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

                      google.maps.event.addListener(
                        this.map,
                        'dragend',
                        _.bind(function() {
                          this.onCenterChange();
              Severity: Major
              Found in app/assets/javascripts/map/views/MapView.js and 2 other locations - About 40 mins to fix
              app/assets/javascripts/map/views/MapControlsView.js on lines 108..114
              app/assets/javascripts/map/views/MapView.js on lines 132..138

              Duplicated Code

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

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

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

              Tuning

              This issue has a mass of 49.

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

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

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

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

              Refactorings

              Further Reading

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

                      google.maps.event.addListener(
                        this.map,
                        'zoom_changed',
                        _.bind(function() {
                          this.onCenterChange();
              Severity: Major
              Found in app/assets/javascripts/map/views/MapView.js and 2 other locations - About 40 mins to fix
              app/assets/javascripts/map/views/MapControlsView.js on lines 108..114
              app/assets/javascripts/map/views/MapView.js on lines 149..155

              Duplicated Code

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

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

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

              Tuning

              This issue has a mass of 49.

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

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

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

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

              Refactorings

              Further Reading

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

                        var layerView = (this.layerInst[layer.slug] = new layersHelper[
                          layer.slug
                        ].view(layer, options, this.map));
              Severity: Minor
              Found in app/assets/javascripts/map/views/MapView.js and 1 other location - About 30 mins to fix
              app/assets/javascripts/map/views/MapView.js on lines 690..692

              Duplicated Code

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

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

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

              Tuning

              This issue has a mass of 45.

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

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

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

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

              Refactorings

              Further Reading

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

                          var layerView = (this.layerInst[layer.slug] = new layersHelper[
                            layer.slug
                          ].view(layer, options, this.map));
              Severity: Minor
              Found in app/assets/javascripts/map/views/MapView.js and 1 other location - About 30 mins to fix
              app/assets/javascripts/map/views/MapView.js on lines 266..268

              Duplicated Code

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

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

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

              Tuning

              This issue has a mass of 45.

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

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

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

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

              Refactorings

              Further Reading

              There are no issues that match your filters.

              Category
              Status