CartoDB/cartodb20

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

Summary

Maintainability
F
2 wks
Test Coverage

File tabledata.js has 631 lines of code (exceeds 250 allowed). Consider refactoring.
Open

cdb.admin.CartoDBTableData = cdb.ui.common.TableData.extend({
  _ADDED_ROW_TEXT: 'Row added correctly',
  _ADDING_ROW_TEXT: 'Adding a new row',
  _GEOMETRY_UPDATED: 'Table geometry updated',

Severity: Major
Found in lib/assets/javascripts/cartodb/models/tabledata.js - About 1 day to fix

    CartoDBTableData has 42 functions (exceeds 20 allowed). Consider refactoring.
    Open

    cdb.admin.CartoDBTableData = cdb.ui.common.TableData.extend({
      _ADDED_ROW_TEXT: 'Row added correctly',
      _ADDING_ROW_TEXT: 'Adding a new row',
      _GEOMETRY_UPDATED: 'Table geometry updated',
    
    
    Severity: Minor
    Found in lib/assets/javascripts/cartodb/models/tabledata.js - About 5 hrs to fix

      Function date_histogram has 66 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        date_histogram: function(nbuckets, column, callback, error) {
      
          column = "EXTRACT(EPOCH FROM " + column + "::TIMESTAMP WITH TIME ZONE )";
      
          var tmpl = _.template(
      Severity: Major
      Found in lib/assets/javascripts/cartodb/models/tabledata.js - About 2 hrs to fix

        Function histogram has 63 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          histogram: function(nbuckets, column, callback, error) {
        
            var tmpl = _.template(
            'with bounds as ( ' +
             'SELECT  ' +
        Severity: Major
        Found in lib/assets/javascripts/cartodb/models/tabledata.js - About 2 hrs to fix

          Function initOptions has 49 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            initOptions: function() {
              var self = this;
              this.options = new cdb.core.Model({
                rows_per_page:40,
                page: 0,
          Severity: Minor
          Found in lib/assets/javascripts/cartodb/models/tabledata.js - About 1 hr to fix

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

              initialize: function(models, options) {
                var self = this;
                this.table = options ? options.table: null;
                this.model.prototype.idAttribute = 'cartodb_id';
                this.initOptions();
            Severity: Minor
            Found in lib/assets/javascripts/cartodb/models/tabledata.js - About 1 hr to fix

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

                wrappedSQL: function(schema, exclude, fetchGeometry) {
                  var self = this;
                  exclude = exclude || ['the_geom_webmercator'];
                  schema = _.clone(schema);
              
              
              Severity: Minor
              Found in lib/assets/javascripts/cartodb/models/tabledata.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 _quantificationMethod has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                _quantificationMethod: function(functionName, nslots, column, distinct, callback, error) {
              Severity: Minor
              Found in lib/assets/javascripts/cartodb/models/tabledata.js - About 45 mins to fix

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

                  _createUrlOptions: function(filter) {
                    var attr;
                    if (filter) {
                      var a = {}
                      for (var k in this.options.attributes) {
                Severity: Minor
                Found in lib/assets/javascripts/cartodb/models/tabledata.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

                Function sync has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  sync: function(method, model, options) {
                    if(!options) { options = {}; }
                    options.data = this._createUrlOptions(function(d) {
                      return d !== 'sql';
                    });
                Severity: Minor
                Found in lib/assets/javascripts/cartodb/models/tabledata.js - About 25 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

                  newPage: function(currentPage, direction) {
                    if(this.pages.indexOf(currentPage) < 0) {
                      this.pages.push(currentPage);
                    };
                     this.pages.sort(function(a, b) {
                Severity: Major
                Found in lib/assets/javascripts/cartodb/models/tabledata.js and 1 other location - About 1 day to fix
                lib/assets/javascripts/dashboard/views/organization/delete-organization-user-view.js on lines 29..38

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

                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

                  getGeometryTypes: function() {
                    var row = null;
                    var i = this.size();
                    while (i-- && !(row && row.get('the_geom'))) {
                      row = this.at(i);
                Severity: Major
                Found in lib/assets/javascripts/cartodb/models/tabledata.js and 1 other location - About 7 hrs to fix
                lib/assets/javascripts/dashboard/data/table/carto-table-data.js on lines 798..811

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

                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._sqlQuery(tmpl({
                      slots: nslots,
                      sql: this.getSQL(),
                      column: column
                    }),
                Severity: Major
                Found in lib/assets/javascripts/cartodb/models/tabledata.js and 1 other location - About 7 hrs to fix
                lib/assets/javascripts/dashboard/data/table/carto-table-data.js on lines 385..405

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

                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

                  geometryTypeFromWKB: function(wkb) {
                    if(!wkb) return null;
                
                    var typeMap = {
                      '0001': 'Point',
                Severity: Major
                Found in lib/assets/javascripts/cartodb/models/tabledata.js and 1 other location - About 5 hrs to fix
                lib/assets/javascripts/dashboard/data/table/carto-table-data.js on lines 772..791

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

                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

                  parse: function(d) {
                    // when the query modifies the data modified flag is true
                    // TODO: change this when SQL API was able to say if a
                    // query modify some data
                    // HACK, it will fail if using returning sql statement
                Severity: Major
                Found in lib/assets/javascripts/cartodb/models/tabledata.js and 1 other location - About 4 hrs to fix
                lib/assets/javascripts/dashboard/data/table/carto-table-data.js on lines 120..132

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

                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(this.options.hasChanged('page')) {
                        opt.add = true;
                        opt.changingPage = true;
                        // if user is going backwards insert new rows at the top
                        if(previous > this.options.get('page')) {
                Severity: Major
                Found in lib/assets/javascripts/cartodb/models/tabledata.js and 1 other location - About 4 hrs to fix
                lib/assets/javascripts/dashboard/data/table/carto-table-data.js on lines 79..92

                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

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

                  _quantificationMethod: function(functionName, nslots, column, distinct, callback, error) {
                    var tmpl = _.template('select unnest(<%= functionName %>(array_agg(<%= simplify_fn %>((<%= column %>::numeric))), <%= slots %>)) as buckets from (<%= sql %>) _table_sql where <%= column %> is not null');
                    this._sqlQuery(tmpl({
                      slots: nslots,
                      sql: this.getSQL(),
                Severity: Major
                Found in lib/assets/javascripts/cartodb/models/tabledata.js and 1 other location - About 3 hrs to fix
                lib/assets/javascripts/dashboard/data/table/carto-table-data.js on lines 408..421

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

                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

                    this.bind('reset', function() {
                      var pages = Math.floor(this.size()/this.options.get('rows_per_page'))
                      this.pages = [];
                
                      for(var i = 0; i < pages; ++i) {
                Severity: Major
                Found in lib/assets/javascripts/cartodb/models/tabledata.js and 1 other location - About 3 hrs to fix
                lib/assets/javascripts/dashboard/data/table/carto-table-data.js on lines 39..46

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

                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(this.table) {
                      this.bind('add change:the_geom', function(row) {
                        var gt = this.table.get('geometry_types')
                        if(gt && gt.length > 0) return;
                        if(row.get('the_geom')) {
                Severity: Major
                Found in lib/assets/javascripts/cartodb/models/tabledata.js and 1 other location - About 3 hrs to fix
                lib/assets/javascripts/dashboard/data/table/carto-table-data.js on lines 48..58

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

                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 (filter) {
                      var a = {}
                      for (var k in this.options.attributes) {
                        if (filter(k)) {
                          a[k] = this.options.attributes[k];
                Severity: Major
                Found in lib/assets/javascripts/cartodb/models/tabledata.js and 1 other location - About 3 hrs to fix
                lib/assets/javascripts/dashboard/data/table/carto-table-data.js on lines 145..155

                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

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

                  quartiles: function(nslots, column, callback, error) {
                    var tmpl = _.template('select quartile, max(<%= column %>) as maxamount from (select <%= column %>, ntile(<%= slots %>) over (order by <%= column %>) as quartile from (<%= sql %>) _table_sql where <%= column %> is not null) x group by quartile order by quartile');
                    this._sqlQuery(tmpl({
                      slots: nslots,
                      sql: this.getSQL(),
                Severity: Major
                Found in lib/assets/javascripts/cartodb/models/tabledata.js and 1 other location - About 3 hrs to fix
                lib/assets/javascripts/dashboard/data/table/carto-table-data.js on lines 367..378

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

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

                    var tmpl = _.template(
                    'with bounds as ( ' +
                     'SELECT  ' +
                      'min(<%= column %>) as lower,  ' +
                      'max(<%= column %>) as upper,  ' +
                Severity: Major
                Found in lib/assets/javascripts/cartodb/models/tabledata.js and 3 other locations - About 2 hrs to fix
                lib/assets/javascripts/cartodb/models/tabledata.js on lines 445..465
                lib/assets/javascripts/dashboard/data/table/carto-table-data.js on lines 448..468
                lib/assets/javascripts/dashboard/data/table/carto-table-data.js on lines 530..550

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

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

                    var tmpl = _.template(
                    'with bounds as ( ' +
                     'SELECT  ' +
                      'current_timestamp as tz, ' +
                      'min(<%= column %>) as lower,  ' +
                Severity: Major
                Found in lib/assets/javascripts/cartodb/models/tabledata.js and 3 other locations - About 2 hrs to fix
                lib/assets/javascripts/cartodb/models/tabledata.js on lines 531..551
                lib/assets/javascripts/dashboard/data/table/carto-table-data.js on lines 448..468
                lib/assets/javascripts/dashboard/data/table/carto-table-data.js on lines 530..550

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

                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

                    r.bind('saved', function _saved() {
                      if(r.table.data().length == 0) {
                        r.table.data().fetch();
                        r.unbind('saved', _saved, r.table);
                      }
                Severity: Major
                Found in lib/assets/javascripts/cartodb/models/tabledata.js and 1 other location - About 2 hrs to fix
                lib/assets/javascripts/dashboard/data/table/carto-table-data.js on lines 329..334

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

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

                      for (var r = 0; r < data.buckets.length; ++r) {
                        var b = data.buckets[r];
                        var v = hist[b] = data.val[r];
                        max = Math.max(max, v);
                      }
                Severity: Major
                Found in lib/assets/javascripts/cartodb/models/tabledata.js and 3 other locations - About 2 hrs to fix
                lib/assets/javascripts/cartodb/models/tabledata.js on lines 589..593
                lib/assets/javascripts/dashboard/data/table/carto-table-data.js on lines 503..507
                lib/assets/javascripts/dashboard/data/table/carto-table-data.js on lines 586..590

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

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

                      for(var r = 0; r < data.buckets.length; ++r) {
                        var b = data.buckets[r];
                        var v = hist[b] = data.val[r];
                        max = Math.max(max, v);
                      }
                Severity: Major
                Found in lib/assets/javascripts/cartodb/models/tabledata.js and 3 other locations - About 2 hrs to fix
                lib/assets/javascripts/cartodb/models/tabledata.js on lines 502..506
                lib/assets/javascripts/dashboard/data/table/carto-table-data.js on lines 503..507
                lib/assets/javascripts/dashboard/data/table/carto-table-data.js on lines 586..590

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

                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 (cdb.admin.CartoDBTableMetadata.alterTableData(this.options.get('sql') || '')) {
                      options.data += "&q=" + encodeURIComponent(this.options.get('sql'));
                      options.type = 'POST';
                    } else {
                      // when a geometry can be lazy fetched, don't fetch it
                Severity: Major
                Found in lib/assets/javascripts/cartodb/models/tabledata.js and 1 other location - About 2 hrs to fix
                lib/assets/javascripts/dashboard/data/table/carto-table-data.js on lines 225..236

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

                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

                  loadPageAtBottom: function() {
                    if(!this._fetching) {
                      var last = this.pages[this.pages.length - 1];
                
                      if(!this.lastPage) {
                Severity: Major
                Found in lib/assets/javascripts/cartodb/models/tabledata.js and 1 other location - About 2 hrs to fix
                lib/assets/javascripts/dashboard/data/table/carto-table-data.js on lines 268..276

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

                      for (var i = 0; i < hist.length; ++i) {
                        if (hist[i] === undefined) {
                          hist[i] = 0;
                        } else {
                          hist[i] = hist[i]/max;
                Severity: Major
                Found in lib/assets/javascripts/cartodb/models/tabledata.js and 3 other locations - About 2 hrs to fix
                lib/assets/javascripts/cartodb/models/tabledata.js on lines 509..515
                lib/assets/javascripts/dashboard/data/table/carto-table-data.js on lines 510..516
                lib/assets/javascripts/dashboard/data/table/carto-table-data.js on lines 593..599

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

                      for (var i = 0; i < hist.length; ++i) {
                        if (hist[i] === undefined) {
                          hist[i] = 0;
                        } else {
                          hist[i] = hist[i]/max;
                Severity: Major
                Found in lib/assets/javascripts/cartodb/models/tabledata.js and 3 other locations - About 2 hrs to fix
                lib/assets/javascripts/cartodb/models/tabledata.js on lines 597..603
                lib/assets/javascripts/dashboard/data/table/carto-table-data.js on lines 510..516
                lib/assets/javascripts/dashboard/data/table/carto-table-data.js on lines 593..599

                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

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

                  loadPageAtTop: function() {
                
                    if(!this._fetching) {
                      var first = this.pages[0];
                
                
                Severity: Major
                Found in lib/assets/javascripts/cartodb/models/tabledata.js and 1 other location - About 1 hr to fix
                lib/assets/javascripts/dashboard/data/table/carto-table-data.js on lines 258..266

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

                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(!opts || !opts.add) {
                      this.options.attributes.page = 0;
                      this.options._previousAttributes.page = 0;
                      this.pages = [];
                    }
                Severity: Major
                Found in lib/assets/javascripts/cartodb/models/tabledata.js and 1 other location - About 1 hr to fix
                lib/assets/javascripts/dashboard/data/table/carto-table-data.js on lines 694..698

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

                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

                  _geometryColumnSQL: function(c) {
                      return [
                        "CASE",
                        "WHEN GeometryType(" + c + ") = 'POINT' THEN",
                          "ST_AsGeoJSON(" + c + ",8)",
                Severity: Major
                Found in lib/assets/javascripts/cartodb/models/tabledata.js and 1 other location - About 1 hr to fix
                lib/assets/javascripts/dashboard/data/table/carto-table-data.js on lines 163..174

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

                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

                    for(var i = 0; i < types.length; ++i) {
                      var t = types[i];
                      if (wkt.indexOf(t) !== -1) {
                        return t;
                      }
                Severity: Major
                Found in lib/assets/javascripts/cartodb/models/tabledata.js and 1 other location - About 1 hr to fix
                lib/assets/javascripts/dashboard/data/table/carto-table-data.js on lines 764..769

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

                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

                  geometryTypeFromGeoJSON: function(geojson) {
                    try {
                      var geo = JSON.parse(geojson);
                      return geo.type
                    } catch(e) {
                Severity: Minor
                Found in lib/assets/javascripts/cartodb/models/tabledata.js and 1 other location - About 35 mins to fix
                lib/assets/javascripts/dashboard/data/table/carto-table-data.js on lines 752..758

                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

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

                    var params = attr.map(function(v, k) {
                      return k + "=" + encodeURIComponent(v);
                    }).join('&');
                Severity: Minor
                Found in lib/assets/javascripts/cartodb/models/tabledata.js and 1 other location - About 30 mins to fix
                lib/assets/javascripts/dashboard/data/table/carto-table-data.js on lines 156..158

                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