balderdashy/waterline

View on GitHub

Showing 156 of 357 total issues

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

              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 (!ThroughWLModel.attributes[attrDef.via].model) {
                throw new Error('Consistency violation: The referenced attribute (`'+attrName+'`, from model `'+modelIdentity+'`) is a "through" association, but its specified `via` ('+attrDef.via+'`) corresponds with an unexpected attribute on the junction model (`'+attrDef.through+'`).  The attribute referenced by `via` should be a singular ("model") association, but instead, got: '+util.inspect(ThroughWLModel.attributes[attrDef.via],{depth: 5})+'');
              }
      Severity: Major
      Found in lib/waterline/utils/ontology/get-attribute.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                    if (process.env.NODE_ENV === 'production') {
                      console.warn('\n'+
                        'Warning: Attempting to populate `'+populateAttrName+'` with the specified subcriteria,\n'+
                        'but this MAY NOT BE SAFE, depending on the number of records stored in your models.\n'+
                        'Since this association does not support optimized populates (i.e. it spans multiple '+'\n'+
        Severity: Major
        Found in lib/waterline/utils/query/forge-stage-two-query.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

              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

              Consider simplifying this complex logical expression.
              Open

                else if (correspondingAttrDef.model) {
              
                  // If `null` was specified, then it _might_ be OK.
                  if (_.isNull(value)) {
              
              
              Severity: Major
              Found in lib/waterline/utils/query/private/normalize-value-to-set.js - About 40 mins to fix

                Consider simplifying this complex logical expression.
                Open

                  if (s3Q.method === 'find' || s3Q.method === 'findOne') {
                    s3Q.method = 'find';
                
                    //  ╔╗ ╦ ╦╦╦  ╔╦╗   ┬┌─┐┬┌┐┌  ┬┌┐┌┌─┐┌┬┐┬─┐┬ ┬┌─┐┌┬┐┬┌─┐┌┐┌┌─┐
                    //  ╠╩╗║ ║║║   ║║   ││ │││││  ││││└─┐ │ ├┬┘│ ││   │ ││ ││││└─┐
                Severity: Major
                Found in lib/waterline/utils/query/forge-stage-three-query.js - About 40 mins to fix

                  Function exports has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  module.exports = function forgeAdapterError(err, omen, adapterMethodName, modelIdentity, orm){
                  Severity: Minor
                  Found in lib/waterline/utils/query/forge-adapter-error.js - About 35 mins to fix

                    Function exports has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    module.exports = function normalizeValueToSet(value, supposedAttrName, modelIdentity, orm, meta) {
                    Severity: Minor
                    Found in lib/waterline/utils/query/private/normalize-value-to-set.js - About 35 mins to fix

                      Function exports has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      module.exports = function normalizeConstraint (constraintRhs, constraintTarget, modelIdentity, orm, meta){
                      Severity: Minor
                      Found in lib/waterline/utils/query/private/normalize-constraint.js - About 35 mins to fix

                        Function exports has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        module.exports = function normalizeNewRecord(newRecord, modelIdentity, orm, currentTimestamp, meta) {
                        Severity: Minor
                        Found in lib/waterline/utils/query/private/normalize-new-record.js - About 35 mins to fix

                          Function normalizeNewRecord has a Cognitive Complexity of 7 (exceeds 5 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: Minor
                          Found in lib/waterline/utils/query/private/normalize-new-record.js - About 35 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 normalizeSortClause has a Cognitive Complexity of 7 (exceeds 5 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: Minor
                          Found in lib/waterline/utils/query/private/normalize-sort-clause.js - About 35 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 too many return statements within this function.
                          Open

                                    } catch (e) { return done(e); }
                          Severity: Major
                          Found in lib/waterline/methods/create.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                return true;
                            Severity: Major
                            Found in lib/waterline/utils/system/has-schema-check.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                              return proceed(undefined, transformedRecords);
                              Severity: Major
                              Found in lib/waterline/methods/destroy.js - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                        if (query.targetRecordIds.length === 0) { return proceed(new Error('Consistency violation: No target record ids-- should never have been possible, because this query should have been halted when it was being forged at stage 2.')); }
                                Severity: Major
                                Found in lib/waterline/methods/replace-collection.js - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                            } catch (e) { return done(e); }
                                  Severity: Major
                                  Found in lib/waterline/methods/create.js - About 30 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language