bbc/flashheart

View on GitHub
docconfig/template/fixtures/documents/probe.js

Summary

Maintainability
F
1 wk
Test Coverage

File probe.js has 489 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"use strict";
/**
 @fileOverview Queries objects in memory using a mongo-like notation for reaching into objects and filtering for records

 @module documents/probe
Severity: Minor
Found in docconfig/template/fixtures/documents/probe.js - About 7 hrs to fix

    Function pushin has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
    Open

    function pushin( path, record, setter, newValue ) {
        var context = record;
        var parent = record;
        var lastPart = null;
        var _i;
    Severity: Minor
    Found in docconfig/template/fixtures/documents/probe.js - About 5 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 pushin has 70 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function pushin( path, record, setter, newValue ) {
        var context = record;
        var parent = record;
        var lastPart = null;
        var _i;
    Severity: Major
    Found in docconfig/template/fixtures/documents/probe.js - About 2 hrs to fix

      Function processExpressionObject has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function processExpressionObject( val, key ) {
          var operator;
          if ( sys.isObject( val ) ) {
              var opKeys = Object.keys( val );
              var op = opKeys[ 0 ];
      Severity: Minor
      Found in docconfig/template/fixtures/documents/probe.js - About 1 hr to fix

        Function execQuery has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function execQuery( obj, qu, shortCircuit, stopOnFirst ) {
            var arrayResults = [];
            var keyResults = [];
            sys.each( obj, function ( record, key ) {
                var expr, result, test, _i, _len;
        Severity: Minor
        Found in docconfig/template/fixtures/documents/probe.js - About 1 hr to fix

          Function processExpressionObject has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          function processExpressionObject( val, key ) {
              var operator;
              if ( sys.isObject( val ) ) {
                  var opKeys = Object.keys( val );
                  var op = opKeys[ 0 ];
          Severity: Minor
          Found in docconfig/template/fixtures/documents/probe.js - About 45 mins 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

          Avoid too many return statements within this function.
          Open

                                  return parent[lastPart].shift();
          Severity: Major
          Found in docconfig/template/fixtures/documents/probe.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                                return parent[lastPart].push( newValue );
            Severity: Major
            Found in docconfig/template/fixtures/documents/probe.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                                  return parent[lastPart];
              Severity: Major
              Found in docconfig/template/fixtures/documents/probe.js - About 30 mins to fix

                Function $elemMatch has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    $elemMatch : function ( qu, value ) {
                        var expression, test, _i, _len;
                
                        if ( sys.isArray( value ) ) {
                            var _ref = qu.operands;
                Severity: Minor
                Found in docconfig/template/fixtures/documents/probe.js - About 25 mins 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

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

                exports.findOne = function ( obj, qu ) {
                    var expression, _i, _len;
                
                    var query = parseQueryExpression( qu );
                    for ( _i = 0, _len = query.length; _i < _len; _i++ ) {
                Severity: Major
                Found in docconfig/template/fixtures/documents/probe.js and 1 other location - About 6 hrs to fix
                docconfig/template/fixtures/documents/probe.js on lines 813..829

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

                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

                exports.findOneKey = function ( obj, qu ) {
                    var expression, _i, _len;
                
                    var query = parseQueryExpression( qu );
                    for ( _i = 0, _len = query.length; _i < _len; _i++ ) {
                Severity: Major
                Found in docconfig/template/fixtures/documents/probe.js and 1 other location - About 6 hrs to fix
                docconfig/template/fixtures/documents/probe.js on lines 788..804

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

                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

                    $not       : function ( qu, value, record ) {
                
                        var result = false;
                        sys.each( qu.operands, function ( expr ) {
                            if ( expr.path ) {
                Severity: Major
                Found in docconfig/template/fixtures/documents/probe.js and 1 other location - About 5 hrs to fix
                docconfig/template/fixtures/documents/probe.js on lines 647..661

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

                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

                    $nor       : function ( qu, value, record ) {
                        var isOr = false;
                        sys.each( qu.operands, function ( expr ) {
                            if ( expr.path ) {
                                expr.splitPath = expr.splitPath || splitPath( expr.path );
                Severity: Major
                Found in docconfig/template/fixtures/documents/probe.js and 1 other location - About 5 hrs to fix
                docconfig/template/fixtures/documents/probe.js on lines 671..687

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

                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

                exports.findKeys = function ( obj, qu ) {
                    var expression, _i, _len;
                
                    var query = parseQueryExpression( qu );
                    for ( _i = 0, _len = query.length; _i < _len; _i++ ) {
                Severity: Major
                Found in docconfig/template/fixtures/documents/probe.js and 1 other location - About 4 hrs to fix
                docconfig/template/fixtures/documents/probe.js on lines 750..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 129.

                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

                exports.find = function ( obj, qu ) {
                    var expression, _i, _len;
                
                    var query = parseQueryExpression( qu );
                    for ( _i = 0, _len = query.length; _i < _len; _i++ ) {
                Severity: Major
                Found in docconfig/template/fixtures/documents/probe.js and 1 other location - About 4 hrs to fix
                docconfig/template/fixtures/documents/probe.js on lines 769..780

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

                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

                    $ne        : function ( qu, value ) {
                        if ( sys.isArray( value ) ) {
                            return sys.find( value, function ( entry ) {
                                return JSON.stringify( qu.operands[0] ) !== JSON.stringify( entry );
                            } ) !== void 0;
                Severity: Major
                Found in docconfig/template/fixtures/documents/probe.js and 1 other location - About 4 hrs to fix
                docconfig/template/fixtures/documents/probe.js on lines 360..368

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

                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

                    $eq        : function ( qu, value ) {
                        if ( sys.isArray( value ) ) {
                            return sys.find( value, function ( entry ) {
                                return JSON.stringify( qu.operands[0] ) === JSON.stringify( entry );
                            } ) !== void 0;
                Severity: Major
                Found in docconfig/template/fixtures/documents/probe.js and 1 other location - About 4 hrs to fix
                docconfig/template/fixtures/documents/probe.js on lines 380..388

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

                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 '$inc':
                                /**
                                 * Increments a field by the amount you specify. It takes the form
                                 * `{ $inc: { field1: amount } }`
                                 * @name $inc
                Severity: Major
                Found in docconfig/template/fixtures/documents/probe.js and 1 other location - About 2 hrs to fix
                docconfig/template/fixtures/documents/probe.js on lines 244..263

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

                            case '$dec':
                                /**
                                 * Decrements a field by the amount you specify. It takes the form
                                 * `{ $dec: { field1: amount }`
                                 * @name $dec
                Severity: Major
                Found in docconfig/template/fixtures/documents/probe.js and 1 other location - About 2 hrs to fix
                docconfig/template/fixtures/documents/probe.js on lines 224..243

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

                    $in        : function ( qu, value ) {
                        var operands;
                
                        operands = sys.flatten( qu.operands );
                        return sys.indexOf( operands, value ) > -1;
                Severity: Major
                Found in docconfig/template/fixtures/documents/probe.js and 1 other location - About 1 hr to fix
                docconfig/template/fixtures/documents/probe.js on lines 487..492

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

                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

                    $nin       : function ( qu, value ) {
                        var operands;
                
                        operands = sys.flatten( qu.operands );
                        return sys.indexOf( operands, value ) === -1;
                Severity: Major
                Found in docconfig/template/fixtures/documents/probe.js and 1 other location - About 1 hr to fix
                docconfig/template/fixtures/documents/probe.js on lines 471..476

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

                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