balderdashy/waterline

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

Summary

Maintainability
D
3 days
Test Coverage

Function create has 143 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function create(newRecord, explicitCbMaybe, metaContainer) {

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

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

    Function _afterPotentiallyRunningBeforeLC has 90 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          })(function _afterPotentiallyRunningBeforeLC(err, query) {
            if (err) {
              return done(err);
            }
    
    
    Severity: Major
    Found in lib/waterline/methods/create.js - About 3 hrs to fix

      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

        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

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

            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/create.js and 2 other locations - About 4 hrs to fix
            lib/waterline/methods/create-each.js on lines 306..329
            lib/waterline/methods/update.js on lines 324..347

            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

            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/create.js and 2 other locations - About 1 hr to fix
            lib/waterline/methods/create-each.js on lines 270..277
            lib/waterline/methods/update.js on lines 285..292

            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

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

            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

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

            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.beforeCreate(query.newRecord, function(err){
                      if (err) { return proceed(err); }
                      return proceed(undefined, query);
                    });
            Severity: Minor
            Found in lib/waterline/methods/create.js and 2 other locations - About 35 mins to fix
            lib/waterline/methods/destroy.js on lines 216..219
            lib/waterline/methods/update.js on lines 222..225

            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.create) {
                      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/create.js and 2 other locations - About 35 mins to fix
            lib/waterline/methods/create-each.js on lines 284..286
            lib/waterline/methods/update.js on lines 300..302

            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

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

                          if (_.has(query.meta, 'skipAllLifecycleCallbacks') && query.meta.skipAllLifecycleCallbacks) {
                            return proceed(undefined, transformedRecord);
                          }//-•
            Severity: Major
            Found in lib/waterline/methods/create.js and 3 other locations - About 30 mins to fix
            lib/waterline/methods/create-each.js on lines 197..199
            lib/waterline/methods/create-each.js on lines 423..425
            lib/waterline/methods/create.js on lines 180..182

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

            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 4 locations. Consider refactoring.
            Open

                    if (_.has(query.meta, 'skipAllLifecycleCallbacks') && query.meta.skipAllLifecycleCallbacks) {
                      return proceed(undefined, query);
                    }//-•
            Severity: Major
            Found in lib/waterline/methods/create.js and 3 other locations - About 30 mins to fix
            lib/waterline/methods/create-each.js on lines 197..199
            lib/waterline/methods/create-each.js on lines 423..425
            lib/waterline/methods/create.js on lines 353..355

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

            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 fetch = modifiedMeta || (_.has(query.meta, 'fetch') && query.meta.fetch);
            Severity: Minor
            Found in lib/waterline/methods/create.js and 1 other location - About 30 mins to fix
            lib/waterline/methods/create-each.js on lines 305..305

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

            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