etnbrd/flx-compiler

View on GitHub
test-set/Moonridge-master/query-builder.js

Summary

Maintainability
C
1 day
Test Coverage

Function MRQuery has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = function MRQuery(model, clientQuery) {
    var query = model.find();

    //query option object,where we index by method, not by invocation order, useful later when we reexecute the query
    var opts = {populate:[]};
Severity: Minor
Found in test-set/Moonridge-master/query-builder.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 MRQuery has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function MRQuery(model, clientQuery) {
    var query = model.find();

    //query option object,where we index by method, not by invocation order, useful later when we reexecute the query
    var opts = {populate:[]};
Severity: Minor
Found in test-set/Moonridge-master/query-builder.js - About 2 hrs to fix

    Avoid deeply nested control flow statements.
    Open

                    }else if(methodName === 'populate'){
                        opts.populate.push(args);
                    }
    Severity: Major
    Found in test-set/Moonridge-master/query-builder.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if (methodName === 'sort' && opts.count) {
                              throw new Error('Mongoose does not support sort and count in one query');    //TODO remove when we update to mongoose 3.9.2
                          }
      Severity: Major
      Found in test-set/Moonridge-master/query-builder.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if (opts[methodName]) {
                                throw new Error(methodName + ' method can be called just once per query');
                            } else {
                                opts[methodName] = args; //we shall add it to the options, this object will be used when reiterating on LQ
                            }
        Severity: Major
        Found in test-set/Moonridge-master/query-builder.js - About 45 mins to fix

          There are no issues that match your filters.

          Category
          Status