CartoDB/cartodb20

View on GitHub
lib/assets/javascripts/cartodb/table/layer_panel_view.js

Summary

Maintainability
F
4 days
Test Coverage

File layer_panel_view.js has 597 lines of code (exceeds 250 allowed). Consider refactoring.
Open


  /**
   *  Layer panel view added in the right menu
   *
   *  - It needs at least layer, visualization and user models.
Severity: Major
Found in lib/assets/javascripts/cartodb/table/layer_panel_view.js - About 1 day to fix

    LayerPanelView has 46 functions (exceeds 20 allowed). Consider refactoring.
    Open

      cdb.admin.LayerPanelView = cdb.admin.RightMenu.extend({
    
        _TEXTS: {
          error:  {
            default:  _t('Something went wrong, try again later')
    Severity: Minor
    Found in lib/assets/javascripts/cartodb/table/layer_panel_view.js - About 6 hrs to fix

      Function setDataLayer has 102 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          setDataLayer: function(dataLayer) {
            var self = this;
            this.add_related_model(dataLayer);
            var enabledModulesInit = self.MODULES;
      
      
      Severity: Major
      Found in lib/assets/javascripts/cartodb/table/layer_panel_view.js - About 4 hrs to fix

        Function _checkButtons has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            _checkButtons: function() {
              var self = this;
              var gt = this.table.get('geometry_types');
        
              // Changes over the SQL button
        Severity: Minor
        Found in lib/assets/javascripts/cartodb/table/layer_panel_view.js - About 1 hr to fix

        Cognitive Complexity

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

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

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

        Further reading

        Function _bindDataLayer has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            _bindDataLayer: function() {
              var self = this;
              this.dataLayer.bindSQLView(this.sqlView);
              this.dataLayer
                .bind('parseError', function() {
        Severity: Minor
        Found in lib/assets/javascripts/cartodb/table/layer_panel_view.js - About 1 hr to fix

          Function _checkButtons has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              _checkButtons: function() {
                var self = this;
                var gt = this.table.get('geometry_types');
          
                // Changes over the SQL button
          Severity: Minor
          Found in lib/assets/javascripts/cartodb/table/layer_panel_view.js - About 1 hr to fix

            Function setActivePanelView has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                setActivePanelView: function(work_view) {
                  if (work_view || !this.currentPanelView) {
                    if (this.activeWorkView === 'map') {
                      var gt = this.table.get('geometry_types');
                      if(this.model.getCurrentState() !== 'error' && (gt && gt.length > 0)) {
            Severity: Minor
            Found in lib/assets/javascripts/cartodb/table/layer_panel_view.js - About 1 hr to fix

            Cognitive Complexity

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

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

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

            Further reading

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

                initialize: function() {
            
                  cdb.admin.RightMenu.prototype.initialize.call(this);
            
                  _.bindAll(this, '_editAlias');
            Severity: Minor
            Found in lib/assets/javascripts/cartodb/table/layer_panel_view.js - About 1 hr to fix

              Function _onChangeStatus has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  _onChangeStatus: function() {
                    var $el = this.$('.layer-info div.left');
                    if (this.view_model.get('state') == "idle") {
                      var alias = $el.find('input').val();
                      $el.find('input').hide();
              Severity: Minor
              Found in lib/assets/javascripts/cartodb/table/layer_panel_view.js - About 55 mins to fix

              Cognitive Complexity

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

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

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

              Further reading

              Function setLayerName has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  setLayerName: function(layer) {
                    if (this.vis.isVisualization()) {
              
                      // table name
                      this.$('.layer-info .info .name')
              Severity: Minor
              Found in lib/assets/javascripts/cartodb/table/layer_panel_view.js - About 35 mins to fix

              Cognitive Complexity

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

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

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

              Further reading

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

                  _readOnlyTableButtons: function() {
                    if(this.activeWorkView === 'map') {
                      this.showTools('mapLite', true);
                    } else {
                      this.showTools('tableLite', true);
              Severity: Minor
              Found in lib/assets/javascripts/cartodb/table/layer_panel_view.js and 1 other location - About 55 mins to fix
              lib/assets/javascripts/cartodb/table/layer_panel_view.js on lines 794..800

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

              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

                  _writableTableButtons: function() {
                    if(this.activeWorkView === 'map') {
                      this.showTools('map', true);
                    } else {
                      this.showTools('table', true);
              Severity: Minor
              Found in lib/assets/javascripts/cartodb/table/layer_panel_view.js and 1 other location - About 55 mins to fix
              lib/assets/javascripts/cartodb/table/layer_panel_view.js on lines 786..792

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

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

                  events: {
                    'dblclick span.name': '_editAlias',
                    'click .name_info a': '_goToLayer',
                    'click .info':        '_switchTo',
                    'click a.visibility': '_switchVisibility',
              Severity: Major
              Found in lib/assets/javascripts/cartodb/table/layer_panel_view.js and 4 other locations - About 35 mins to fix
              lib/assets/javascripts/cartodb/table/export_image_view.js on lines 10..19
              lib/assets/javascripts/cartodb/table/menu_modules/filters/selection.js on lines 87..96
              lib/assets/javascripts/cartodb/table/overlays/image.js on lines 5..18
              lib/assets/javascripts/cartodb/table/overlays/text.js on lines 7..20

              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

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

                  show: function() {
                    this.$('.layer-sidebar').show();
                    this.$('.layer-views').show();
                  },
              Severity: Minor
              Found in lib/assets/javascripts/cartodb/table/layer_panel_view.js and 2 other locations - About 35 mins to fix
              lib/assets/javascripts/cartodb/table/menu_modules/infowindow/infowindow_fields_pane.js on lines 167..170
              lib/assets/javascripts/cartodb/table/menu_modules/legends/legend_fields_pane.js on lines 449..452

              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