balderdashy/waterline

View on GitHub

Showing 156 of 357 total issues

Function count has 73 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function count( /* criteria?, explicitCbMaybe?, meta?, moreQueryKeys? */ ) {

  // Verify `this` refers to an actual Sails/Waterline model.
  verifyModelMethodContext(this);

Severity: Major
Found in lib/waterline/methods/count.js - About 2 hrs to fix

    Function getAttribute has 71 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    module.exports = function getAttribute(attrName, modelIdentity, orm) {
    
      // ================================================================================================
      // Check that the provided `attrName` is valid.
      // (`modelIdentity` and `orm` will be automatically checked by calling `getModel()`)
    Severity: Major
    Found in lib/waterline/utils/ontology/get-attribute.js - About 2 hrs to fix

      Function destroyOne has 70 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports = function destroyOne(criteria, explicitCbMaybe, metaContainer){
      
        // Verify `this` refers to an actual Sails/Waterline model.
        verifyModelMethodContext(this);
      
      
      Severity: Major
      Found in lib/waterline/methods/destroy-one.js - About 2 hrs to fix

        Function whenWaterlineIsReady has 70 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          }, function whenWaterlineIsReady (err, orm) {
            if (err) {
              return done(new Error('Could not start up Waterline ORM: '+err.stack));
            }//--•
        
        
        Severity: Major
        Found in example/raw/raw-example.js - About 2 hrs to fix

          Function archiveOne has 70 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          module.exports = function archiveOne(criteria, explicitCbMaybe, metaContainer){
          
            // Verify `this` refers to an actual Sails/Waterline model.
            verifyModelMethodContext(this);
          
          
          Severity: Major
          Found in lib/waterline/methods/archive-one.js - About 2 hrs to fix

            Function _afterTalkingToAdapter has 69 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    adapter.update(WLModel.datastore, query, function _afterTalkingToAdapter(err, rawAdapterResult) {
                      if (err) {
                        err = forgeAdapterError(err, omen, 'update', modelIdentity, orm);
                        return done(err);
                      }//-•
            Severity: Major
            Found in lib/waterline/methods/update.js - About 2 hrs to fix

              Function _afterPotentiallyWipingCollections has 65 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                          })(function _afterPotentiallyWipingCollections(err) {// ~∞%°
                            if (err) {
                              return done(err);
                            }
              
              
              Severity: Major
              Found in lib/waterline/methods/destroy.js - About 2 hrs to fix

                Function normalizePkValue has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                module.exports = function normalizePkValue (pkValue, expectedPkType){
                
                  // Check usage
                  if (expectedPkType !== 'string' && expectedPkType !== 'number') {
                    throw new Error('Consistency violation: The internal normalizePkValue() utility must always be called with a valid second argument ("string" or "number").  But instead, got: '+util.inspect(expectedPkType, {depth:5})+'');
                Severity: Major
                Found in lib/waterline/utils/query/private/normalize-pk-value.js - About 2 hrs to fix

                  Function processAllRecords has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                  Open

                  module.exports = function processAllRecords(records, meta, modelIdentity, orm) {
                    // console.time('processAllRecords');
                  
                  
                    if (!_.isArray(records)) {
                  Severity: Minor
                  Found in lib/waterline/utils/query/process-all-records.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 start has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  module.exports.start = function (options, done){
                  
                    // Verify usage & apply defaults:
                    if (!_.isFunction(done)) {
                      throw new Error('Please provide a valid callback function as the 2nd argument to `Waterline.start()`.  (Instead, got: `'+done+'`)');
                  Severity: Major
                  Found in lib/waterline.js - About 2 hrs to fix

                    Function paginate has 61 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      paginate: function(pageNumOrOpts, pageSize) {
                    
                        if (!this._alreadyInitiallyExpandedCriteria) {
                          this._wlQueryInfo.criteria = expandWhereShorthand(this._wlQueryInfo.criteria);
                          this._alreadyInitiallyExpandedCriteria = true;
                    Severity: Major
                    Found in lib/waterline/utils/query/get-query-modifier-methods.js - About 2 hrs to fix

                      Function _afterTalkingToAdapter has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                              adapter.create(WLModel.datastore, query, function _afterTalkingToAdapter(err, rawAdapterResult) {
                                if (err) {
                                  err = forgeAdapterError(err, omen, 'create', modelIdentity, orm);
                                  return done(err);
                                }//-•
                      Severity: Major
                      Found in lib/waterline/methods/create.js - About 2 hrs to fix

                        File process-all-records.js has 258 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        /**
                         * Module dependencies
                         */
                        
                        var assert = require('assert');
                        Severity: Minor
                        Found in lib/waterline/utils/query/process-all-records.js - About 2 hrs to fix

                          File replace-collection.js has 251 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          /**
                           * Module dependencies
                           */
                          
                          var assert = require('assert');
                          Severity: Minor
                          Found in lib/waterline/methods/replace-collection.js - About 2 hrs to fix

                            Function serializeCriteria has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            Transformation.prototype.serializeCriteria = function(values) {
                              var self = this;
                            
                              function recursiveParse(obj) {
                            
                            
                            Severity: Minor
                            Found in lib/waterline/utils/system/transformer-builder.js - About 2 hrs to fix

                              Function isCapableOfOptimizedPopulate has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                              Open

                              module.exports = function isCapableOfOptimizedPopulate(attrName, modelIdentity, orm) {
                              
                                if (!_.isString(attrName)) {
                                  throw new Error('Consistency violation: Must specify `attrName` as a string.  But instead, got: '+util.inspect(attrName, {depth:5})+'');
                                }
                              Severity: Minor
                              Found in lib/waterline/utils/ontology/is-capable-of-optimized-populate.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 recursiveParse has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                function recursiveParse(obj) {
                              
                                  // Return if no object
                                  if (!obj) {
                                    return;
                              Severity: Minor
                              Found in lib/waterline/utils/system/transformer-builder.js - About 1 hr to fix

                                Function isCapableOfOptimizedPopulate has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                module.exports = function isCapableOfOptimizedPopulate(attrName, modelIdentity, orm) {
                                
                                  if (!_.isString(attrName)) {
                                    throw new Error('Consistency violation: Must specify `attrName` as a string.  But instead, got: '+util.inspect(attrName, {depth:5})+'');
                                  }
                                Severity: Minor
                                Found in lib/waterline/utils/ontology/is-capable-of-optimized-populate.js - About 1 hr to fix

                                  Function paginate has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                    paginate: function(pageNumOrOpts, pageSize) {
                                  
                                      if (!this._alreadyInitiallyExpandedCriteria) {
                                        this._wlQueryInfo.criteria = expandWhereShorthand(this._wlQueryInfo.criteria);
                                        this._alreadyInitiallyExpandedCriteria = true;
                                  Severity: Minor
                                  Found in lib/waterline/utils/query/get-query-modifier-methods.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 getModel has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  module.exports = function getModel(modelIdentity, orm) {
                                  
                                    // ================================================================================================
                                    // Check that this utility function is being used properly, and that the provided `modelIdentity` and `orm` are valid.
                                    if (!_.isString(modelIdentity) || modelIdentity === '') {
                                  Severity: Minor
                                  Found in lib/waterline/utils/ontology/get-model.js - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language