CartoDB/cartodb20

View on GitHub
lib/assets/javascripts/cartodb/table/menu_modules/sql.js

Summary

Maintainability
F
6 days
Test Coverage

SQL has 28 functions (exceeds 20 allowed). Consider refactoring.
Open

cdb.admin.mod.SQL = cdb.admin.Module.extend({

    _TEXTS: {
      tip: '<strong>Ctrl + SPACE</strong> to autocomplete. <strong><%- key %> + S</strong> to apply your query.'
    },
Severity: Minor
Found in lib/assets/javascripts/cartodb/table/menu_modules/sql.js - About 3 hrs to fix

    File sql.js has 303 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /**
     * menu bar sql module
     * this module is used to perform custom SQL queries on the table (and the map)
     */
    
    
    Severity: Minor
    Found in lib/assets/javascripts/cartodb/table/menu_modules/sql.js - About 3 hrs to fix

      Function _onKeyUpEditor has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          _onKeyUpEditor: function(cm, e) {
            var code = (e.keyCode ? e.keyCode : e.which);
      
            if (e.type == "keyup" && code != 27 ) {
              var self = this;
      Severity: Minor
      Found in lib/assets/javascripts/cartodb/table/menu_modules/sql.js - About 3 hrs 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

      Function _updateSQL has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          _updateSQL: function() {
            // Send clear error event to clear the error icon if there was any
            this.trigger('clearError');
      
            if (this.codeEditor) {
      Severity: Minor
      Found in lib/assets/javascripts/cartodb/table/menu_modules/sql.js - About 55 mins 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

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

          _initHelp: function() {
            var so = "rest";
            var ua = navigator.userAgent.toLowerCase();
      
            if (/mac os/.test(ua)) {
      Severity: Major
      Found in lib/assets/javascripts/cartodb/table/menu_modules/sql.js and 1 other location - About 1 day to fix
      lib/assets/javascripts/cartodb/table/menu_modules/carto_editor.js on lines 166..180

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

      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

          _initBinds: function() {
             // Codemirror extrakey
            // Add save keymap
            // PC & LINUX -> Ctrl + s
            // MAC        -> Cmd + s
      Severity: Major
      Found in lib/assets/javascripts/cartodb/table/menu_modules/sql.js and 1 other location - About 6 hrs to fix
      lib/assets/javascripts/cartodb/table/menu_modules/carto_editor.js on lines 115..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 167.

      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

          _checkDoButtons: function() {
            // Redo
            if (!this.model.isHistoryAtLastPosition('query')) {
              this.$el.find('a.next').removeClass("disabled")
            } else {
      Severity: Major
      Found in lib/assets/javascripts/cartodb/table/menu_modules/sql.js and 1 other location - About 6 hrs to fix
      lib/assets/javascripts/cartodb/table/menu_modules/carto_editor.js on lines 470..483

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

      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

          _adjustCodeEditorSize: function() {
            // Fit editor with the error
            var info_h = this.$('.info').is(':visible') ? this.$('.info').outerHeight() : 0;
            var help_h = this.$('.help-tip').is(':visible') ? 36 : 0 ;
            // If layer is not visible, we need to take into account
      Severity: Major
      Found in lib/assets/javascripts/cartodb/table/menu_modules/sql.js and 1 other location - About 6 hrs to fix
      lib/assets/javascripts/cartodb/table/menu_modules/carto_editor.js on lines 358..369

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

      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.codeEditor = CodeMirror.fromTextArea(this.$('textarea')[0], {
              mode: "text/x-postgres",
              tabMode: "indent",
              matchBrackets: true,
              lineNumbers: true,
      Severity: Major
      Found in lib/assets/javascripts/cartodb/table/menu_modules/sql.js and 1 other location - About 3 hrs to fix
      lib/assets/javascripts/cartodb/table/menu_modules/carto_editor.js on lines 140..150

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

      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

          _undo: function(e) {
            e.preventDefault();
            var newQuery = this.model.undoHistory('query');
            if (this.codeEditor && newQuery) {
              this.codeEditor.setValue(newQuery);
      Severity: Major
      Found in lib/assets/javascripts/cartodb/table/menu_modules/sql.js and 1 other location - About 2 hrs to fix
      lib/assets/javascripts/cartodb/table/menu_modules/sql.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 83.

      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

          _do: function(e) {
            e.preventDefault();
            var newQuery = this.model.redoHistory('query');
            if (this.codeEditor && newQuery) {
              this.codeEditor.setValue(newQuery);
      Severity: Major
      Found in lib/assets/javascripts/cartodb/table/menu_modules/sql.js and 1 other location - About 2 hrs to fix
      lib/assets/javascripts/cartodb/table/menu_modules/sql.js on lines 350..358

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

      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

          _showAutocomplete: function(cm) {
            CodeMirror.showHint(cm, CodeMirror.hint['custom-list-with-type'], {
              completeSingle: false,
              list: _.union( this._getTableName(), this._getSQLColumns())
            });
      Severity: Major
      Found in lib/assets/javascripts/cartodb/table/menu_modules/sql.js and 1 other location - About 1 hr to fix
      lib/assets/javascripts/cartodb/table/menu_modules/carto_editor.js on lines 183..188

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

      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

          activated: function() {
            if(this.codeEditor) {
              this.codeEditor.refresh();
              this.codeEditor.focus();
              this._adjustCodeEditorSize();
      Severity: Major
      Found in lib/assets/javascripts/cartodb/table/menu_modules/sql.js and 1 other location - About 1 hr to fix
      lib/assets/javascripts/cartodb/table/menu_modules/carto_editor.js on lines 92..98

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

      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

          _clearErrors: function() {
            // Remove error text and hide it
            this.$('.info')
              .removeClass('error')
              .html('')
      Severity: Major
      Found in lib/assets/javascripts/cartodb/table/menu_modules/sql.js and 2 other locations - About 1 hr to fix
      lib/assets/javascripts/cartodb/table/menu_modules/infowindow/infowindow_html_pane.js on lines 248..256
      lib/assets/javascripts/cartodb/table/menu_modules/legends/legend_html_pane.js on lines 207..215

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

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

                  if (!cm.state.completionActive && str.length > 2 && list.length > 0) {
                    self._showAutocomplete(cm)
                  }
      Severity: Major
      Found in lib/assets/javascripts/cartodb/table/menu_modules/sql.js and 3 other locations - About 50 mins to fix
      lib/assets/javascripts/cartodb/table/menu_modules/carto_editor.js on lines 224..226
      lib/assets/javascripts/cartodb/table/menu_modules/infowindow/infowindow_html_pane.js on lines 111..113
      lib/assets/javascripts/cartodb/table/menu_modules/legends/legend_html_pane.js on lines 106..108

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

          _showDoc: function(ev) {
            ev.preventDefault();
            cdb.editor.ViewFactory.createDialogByTemplate('common/dialogs/help/postgres_sql').appendToBody();
          }
      Severity: Minor
      Found in lib/assets/javascripts/cartodb/table/menu_modules/sql.js and 1 other location - About 35 mins to fix
      lib/assets/javascripts/cartodb/table/menu_modules/carto_editor.js on lines 485..488

      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

      There are no issues that match your filters.

      Category
      Status