Vizzuality/gfw-climate

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

Summary

Maintainability
F
5 days
Test Coverage

File AnalysisPresenter.js has 636 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * The AnalysisToolPresenter class for the AnalysisToolView.
 *
 * @return AnalysisToolPresenter class.
 */
Severity: Major
Found in app/assets/javascripts/map/presenters/tabs/AnalysisPresenter.js - About 1 day to fix

    Function _analyzeConcession has 67 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          _analyzeConcession: function(useid, layerSlug) {
            var resource = this._buildResource({
              useid: useid,
              use: layerSlug,
              type: 'other'
    Severity: Major
    Found in app/assets/javascripts/map/presenters/tabs/AnalysisPresenter.js - About 2 hrs to fix

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

            _analyzeIso: function(iso) {
              this.deleteAnalysis();
      
              this.view.setSelects(iso, this.status.get('dont_analyze'));
              mps.publish('LocalMode/updateIso', [
      Severity: Major
      Found in app/assets/javascripts/map/presenters/tabs/AnalysisPresenter.js - About 2 hrs to fix

        Function _buildResource has 43 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/AnalysisPresenter.js - About 1 hr to fix

          Function _analyzeWdpai has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                _analyzeWdpai: function(wdpaid) {
                  // Build resource
          
                  this.wdpaidBool = this.wdpaid == wdpaid ? false : true;
                  this.wdpaid = wdpaid;
          Severity: Minor
          Found in app/assets/javascripts/map/presenters/tabs/AnalysisPresenter.js - About 1 hr to fix

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

                  _handlePlaceGo: function(params) {
                    // this.deleteAnalysis();
            
                    //Open analysis tab
                    if (
            Severity: Minor
            Found in app/assets/javascripts/map/presenters/tabs/AnalysisPresenter.js - About 1 hr to fix

              Consider simplifying this complex logical expression.
              Open

                      if (
                        (!this.status.get('dont_analyze') &&
                          (params.iso &&
                            params.iso.country &&
                            params.iso.country !== 'ALL')) ||
              Severity: Major
              Found in app/assets/javascripts/map/presenters/tabs/AnalysisPresenter.js - About 1 hr to fix

                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/SubscriptionPresenter.js on lines 365..407

                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/SubscriptionPresenter.js on lines 29..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 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.geostore) {
                app/assets/javascripts/map/presenters/tabs/SubscriptionPresenter.js on lines 519..527

                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/SubscriptionPresenter.js on lines 484..488

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

                      init: function(view) {
                        this.view = view;
                        this.status = new StatusModel();
                        this._super();
                        mps.publish('Place/register', [this]);
                app/assets/javascripts/map/presenters/MapPresenter.js on lines 26..31
                app/assets/javascripts/map/presenters/TimelinePresenter.js on lines 25..30

                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

                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/SubscriptionPresenter.js on lines 500..505

                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

                          date[0] =
                            date[0] != null
                              ? !!date[0]._isAMomentObject ? date[0] : date[0].substr(0, 10)
                              : '2001-01-01';
                app/assets/javascripts/map/presenters/tabs/AnalysisPresenter.js on lines 600..603

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

                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

                          date[1] =
                            date[1] != null
                              ? !!date[1]._isAMomentObject ? date[1] : date[1].substr(0, 10)
                              : '2014-12-31';
                app/assets/javascripts/map/presenters/tabs/AnalysisPresenter.js on lines 596..599

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

                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

                        } else if (resource.geostore) {
                          p.geostore = resource.geostore;
                        } else if (resource.geojson) {
                          p.geojson = encodeURIComponent(resource.geojson);
                        } else if (resource.wdpaid) {
                app/assets/javascripts/map/presenters/tabs/SubscriptionPresenter.js on lines 519..527

                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

                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/SubscriptionPresenter.js on lines 303..313

                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/SubscriptionPresenter.js on lines 494..498

                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]);
                        }
                Severity: Minor
                Found in app/assets/javascripts/map/presenters/tabs/AnalysisPresenter.js and 1 other location - About 40 mins to fix
                app/assets/javascripts/map/presenters/tabs/SubscriptionPresenter.js on lines 459..464

                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

                        baselayer =
                          baselayers[
                            _.first(
                              _.intersection(_.pluck(baselayers, 'slug'), _.keys(this.datasets))
                            )
                Severity: Minor
                Found in app/assets/javascripts/map/presenters/tabs/AnalysisPresenter.js and 1 other location - About 40 mins to fix
                app/assets/javascripts/map/presenters/analysis/AnalysisResultsPresenter.js on lines 127..135

                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

                        {
                          'Threshold/changed': function(threshold) {
                            this.status.set('threshold', threshold);
                            this.openAnalysisTab();
                            this._updateAnalysis();
                Severity: Minor
                Found in app/assets/javascripts/map/presenters/tabs/AnalysisPresenter.js and 1 other location - About 40 mins to fix
                app/assets/javascripts/map/presenters/LegendPresenter.js on lines 52..58

                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