CartoDB/cartodb20

View on GitHub
lib/assets/javascripts/cartodb/models/wizard.js

Summary

Maintainability
D
2 days
Test Coverage

File wizard.js has 445 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// form validation

var alwaysTrueValidator = function(form) { return true };

function columnExistsValidatorFor(column_name) {
Severity: Minor
Found in lib/assets/javascripts/cartodb/models/wizard.js - About 6 hrs to fix

    Function propertiesFromStyle has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

      propertiesFromStyle: function(cartocss) {
        var parser = new cdb.admin.CartoParser();
        var parsed = parser.parse(cartocss);
        if (!parsed) return {};
        var rules = parsed.getDefaultRules();
    Severity: Minor
    Found in lib/assets/javascripts/cartodb/models/wizard.js - About 2 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 initialize has 61 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      initialize: function() {
        // params
        this.table = this.get('table');
        this.unset('table');
        if(!this.table) throw new Error('table is undefined');
    Severity: Major
    Found in lib/assets/javascripts/cartodb/models/wizard.js - About 2 hrs to fix

      WizardProperties has 22 functions (exceeds 20 allowed). Consider refactoring.
      Open

      cdb.admin.WizardProperties = cdb.core.Model.extend({
      
        initialize: function() {
          // params
          this.table = this.get('table');
      Severity: Minor
      Found in lib/assets/javascripts/cartodb/models/wizard.js - About 2 hrs to fix

        Function linkLayer has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          linkLayer: function(layer) {
            var self = this;
            /*
             * this is disabled because we need to improve propertiesFromStyle method
             * in order to not override properties which shouldn't be, see CDB-1566
        Severity: Minor
        Found in lib/assets/javascripts/cartodb/models/wizard.js - About 1 hr to fix

          Function _updateForm has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            _updateForm: function() {
              //unbind all forms
              for(var k in this.forms) {
                var forms = this.forms[k];
                for(var f in forms) {
          Severity: Minor
          Found in lib/assets/javascripts/cartodb/models/wizard.js - About 1 hr to fix

            Function propertiesFromStyle has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              propertiesFromStyle: function(cartocss) {
                var parser = new cdb.admin.CartoParser();
                var parsed = parser.parse(cartocss);
                if (!parsed) return {};
                var rules = parsed.getDefaultRules();
            Severity: Minor
            Found in lib/assets/javascripts/cartodb/models/wizard.js - About 1 hr to fix

              Function _fillColumns has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                _fillColumns: function(opts) {
                  var self = this;
                  // lazy shallow copy
                  var attrs = JSON.parse(JSON.stringify(this.attributes));
                  _.each(attrs, function(field) {
              Severity: Minor
              Found in lib/assets/javascripts/cartodb/models/wizard.js - About 1 hr to fix

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

                  linkLayer: function(layer) {
                    var self = this;
                    /*
                     * this is disabled because we need to improve propertiesFromStyle method
                     * in order to not override properties which shouldn't be, see CDB-1566
                Severity: Minor
                Found in lib/assets/javascripts/cartodb/models/wizard.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

                Avoid deeply nested control flow statements.
                Open

                              if (customColumns.length) {
                                f.value = customColumns[0];
                              }
                Severity: Major
                Found in lib/assets/javascripts/cartodb/models/wizard.js - About 45 mins to fix

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

                    active: function(type, props, opts) {
                      opts = _.defaults(opts || {}, { persist: true });
                  
                      // if the geometry is undefined the wizard can't be applied
                      var currentGeom = this.table.geomColumnTypes()[0];
                  Severity: Minor
                  Found in lib/assets/javascripts/cartodb/models/wizard.js - About 35 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

                  Avoid too many return statements within this function.
                  Open

                      return {};
                  Severity: Major
                  Found in lib/assets/javascripts/cartodb/models/wizard.js - About 30 mins to fix

                    There are no issues that match your filters.

                    Category
                    Status