CartoDB/cartodb20

View on GitHub
lib/assets/javascripts/cartodb/common/background_polling/views/imports/background_import_item_view.js

Summary

Maintainability
F
4 days
Test Coverage

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

  render: function() {
    var upload = this.model.get('upload');
    var imp = this.model.get('import');

    var d = {

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() {
    var upload = this.model.get('upload');
    var imp = this.model.get('import');

    var d = {

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

        if (upload.type) {
          if (upload.type === "file") {
            if (upload.value.length > 1) {
              d.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/dashboard/views/dashboard/imports/background-import-item/background-import-item-view.js on lines 66..91

    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

        var d = {
          name: '',
          state: this.model.get('state'),
          progress: '',
          service: '',
    lib/assets/javascripts/dashboard/views/dashboard/imports/background-import-item/background-import-item-view.js on lines 43..55

    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') {
          d.progress = this.model.get('upload').progress;
        } else {
          d.progress = (UploadConfig.uploadStates.indexOf(d.state)/UploadConfig.uploadStates.length) * 100;
        }
    lib/assets/javascripts/dashboard/views/dashboard/imports/background-import-item/background-import-item-view.js on lines 97..101

    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

      initialize: function() {
        this.user = this.options.user;
        this._showSuccessDetailsButton = this.options.showSuccessDetailsButton;
        this.template = cdb.templates.getTemplate('common/background_polling/views/imports/background_import_item');
        this._initBinds();
    lib/assets/javascripts/cartodb/common/background_polling/views/analysis/background_analysis_item_view.js on lines 16..21

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

    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 (d.state === "complete") {
          var vis = this.model.importedVis();
          if (vis) {
            d.url = encodeURI(vis.viewUrl(this.user).edit());
          }
    lib/assets/javascripts/dashboard/views/dashboard/imports/background-import-item/background-import-item-view.js on lines 58..63

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

      _showImportWarnings: function() {
        var dialog = ViewFactory.createDialogByView(
          new WarningsDetailsView({
            warnings: this.model.getWarnings(),
            user: this.user
    lib/assets/javascripts/cartodb/common/background_polling/views/imports/background_import_item_view.js on lines 121..129

    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

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

      _showImportError: function() {
        var dialog = ViewFactory.createDialogByView(
          new ErrorDetailsView({
            err: this.model.getError(),
            user: this.user
    lib/assets/javascripts/cartodb/common/background_polling/views/imports/background_import_item_view.js on lines 131..139

    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

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

      _initBinds: function() {
        this.model.bind('change', this.render, this);
        this.model.bind('remove', this.clean, this);
      },
    lib/assets/javascripts/builder/components/background-importer/background-importer.js on lines 61..64
    lib/assets/javascripts/builder/components/custom-list/custom-view.js on lines 101..104
    lib/assets/javascripts/builder/components/modals/add-layer/content/imports/import-bigquery/import-bigquery-form-view.js on lines 86..89
    lib/assets/javascripts/builder/components/modals/add-layer/content/imports/import-database/import-database-connect-form-view.js on lines 57..60
    lib/assets/javascripts/builder/components/modals/add-layer/content/imports/import-database/import-database-query-form-view.js on lines 50..53
    lib/assets/javascripts/builder/components/pagination-search/pagination-search-model.js on lines 28..31
    lib/assets/javascripts/builder/components/table/body/table-body-row-view.js on lines 44..47
    lib/assets/javascripts/builder/editor/layers/layer-content-views/infowindow/infowindow-fields-view.js on lines 28..31
    lib/assets/javascripts/cartodb/common/background_polling/views/geocodings/background_geocoding_item_view.js on lines 55..58
    lib/assets/javascripts/cartodb/common/dialogs/create/listing/imports/import_data_view.js on lines 117..120
    lib/assets/javascripts/cartodb/common/dialogs/create/listing/imports/service_import/service_loader_view.js on lines 34..37
    lib/assets/javascripts/cartodb/common/dialogs/edit_vis_metadata/edit_vis_form_view.js on lines 51..54
    lib/assets/javascripts/cartodb/common/dialogs/georeference/tab_item_view.js on lines 36..39
    lib/assets/javascripts/cartodb/common/dialogs/map/image_picker/footer_view.js on lines 40..43
    lib/assets/javascripts/cartodb/common/dialogs/merge_datasets/spatial_merge/merge_method_view.js on lines 51..54
    lib/assets/javascripts/cartodb/common/dialogs/pecan/pecan_dialog_view.js on lines 97..100
    lib/assets/javascripts/cartodb/common/edit_fields/edit_field_view.js on lines 49..52

    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/dashboard/views/dashboard/imports/background-import-item/background-import-item-view.js on lines 113..117

    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