Vizzuality/gfw-climate

View on GitHub
app/assets/javascripts/map/presenters/tabs/SubscriptionPresenter.js

Summary

Maintainability
F
4 days
Test Coverage

File SubscriptionPresenter.js has 400 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * The SubscriptionPresenter class for the AnalysisToolView.
 *
 * @return SubscriptionPresenter class.
 */
Severity: Minor
Found in app/assets/javascripts/map/presenters/tabs/SubscriptionPresenter.js - About 5 hrs to fix

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

          _subscribeConcession: function(useid, layerSlug) {
            var resource = this._buildResource({
              useid: useid,
              use: layerSlug,
              type: 'other'
    Severity: Minor
    Found in app/assets/javascripts/map/presenters/tabs/SubscriptionPresenter.js - About 1 hr to fix

      Function _subscribeIso has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            _subscribeIso: function(iso) {
              this.deleteSubscription();
              this.view.setStyle();
              this.view.setSelects(iso, this.status.get('dont_analyze'));
      
      
      Severity: Minor
      Found in app/assets/javascripts/map/presenters/tabs/SubscriptionPresenter.js - About 1 hr to fix

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

              _buildResource: function(resource) {
                mps.publish('Spinner/start');
                var date, dateFormat;
                var baselayer = this.status.get('baselayer');
        
        
        Severity: Minor
        Found in app/assets/javascripts/map/presenters/tabs/SubscriptionPresenter.js - About 1 hr to fix

          Function _subscribeWdpai has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                _subscribeWdpai: function(wdpaid) {
                  // Build resource
                  var resource = this._buildResource({
                    wdpaid: wdpaid,
                    type: 'other'
          Severity: Minor
          Found in app/assets/javascripts/map/presenters/tabs/SubscriptionPresenter.js - About 1 hr to fix

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

                    $.getJSON(
                      url,
                      _.bind(function(data) {
                        if (data.rows.length > 0) {
                          var geojson = {
            app/assets/javascripts/map/presenters/tabs/SubscriptionPresenter.js on lines 257..275

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

            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

                    $.getJSON(
                      url,
                      _.bind(function(data) {
                        if (data.rows.length > 0) {
                          var geojson = {
            app/assets/javascripts/map/presenters/tabs/SubscriptionPresenter.js on lines 315..333

            Duplicated Code

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

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

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

            Tuning

            This issue has a mass of 154.

            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 (baselayer.slug !== 'forestgain') {
                      // Append dataset string
                      resource.dataset = this.datasets[baselayer.slug];
            
                      // Append period
            app/assets/javascripts/map/presenters/tabs/AnalysisPresenter.js on lines 587..636

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

            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 StatusModel = Backbone.Model.extend({
                  defaults: {
                    baselayer: null,
                    both: false,
                    resource: null, // analysis resource
            app/assets/javascripts/map/presenters/tabs/AnalysisPresenter.js on lines 33..46

            Duplicated Code

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

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

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

            Tuning

            This issue has a mass of 84.

            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 (resource.iso) {
                      p.iso = {};
                      p.iso.country = resource.iso;
                      p.iso.region = resource.id1 ? resource.id1 : null;
                    } else if (resource.geojson) {
            app/assets/javascripts/map/presenters/tabs/AnalysisPresenter.js on lines 797..807

            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

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

                  onOverlayComplete: function(e) {
                    e.overlay.type = e.type;
                    e.overlay.setEditable(true);
                    this.setOverlay(e.overlay);
                  },
            app/assets/javascripts/map/presenters/tabs/AnalysisPresenter.js on lines 762..766

            Duplicated Code

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

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

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

            Tuning

            This issue has a mass of 62.

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

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

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

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

            Refactorings

            Further Reading

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

                  deleteMultiPoligon: function() {
                    this.view.deleteGeom({
                      overlay: this.status.get('overlay'),
                      multipolygon: this.status.get('multipolygon')
                    });
            app/assets/javascripts/map/presenters/tabs/AnalysisPresenter.js on lines 778..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 60.

            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 url = (function() {
                      if (!!concessionsSql[layerSlug])
                        return concessionsSql[layerSlug].format(useid);
                      else
                        return (
            app/assets/javascripts/map/presenters/tabs/AnalysisPresenter.js on lines 490..500

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

            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

                  setMultipolygon: function(multipolygon, geojson) {
                    this.deleteMultiPoligon();
                    this.status.set('multipolygon', multipolygon);
                    mps.publish('AnalysisTool/iso-drawn', [geojson.geometry]);
                  },
            app/assets/javascripts/map/presenters/tabs/AnalysisPresenter.js on lines 772..776

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

            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

                  _geojsonFitBounds: function(geojson) {
                    var bounds = geojsonUtilsHelper.getBoundsFromGeojson(geojson);
                    if (bounds) {
                      mps.publish('Map/fit-bounds', [bounds]);
                    }
            app/assets/javascripts/map/presenters/tabs/AnalysisPresenter.js on lines 737..742

            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

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

                  init: function(view) {
                    this.view = view;
                    this.status = new StatusModel();
                    this._super();
                  },
            app/assets/javascripts/map/presenters/analysis/AnalysisResultsPresenter.js on lines 38..42

            Duplicated Code

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

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

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

            Tuning

            This issue has a mass of 46.

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

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

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

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

            Refactorings

            Further Reading

            There are no issues that match your filters.

            Category
            Status