CartoDB/cartodb20

View on GitHub
lib/assets/javascripts/dashboard/views/dashboard/imports/background-import-item/background-import-item-view.js

Summary

Maintainability
F
3 days
Test Coverage

Function render has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

  render: function () {
    const upload = this.model.get('upload');
    const importModel = this.model.get('import');

    let templateData = {

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 render has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  render: function () {
    const upload = this.model.get('upload');
    const importModel = this.model.get('import');

    let templateData = {

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

        if (upload.type) {
          if (upload.type === 'file') {
            if (upload.value.length > 1) {
              templateData.name = upload.value.length + ' files';
            } else {
    lib/assets/javascripts/builder/components/background-importer/background-import-item-view.js on lines 100..125
    lib/assets/javascripts/cartodb/common/background_polling/views/imports/background_import_item_view.js on lines 60..85

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

    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

        let templateData = {
          name: '',
          state: this.model.get('state'),
          progress: '',
          service: '',
    lib/assets/javascripts/cartodb/common/background_polling/views/imports/background_import_item_view.js on lines 37..49

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

    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.model.get('step') === 'upload') {
          templateData.progress = this.model.get('upload').progress;
        } else {
          templateData.progress = (UploadConfig.uploadStates.indexOf(templateData.state) / UploadConfig.uploadStates.length) * 100;
        }
    lib/assets/javascripts/cartodb/common/background_polling/views/imports/background_import_item_view.js on lines 91..95

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

    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 (templateData.state === 'complete') {
          const vis = this.model.importedVis();
          if (vis) {
            templateData.url = encodeURI(vis.viewUrl(this._userModel).edit());
          }
    lib/assets/javascripts/cartodb/common/background_polling/views/imports/background_import_item_view.js on lines 52..57

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

    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.model, 'change', this.render);
        this.listenTo(this.model, 'remove', this.clean);
      },
    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/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
    lib/assets/javascripts/dashboard/views/organization/icon-picker/icons/organization-icons-view.js on lines 53..56

    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

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

      _removeItem: function () {
        this.trigger('remove', this.model, this);
        this.model.pause();
        this.clean();
      },
    lib/assets/javascripts/builder/components/background-importer/background-import-item-view.js on lines 47..51
    lib/assets/javascripts/cartodb/common/background_polling/views/imports/background_import_item_view.js on lines 107..111

    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

    There are no issues that match your filters.

    Category
    Status