CartoDB/cartodb20

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

Summary

Maintainability
D
1 day
Test Coverage

File cartodb_layer.js has 394 lines of code (exceeds 250 allowed). Consider refactoring.
Open

cdb.admin.CartoDBLayer = cdb.geo.CartoDBLayer.extend({
  MAX_HISTORY: 5,
  MAX_HISTORY_QUERY: 5,
  MAX_HISTORY_TILE_STYLE: 5,

Severity: Minor
Found in lib/assets/javascripts/cartodb/models/cartodb_layer.js - About 5 hrs to fix

    CartoDBLayer has 30 functions (exceeds 20 allowed). Consider refactoring.
    Open

    cdb.admin.CartoDBLayer = cdb.geo.CartoDBLayer.extend({
      MAX_HISTORY: 5,
      MAX_HISTORY_QUERY: 5,
      MAX_HISTORY_TILE_STYLE: 5,
    
    
    Severity: Minor
    Found in lib/assets/javascripts/cartodb/models/cartodb_layer.js - About 3 hrs to fix

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

        initialize: function() {
          this.sync = _.debounce(this.sync, 1000);
          this.error = false;
      
          this.set('use_server_style', true);
      Severity: Minor
      Found in lib/assets/javascripts/cartodb/models/cartodb_layer.js - About 1 hr to fix

        Function _manageInteractivity has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

          _manageInteractivity: function() {
            var interactivity = null;
            if (this.wizard_properties.supportsInteractivity()) {
              if(this.table.containsColumn('cartodb_id')) {
                interactivity = ['cartodb_id'];
        Severity: Minor
        Found in lib/assets/javascripts/cartodb/models/cartodb_layer.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

        Function toJSON has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          toJSON: function() {
            var c = _.clone(this.attributes);
            // remove api key
            if(c.extra_params) {
              c.extra_params = _.clone(this.attributes.extra_params);
        Severity: Minor
        Found in lib/assets/javascripts/cartodb/models/cartodb_layer.js - About 1 hr to fix

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

            parse: function(data, xhr) {
              var c = {};
              // in case this is a response of saving the layer discard
              // values from the server
              if (!data || this._saving && !this.isNew()) {
          Severity: Minor
          Found in lib/assets/javascripts/cartodb/models/cartodb_layer.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

          Function toJSON has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            toJSON: function() {
              var c = _.clone(this.attributes);
              // remove api key
              if(c.extra_params) {
                c.extra_params = _.clone(this.attributes.extra_params);
          Severity: Minor
          Found in lib/assets/javascripts/cartodb/models/cartodb_layer.js - About 45 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

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

            isHistoryAtFirstPosition: function(property) {
              if(this.get(property+'_history').length === 0) {
                return true;
              }
              var stored = this[property+'_storage'].get();
          Severity: Minor
          Found in lib/assets/javascripts/cartodb/models/cartodb_layer.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

          There are no issues that match your filters.

          Category
          Status