Yoobic/loopback-connector-rethinkdbdash

View on GitHub

Showing 24 of 24 total issues

File rethink.js has 544 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* jshint undef: true, unused: true, latedef: nofunc*/
/*eslint no-use-before-define:0, no-extra-parens:0, consistent-this:0*/
'use strict';

var r;
Severity: Major
Found in lib/rethink.js - About 1 day to fix

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

        inq: function(key, value) {
            var query = [];
    
            value.forEach(function(v) {
                query.push(r.row(key).eq(v));
    Severity: Major
    Found in lib/rethink.js and 1 other location - About 3 hrs to fix
    lib/rethink.js on lines 591..603

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

    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

        nin: function(key, value) {
            var query = [];
    
            value.forEach(function(v) {
                query.push(r.row(key).ne(v));
    Severity: Major
    Found in lib/rethink.js and 1 other location - About 3 hrs to fix
    lib/rethink.js on lines 578..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 101.

    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

    Function autoupdate has 58 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    RethinkDB.prototype.autoupdate = function(models, done) {
        debug('autoupdate');
        var _this = this;
    
        if((!done) && ('function' === typeof models)) {
    Severity: Major
    Found in lib/rethink.js - About 2 hrs to fix

      Function autoupdate has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      RethinkDB.prototype.autoupdate = function(models, done) {
          debug('autoupdate');
          var _this = this;
      
          if((!done) && ('function' === typeof models)) {
      Severity: Minor
      Found in lib/rethink.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 initializeDataSource has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      exports.initialize = function initializeDataSource(dataSource, callback) {
          debug('initialize');
      
          var s = dataSource.settings;
      
      
      Severity: Minor
      Found in lib/rethink.js - About 1 hr to fix

        Function createAllPromise has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        var createAllPromise = function(model, filter) {
            var _this = this;
        
            if(!filter) {
                filter = {};
        Severity: Minor
        Found in lib/rethink.js - About 1 hr to fix

          Function isActual has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          RethinkDB.prototype.isActual = function(cb) {
              debug('isActual');
              var _this = this;
          
              r.db(_this.database).tableList().run()
          Severity: Minor
          Found in lib/rethink.js - About 1 hr to fix

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

                        } else {
                            if(hasIndex) {
                                promise = promise.orderBy({
                                    index: r.asc(key)
                                });
            Severity: Major
            Found in lib/rethink.js and 1 other location - About 1 hr to fix
            lib/rethink.js on lines 363..371

            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

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

                        if(m && m[1] === 'DE') {
                            if(hasIndex) {
                                promise = promise.orderBy({
                                    index: r.desc(key)
                                });
            Severity: Major
            Found in lib/rethink.js and 1 other location - About 1 hr to fix
            lib/rethink.js on lines 371..379

            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

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

            RethinkDB.prototype.save = function(model, data, callback, strict, returnObject) {
                debug('save');
                var _this = this;
            
                if(strict === undefined) {
            Severity: Minor
            Found in lib/rethink.js - About 1 hr to fix

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

              function buildFilter(where) {
                  var filter = [];
              
                  Object.keys(where).forEach(function(k) {
              
              
              Severity: Minor
              Found in lib/rethink.js - About 1 hr to fix

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

                    function createIndices(model) {
                        var properties = _this._models[model].properties;
                        var settings = _this._models[model].settings;
                        var indexCollection = _.extend({}, properties, settings);
                
                
                Severity: Minor
                Found in lib/rethink.js - About 1 hr to fix

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

                              var promises = Object.keys(_this._models).map(function(model) {
                                  if(!actual) {
                                      cb(null, false);
                                      return;
                                  }
                  Severity: Minor
                  Found in lib/rethink.js - About 1 hr to fix

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

                    var createAllPromise = function(model, filter) {
                        var _this = this;
                    
                        if(!filter) {
                            filter = {};
                    Severity: Minor
                    Found in lib/rethink.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 initializeDataSource has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                    exports.initialize = function initializeDataSource(dataSource, callback) {
                        debug('initialize');
                    
                        var s = dataSource.settings;
                    
                    
                    Severity: Minor
                    Found in lib/rethink.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

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

                        Object.keys(data).forEach(function(key) {
                            if(data[key] === undefined) {
                                data[key] = null;
                            }
                        });
                    Severity: Minor
                    Found in lib/rethink.js and 1 other location - About 50 mins to fix
                    lib/rethink.js on lines 261..265

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

                    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

                        Object.keys(data).forEach(function(key) {
                            if(data[key] === undefined) {
                                data[key] = null;
                            }
                        });
                    Severity: Minor
                    Found in lib/rethink.js and 1 other location - About 50 mins to fix
                    lib/rethink.js on lines 491..495

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

                    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

                        r.db(_this.database).table(model).get(id).run()
                            .catch(callback)
                            .then(function(data) {
                                return !!(data);
                            })
                    Severity: Major
                    Found in lib/rethink.js and 2 other locations - About 40 mins to fix
                    lib/rethink.js on lines 318..332
                    lib/rethink.js on lines 496..500

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

                    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

                        r.db(_this.database).table(model).update(data).run()
                            .catch(cb)
                            .then(function() {
                                return data;
                            })
                    Severity: Major
                    Found in lib/rethink.js and 2 other locations - About 40 mins to fix
                    lib/rethink.js on lines 305..309
                    lib/rethink.js on lines 318..332

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

                    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

                    Severity
                    Category
                    Status
                    Source
                    Language