balderdashy/waterline

View on GitHub

Showing 357 of 357 total issues

File help-find.js has 341 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * Module dependencies
 */

var util = require('util');
Severity: Minor
Found in lib/waterline/utils/query/help-find.js - About 4 hrs to fix

    Function customizations has 104 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        var customizations = (function(){
    
          //  ███╗   ██╗ ██████╗ ████████╗     █████╗ ███╗   ██╗    ███████╗██████╗ ██████╗  ██████╗ ██████╗
          //  ████╗  ██║██╔═══██╗╚══██╔══╝    ██╔══██╗████╗  ██║    ██╔════╝██╔══██╗██╔══██╗██╔═══██╗██╔══██╗
          //  ██╔██╗ ██║██║   ██║   ██║       ███████║██╔██╗ ██║    █████╗  ██████╔╝██████╔╝██║   ██║██████╔╝
    Severity: Major
    Found in lib/waterline/utils/query/forge-adapter-error.js - About 4 hrs to fix

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

      var FETCH_Q_METHODS = {
      
      
        /**
         * Add `fetch: true` to the query's `meta`.
      Severity: Major
      Found in lib/waterline/utils/query/get-query-modifier-methods.js and 1 other location - About 4 hrs to fix
      lib/waterline/utils/query/get-query-modifier-methods.js on lines 548..576

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

      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 DECRYPT_Q_METHODS = {
      
      
        /**
         * Add `decrypt: true` to the query's `meta`.
      Severity: Major
      Found in lib/waterline/utils/query/get-query-modifier-methods.js and 1 other location - About 4 hrs to fix
      lib/waterline/utils/query/get-query-modifier-methods.js on lines 517..544

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

      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 find has 99 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports = function find( /* criteria?, populates?, explicitCbMaybe?, meta? */ ) {
      
        // Verify `this` refers to an actual Sails/Waterline model.
        verifyModelMethodContext(this);
      
      
      Severity: Major
      Found in lib/waterline/methods/find.js - About 3 hrs to fix

        Function normalizeComparisonValue has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
        Open

        module.exports = function normalizeComparisonValue (value, attrName, modelIdentity, orm){
          if (!_.isString(attrName)) { throw new Error('Consistency violation: This internal utility must always be called with a valid second argument (the attribute name).  But instead, got: '+util.inspect(attrName, {depth:5})+''); }
          if (!_.isString(modelIdentity)) { throw new Error('Consistency violation: This internal utility must always be called with a valid third argument (the model identity).  But instead, got: '+util.inspect(modelIdentity, {depth:5})+''); }
          if (!_.isObject(orm)) { throw new Error('Consistency violation: This internal utility must always be called with a valid fourth argument (the orm instance).  But instead, got: '+util.inspect(orm, {depth:5})+''); }
        
        
        Severity: Minor
        Found in lib/waterline/utils/query/private/normalize-comparison-value.js - About 3 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 sum has 96 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        module.exports = function sum( /* numericAttrName?, criteria?, explicitCbMaybe?, meta?, moreQueryKeys? */ ) {
        
          // Verify `this` refers to an actual Sails/Waterline model.
          verifyModelMethodContext(this);
        
        
        Severity: Major
        Found in lib/waterline/methods/sum.js - About 3 hrs to fix

          Function archive has 95 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          module.exports = function archive(/* criteria, explicitCbMaybe, metaContainer */) {
          
            // Verify `this` refers to an actual Sails/Waterline model.
            verifyModelMethodContext(this);
          
          
          Severity: Major
          Found in lib/waterline/methods/archive.js - About 3 hrs to fix

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

                      (function _maybeRunAfterLC(proceed){
            
                        // If the `skipAllLifecycleCallbacks` meta key was enabled, then don't run this LC.
                        if (_.has(query.meta, 'skipAllLifecycleCallbacks') && query.meta.skipAllLifecycleCallbacks) {
                          return proceed(undefined, thePopulatedRecord);
            Severity: Major
            Found in lib/waterline/methods/find-one.js and 1 other location - About 3 hrs to fix
            lib/waterline/methods/find.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 109.

            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

                      (function _maybeRunAfterLC(proceed){
            
                        // If the `skipAllLifecycleCallbacks` meta key was enabled, then don't run this LC.
                        if (_.has(query.meta, 'skipAllLifecycleCallbacks') && query.meta.skipAllLifecycleCallbacks) {
                          return proceed(undefined, populatedRecords);
            Severity: Major
            Found in lib/waterline/methods/find.js and 1 other location - About 3 hrs to fix
            lib/waterline/methods/find-one.js on lines 315..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 109.

            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 _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 helpFind has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
              Open

              module.exports = function helpFind(WLModel, s2q, omen, done) {
              
                if (!_.isFunction(done)) {
                  throw new Error('Consistency violation: `done` (4th argument) should be a function');
                }
              Severity: Minor
              Found in lib/waterline/utils/query/help-find.js - About 3 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 findOrCreate has 89 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              module.exports = function findOrCreate( /* criteria?, newRecord?, explicitCbMaybe?, meta? */ ) {
              
                // Verify `this` refers to an actual Sails/Waterline model.
                verifyModelMethodContext(this);
              
              
              Severity: Major
              Found in lib/waterline/methods/find-or-create.js - About 3 hrs to fix

                File normalize-value-to-set.js has 314 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                /**
                 * Module dependencies
                 */
                
                var util = require('util');
                Severity: Minor
                Found in lib/waterline/utils/query/private/normalize-value-to-set.js - About 3 hrs to fix

                  Function updateOne has 87 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  module.exports = function updateOne(criteria, valuesToSet, explicitCbMaybe, metaContainer) {
                  
                    // Verify `this` refers to an actual Sails/Waterline model.
                    verifyModelMethodContext(this);
                  
                  
                  Severity: Major
                  Found in lib/waterline/methods/update-one.js - About 3 hrs to fix

                    Function _afterGettingPopulatedPhysicalRecords has 80 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      }) (function _afterGettingPopulatedPhysicalRecords (err, populatedRecords){
                    
                        if (err) { return done(err); }
                    
                        //
                    Severity: Major
                    Found in lib/waterline/utils/query/help-find.js - About 3 hrs to fix

                      Function _makeCallOrCallsToAppropriateIteratee has 77 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                                (function _makeCallOrCallsToAppropriateIteratee(proceed){
                      
                                  // Check if the iteratee declares a callback parameter
                                  var seemsToExpectCallback = (function(){
                                    var fn = query.eachBatchFn || query.eachRecordFn;
                      Severity: Major
                      Found in lib/waterline/methods/stream.js - About 3 hrs to fix

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

                                  _.each(originalModels[reference.referenceIdentity].schema, function(val, key) {
                                    // Ignore virtual attributes
                                    if(_.has(val, 'collection')) {
                                      return;
                                    }
                        Severity: Major
                        Found in lib/waterline/utils/query/forge-stage-three-query.js and 1 other location - About 3 hrs to fix
                        lib/waterline/utils/query/forge-stage-three-query.js on lines 361..374

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

                        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

                                _.each(originalModels[parentAttr.referenceIdentity].schema, function(val, key) {
                                  // Ignore virtual attributes
                                  if(_.has(val, 'collection')) {
                                    return;
                                  }
                        Severity: Major
                        Found in lib/waterline/utils/query/forge-stage-three-query.js and 1 other location - About 3 hrs to fix
                        lib/waterline/utils/query/forge-stage-three-query.js on lines 424..437

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

                        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 normalizeComparisonValue has 74 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        module.exports = function normalizeComparisonValue (value, attrName, modelIdentity, orm){
                          if (!_.isString(attrName)) { throw new Error('Consistency violation: This internal utility must always be called with a valid second argument (the attribute name).  But instead, got: '+util.inspect(attrName, {depth:5})+''); }
                          if (!_.isString(modelIdentity)) { throw new Error('Consistency violation: This internal utility must always be called with a valid third argument (the model identity).  But instead, got: '+util.inspect(modelIdentity, {depth:5})+''); }
                          if (!_.isObject(orm)) { throw new Error('Consistency violation: This internal utility must always be called with a valid fourth argument (the orm instance).  But instead, got: '+util.inspect(orm, {depth:5})+''); }
                        
                        
                        Severity: Major
                        Found in lib/waterline/utils/query/private/normalize-comparison-value.js - About 2 hrs to fix
                          Severity
                          Category
                          Status
                          Source
                          Language