balderdashy/waterline

View on GitHub
lib/waterline/utils/query/private/normalize-constraint.js

Summary

Maintainability
F
2 wks
Test Coverage

Function normalizeConstraint has a Cognitive Complexity of 188 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = function normalizeConstraint (constraintRhs, constraintTarget, modelIdentity, orm, meta){
  if (_.isUndefined(constraintRhs)) {
    throw new Error('Consistency violation: The internal normalizeConstraint() utility must always be called with a first argument (the RHS of the constraint to normalize).  But instead, got: '+util.inspect(constraintRhs, {depth:5})+'');
  }
  if (!_.isString(constraintTarget)) {
Severity: Minor
Found in lib/waterline/utils/query/private/normalize-constraint.js - About 3 days 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 normalizeConstraint has 425 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function normalizeConstraint (constraintRhs, constraintTarget, modelIdentity, orm, meta){
  if (_.isUndefined(constraintRhs)) {
    throw new Error('Consistency violation: The internal normalizeConstraint() utility must always be called with a first argument (the RHS of the constraint to normalize).  But instead, got: '+util.inspect(constraintRhs, {depth:5})+'');
  }
  if (!_.isString(constraintTarget)) {
Severity: Major
Found in lib/waterline/utils/query/private/normalize-constraint.js - About 2 days to fix

    File normalize-constraint.js has 457 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-constraint.js - About 7 hrs to fix

      Avoid deeply nested control flow statements.
      Open

            if (modifier.length === 0) {
              throw flaverr('E_CONSTRAINT_WOULD_MATCH_EVERYTHING', new Error(
                'Since this `nin` ("not in") modifier is an empty array, it would match ANYTHING.'
              ));
            }//-•
      Severity: Major
      Found in lib/waterline/utils/query/private/normalize-constraint.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

            else if (modifierKind === '>') {
        
              // If it matches a known attribute, verify that the attribute does not declare
              // itself `type: 'boolean'` (it wouldn't make any sense to attempt that)
              if (attrDef && attrDef.type === 'boolean'){
        Severity: Major
        Found in lib/waterline/utils/query/private/normalize-constraint.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                if (!_.isArray(modifier)) {
                  throw flaverr('E_CONSTRAINT_NOT_USABLE', new Error(
                    'A `nin` ("not in") modifier should always be provided as an array.  '+
                    'But instead, for the `nin` modifier at `'+constraintTarget+'`, got: '+
                    util.inspect(modifier, {depth:5})+''
          Severity: Major
          Found in lib/waterline/utils/query/private/normalize-constraint.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                    if (_.isNull(item)){
                      throw flaverr('E_CONSTRAINT_NOT_USABLE', new Error(
                        'Got unsupported value (`null`) in a `nin` ("not in") modifier array.  Please use `or: [{ '+constraintTarget+': { \'!=\': null }, ...]` instead.'
                      ));
                    }//-•
            Severity: Major
            Found in lib/waterline/utils/query/private/normalize-constraint.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                        switch (e.code) {
                          case 'E_VALUE_NOT_USABLE': throw flaverr('E_CONSTRAINT_NOT_USABLE', new Error('Invalid item within `nin` ("not in") modifier array.  '+e.message));
                          default:                   throw e;
                        }
              Severity: Major
              Found in lib/waterline/utils/query/private/normalize-constraint.js - About 45 mins to fix

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

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

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

                      else if (modifierKind === 'nin') {
                  
                        if (!_.isArray(modifier)) {
                          throw flaverr('E_CONSTRAINT_NOT_USABLE', new Error(
                            'A `nin` ("not in") modifier should always be provided as an array.  '+
                  Severity: Major
                  Found in lib/waterline/utils/query/private/normalize-constraint.js and 1 other location - About 1 day to fix
                  lib/waterline/utils/query/private/normalize-constraint.js on lines 370..415

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

                  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

                      else if (modifierKind === 'in') {
                  
                        if (!_.isArray(modifier)) {
                          throw flaverr('E_CONSTRAINT_NOT_USABLE', new Error(
                            'An `in` modifier should always be provided as an array.  '+
                  Severity: Major
                  Found in lib/waterline/utils/query/private/normalize-constraint.js and 1 other location - About 1 day to fix
                  lib/waterline/utils/query/private/normalize-constraint.js on lines 419..464

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

                  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

                      else if (modifierKind === '>') {
                  
                        // If it matches a known attribute, verify that the attribute does not declare
                        // itself `type: 'boolean'` (it wouldn't make any sense to attempt that)
                        if (attrDef && attrDef.type === 'boolean'){
                  Severity: Major
                  Found in lib/waterline/utils/query/private/normalize-constraint.js and 2 other locations - About 6 hrs to fix
                  lib/waterline/utils/query/private/normalize-constraint.js on lines 505..836
                  lib/waterline/utils/query/private/normalize-constraint.js on lines 541..836

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

                  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

                      else if (modifierKind === '>=') {
                  
                        // If it matches a known attribute, verify that the attribute does not declare
                        // itself `type: 'boolean'` (it wouldn't make any sense to attempt that)
                        if (attrDef && attrDef.type === 'boolean'){
                  Severity: Major
                  Found in lib/waterline/utils/query/private/normalize-constraint.js and 2 other locations - About 6 hrs to fix
                  lib/waterline/utils/query/private/normalize-constraint.js on lines 469..836
                  lib/waterline/utils/query/private/normalize-constraint.js on lines 541..836

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

                  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

                      else if (modifierKind === '<') {
                  
                        // If it matches a known attribute, verify that the attribute does not declare
                        // itself `type: 'boolean'` (it wouldn't make any sense to attempt that)
                        if (attrDef && attrDef.type === 'boolean'){
                  Severity: Major
                  Found in lib/waterline/utils/query/private/normalize-constraint.js and 2 other locations - About 6 hrs to fix
                  lib/waterline/utils/query/private/normalize-constraint.js on lines 469..836
                  lib/waterline/utils/query/private/normalize-constraint.js on lines 505..836

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

                  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 (attrDef && (
                          attrDef.type === 'number' ||
                          attrDef.type === 'boolean' ||
                          (attrDef.model && reciprocalPKA.type === 'number')
                        )){
                  Severity: Major
                  Found in lib/waterline/utils/query/private/normalize-constraint.js and 2 other locations - About 2 hrs to fix
                  lib/waterline/utils/query/private/normalize-constraint.js on lines 618..627
                  lib/waterline/utils/query/private/normalize-constraint.js on lines 677..686

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

                  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 (attrDef && (
                          attrDef.type === 'number' ||
                          attrDef.type === 'boolean' ||
                          (attrDef.model && reciprocalPKA.type === 'number')
                        )){
                  Severity: Major
                  Found in lib/waterline/utils/query/private/normalize-constraint.js and 2 other locations - About 2 hrs to fix
                  lib/waterline/utils/query/private/normalize-constraint.js on lines 618..627
                  lib/waterline/utils/query/private/normalize-constraint.js on lines 735..744

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

                  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 (attrDef && (
                          attrDef.type === 'number' ||
                          attrDef.type === 'boolean' ||
                          (attrDef.model && reciprocalPKA.type === 'number')
                        )){
                  Severity: Major
                  Found in lib/waterline/utils/query/private/normalize-constraint.js and 2 other locations - About 2 hrs to fix
                  lib/waterline/utils/query/private/normalize-constraint.js on lines 677..686
                  lib/waterline/utils/query/private/normalize-constraint.js on lines 735..744

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

                  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

                        try {
                          modifier = rttc.validate('string', modifier);
                        } catch (e) {
                          switch (e.code) {
                  
                  
                  Severity: Major
                  Found in lib/waterline/utils/query/private/normalize-constraint.js and 2 other locations - About 2 hrs to fix
                  lib/waterline/utils/query/private/normalize-constraint.js on lines 631..644
                  lib/waterline/utils/query/private/normalize-constraint.js on lines 748..761

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

                  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

                        try {
                          modifier = rttc.validate('string', modifier);
                        } catch (e) {
                          switch (e.code) {
                  
                  
                  Severity: Major
                  Found in lib/waterline/utils/query/private/normalize-constraint.js and 2 other locations - About 2 hrs to fix
                  lib/waterline/utils/query/private/normalize-constraint.js on lines 690..703
                  lib/waterline/utils/query/private/normalize-constraint.js on lines 748..761

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

                  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

                        try {
                          modifier = rttc.validate('string', modifier);
                        } catch (e) {
                          switch (e.code) {
                  
                  
                  Severity: Major
                  Found in lib/waterline/utils/query/private/normalize-constraint.js and 2 other locations - About 2 hrs to fix
                  lib/waterline/utils/query/private/normalize-constraint.js on lines 631..644
                  lib/waterline/utils/query/private/normalize-constraint.js on lines 690..703

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

                  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

                    try {
                      attrDef = getAttribute(attrName, modelIdentity, orm);
                    } catch (e){
                      switch (e.code) {
                        case 'E_ATTR_NOT_REGISTERED':
                  Severity: Major
                  Found in lib/waterline/utils/query/private/normalize-constraint.js and 3 other locations - About 50 mins to fix
                  lib/waterline/utils/query/private/normalize-criteria.js on lines 757..767
                  lib/waterline/utils/query/private/normalize-criteria.js on lines 869..879
                  lib/waterline/utils/query/private/normalize-sort-clause.js on lines 306..316

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

                  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 (!_.isString(modelIdentity)) {
                      throw new Error('Consistency violation: The internal normalizeConstraint() utility must always be called with a valid third argument (a string).  But instead, got: '+util.inspect(modelIdentity, {depth:5})+'');
                    }
                  Severity: Minor
                  Found in lib/waterline/utils/query/private/normalize-constraint.js and 1 other location - About 40 mins to fix
                  lib/waterline/utils/query/private/build-usage-error.js on lines 165..167

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

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

                    if (!_.isString(constraintTarget)) {
                      throw new Error('Consistency violation: The internal normalizeConstraint() utility must always be called with a valid second argument (a string).  But instead, got: '+util.inspect(constraintTarget, {depth:5})+'');
                    }
                  Severity: Major
                  Found in lib/waterline/utils/query/private/normalize-constraint.js and 8 other locations - About 35 mins to fix
                  lib/waterline/utils/ontology/is-capable-of-optimized-populate.js on lines 32..34
                  lib/waterline/utils/ontology/is-capable-of-optimized-populate.js on lines 35..37
                  lib/waterline/utils/ontology/is-exclusive.js on lines 34..36
                  lib/waterline/utils/ontology/is-exclusive.js on lines 37..39
                  lib/waterline/utils/query/private/build-usage-error.js on lines 162..164
                  lib/waterline/utils/query/private/normalize-comparison-value.js on lines 55..55
                  lib/waterline/utils/query/private/normalize-comparison-value.js on lines 56..56
                  lib/waterline/utils/query/private/normalize-comparison-value.js on lines 57..57

                  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

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

                    else if (WLModel.hasSchema === false) {
                  
                      // Make sure this is at least a valid name for a Waterline attribute.
                      if (!isValidAttributeName(attrName)) {
                        throw flaverr('E_CONSTRAINT_NOT_USABLE', new Error(
                  Severity: Major
                  Found in lib/waterline/utils/query/private/normalize-constraint.js and 3 other locations - About 35 mins to fix
                  lib/waterline/utils/query/private/normalize-criteria.js on lines 782..792
                  lib/waterline/utils/query/private/normalize-criteria.js on lines 893..909
                  lib/waterline/utils/query/private/normalize-sort-clause.js on lines 335..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 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 2 locations. Consider refactoring.
                  Open

                    if (_.isString(constraintTarget)){
                      deepTargetHops = constraintTarget.split(/\./);
                      isDeepTarget = (deepTargetHops.length > 1);
                    }
                  Severity: Minor
                  Found in lib/waterline/utils/query/private/normalize-constraint.js and 1 other location - About 30 mins to fix
                  lib/waterline/utils/query/private/normalize-sort-clause.js on lines 276..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 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