Vizzuality/gfw-climate

View on GitHub
app/assets/javascripts/map/views/tabs/CountriesView.js

Summary

Maintainability
D
3 days
Test Coverage

File CountriesView.js has 378 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * The CountriesView selector view.
 *
 * @return CountriesView instance (extends Backbone.View).
 */
Severity: Minor
Found in app/assets/javascripts/map/views/tabs/CountriesView.js - About 5 hrs to fix

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

          printCountries: function(countries) {
            if (this.mobile) {
              var options = '';
              var letters = [];
              _.each(
    Severity: Minor
    Found in app/assets/javascripts/map/views/tabs/CountriesView.js - About 1 hr to fix

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

            commonIsoChanges: function() {
              this.setIsoLayers();
              this.setButtons(!!this.iso);
              if (this.mobile) {
                var country = _.find(
      Severity: Minor
      Found in app/assets/javascripts/map/views/tabs/CountriesView.js - About 1 hr to fix

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

              initialize: function(map) {
                this.embed = $('body').hasClass('is-embed-action');
                this.map = map;
                this.model = new CountriesModel();
                this.presenter = new Presenter(this);
        Severity: Minor
        Found in app/assets/javascripts/map/views/tabs/CountriesView.js - About 1 hr to fix

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

                    if (!!this.iso) {
                      this.$countryReset.show(0);
                      this.$countryBack.hide(0);
                      this.$countryUl.addClass('hidden');
                      this.$letters.parents('.letters-ul-mobile-box').addClass('hidden');
          Severity: Major
          Found in app/assets/javascripts/map/views/tabs/CountriesView.js and 1 other location - About 2 hrs to fix
          app/assets/javascripts/map/views/tabs/CountriesView.js on lines 403..411

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

          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

                    } else {
                      this.$countryReset.hide(0);
                      this.$countryBack.show(0);
                      this.$countryUl.removeClass('hidden');
                      this.$letters
          Severity: Major
          Found in app/assets/javascripts/map/views/tabs/CountriesView.js and 1 other location - About 2 hrs to fix
          app/assets/javascripts/map/views/tabs/CountriesView.js on lines 397..403

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

          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

                    _.each(
                      _.sortBy(countries, function(country) {
                        return country.name;
                      }),
                      _.bind(function(country, i) {
          Severity: Major
          Found in app/assets/javascripts/map/views/tabs/CountriesView.js and 1 other location - About 2 hrs to fix
          app/assets/javascripts/map/views/tabs/SubscriptionView.js on lines 269..277

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

          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 6 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/tabs/CountriesView.js and 5 other locations - About 1 hr to fix
          app/assets/javascripts/compare/views/index/CompareGridView.js on lines 25..33
          app/assets/javascripts/compare/views/index/CompareGridView.js on lines 35..43
          app/assets/javascripts/map/views/tabs/AnalysisView.js on lines 72..80
          app/assets/javascripts/map/views/tabs/CountriesView.js on lines 76..84
          app/assets/javascripts/widgets/views/WidgetView.js on lines 40..48

          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 6 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/tabs/CountriesView.js and 5 other locations - About 1 hr to fix
          app/assets/javascripts/compare/views/index/CompareGridView.js on lines 25..33
          app/assets/javascripts/compare/views/index/CompareGridView.js on lines 35..43
          app/assets/javascripts/map/views/tabs/AnalysisView.js on lines 72..80
          app/assets/javascripts/map/views/tabs/CountriesView.js on lines 85..93
          app/assets/javascripts/widgets/views/WidgetView.js on lines 40..48

          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

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

                  if (
                    !$(e.target).hasClass('source') &&
                    !$(e.target)
                      .parent()
                      .hasClass('source') &&
          Severity: Major
          Found in app/assets/javascripts/map/views/tabs/CountriesView.js and 2 other locations - About 1 hr to fix
          app/assets/javascripts/map/views/LayersNavView.js on lines 205..228
          app/assets/javascripts/map/views/LayersNavView.js on lines 272..301

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

          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

                  _.each(
                    this.isoLayers,
                    _.bind(function(layer) {
                      if (layer.iso === this.iso) {
                        layersToRender.push(layer);
          Severity: Major
          Found in app/assets/javascripts/map/views/tabs/CountriesView.js and 1 other location - About 1 hr to fix
          app/assets/javascripts/map/views/LayersNavView.js on lines 377..384

          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

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

                    var country = _.find(
                      amplify.store('countries'),
                      _.bind(function(country) {
                        return country.iso === this.iso;
                      }, this)
          Severity: Minor
          Found in app/assets/javascripts/map/views/tabs/CountriesView.js and 1 other location - About 55 mins to fix
          app/assets/javascripts/map/views/LayersNavView.js on lines 403..408

          Duplicated Code

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

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

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

          Tuning

          This issue has a mass of 54.

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

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

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

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

          Refactorings

          Further Reading

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

                  if (
                    !$(event.target).hasClass('source') &&
                    !$(event.target)
                      .parent()
                      .hasClass('source')
          Severity: Major
          Found in app/assets/javascripts/map/views/tabs/CountriesView.js and 2 other locations - About 40 mins to fix
          app/assets/javascripts/map/views/LayersNavView.js on lines 158..187
          app/assets/javascripts/map/views/tabs/BasemapsView.js on lines 66..78

          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

          There are no issues that match your filters.

          Category
          Status