CartoDB/cartodb20

View on GitHub
lib/assets/javascripts/dashboard/views/organization/icon-picker/icons/organization-icons-view.js

Summary

Maintainability
F
3 days
Test Coverage

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

module.exports = CoreView.extend({

  events: {
    'click .js-addIcon': '_onAddIconClicked',
    'click .js-selectAllIcons': '_onSelectAllIconsClicked',

    File organization-icons-view.js has 293 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    const Backbone = require('backbone');
    const CoreView = require('backbone/core-view');
    const _ = require('underscore');
    const IconCollection = require('./organization-icon-collection');
    const IconView = require('./organization-icon-view');

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

        _refreshActions: function () {
          if (this.model.get('isProcessRunning')) {
            return;
          }
          var limit = Math.min(this._iconCollection.length);

      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 _parseResponseText has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        _parseResponseText: function (response) {
          if (response && response.responseText) {
            try {
              var text = JSON.parse(response.responseText);
              if (text && text.errors && typeof text.errors === 'string') {

      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

          if (numOfSelectedIcons === 0) {
            this.$('.js-iconMainLabel').text('');
            this._hide('.js-iconMainLabel, .js-selectAllIcons, .js-deselectAllIcons, .js-deleteIcons');
            this._show('.js-iconsInfo');
          } else if (numOfSelectedIcons < limit) {
      lib/assets/javascripts/dashboard/views/organization/icon-picker/organization-icon-picker-view.js on lines 89..99

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

      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

            icon.destroy({
              beforeSend: this._beforeIconDelete.bind(this),
              success: this._onIconDeleted.bind(this),
              error: this._onIconDeleteError.bind(this),
              complete: this._onIconDeleteComplete.bind(this)
      lib/assets/javascripts/builder/components/input-color/assets-picker/assets-view.js on lines 124..129
      lib/assets/javascripts/dashboard/views/organization/icon-picker/icons/organization-icons-view.js on lines 118..123

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

      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

            }, {
              beforeSend: this._beforeIconUpload.bind(this),
              success: this._onIconUploaded.bind(this),
              error: this._onIconUploadError.bind(this),
              complete: this._onIconUploadComplete.bind(this)
      lib/assets/javascripts/builder/components/input-color/assets-picker/assets-view.js on lines 124..129
      lib/assets/javascripts/dashboard/views/organization/icon-picker/icons/organization-icons-view.js on lines 235..240

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

      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

        _renderIcon: function (iconModel) {
          var iconView = new IconView({
            model: iconModel
          });
          iconView.render();
      lib/assets/javascripts/dashboard/views/organization/icon-picker/organization-icon-picker-view.js on lines 64..71

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

      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 (numOfSelectedIcons > 1) {
            this.$('.js-deleteIcons a').text('Delete icons...');
          } else if (numOfSelectedIcons === 1) {
            this.$('.js-deleteIcons a').text('Delete icon...');
          }
      lib/assets/javascripts/dashboard/views/organization/icon-picker/organization-icon-picker-view.js on lines 101..105

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

      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

        _beforeIconDelete: function () {
          this._numOfDeletingProcesses++;
          if (this._numOfDeletingProcesses > 0) {
            this._runningMessage = 'Deleting icons...';
            this.model.set('isProcessRunning', true);
      lib/assets/javascripts/dashboard/views/organization/icon-picker/icons/organization-icons-view.js on lines 127..133

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

      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

        _beforeIconUpload: function () {
          this._numOfUploadingProcesses++;
          if (this._numOfUploadingProcesses > 0) {
            this._runningMessage = 'Uploading icons...';
            this.model.set('isProcessRunning', true);
      lib/assets/javascripts/dashboard/views/organization/icon-picker/icons/organization-icons-view.js on lines 248..254

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

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

        _initBinds: function () {
          this.listenTo(this._iconCollection, 'change:selected', this._refreshActions);
          this.listenTo(this.model, 'change:isProcessRunning', this._onProcessRunningChanged);
        },
      lib/assets/javascripts/builder/components/dialog/dialog-view.js on lines 29..32
      lib/assets/javascripts/builder/components/form-components/editors/datetime/datetime-dialog-view.js on lines 24..27
      lib/assets/javascripts/builder/components/infobox/infobox-view.js on lines 25..28
      lib/assets/javascripts/builder/components/infobox/infobox-view.js on lines 52..55
      lib/assets/javascripts/builder/components/input-color/assets-picker/organization-assets-list-view.js on lines 32..35
      lib/assets/javascripts/builder/components/input-color/input-color-file-view.js on lines 38..41
      lib/assets/javascripts/builder/components/input-color/input-color-picker/input-color-picker-view.js on lines 38..41
      lib/assets/javascripts/builder/components/modals/add-widgets/category/category-option-view.js on lines 76..79
      lib/assets/javascripts/builder/components/onboardings/onboarding-view.js on lines 11..14
      lib/assets/javascripts/builder/components/table/editors/editor-view.js on lines 6..9
      lib/assets/javascripts/builder/components/toggler/toggler-view.js on lines 53..56
      lib/assets/javascripts/builder/dataset/dataset-content/dataset-content-options-view.js on lines 59..62
      lib/assets/javascripts/builder/editor/editor-map-view.js on lines 193..196
      lib/assets/javascripts/builder/editor/export-image-pane/export-image-form-view.js on lines 39..42
      lib/assets/javascripts/builder/editor/layers/analysis-views/source-layer-analysis-view.js on lines 119..122
      lib/assets/javascripts/builder/editor/layers/layer-content-views/infowindow/infowindow-content-view.js on lines 33..36
      lib/assets/javascripts/builder/editor/style/style-cartocss-view.js on lines 44..47
      lib/assets/javascripts/dashboard/views/dashboard/background-polling/background-polling-view.js on lines 48..51
      lib/assets/javascripts/dashboard/views/dashboard/dialogs/change-privacy/start-view.js on lines 64..67
      lib/assets/javascripts/dashboard/views/dashboard/imports/background-import-item/background-import-item-view.js on lines 108..111
      lib/assets/javascripts/dashboard/views/organization/groups-admin/add-group-users/add-group-users-view.js on lines 125..128
      lib/assets/javascripts/dashboard/views/organization/icon-picker/icons/organization-icon-view.js on lines 30..33

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

      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

        _onAddIconClicked: function (event) {
          this.killEvent(event);
      
          this._hideErrorMessage();
          this.$('.js-inputFile').trigger('click');
      lib/assets/javascripts/dashboard/views/organization/icon-picker/icon-picker-dialog/icon-picker-dialog-view.js on lines 54..59

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

        _onIconUploadComplete: function () {
          this._numOfUploadingProcesses--;
          if (this._numOfUploadingProcesses <= 0) {
            this.model.set('isProcessRunning', false);
          }
      lib/assets/javascripts/dashboard/views/organization/icon-picker/icons/organization-icons-view.js on lines 270..275

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 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 2 locations. Consider refactoring.
      Open

        _uploadErrorMessage: function (errorText) {
          var message = 'Error uploading your image. ';
          if (errorText) {
            message += '[ ' + errorText + ' ]. ';
          }
      lib/assets/javascripts/dashboard/views/organization/icon-picker/icons/organization-icons-view.js on lines 340..348

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

        _deleteErrorMessage: function (errorText) {
          var message = 'Error deleting your image. ';
          if (errorText) {
            message += '[ ' + errorText + ' ]. ';
          }
      lib/assets/javascripts/dashboard/views/organization/icon-picker/icons/organization-icons-view.js on lines 330..338

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

        _onIconDeleteComplete: function () {
          this._numOfDeletingProcesses--;
          if (this._numOfDeletingProcesses <= 0) {
            this.model.set('isProcessRunning', false);
          }
      lib/assets/javascripts/dashboard/views/organization/icon-picker/icons/organization-icons-view.js on lines 146..151

      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

      There are no issues that match your filters.

      Category
      Status