CartoDB/cartodb20

View on GitHub
lib/assets/javascripts/builder/editor/layers/layer-content-views/legend/legend-base-type-view.js

Summary

Maintainability
F
4 days
Test Coverage

File legend-base-type-view.js has 343 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var cdb = require('internal-carto.js');
var _ = require('underscore');
var Backbone = require('backbone');
var CoreView = require('backbone/core-view');
var PanelWithOptionsView = require('builder/components/view-options/panel-with-options-view');

    exports has 25 functions (exceeds 20 allowed). Consider refactoring.
    Open

    module.exports = CoreView.extend({
      initialize: function (opts) {
        checkAndBuildOpts(opts, REQUIRED_OPTS, this);
    
        // this.legendTypes is defined in the subview

      Function _initViews has 68 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        _initViews: function () {
          var self = this;
      
          var infoboxSstates = [
            {

        Function _configPanes has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          _configPanes: function () {
            var self = this;
            var tabPaneTabs = [{
              selected: !self._legendDefinitionModel.hasCustomHtml(),
              createContentView: function () {

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

              } else if (!edition && this._legendDefinitionModel.hasCustomHtml()) {
                this._infoboxModel.set({ state: 'html-legend' });
                this._overlayModel.set({ visible: true });
              } else if (this._isLayerHidden()) {
                this._infoboxModel.set({ state: 'layer-hidden' });
          lib/assets/javascripts/builder/editor/layers/layer-content-views/infowindow/infowindow-base-view.js on lines 341..352
          lib/assets/javascripts/builder/editor/style/style-view.js on lines 453..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 145.

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

              var panelWithOptionsView = new PanelWithOptionsView({
                className: 'Editor-content',
                editorModel: self._editorModel,
                infoboxModel: self._infoboxModel,
                infoboxCollection: infoboxCollection,
          lib/assets/javascripts/builder/editor/layers/layer-content-views/data/data-view.js on lines 406..427
          lib/assets/javascripts/builder/editor/layers/layer-content-views/infowindow/infowindow-base-view.js on lines 121..142
          lib/assets/javascripts/builder/editor/style/style-view.js on lines 197..218

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

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

                }, {
                  state: 'layer-hidden',
                  createContentView: function () {
                    return Infobox.createWithAction({
                      type: 'alert',
          lib/assets/javascripts/builder/editor/layers/layer-content-views/analyses/analyses-view.js on lines 84..97
          lib/assets/javascripts/builder/editor/layers/layer-content-views/data/data-view.js on lines 366..379
          lib/assets/javascripts/builder/editor/layers/layer-content-views/data/data-view.js on lines 388..401
          lib/assets/javascripts/builder/editor/layers/layer-content-views/infowindow/infowindow-base-view.js on lines 90..103
          lib/assets/javascripts/builder/editor/layers/layer-content-views/infowindow/infowindow-base-view.js on lines 103..116
          lib/assets/javascripts/builder/editor/layers/layer-content-views/legend/legend-base-type-view.js on lines 207..220
          lib/assets/javascripts/builder/editor/layers/layer-content-views/legend/legend-base-type-view.js on lines 233..246

          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

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

                }, {
                  state: 'legends-disabled',
                  createContentView: function () {
                    return Infobox.createWithAction({
                      type: 'alert',
          lib/assets/javascripts/builder/editor/layers/layer-content-views/analyses/analyses-view.js on lines 84..97
          lib/assets/javascripts/builder/editor/layers/layer-content-views/data/data-view.js on lines 366..379
          lib/assets/javascripts/builder/editor/layers/layer-content-views/data/data-view.js on lines 388..401
          lib/assets/javascripts/builder/editor/layers/layer-content-views/infowindow/infowindow-base-view.js on lines 90..103
          lib/assets/javascripts/builder/editor/layers/layer-content-views/infowindow/infowindow-base-view.js on lines 103..116
          lib/assets/javascripts/builder/editor/layers/layer-content-views/legend/legend-base-type-view.js on lines 207..220
          lib/assets/javascripts/builder/editor/layers/layer-content-views/legend/legend-base-type-view.js on lines 220..233

          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

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

                {
                  state: 'html-legend',
                  createContentView: function () {
                    return Infobox.createWithAction({
                      type: 'alert',
          lib/assets/javascripts/builder/editor/layers/layer-content-views/analyses/analyses-view.js on lines 84..97
          lib/assets/javascripts/builder/editor/layers/layer-content-views/data/data-view.js on lines 366..379
          lib/assets/javascripts/builder/editor/layers/layer-content-views/data/data-view.js on lines 388..401
          lib/assets/javascripts/builder/editor/layers/layer-content-views/infowindow/infowindow-base-view.js on lines 90..103
          lib/assets/javascripts/builder/editor/layers/layer-content-views/infowindow/infowindow-base-view.js on lines 103..116
          lib/assets/javascripts/builder/editor/layers/layer-content-views/legend/legend-base-type-view.js on lines 220..233
          lib/assets/javascripts/builder/editor/layers/layer-content-views/legend/legend-base-type-view.js on lines 233..246

          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

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

              this._togglerModel = new Backbone.Model({
                labels: [_t('editor.legend.data-toggle.values'), _t('editor.legend.data-toggle.html')],
                active: this._editorModel.isEditing(),
                disabled: this._editorModel.isDisabled(),
                isDisableable: true,
          lib/assets/javascripts/builder/editor/layers/layer-content-views/infowindow/infowindow-base-view.js on lines 77..83
          lib/assets/javascripts/builder/editor/style/style-view.js on lines 72..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 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

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

            render: function () {
              this.clearSubViews();
              this.$el.empty();
          
              this._initViews();
          lib/assets/javascripts/builder/editor/layers/layer-content-views/infowindow/infowindow-base-view.js on lines 39..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 67.

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

            _showHiddenLayer: function () {
              var savingOptions = {
                shouldPreserveAutoStyle: true
              };
              this._layerDefinitionModel.toggleVisible();
          lib/assets/javascripts/builder/editor/layers/layer-content-views/data/data-view.js on lines 455..461
          lib/assets/javascripts/builder/editor/layers/layer-content-views/infowindow/infowindow-base-view.js on lines 355..361
          lib/assets/javascripts/builder/editor/layers/layer-content-views/infowindow/infowindows-view.js on lines 225..231
          lib/assets/javascripts/builder/editor/layers/layer-content-views/legend/legends-view.js on lines 218..224
          lib/assets/javascripts/builder/editor/style/style-view.js on lines 467..473

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

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

            _onTogglerChanged: function () {
              var checked = this._togglerModel.get('active');
              this._editorModel.set({ edition: checked });
            },
          lib/assets/javascripts/builder/dataset/dataset-options/dataset-options-view.js on lines 135..138
          lib/assets/javascripts/builder/dataset/dataset-options/dataset-options-view.js on lines 140..143
          lib/assets/javascripts/builder/editor/layers/layer-content-views/data/data-view.js on lines 293..296
          lib/assets/javascripts/builder/editor/layers/layer-content-views/data/data-view.js on lines 298..301
          lib/assets/javascripts/builder/editor/layers/layer-content-views/infowindow/infowindow-base-view.js on lines 317..320
          lib/assets/javascripts/builder/editor/layers/layer-content-views/infowindow/infowindow-base-view.js on lines 322..325
          lib/assets/javascripts/builder/editor/layers/layer-content-views/legend/legend-base-type-view.js on lines 193..196
          lib/assets/javascripts/builder/editor/style/style-view.js on lines 335..338
          lib/assets/javascripts/builder/editor/style/style-view.js on lines 340..343

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

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

            _onChangeDisabled: function () {
              var disabled = this._editorModel.get('disabled');
              this._togglerModel.set({ disabled: disabled });
            },
          lib/assets/javascripts/builder/dataset/dataset-options/dataset-options-view.js on lines 135..138
          lib/assets/javascripts/builder/dataset/dataset-options/dataset-options-view.js on lines 140..143
          lib/assets/javascripts/builder/editor/layers/layer-content-views/data/data-view.js on lines 293..296
          lib/assets/javascripts/builder/editor/layers/layer-content-views/data/data-view.js on lines 298..301
          lib/assets/javascripts/builder/editor/layers/layer-content-views/infowindow/infowindow-base-view.js on lines 317..320
          lib/assets/javascripts/builder/editor/layers/layer-content-views/infowindow/infowindow-base-view.js on lines 322..325
          lib/assets/javascripts/builder/editor/layers/layer-content-views/legend/legend-base-type-view.js on lines 198..201
          lib/assets/javascripts/builder/editor/style/style-view.js on lines 335..338
          lib/assets/javascripts/builder/editor/style/style-view.js on lines 340..343

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

          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

            _toggleOverlay: function () {
              var isDisabled = this._overlayModel.get('visible');
              this.$('.js-overlay').toggleClass('is-disabled', isDisabled);
            },
          lib/assets/javascripts/builder/editor/layers/layer-content-views/infowindow/infowindow-base-view.js on lines 158..161

          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