balderdashy/waterline

View on GitHub

Showing 156 of 357 total issues

Function getModel has a Cognitive Complexity of 13 (exceeds 5 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

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 _afterPotentiallyRunningBeforeLC has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      })(function _afterPotentiallyRunningBeforeLC(err, query) {
        if (err) {
          return done(err);
        }

Severity: Minor
Found in lib/waterline/methods/find-one.js - About 1 hr to fix

    Function _maybeWipeAssociatedCollections has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

                (function _maybeWipeAssociatedCollections(proceed) {
    
                  // If `cascade` meta key is NOT enabled, then just proceed.
                  if (!query.meta || !query.meta.cascade) {
                    return proceed();
    Severity: Minor
    Found in lib/waterline/methods/destroy.js - About 1 hr to fix

      Function _maybeTransformRecords has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                    (function _maybeTransformRecords(proceed){
      
                      // If `fetch` was not enabled, return.
                      if (!_.has(query.meta, 'fetch') || query.meta.fetch === false) {
      
      
      Severity: Minor
      Found in lib/waterline/methods/destroy.js - About 1 hr to fix

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

        module.exports = function forgeAdapterError(err, omen, adapterMethodName, modelIdentity, orm){
        
          try {
            // Sanity checks
            assert(err, 'Should never call `forgeAdapterError` with a falsy first argument!');
        Severity: Minor
        Found in lib/waterline/utils/query/forge-adapter-error.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 _afterFetchingRecords has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                helpFind(WLModel, query, omen, function _afterFetchingRecords(err, populatedRecords) {
                  if (err) {
                    return done(err);
                  }//-•
                  // console.log('result from operation runner:', record);
        Severity: Minor
        Found in lib/waterline/methods/find-one.js - About 1 hr to fix

          Function normalizePkValueOrValues has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

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

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

              populate: function(keyName, subcriteria) {
            
                assert(this._wlQueryInfo.method === 'find' || this._wlQueryInfo.method === 'findOne' || this._wlQueryInfo.method === 'stream', 'Cannot chain `.populate()` onto the `.'+this._wlQueryInfo.method+'()` method.  (In fact, this shouldn\'t even be possible!  So the fact that you are seeing this message at all is, itself, likely due to a bug in Waterline.)');
            
                // Backwards compatibility for arrays passed in as `keyName`.
            Severity: Minor
            Found in lib/waterline/utils/query/get-query-modifier-methods.js - About 1 hr to fix

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

                          async.eachSeries(batchOfRecords, function _eachRecordInBatch(record, next) {
                            // Note that, if you try to call next() more than once in the iteratee, Waterline
                            // logs a warning explaining what's up, ignoring all subsequent calls to next()
                            // that occur after the first.
                            var didIterateeAlreadyHalt;
              Severity: Minor
              Found in lib/waterline/methods/stream.js - About 1 hr to fix

                Function validate has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                module.exports = function validate(attrName, value) {
                
                  // Verify `this` refers to an actual Sails/Waterline model.
                  verifyModelMethodContext(this);
                
                
                Severity: Minor
                Found in lib/waterline/methods/validate.js - About 1 hr to fix

                  Function sum has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                  module.exports = function sum( /* numericAttrName?, criteria?, explicitCbMaybe?, meta?, moreQueryKeys? */ ) {
                  
                    // Verify `this` refers to an actual Sails/Waterline model.
                    verifyModelMethodContext(this);
                  
                  
                  Severity: Minor
                  Found in lib/waterline/methods/sum.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 avg has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                  module.exports = function avg( /* numericAttrName?, criteria?, explicitCbMaybe?, meta?, moreQueryKeys? */ ) {
                  
                    // Verify `this` refers to an actual Sails/Waterline model.
                    verifyModelMethodContext(this);
                  
                  
                  Severity: Minor
                  Found in lib/waterline/methods/avg.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 start has a Cognitive Complexity of 10 (exceeds 5 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: Minor
                  Found in lib/waterline.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 _afterFinding has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                        WLModel.find(s2qCriteriaForFind, function _afterFinding(err, foundRecords) {
                          if (err) { return done(err); }
                  
                          // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                          // FUTURE: as an optimization, fetch records batch-at-a-time
                  Severity: Minor
                  Found in lib/waterline/methods/archive.js - About 1 hr to fix

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

                            (function _maybeFindIdsToDestroy(proceed) {
                    
                              // If `cascade` meta key is NOT enabled, then just proceed.
                              if (!query.meta || !query.meta.cascade) {
                                return proceed();
                    Severity: Minor
                    Found in lib/waterline/methods/destroy.js - About 1 hr to fix

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

                      module.exports = function hasSchemaCheck(context) {
                        // If hasSchema is defined on the collection, return the value
                        if (_.has(Object.getPrototypeOf(context), 'hasSchema')) {
                          var proto = Object.getPrototypeOf(context);
                          if (!_.isUndefined(proto.hasSchema)) {
                      Severity: Minor
                      Found in lib/waterline/utils/system/has-schema-check.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 CollectionBuilder has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                      module.exports = function CollectionBuilder(collection, datastores, context) {
                        //  ╦  ╦╔═╗╦  ╦╔╦╗╔═╗╔╦╗╔═╗
                        //  ╚╗╔╝╠═╣║  ║ ║║╠═╣ ║ ║╣
                        //   ╚╝ ╩ ╩╩═╝╩═╩╝╩ ╩ ╩ ╚═╝
                      
                      
                      Severity: Minor
                      Found in lib/waterline/utils/system/collection-builder.js - About 55 mins to fix

                      Cognitive Complexity

                      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                      A method's cognitive complexity is based on a few simple rules:

                      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                      • Code is considered more complex for each "break in the linear flow of the code"
                      • Code is considered more complex when "flow breaking structures are nested"

                      Further reading

                      Avoid deeply nested control flow statements.
                      Open

                            if (modifier.length === 0) {
                              throw flaverr('E_CONSTRAINT_WOULD_MATCH_EVERYTHING', new Error(
                                'Since this `nin` ("not in") modifier is an empty array, it would match ANYTHING.'
                              ));
                            }//-•
                      Severity: Major
                      Found in lib/waterline/utils/query/private/normalize-constraint.js - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                else if (attrDef.autoCreatedAt || attrDef.autoUpdatedAt) {
                        
                                  assert(!attrDef.allowNull, 'Timestamp attributes should never be defined with `allowNull:true`.  (This should have already been caught in wl-schema during ORM initialization!  Please report this at http://sailsjs.com/bugs)');
                        
                                  // If there is no value defined on the record for this attribute...
                        Severity: Major
                        Found in lib/waterline/utils/query/process-all-records.js - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                              if (correspondingAttrDef.allowNull && _.isNull(value)) {
                                // Nothing else to validate here.
                              }
                              //‡
                              // Otherwise, verify that this value matches the expected type, and potentially
                          Severity: Major
                          Found in lib/waterline/utils/query/private/normalize-value-to-set.js - About 45 mins to fix
                            Severity
                            Category
                            Status
                            Source
                            Language