balderdashy/waterline

View on GitHub

Showing 156 of 357 total issues

Avoid deeply nested control flow statements.
Open

    if (correspondingAttrDef.autoCreatedAt || correspondingAttrDef.autoUpdatedAt) {

      // Ensure we are not trying to set it to empty string
      // (this would never make sense.)
      if (value === '') {
Severity: Major
Found in lib/waterline/utils/query/private/normalize-value-to-set.js - About 45 mins to fix

    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

                  if (!_.isUndefined(singleJoin.criteria.limit)) {
                    baseChildTableQuery.criteria.limit = singleJoin.criteria.limit;
                  } else {
                    baseChildTableQuery.criteria.limit = Number.MAX_SAFE_INTEGER||9007199254740991;
                  }
      Severity: Major
      Found in lib/waterline/utils/query/help-find.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

            if (_.isNull(value)) {
        
              // We allow `null` for singular associations UNLESS they are required.
              if (correspondingAttrDef.required) {
                throw flaverr('E_REQUIRED', new Error(
        Severity: Major
        Found in lib/waterline/utils/query/private/normalize-value-to-set.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                    if (_.isUndefined(record[attrName])) {
                    }
                    // If the value for this singular association came back as an array, then
                    // that might be ok too-- it probably means that the association was populated.
                    else if (_.isArray(record[attrName])) {
          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 (_.keys(singleJoin.criteria.where).length > 0) {
                          // If the "where" clause has an "and" modifier already, just push it onto our "and".
                          if (singleJoin.criteria.where.and) {
                            baseChildTableQuery.criteria.where.and = baseChildTableQuery.criteria.where.and.concat(singleJoin.criteria.where.and);
                          } else {
            Severity: Major
            Found in lib/waterline/utils/query/help-find.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                          if (!_.isUndefined(singleJoin.criteria.sort)) {
                            baseChildTableQuery.criteria.sort = singleJoin.criteria.sort;
                          }
                          else {
                            baseChildTableQuery.criteria.sort = [];
              Severity: Major
              Found in lib/waterline/utils/query/help-find.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                              if (err) { return nextSetOfJoins(err); }
                Severity: Major
                Found in lib/waterline/utils/query/help-find.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                          if (!ThroughWLModel.attributes[attrDef.via]) {
                            throw new Error('Consistency violation: The referenced attribute (`'+attrName+'`, from model `'+modelIdentity+'`) is a "through" association, because it declares a `through`.  But the association\'s specified `via` ('+attrDef.via+'`) does not correspond with a recognized attribute on the junction model (`'+attrDef.through+'`)');
                          }
                  Severity: Major
                  Found in lib/waterline/utils/ontology/get-attribute.js - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                        if (!_.isString(correspondingAttrDef.type) || correspondingAttrDef.type === '') {
                          throw new Error('Consistency violation: There is no way this attribute (`'+supposedAttrName+'`) should have been allowed to be registered with neither a `type`, `model`, nor `collection`!  Here is the attr def: '+util.inspect(correspondingAttrDef, {depth:5})+'');
                        }
                    Severity: Major
                    Found in lib/waterline/utils/query/private/normalize-value-to-set.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                switch (e.code) {
                                  case 'E_VALUE_NOT_USABLE': throw flaverr('E_CONSTRAINT_NOT_USABLE', new Error('Invalid item within `nin` ("not in") modifier array.  '+e.message));
                                  default:                   throw e;
                                }
                      Severity: Major
                      Found in lib/waterline/utils/query/private/normalize-constraint.js - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                if (!OtherWLModel.attributes[attrDef.via]) {
                                  throw new Error('Consistency violation: The referenced attribute (`'+attrName+'`, from model `'+modelIdentity+'`) is an association, because it declares a `collection`.  But that association also specifies a `via` ('+attrDef.via+'`) which does not correspond with a recognized attribute on the other model (`'+attrDef.collection+'`)');
                                }
                        Severity: Major
                        Found in lib/waterline/utils/ontology/get-attribute.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

                            Function stream has a Cognitive Complexity of 8 (exceeds 5 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: Minor
                            Found in lib/waterline/methods/stream.js - About 45 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 count has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                            module.exports = function count( /* criteria?, explicitCbMaybe?, meta?, moreQueryKeys? */ ) {
                            
                              // Verify `this` refers to an actual Sails/Waterline model.
                              verifyModelMethodContext(this);
                            
                            
                            Severity: Minor
                            Found in lib/waterline/methods/count.js - About 45 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 (secondJoin.criteria.where.and) {
                                              baseChildTableQuery.criteria.where.and = baseChildTableQuery.criteria.where.and.concat(secondJoin.criteria.where.and);
                                            }
                                            else {
                                              // Otherwise push the whole "where" clause in to the "and" array as a new conjunct.
                            Severity: Major
                            Found in lib/waterline/utils/query/help-find.js - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                      if (_.isNull(item)){
                                        throw flaverr('E_CONSTRAINT_NOT_USABLE', new Error(
                                          'Got unsupported value (`null`) in a `nin` ("not in") modifier array.  Please use `or: [{ '+constraintTarget+': { \'!=\': null }, ...]` instead.'
                                        ));
                                      }//-•
                              Severity: Major
                              Found in lib/waterline/utils/query/private/normalize-constraint.js - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                if (singleJoin.collection === true) {
                                                  parentRecord[alias] = childTableResults || [];
                                                }
                                
                                                // Otherwise, if this is a to-one join, add the single result to the join key column
                                Severity: Major
                                Found in lib/waterline/utils/query/help-find.js - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                      else if (modifierKind === '>') {
                                  
                                        // If it matches a known attribute, verify that the attribute does not declare
                                        // itself `type: 'boolean'` (it wouldn't make any sense to attempt that)
                                        if (attrDef && attrDef.type === 'boolean'){
                                  Severity: Major
                                  Found in lib/waterline/utils/query/private/normalize-constraint.js - About 45 mins to fix

                                    Function isExclusive has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                    module.exports = function isExclusive(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-exclusive.js - About 45 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

                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language