balderdashy/waterline

View on GitHub

Showing 156 of 357 total issues

Function forgeStageTwoQuery has a Cognitive Complexity of 231 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = function forgeStageTwoQuery(query, orm) {
  // if (process.env.NODE_ENV !== 'production') {
  //   console.time('forgeStageTwoQuery');
  // }

Severity: Minor
Found in lib/waterline/utils/query/forge-stage-two-query.js - About 4 days 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 normalizeConstraint has a Cognitive Complexity of 188 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = function normalizeConstraint (constraintRhs, constraintTarget, modelIdentity, orm, meta){
  if (_.isUndefined(constraintRhs)) {
    throw new Error('Consistency violation: The internal normalizeConstraint() utility must always be called with a first argument (the RHS of the constraint to normalize).  But instead, got: '+util.inspect(constraintRhs, {depth:5})+'');
  }
  if (!_.isString(constraintTarget)) {
Severity: Minor
Found in lib/waterline/utils/query/private/normalize-constraint.js - About 3 days 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 forgeStageTwoQuery has 708 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function forgeStageTwoQuery(query, orm) {
  // if (process.env.NODE_ENV !== 'production') {
  //   console.time('forgeStageTwoQuery');
  // }

Severity: Major
Found in lib/waterline/utils/query/forge-stage-two-query.js - About 3 days to fix

    Function normalizeValueToSet has a Cognitive Complexity of 130 (exceeds 5 allowed). Consider refactoring.
    Open

    module.exports = function normalizeValueToSet(value, supposedAttrName, modelIdentity, orm, meta) {
    
      // ================================================================================================
      assert(_.isString(supposedAttrName), '`supposedAttrName` must be a string.');
      // (`modelIdentity` and `orm` will be automatically checked by calling `getModel()` below)
    Severity: Minor
    Found in lib/waterline/utils/query/private/normalize-value-to-set.js - About 2 days 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 normalizeConstraint has 425 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    module.exports = function normalizeConstraint (constraintRhs, constraintTarget, modelIdentity, orm, meta){
      if (_.isUndefined(constraintRhs)) {
        throw new Error('Consistency violation: The internal normalizeConstraint() utility must always be called with a first argument (the RHS of the constraint to normalize).  But instead, got: '+util.inspect(constraintRhs, {depth:5})+'');
      }
      if (!_.isString(constraintTarget)) {
    Severity: Major
    Found in lib/waterline/utils/query/private/normalize-constraint.js - About 2 days to fix

      Function normalizeCriteria has 411 lines of code (exceeds 25 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: Major
      Found in lib/waterline/utils/query/private/normalize-criteria.js - About 2 days to fix

        Function Waterline has 385 lines of code (exceeds 25 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: Major
        Found in lib/waterline.js - About 1 day to fix

          Function forgeStageThreeQuery has 380 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          module.exports = function forgeStageThreeQuery(options) {
            //  ╦  ╦╔═╗╦  ╦╔╦╗╔═╗╔╦╗╔═╗  ┌─┐┌─┐┌┬┐┬┌─┐┌┐┌┌─┐
            //  ╚╗╔╝╠═╣║  ║ ║║╠═╣ ║ ║╣   │ │├─┘ │ ││ ││││└─┐
            //   ╚╝ ╩ ╩╩═╝╩═╩╝╩ ╩ ╩ ╚═╝  └─┘┴   ┴ ┴└─┘┘└┘└─┘
            if (!_.has(options, 'stageTwoQuery') || !_.isPlainObject(options.stageTwoQuery)) {
          Severity: Major
          Found in lib/waterline/utils/query/forge-stage-three-query.js - About 1 day to fix

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

              orm.initialize = function initialize(options, done) {
            
                try {
            
            
            
            Severity: Major
            Found in lib/waterline.js - About 1 day to fix

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

              /**
               * Module dependencies
               */
              
              var assert = require('assert');
              Severity: Major
              Found in lib/waterline/utils/query/forge-stage-two-query.js - About 1 day to fix

                Function helpFind has 332 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                module.exports = function helpFind(WLModel, s2q, omen, done) {
                
                  if (!_.isFunction(done)) {
                    throw new Error('Consistency violation: `done` (4th argument) should be a function');
                  }
                Severity: Major
                Found in lib/waterline/utils/query/help-find.js - About 1 day to fix

                  Function normalizeValueToSet has 301 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  module.exports = function normalizeValueToSet(value, supposedAttrName, modelIdentity, orm, meta) {
                  
                    // ================================================================================================
                    assert(_.isString(supposedAttrName), '`supposedAttrName` must be a string.');
                    // (`modelIdentity` and `orm` will be automatically checked by calling `getModel()` below)
                  Severity: Major
                  Found in lib/waterline/utils/query/private/normalize-value-to-set.js - About 1 day to fix

                    Function forgeStageThreeQuery has a Cognitive Complexity of 71 (exceeds 5 allowed). Consider refactoring.
                    Open

                    module.exports = function forgeStageThreeQuery(options) {
                      //  ╦  ╦╔═╗╦  ╦╔╦╗╔═╗╔╦╗╔═╗  ┌─┐┌─┐┌┬┐┬┌─┐┌┐┌┌─┐
                      //  ╚╗╔╝╠═╣║  ║ ║║╠═╣ ║ ║╣   │ │├─┘ │ ││ ││││└─┐
                      //   ╚╝ ╩ ╩╩═╝╩═╩╝╩ ╩ ╩ ╚═╝  └─┘┴   ┴ ┴└─┘┘└┘└─┘
                      if (!_.has(options, 'stageTwoQuery') || !_.isPlainObject(options.stageTwoQuery)) {
                    Severity: Minor
                    Found in lib/waterline/utils/query/forge-stage-three-query.js - About 1 day 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 replaceCollection has 241 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

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

                      Function destroy has 233 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

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

                        Function processAllRecords has 227 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        module.exports = function processAllRecords(records, meta, modelIdentity, orm) {
                          // console.time('processAllRecords');
                        
                        
                          if (!_.isArray(records)) {
                        Severity: Major
                        Found in lib/waterline/utils/query/process-all-records.js - About 1 day to fix

                          Function _getPopulatedRecords has 220 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            (function _getPopulatedRecords(proceed){
                          
                              //  ┌┬┐┌─┐  ┬ ┬┌─┐  ┌┐┌┌─┐┌─┐┌┬┐  ┌─┐┬ ┬┬┌┬┐┌─┐
                              //   │││ │  │││├┤   │││├┤ ├┤  ││  └─┐├─┤││││ ┌┘
                              //  ─┴┘└─┘  └┴┘└─┘  ┘└┘└─┘└─┘─┴┘  └─┘┴ ┴┴┴ ┴ o
                          Severity: Major
                          Found in lib/waterline/utils/query/help-find.js - About 1 day to fix

                            Function _eachParentOrChildRecord has 215 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              eachRecordDeep(records, function _eachParentOrChildRecord(record, WLModel){
                            
                                // First, check the results to verify compliance with the adapter spec.,
                                // as well as any issues related to stale data that might not have been
                                // been migrated to keep up with the logical schema (`type`, etc. in
                            Severity: Major
                            Found in lib/waterline/utils/query/process-all-records.js - About 1 day to fix

                              Function getAttribute has a Cognitive Complexity of 55 (exceeds 5 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: Minor
                              Found in lib/waterline/utils/ontology/get-attribute.js - About 1 day 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 normalizeWhereClause has a Cognitive Complexity of 54 (exceeds 5 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: Minor
                              Found in lib/waterline/utils/query/private/normalize-where-clause.js - About 1 day 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

                              Severity
                              Category
                              Status
                              Source
                              Language