CartoDB/cartodb20

View on GitHub
lib/assets/javascripts/builder/editor/layers/layer-header-view.js

Summary

Maintainability
F
4 days
Test Coverage

File layer-header-view.js has 372 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var CoreView = require('backbone/core-view');
var Backbone = require('backbone');
var template = require('./layer-header.tpl');
var SyncInfoView = require('./sync-info/sync-info-view');
var ContextMenuView = require('builder/components/context-menu/context-menu-view');
Severity: Minor
Found in lib/assets/javascripts/builder/editor/layers/layer-header-view.js - About 4 hrs to fix

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

    module.exports = CoreView.extend({
      module: 'layers:layer-header-view',
    
      className: 'js-editorPanelHeader',
    
    
    Severity: Minor
    Found in lib/assets/javascripts/builder/editor/layers/layer-header-view.js - About 4 hrs to fix

      Function _showContextMenu has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        _showContextMenu: function (position) {
          var menuItems = new CustomListCollection([{
            label: _t('editor.layers.options.rename'),
            val: 'rename-layer'
          }, {
      Severity: Minor
      Found in lib/assets/javascripts/builder/editor/layers/layer-header-view.js - About 1 hr to fix

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

          _initViews: function () {
            this._addSyncInfo();
        
            this._inlineEditor = new InlineEditorView({
              template: templateInlineEditor,
        Severity: Minor
        Found in lib/assets/javascripts/builder/editor/layers/layer-header-view.js - About 1 hr to fix

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

            render: function () {
              this.clearSubViews();
          
              var tableName = '';
              var url = '';
          Severity: Minor
          Found in lib/assets/javascripts/builder/editor/layers/layer-header-view.js - About 1 hr to fix

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

              _renameLayer: function () {
                var newName = this._inlineEditor.getValue();
            
                if (newName !== '') {
                  // Optimistic
            lib/assets/javascripts/builder/editor/layers/layer-views/data-layer-view.js on lines 448..463

            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

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

              _confirmDeleteLayer: function () {
                this._modals.create(function (modalModel) {
                  var deleteLayerConfirmationView = new DeleteLayerConfirmationView({
                    userActions: this._userActions,
                    modals: this._modals,
            lib/assets/javascripts/builder/editor/layers/layer-views/data-layer-view.js on lines 433..446

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

            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

                this._modals.create(function (modalModel) {
                  return new ModalExportDataView({
                    fromView: 'layer',
                    modalModel: modalModel,
                    queryGeometryModel,
            lib/assets/javascripts/builder/editor/layers/layer-views/data-layer-view.js on lines 419..430

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

            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

                if (this._sourceNodeModel) {
                  var tableName = this._sourceNodeModel.get('table_name');
                  this._visTableModel = new VisTableModel({
                    id: tableName,
                    table: {
            lib/assets/javascripts/builder/editor/widgets/widgets-form/widget-header.js on lines 29..39

            Duplicated Code

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

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

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

            Tuning

            This issue has a mass of 73.

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

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

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

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

            Refactorings

            Further Reading

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

                this._inlineEditor = new InlineEditorView({
                  template: templateInlineEditor,
                  renderOptions: {
                    alias: this._layerDefinitionModel.getName()
                  },
            lib/assets/javascripts/builder/dataset/dataset-header/dataset-header-view.js on lines 122..128

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

                if (this._hasContextMenu()) {
                  this._hideContextMenu();
                } else {
                  this._showContextMenu({
                    x: event.pageX,
            lib/assets/javascripts/builder/components/context-menu-factory-view.js on lines 98..105
            lib/assets/javascripts/builder/editor/layers/layer-views/data-layer-view.js on lines 321..328

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

                this._menuView.model.bind('change:visible', function (model, isContextMenuVisible) {
                  if (this._hasContextMenu() && !isContextMenuVisible) {
                    this._hideContextMenu();
                  }
                }, this);
            lib/assets/javascripts/builder/components/context-menu-factory-view.js on lines 70..74
            lib/assets/javascripts/builder/components/table/body/table-body-view.js on lines 305..309
            lib/assets/javascripts/builder/components/table/head/table-head-item-view.js on lines 171..175
            lib/assets/javascripts/builder/editor/layers/basemap-content-views/basemap-mosaic-remove-view.js on lines 59..63
            lib/assets/javascripts/builder/editor/layers/layer-views/data-layer-view.js on lines 403..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 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 3 locations. Consider refactoring.
            Open

              _initViewState: function () {
                this._viewState = new Backbone.Model({
                  isLayerEmpty: false,
                  hasGeom: true,
                  canBeGeoreferenced: false
            lib/assets/javascripts/builder/editor/layers/layer-content-view.js on lines 124..131
            lib/assets/javascripts/builder/editor/layers/layer-content-views/data/data-content-view.js on lines 38..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 55.

            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

              _onSaveError: function (oldName) {
                this.$('.js-title').text(oldName).show();
                this._inlineEditor.hide();
              },
            lib/assets/javascripts/builder/editor/editor-header.js on lines 295..298
            lib/assets/javascripts/builder/editor/editor-header.js on lines 300..303
            lib/assets/javascripts/builder/editor/layers/layer-views/data-layer-view.js on lines 465..468
            lib/assets/javascripts/builder/editor/layers/layer-views/data-layer-view.js on lines 470..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 51.

            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

              _hideContextMenu: function () {
                this.removeView(this._menuView);
                this._menuView.clean();
                delete this._menuView;
              },
            lib/assets/javascripts/builder/components/context-menu-factory-view.js on lines 89..93
            lib/assets/javascripts/builder/editor/layers/basemap-content-views/basemap-mosaic-remove-view.js on lines 31..35
            lib/assets/javascripts/builder/editor/layers/layer-header-view.js on lines 197..201
            lib/assets/javascripts/builder/editor/layers/layer-views/data-layer-view.js on lines 335..339

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

            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

              _destroySyncInfo: function () {
                this.removeView(this._syncInfoView);
                this._syncInfoView.clean();
                delete this._syncInfoView;
              },
            lib/assets/javascripts/builder/components/context-menu-factory-view.js on lines 89..93
            lib/assets/javascripts/builder/editor/layers/basemap-content-views/basemap-mosaic-remove-view.js on lines 31..35
            lib/assets/javascripts/builder/editor/layers/layer-header-view.js on lines 354..358
            lib/assets/javascripts/builder/editor/layers/layer-views/data-layer-view.js on lines 335..339

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

            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

                if (this._tableNodeModel) {
                  this._tableNodeModel.bind('change:synchronization', this.render, this);
                  this.add_related_model(this._tableNodeModel);
                }
            lib/assets/javascripts/builder/components/modals/publish/publish/publish-view.js on lines 75..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 47.

            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 centerTooltip = new TipsyTooltipView({
                  el: this._getZoom(),
                  gravity: 'w',
                  title: function () {
                    return _t('editor.layers.options.center-map');
            lib/assets/javascripts/builder/editor/layers/layer-header-view.js on lines 136..142

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

                var toggleMenuTooltip = new TipsyTooltipView({
                  el: this._getToggleMenu(),
                  gravity: 'w',
                  title: function () {
                    return _t('more-options');
            lib/assets/javascripts/builder/editor/layers/layer-header-view.js on lines 126..132

            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