balderdashy/waterline

View on GitHub

Showing 156 of 357 total issues

Function normalizeSortClause has 208 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function normalizeSortClause(sortClause, modelIdentity, orm, meta) {

  // Look up the Waterline model for this query.
  // > This is so that we can reference the original model definition.
  var WLModel = getModel(modelIdentity, orm);
Severity: Major
Found in lib/waterline/utils/query/private/normalize-sort-clause.js - About 1 day to fix

    Function stream has 194 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    module.exports = function stream( /* criteria?, eachRecordFn?, explicitCbMaybe?, meta?, moreQueryKeys? */ ) {
    
      // Verify `this` refers to an actual Sails/Waterline model.
      verifyModelMethodContext(this);
    
    
    Severity: Major
    Found in lib/waterline/methods/stream.js - About 7 hrs to fix

      Function createEach has 191 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports = function createEach( /* newRecords?, explicitCbMaybe?, meta? */ ) {
      
        // Verify `this` refers to an actual Sails/Waterline model.
        verifyModelMethodContext(this);
      
      
      Severity: Major
      Found in lib/waterline/methods/create-each.js - About 7 hrs to fix

        File waterline.js has 484 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        //  ██╗    ██╗ █████╗ ████████╗███████╗██████╗ ██╗     ██╗███╗   ██╗███████╗
        //  ██║    ██║██╔══██╗╚══██╔══╝██╔════╝██╔══██╗██║     ██║████╗  ██║██╔════╝
        //  ██║ █╗ ██║███████║   ██║   █████╗  ██████╔╝██║     ██║██╔██╗ ██║█████╗
        //  ██║███╗██║██╔══██║   ██║   ██╔══╝  ██╔══██╗██║     ██║██║╚██╗██║██╔══╝
        //  ╚███╔███╔╝██║  ██║   ██║   ███████╗██║  ██║███████╗██║██║ ╚████║███████╗
        Severity: Minor
        Found in lib/waterline.js - About 7 hrs to fix

          Function normalizeCriteria has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
          Open

          module.exports = function normalizeCriteria(criteria, modelIdentity, orm, meta) {
          
            // Sanity checks.
            // > These are just some basic, initial usage assertions to help catch
            // > bugs during development of Waterline core.
          Severity: Minor
          Found in lib/waterline/utils/query/private/normalize-criteria.js - About 7 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 addToCollection has 184 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          module.exports = function addToCollection(/* targetRecordIds, collectionAttrName, associatedIds?, explicitCbMaybe?, meta? */) {
          
            // Verify `this` refers to an actual Sails/Waterline model.
            verifyModelMethodContext(this);
          
          
          Severity: Major
          Found in lib/waterline/methods/add-to-collection.js - About 7 hrs to fix

            Function removeFromCollection has 181 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            module.exports = function removeFromCollection(/* targetRecordIds?, collectionAttrName?, associatedIds?, explicitCbMaybe?, meta? */) {
            
              // Verify `this` refers to an actual Sails/Waterline model.
              verifyModelMethodContext(this);
            
            
            Severity: Major
            Found in lib/waterline/methods/remove-from-collection.js - About 7 hrs to fix

              File normalize-constraint.js has 457 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              /**
               * Module dependencies
               */
              
              var util = require('util');
              Severity: Minor
              Found in lib/waterline/utils/query/private/normalize-constraint.js - About 7 hrs to fix

                Function update has 174 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

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

                  Function normalizeWhereClause has 174 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  module.exports = function normalizeWhereClause(whereClause, modelIdentity, orm, meta) {
                  
                    // Look up the Waterline model for this query.
                    // > This is so that we can reference the original model definition.
                    var WLModel = getModel(modelIdentity, orm);
                  Severity: Major
                  Found in lib/waterline/utils/query/private/normalize-where-clause.js - About 6 hrs to fix

                    Function _afterRunningBeforeLC has 164 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          })(function _afterRunningBeforeLC(err, query) {
                            if (err) {
                              return done(err);
                            }
                    
                    
                    Severity: Major
                    Found in lib/waterline/methods/destroy.js - About 6 hrs to fix

                      File normalize-criteria.js has 423 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      /**
                       * Module dependencies
                       */
                      
                      var util = require('util');
                      Severity: Minor
                      Found in lib/waterline/utils/query/private/normalize-criteria.js - About 6 hrs to fix

                        Function create has 143 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

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

                          Function normalizePkValue has a Cognitive Complexity of 36 (exceeds 5 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: Minor
                          Found in lib/waterline/utils/query/private/normalize-pk-value.js - About 5 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 Waterline has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
                          Open

                          function Waterline() {
                          
                            // Start by setting up an array of model definitions.
                            // (This will hold the raw model definitions that were passed in,
                            // plus any implicitly introduced models-- but that part comes later)
                          Severity: Minor
                          Found in lib/waterline.js - About 5 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

                          File forge-stage-three-query.js has 385 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          /**
                           * Module dependencies
                           */
                          
                          var util = require('util');
                          Severity: Minor
                          Found in lib/waterline/utils/query/forge-stage-three-query.js - About 5 hrs to fix

                            Function _afterPotentiallyRunningBeforeLC has 125 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                  })(function _afterPotentiallyRunningBeforeLC(err, query) {
                                    if (err) {
                                      return done(err);
                                    }
                            
                            
                            Severity: Major
                            Found in lib/waterline/methods/create-each.js - About 5 hrs to fix

                              Function normalizeNewRecord has 124 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              module.exports = function normalizeNewRecord(newRecord, modelIdentity, orm, currentTimestamp, meta) {
                              
                                // Tolerate this being left undefined by inferring a reasonable default.
                                // Note that we can't bail early, because we need to check for more stuff
                                // (there might be required attrs!)
                              Severity: Major
                              Found in lib/waterline/utils/query/private/normalize-new-record.js - About 4 hrs to fix

                                Function forgeAdapterError has 123 lines of code (exceeds 25 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: Major
                                Found in lib/waterline/utils/query/forge-adapter-error.js - About 4 hrs to fix

                                  Function _recursiveStep has 123 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      (function _recursiveStep(branch, recursionDepth, parent, indexInParent){
                                  
                                        var MAX_RECURSION_DEPTH = 25;
                                        if (recursionDepth > MAX_RECURSION_DEPTH) {
                                          throw flaverr('E_WHERE_CLAUSE_UNUSABLE', new Error('This `where` clause seems to have a circular reference. Aborted automatically after reaching maximum recursion depth ('+MAX_RECURSION_DEPTH+').'));
                                  Severity: Major
                                  Found in lib/waterline/utils/query/private/normalize-where-clause.js - About 4 hrs to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language