balderdashy/waterline

View on GitHub
lib/waterline/methods/update.js

Summary

Maintainability
F
4 days
Test Coverage

Function update has 174 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function update(criteria, valuesToSet, explicitCbMaybe, metaContainer) {

  // Verify `this` refers to an actual Sails/Waterline model.
  verifyModelMethodContext(this);

Severity: Major
Found in lib/waterline/methods/update.js - About 6 hrs to fix

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

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

      Avoid too many return statements within this function.
      Open

                } catch (e) { return done(e); }
      Severity: Major
      Found in lib/waterline/methods/update.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/update.js - About 30 mins to fix

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

                      async.each(transformedRecords, function _eachRecord(record, next) {
          
                        // If the `skipAllLifecycleCallbacks` meta flag was set, don't run any of
                        // the methods.
                        if (_.has(query.meta, 'skipAllLifecycleCallbacks') && query.meta.skipAllLifecycleCallbacks) {
          Severity: Major
          Found in lib/waterline/methods/update.js and 1 other location - About 6 hrs to fix
          lib/waterline/methods/destroy.js on lines 522..551

          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 174.

          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 (!fetch) {
          
                      // > Note: This `if` statement is a convenience, for cases where the result from
                      // > the adapter may have been coerced from `undefined` to `null` automatically.
                      // > (we want it to be `undefined` still, for consistency)
          Severity: Major
          Found in lib/waterline/methods/update.js and 2 other locations - About 4 hrs to fix
          lib/waterline/methods/create-each.js on lines 306..329
          lib/waterline/methods/create.js on lines 277..300

          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 134.

          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

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

                  try {
                    query = forgeStageThreeQuery({
                      stageTwoQuery: query,
                      identity: modelIdentity,
                      transformer: WLModel._transformer,
          Severity: Major
          Found in lib/waterline/methods/update.js and 2 other locations - About 1 hr to fix
          lib/waterline/methods/create-each.js on lines 270..277
          lib/waterline/methods/create.js on lines 239..246

          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 72.

          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

            var query = {
              method: 'update',
              using: modelIdentity,
              criteria: criteria,
              valuesToSet: valuesToSet,
          Severity: Major
          Found in lib/waterline/methods/update.js and 1 other location - About 1 hr to fix
          lib/waterline/methods/update-one.js on lines 47..53

          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 69.

          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 (_.keys(collectionResets).length > 0) {
                    // Build a modified shallow clone of the originally-provided `meta`
                    // that also has `fetch: true`.
                    modifiedMetaForCollectionResets = _.extend({}, query.meta || {}, { fetch: true });
                  }//>-
          Severity: Major
          Found in lib/waterline/methods/update.js and 1 other location - About 1 hr to fix
          lib/waterline/methods/create.js on lines 228..232

          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 68.

          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

                    case 'E_NOOP':
                      // Determine the appropriate no-op result.
                      // If `fetch` meta key is set, use `[]`-- otherwise use `undefined`.
                      //
                      // > Note that future versions might simulate output from the raw driver.
          Severity: Major
          Found in lib/waterline/methods/update.js and 1 other location - About 1 hr to fix
          lib/waterline/methods/destroy.js on lines 182..193

          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 61.

          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

                    async.each(_.keys(collectionResets), function _eachReplaceCollectionOp(collectionAttrName, next) {
          
                      WLModel.replaceCollection(targetIds, collectionAttrName, collectionResets[collectionAttrName], function(err){
                        if (err) { return next(err); }
                        return next();
          Severity: Major
          Found in lib/waterline/methods/update.js and 1 other location - About 1 hr to fix
          lib/waterline/methods/create.js on lines 336..343

          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 59.

          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

                  WLModel._callbacks.beforeUpdate(query.valuesToSet, function(err){
                    if (err) { return proceed(err); }
                    return proceed(undefined, query);
                  });
          Severity: Minor
          Found in lib/waterline/methods/update.js and 2 other locations - About 35 mins to fix
          lib/waterline/methods/create.js on lines 190..193
          lib/waterline/methods/destroy.js on lines 216..219

          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 47.

          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 (!adapter.update) {
                    return done(new Error('The adapter used by this model (`' + modelIdentity + '`) doesn\'t support the `'+query.method+'` method.'));
                  }
          Severity: Minor
          Found in lib/waterline/methods/update.js and 2 other locations - About 35 mins to fix
          lib/waterline/methods/create-each.js on lines 284..286
          lib/waterline/methods/create.js on lines 254..256

          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 46.

          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

          There are no issues that match your filters.

          Category
          Status