CartoDB/cartodb20

View on GitHub
lib/assets/javascripts/cartodb/table/export_image_view.js

Summary

Maintainability
F
3 days
Test Coverage

File export_image_view.js has 342 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 *  Generate export image view
 *
 */

Severity: Minor
Found in lib/assets/javascripts/cartodb/table/export_image_view.js - About 4 hrs to fix

    ExportImageView has 29 functions (exceeds 20 allowed). Consider refactoring.
    Open

    cdb.admin.ExportImageView = cdb.core.View.extend({
    
      className: 'ExportImageView',
    
      events: {
    Severity: Minor
    Found in lib/assets/javascripts/cartodb/table/export_image_view.js - About 3 hrs to fix

      Function initialize has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        initialize: function() {
      
          _.bindAll(this, "_onResizeWindow", "_onChangeDimensions", "_onImageCallback", "_onAdvancedImageCallback", "_keydown", "_onDrag", "_onResize", "_updateHelpers");
      
          $(document).bind('keydown', this._keydown);
      Severity: Minor
      Found in lib/assets/javascripts/cartodb/table/export_image_view.js - About 1 hr to fix

        Function _onKeyUp has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          _onKeyUp: function(e) {
            this.killEvent(e);
        
            var property = "width";
            var value = +$(e.target).val();
        Severity: Minor
        Found in lib/assets/javascripts/cartodb/table/export_image_view.js - About 1 hr to fix

          Function _onKeyUp has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            _onKeyUp: function(e) {
              this.killEvent(e);
          
              var property = "width";
              var value = +$(e.target).val();
          Severity: Minor
          Found in lib/assets/javascripts/cartodb/table/export_image_view.js - About 1 hr to fix

          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

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

            _getMarkdown: function(content) {
              content = cdb.Utils.stripHTML(content);
              content = markdown.toHTML(content);
              content = cdb.Utils.stripHTML(content, '<a><i><em><strong><b><u><s>');
              content = content.replace(/&#39;/g, "'"); // replaces single quote
          Severity: Major
          Found in lib/assets/javascripts/cartodb/table/export_image_view.js and 1 other location - About 3 hrs to fix
          lib/assets/javascripts/cartodb/table/overlays/header.js on lines 198..207

          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

              if (property === 'height') {
                var top = this.$(".CanvasExport").position().top;
                var canvasHeight = this.options.mapView.$el.height();
          
                if (top + value > canvasHeight) {
          Severity: Major
          Found in lib/assets/javascripts/cartodb/table/export_image_view.js and 1 other location - About 3 hrs to fix
          lib/assets/javascripts/cartodb/table/export_image_view.js on lines 398..406

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

          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

              } else {
                var left = this.$(".CanvasExport").position().left;
                var canvasWidth  = this.options.mapView.$el.width();
          
                if (left + value > canvasWidth) {
          Severity: Major
          Found in lib/assets/javascripts/cartodb/table/export_image_view.js and 1 other location - About 3 hrs to fix
          lib/assets/javascripts/cartodb/table/export_image_view.js on lines 390..398

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

          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.mapOverlays.overlays.each(function(overlay) {
                var type = overlay.get("type");
                if (type !== "zoom" && type !== "loader" && type !== "annotation" && type !== "text" && type !== "image") {
                  overlay.set("display", false);
                }
          Severity: Major
          Found in lib/assets/javascripts/cartodb/table/export_image_view.js and 1 other location - About 3 hrs to fix
          lib/assets/javascripts/cartodb/table/export_image_view.js on lines 147..152

          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

              this.mapOverlays.overlays.each(function(overlay) {
                var type = overlay.get("type");
                if (type !== "zoom" && type !== "loader" && type !== "annotation" && type !== "text" && type !== "image") {
                  overlay.set("display", true);
                }
          Severity: Major
          Found in lib/assets/javascripts/cartodb/table/export_image_view.js and 1 other location - About 3 hrs to fix
          lib/assets/javascripts/cartodb/table/export_image_view.js on lines 165..170

          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

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

              if (error && error.errors) {
                cdb.editor.ViewFactory.createDialogByTemplate('common/templates/fail', { msg: error.errors })
                .render().appendToBody();
                return;
              }
          Severity: Major
          Found in lib/assets/javascripts/cartodb/table/export_image_view.js and 1 other location - About 1 hr to fix
          lib/assets/javascripts/cartodb/table/export_image_view.js on lines 249..253

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

              if (error && error.errors) {
                cdb.editor.ViewFactory.createDialogByTemplate('common/templates/fail', { msg: error.errors })
                .render().appendToBody();
                return;
              }
          Severity: Major
          Found in lib/assets/javascripts/cartodb/table/export_image_view.js and 1 other location - About 1 hr to fix
          lib/assets/javascripts/cartodb/table/export_image_view.js on lines 338..342

          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

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

                this.$(".js-helper-west").css({ left: 0, top: y + 1, width: x + 1, height: height});
          Severity: Minor
          Found in lib/assets/javascripts/cartodb/table/export_image_view.js and 1 other location - About 40 mins to fix
          lib/assets/javascripts/builder/editor/export-image-pane/export-image-widget.js on lines 136..136

          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

            events: {
              'click .js-ok': '_ok',
              'click .js-format': '_openFormatDropdow',
              'dblclick .js-format': 'killEvent',
              'click .js-advanced': '_openAdvancedExport',
          Severity: Major
          Found in lib/assets/javascripts/cartodb/table/export_image_view.js and 4 other locations - About 35 mins to fix
          lib/assets/javascripts/cartodb/table/layer_panel_view.js on lines 31..40
          lib/assets/javascripts/cartodb/table/menu_modules/filters/selection.js on lines 87..96
          lib/assets/javascripts/cartodb/table/overlays/image.js on lines 5..18
          lib/assets/javascripts/cartodb/table/overlays/text.js on lines 7..20

          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

            _onChangeFormat: function() {
              this.$(".js-formatName").text('.' + this.model.get("format"));
            },
          Severity: Minor
          Found in lib/assets/javascripts/cartodb/table/export_image_view.js and 1 other location - About 30 mins to fix
          lib/assets/javascripts/cartodb/common/dialogs/create/listing/imports/twitter_import/twitter_categories/twitter_category_view.js on lines 48..50

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

          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