balderdashy/waterline

View on GitHub

Showing 357 of 357 total issues

Similar blocks of code found in 6 locations. Consider refactoring.
Open

  limit: function(limit) {

    if (!this._alreadyInitiallyExpandedCriteria) {
      this._wlQueryInfo.criteria = expandWhereShorthand(this._wlQueryInfo.criteria);
      this._alreadyInitiallyExpandedCriteria = true;
Severity: Major
Found in lib/waterline/utils/query/get-query-modifier-methods.js and 5 other locations - About 2 hrs to fix
lib/waterline/utils/query/get-query-modifier-methods.js on lines 293..303
lib/waterline/utils/query/get-query-modifier-methods.js on lines 432..442
lib/waterline/utils/query/get-query-modifier-methods.js on lines 457..467
lib/waterline/utils/query/get-query-modifier-methods.js on lines 475..485
lib/waterline/utils/query/get-query-modifier-methods.js on lines 501..511

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 90.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function normalizePkValue has 65 lines of code (exceeds 25 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: Major
Found in lib/waterline/utils/query/private/normalize-pk-value.js - About 2 hrs to fix

    Function _afterPotentiallyWipingCollections has 65 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

                })(function _afterPotentiallyWipingCollections(err) {// ~∞%°
                  if (err) {
                    return done(err);
                  }
    
    
    Severity: Major
    Found in lib/waterline/methods/destroy.js - About 2 hrs to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

            adapter.sum(WLModel.datastore, query, function _afterTalkingToAdapter(err, sum) {
              if (err) {
                err = forgeAdapterError(err, omen, 'sum', modelIdentity, orm);
                return done(err);
              }//-•
      Severity: Major
      Found in lib/waterline/methods/sum.js and 1 other location - About 2 hrs to fix
      lib/waterline/methods/avg.js on lines 272..290

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 87.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

            adapter.avg(WLModel.datastore, query, function _afterTalkingToAdapter(err, arithmeticMean) {
              if (err) {
                err = forgeAdapterError(err, omen, 'avg', modelIdentity, orm);
                return done(err);
              }//-•
      Severity: Major
      Found in lib/waterline/methods/avg.js and 1 other location - About 2 hrs to fix
      lib/waterline/methods/sum.js on lines 263..281

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 87.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Function processAllRecords has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

      module.exports = function processAllRecords(records, meta, modelIdentity, orm) {
        // console.time('processAllRecords');
      
      
        if (!_.isArray(records)) {
      Severity: Minor
      Found in lib/waterline/utils/query/process-all-records.js - About 2 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 start has 64 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports.start = function (options, done){
      
        // Verify usage & apply defaults:
        if (!_.isFunction(done)) {
          throw new Error('Please provide a valid callback function as the 2nd argument to `Waterline.start()`.  (Instead, got: `'+done+'`)');
      Severity: Major
      Found in lib/waterline.js - About 2 hrs to fix

        Function paginate has 61 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          paginate: function(pageNumOrOpts, pageSize) {
        
            if (!this._alreadyInitiallyExpandedCriteria) {
              this._wlQueryInfo.criteria = expandWhereShorthand(this._wlQueryInfo.criteria);
              this._alreadyInitiallyExpandedCriteria = true;
        Severity: Major
        Found in lib/waterline/utils/query/get-query-modifier-methods.js - About 2 hrs to fix

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

              if (!_.isString(attrDef.collection) || attrDef.collection === '') {
                throw new Error('Consistency violation: The referenced attribute (`'+attrName+'`, from model `'+modelIdentity+'`) has an invalid `collection` property.  If specified, `collection` should be a non-empty string.  But instead, got: '+util.inspect(attrDef.collection, {depth:5})+'');
              }
          Severity: Major
          Found in lib/waterline/utils/ontology/get-attribute.js and 2 other locations - About 2 hrs to fix
          lib/waterline/utils/ontology/get-attribute.js on lines 89..91
          lib/waterline/utils/ontology/get-attribute.js on lines 150..152

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 83.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

              if(!_.isString(attrDef.model) || attrDef.model === '') {
                throw new Error('Consistency violation: The referenced attribute (`'+attrName+'`, from model `'+modelIdentity+'`) has an invalid `model` property.  If specified, `model` should be a non-empty string.  But instead, got: '+util.inspect(attrDef.model, {depth:5})+'');
              }
          Severity: Major
          Found in lib/waterline/utils/ontology/get-attribute.js and 2 other locations - About 2 hrs to fix
          lib/waterline/utils/ontology/get-attribute.js on lines 105..107
          lib/waterline/utils/ontology/get-attribute.js on lines 150..152

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 83.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

              if(!_.isString(attrDef.type) || attrDef.type === '') {
                throw new Error('Consistency violation: The referenced attribute (`'+attrName+'`, from model `'+modelIdentity+'`) has an invalid `type` property.  If specified, `type` should be a non-empty string.  But instead, got: '+util.inspect(attrDef.type, {depth:5})+'');
              }
          Severity: Major
          Found in lib/waterline/utils/ontology/get-attribute.js and 2 other locations - About 2 hrs to fix
          lib/waterline/utils/ontology/get-attribute.js on lines 89..91
          lib/waterline/utils/ontology/get-attribute.js on lines 105..107

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 83.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Function _afterTalkingToAdapter has 59 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  adapter.create(WLModel.datastore, query, function _afterTalkingToAdapter(err, rawAdapterResult) {
                    if (err) {
                      err = forgeAdapterError(err, omen, 'create', modelIdentity, orm);
                      return done(err);
                    }//-•
          Severity: Major
          Found in lib/waterline/methods/create.js - About 2 hrs to fix

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              try {
                WLModel = getModel(modelIdentity, orm);
              } catch (e) {
                switch (e.code) {
                  case 'E_MODEL_NOT_REGISTERED': throw new Error('Consistency violation: '+e.message);
            Severity: Major
            Found in lib/waterline/utils/query/private/normalize-new-record.js and 1 other location - About 2 hrs to fix
            lib/waterline/utils/query/private/normalize-criteria.js on lines 109..116

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 82.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              try {
                WLModel = getModel(modelIdentity, orm);
              } catch (e) {
                switch (e.code) {
                  case 'E_MODEL_NOT_REGISTERED': throw new Error('Consistency violation: '+e.message);
            Severity: Major
            Found in lib/waterline/utils/query/private/normalize-criteria.js and 1 other location - About 2 hrs to fix
            lib/waterline/utils/query/private/normalize-new-record.js on lines 142..149

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 82.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              if (explicitCbMaybe !== undefined && !_.isFunction(explicitCbMaybe)) {
                throw flaverr({
                  name: 'UsageError',
                  message:
                  '`.sum()` received an explicit callback function argument... but it '+
            Severity: Major
            Found in lib/waterline/methods/sum.js and 1 other location - About 2 hrs to fix
            lib/waterline/methods/avg.js on lines 143..150

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 81.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                          if (!_.isUndefined(secondJoin.criteria.limit)) {
                            baseChildTableQuery.criteria.limit = secondJoin.criteria.limit;
                          } else {
                            baseChildTableQuery.criteria.limit = Number.MAX_SAFE_INTEGER||9007199254740991;
                          }
            Severity: Major
            Found in lib/waterline/utils/query/help-find.js and 1 other location - About 2 hrs to fix
            lib/waterline/utils/query/help-find.js on lines 479..483

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 81.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            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 and 1 other location - About 2 hrs to fix
            lib/waterline/utils/query/help-find.js on lines 329..333

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 81.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              if (explicitCbMaybe !== undefined && !_.isFunction(explicitCbMaybe)) {
                throw flaverr({
                  name: 'UsageError',
                  message:
                  '`.avg()` received an explicit callback function argument... but it '+
            Severity: Major
            Found in lib/waterline/methods/avg.js and 1 other location - About 2 hrs to fix
            lib/waterline/methods/sum.js on lines 145..152

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 81.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                      if (!_.isArray(rawAdapterResult)) {
                        return done(new Error(
                          'Unexpected behavior in database adapter: Since `fetch: true` was enabled, this adapter '+
                          '(for datastore `'+WLModel.datastore+'`) should have sent back an array of records as the '+
                          '2nd argument when triggering the callback from its `update` method.  But instead, got: '+
            Severity: Major
            Found in lib/waterline/methods/update.js and 1 other location - About 2 hrs to fix
            lib/waterline/methods/destroy.js on lines 485..491

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 79.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                            if (!_.isArray(rawAdapterResult)) {
                              return proceed(new Error(
                                'Unexpected behavior in database adapter: Since `fetch: true` was enabled, this adapter '+
                                '(for datastore `'+WLModel.datastore+'`) should have sent back an array of records as the 2nd argument when triggering '+
                                'the callback from its `destroy` method.  But instead, got: '+util.inspect(rawAdapterResult, {depth:5})+''
            Severity: Major
            Found in lib/waterline/methods/destroy.js and 1 other location - About 2 hrs to fix
            lib/waterline/methods/update.js on lines 354..361

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 79.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Severity
            Category
            Status
            Source
            Language