balderdashy/waterline

View on GitHub

Showing 156 of 357 total issues

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 (err) {
                      err = forgeAdapterError(err, omen, 'find', childTableModel.identity, orm);
                      return nextParentRecord(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 (!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

        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 (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 (!_.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

                          if (_.isUndefined(parentRecord[singleJoin.parentKey])) {
                            if (singleJoin.collection === true) {
                              parentRecord[alias] = [];
                            } else {
                              parentRecord[singleJoin.parentKey] = null;
            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.select)) {
                            baseChildTableQuery.criteria.select = singleJoin.criteria.select;
                          }
              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 (isProvidingNullForIncompatibleOptionalAttr) {
                        throw flaverr({ code: 'E_TYPE', expectedType: correspondingAttrDef.type }, new Error(
                          'Specified value (`null`) is not a valid `'+supposedAttrName+'`.  '+
                          'Even though this attribute is optional, it still does not allow `null` to '+
                          'be explicitly set, because `null` is not valid vs. the expected '+
                  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(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

                      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

                      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

                            if (correspondingAttrDef.required) {
                        
                              // "" (empty string) is never allowed as a value for a required attribute.
                              if (value === '') {
                                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 (_.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

                                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

                              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 (!_.isArray(modifier)) {
                                        throw flaverr('E_CONSTRAINT_NOT_USABLE', new Error(
                                          'A `nin` ("not in") modifier should always be provided as an array.  '+
                                          'But instead, for the `nin` modifier at `'+constraintTarget+'`, got: '+
                                          util.inspect(modifier, {depth:5})+''
                                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.skip)) {
                                                baseChildTableQuery.criteria.skip = singleJoin.criteria.skip;
                                              } else {
                                                baseChildTableQuery.criteria.skip = 0;
                                              }
                                  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.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
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language